Migration of datastore-identity strategy in JDO? - jdo

The current configuration of JDO metadata we have all the clases like this:
<class name="ObjectOne" identity-type="datastore" table="ObjectOne" requires-extent="true" detachable="false">
<datastore-identity column="JDOID" strategy="native" >
</datastore-identity >
</class>
<class name="ObjectTwo" identity-type="datastore" table="ObjectTwo" requires-extent="true" detachable="false">
<datastore-identity column="JDOID" strategy="native" >
</datastore-identity >
</class>
But right the problem is this that the JDOID or the Id of the object is not sequencial. Example:
Object 1 JDOID | Object 2 JDOID
1 3
2
4
Like you see this is a Big Issue because the ID is the number of produced Object. But now I need to migrate this to a different datastore-identity strategy. I'm using auto-assign strategy and everything works in new tables like for Object 3 is generating from 1. But changing the strategy in ObjectOne and ObjectTwo is giving me that the id can't not be null. Any suggestions giving in this problem?

Related

How to map a 4 loops schema to a 3 loops schema in Biztalk

Now I have a source schema which having 3 loops, "OrderHeader", "OrderLine" and "OrderSchedule", like the following picture.
Source schema
Now I want to map it to the standard X12 EDI 855 schema
And the following picture is mapping
The following is my input file
<OrderHeader>
<code_BAK02>1</code_BAK02>
<po_no_BAK03>2</po_no_BAK03>
<po_date_BAK04>20200630</po_date_BAK04>
<OrderLine>
<assigned_id_PO101>1</assigned_id_PO101>
<qty_PO102>1</qty_PO102>
<OrderSchedule>
<sch_qty_ACK02>1</sch_qty_ACK02>
</OrderSchedule>
</OrderLine>
</OrderHeader>
<OrderHeader>
<code_BAK02>2</code_BAK02>
<po_no_BAK03>3</po_no_BAK03>
<po_date_BAK04>20200830</po_date_BAK04>
<OrderLine>
<assigned_id_PO101>1</assigned_id_PO101>
<qty_PO102>100</qty_PO102>
<OrderSchedule>
<sch_qty_ACK02>100</sch_qty_ACK02>
</OrderSchedule>
</OrderLine>
</OrderHeader>
After executing test mapping, the result is like following, which is not what I expect.
<ns0:X12_00403_855>
<ns0:BAK>
<BAK02>112220000204853</BAK02>
<BAK03>20201116</BAK03>
<BAK04>20210730</BAK04>
</ns0:BAK>
<ns0:BAK>
<BAK02>112220000206821</BAK02>
<BAK03>20201119</BAK03>
<BAK04>20210630</BAK04>
</ns0:BAK>
<ns0:PO1Loop1>
<ns0:PO1>
<PO101>1</PO101>
<PO102>1</PO102>
</ns0:PO1>
<ns0:PO1>
<PO101>1</PO101>
<PO102>100</PO102>
</ns0:PO1>
<ns0:ACKLoop1>
<ns0:ACK>
<ACK02>1</ACK02>
</ns0:ACK>
<ns0:ACK>
<ACK02>100</ACK02>
</ns0:ACK>
</ns0:ACKLoop1>
</ns0:PO1Loop1>
</ns0:X12_00403_855>
What I expect is like following,
<ns0:X12_00403_855>
<ns0:BAK>
<BAK02>112220000204853</BAK02>
<BAK03>20201116</BAK03>
<BAK04>20210730</BAK04>
<ns0:PO1Loop1>
<ns0:PO1>
<PO101>1</PO101>
<PO102>1</PO102>
</ns0:PO1>
<ns0:ACKLoop1>
<ns0:ACK>
<ACK02>1</ACK02>
</ns0:ACK>
</ns0:ACKLoop1>
</ns0:PO1Loop1>
</ns0:BAK>
<ns0:BAK>
<BAK02>112220000206821</BAK02>
<BAK03>20201119</BAK03>
<BAK04>20210630</BAK04>
<ns0:PO1Loop1>
<ns0:PO1>
<PO101>1</PO101>
<PO102>100</PO102>
</ns0:PO1>
<ns0:ACKLoop1>
<ns0:ACK>
<ACK02>100</ACK02>
</ns0:ACK>
</ns0:ACKLoop1>
</ns0:PO1Loop1>
</ns0:BAK>
</ns0:X12_00403_855>
The result I want is to following the structure of the input file, is there any method to achieve that?

Multiple if else in gremlin query

Data Model is as follows:
g.addV('A').property('property1',0).property('input','two').next()
g.addV('B').property('property2',0).next()
g.V().has('property1',0).as('fromV').V().has('property2',0).as('toV').addE('AB').from('fromV').to('toV').iterate()
First, need to check whether the node A and B are connected by AB relation. If yes, change the property value for node A according to the given input.
Condition for property value:
if input="one" then 1
else if input="two" then 2
else if input="three" then 3
else 0
Tried the following query:
g.V().has('property1',0).where(outE('AB').inV('B')).property('property1',choose(values('input').is(eq('one')),1,choose(values('input').is(eq('two')),2,choose(values('input').is(eq('three')),3,0))))
Error:
No signature of method: static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.choose() is applicable for argument types: (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal...) values: [[PropertiesStep([input_currency],value), IsStep(eq(Local))], ...]
Possible solutions: choose(java.util.function.Function), choose(org.apache.tinkerpop.gremlin.process.traversal.Traversal), choose(java.util.function.Predicate, org.apache.tinkerpop.gremlin.process.traversal.Traversal), choose(org.apache.tinkerpop.gremlin.process.traversal.Traversal, org.apache.tinkerpop.gremlin.process.traversal.Traversal), choose(java.util.function.Predicate, org.apache.tinkerpop.gremlin.process.traversal.Traversal, org.apache.tinkerpop.gremlin.process.traversal.Traversal), choose(org.apache.tinkerpop.gremlin.process.traversal.Traversal, org.apache.tinkerpop.gremlin.process.traversal.Traversal, org.apache.tinkerpop.gremlin.process.traversal.Traversal)
Type ':help' or ':h' for help.
Display stack trace? [yN]
using option solves the problem.
Query:
g.V().has('property1',0).where(outE('AB').inV('B')).property('property1',choose(values('input')).option('one',1).option('two',2).option('three',3))

cts search ignoring index order with cts:element-attribute-reference date

Background
I'm using a cts search in MarkLogic and it is not sorting by the passed sort option.
For example the following produces unsorted results
xdmp:document-insert("/test/test1",<test attrDate="2016-1-10"></test>);
xdmp:document-insert("/test/test2",<test attrDate="2015-1-10"></test>);
xdmp:document-insert("/test/test3",<test attrDate="2017-1-10"></test>);
cts:search(
xdmp:directory("/test/", "infinity")/test,
cts:true-query(),
(
cts:index-order(cts:element-attribute-reference(xs:QName("test"), xs:QName("attrDate")), ("ascending"))
)
);
This returns the following:
<test attrDate="2016-1-10">
</test>
element
<test attrDate="2015-1-10">
</test>
element
<test attrDate="2017-1-10">
</test>
So the correct results but unsorted.
Question
How can I sort by an attribute in a MarkLogic cts query?
Further Background
I have an index set up on that attribute, here is the config:
(This can index be created at http://localhost:8001/ > summary > YOURDATABASE-content > Attribute Range Indexes > Add, although I added it via Roxy)
It turns out this was a simple data issue (which I found in the last 5 seconds before posting this)
2016-01-10 is the 10th of January 2016
2016-1-10 is a malformed string that MarkLogic just ignores

Getting the level x value of the currentmember in a parent-child hierarchy in MDX

I have an employee parent-child hierarchy in a dimension called Employees which shows the managerial structure of an organisation. This hierarchy is [Employees].[Managerial].
There is another hierarchy that lists all the employees for an organisation. This is a single level hierarchy and it is [Employess].[All Employees].
I have a query that looks something like this:
With
Member measures.[FullTimeSalary] as measures.[Salary] * measures.[FullTimeFactor]
Select {measures.[FullTimeSalary]} on 0,
Non empty
{
[Employess].[All Employees].[All].Children
}
On 1
From MyCube
Where ([Time].[Month].&[201501])
Now if I expand the parent-child hierarchy (the [Employees].[Managerial] hierarchy) I can see each of the different levels of this structure( [Level 02], [Level 03], [Level 04], ect) and what I need to do now is create a new calculated measure called measures.[SupervisingManager] that brings back the currentmembers value at [Level 03] of the hierarchy.
I've tried
member measures.[SupervisingManager] as [Employees].[Managerial].[Level 03].currentmember.member_name
but that just returns "#Error" and using
member measures.[SupervisingManager] as [Employees].[Managerial].currentmember.member_name
returns that currentmember. I also experimented with
measures.[SupervisingManager] as [Employees].[Managerial].currentmember.parent.member_name
but the issue with this is that the currentmember can be located at any within the hierarchy. The only way I can think of doing this is to do a massive case statement, get the ordinal value of the current member and use the appropriate .parent.parent logic. Is there a neater way to do this?
Maybe something along these lines will help:
WITH
MEMBER measures.[FullTimeSalary] AS
measures.[Salary] * measures.[FullTimeFactor]
MEMBER measures.[SupervisingManager] AS
IIF
(
[Employees].CurrentMember.Parent.Level.Name = 'Level 03'
,[Employees].CurrentMember.Parent.Member_Caption
,'n/a'
)
SELECT
{
measures.[FullTimeSalary]
,measures.[SupervisingManager]
} ON 0
,NON EMPTY
{[Employess].[All Employees].[All].Children} ON 1
FROM MyCube
WHERE
[Time].[Month].&[201501];

rJava: using java/lang/Vector with a certain template class

I'm currently programming an R-script which uses a java .jar that makes use of the java/lang/Vector class, which in this case uses a class in a method that is not native. In java source code:
public static Vector<ClassName> methodname(String param)
I found nothing in the documentation of rJava on how to handle a template class like vector and what to write when using jcall or any other method.
I'm currently trying to do something like this:
v <- .jnew("java/util/Vector")
b <- .jcall(v, returnSig = "Ljava/util/Vector", method = "methodname",param)
but R obviously throws an exception:
method methodname with signature (Ljava/lang/String;)Ljava/util/Vector not found
How do I work the template class into this command? Or for that matter, how do I create a vector of a certain class in the first place? Is this possible?
rJava does not know java generics, there is no syntax that will create a Vector of a given type. You can only create Vectors of Objects.
Why are you sticking with the old .jcall api when you can use the J system, which lets you use java objects much more nicely:
> v <- new( J("java.util.Vector") )
> v$add( 1:10 )
[1] TRUE
> v$size()
[1] 1
# code completion
> v$
v$add( v$getClass() v$removeElement(
v$addAll( v$hashCode() v$removeElementAt(
v$addElement( v$indexOf( v$retainAll(
v$capacity() v$insertElementAt( v$set(
v$clear() v$isEmpty() v$setElementAt(
v$clone() v$iterator() v$setSize(
v$contains( v$lastElement() v$size()
v$containsAll( v$lastIndexOf( v$subList(
v$copyInto( v$listIterator( v$toArray(
v$elementAt( v$listIterator() v$toArray()
v$elements() v$notify() v$toString()
v$ensureCapacity( v$notifyAll() v$trimToSize()
v$equals( v$remove( v$wait(
v$firstElement() v$removeAll( v$wait()
v$get( v$removeAllElements()

Resources