Skip to content

Commit

Permalink
Merge pull request #1155 from OriginTrail/prerelease/testnet
Browse files Browse the repository at this point in the history
OriginTrail Testnet Release v4.0.5
  • Loading branch information
Kuki145 authored Feb 10, 2020
2 parents 4bfda7d + 58bcaf5 commit 54628d3
Show file tree
Hide file tree
Showing 22 changed files with 363 additions and 162 deletions.
26 changes: 26 additions & 0 deletions importers/sample_files/DC1_01-sample_product_packing.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE project>
<epcis:EPCISDocument xmlns:epcis="urn:epcglobal:epcis:xsd:1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creationDate="2005-07-11T11:30:47.0Z"
schemaVersion="1.2">
<EPCISBody>
<EventList>
<ObjectEvent id="packing_product">
<eventTime>2019-09-18T10:30:00.000-06:00</eventTime>
<eventTimeZoneOffset>-06:00</eventTimeZoneOffset>
<epcList>
<epc>urn:epc:id:sgtin:111111111</epc>
</epcList>
<action>ADD</action>
<bizStep>urn:epcglobal:cbv:bizstep:packing</bizStep>
<disposition>urn:epcglobal:cbv:disp:active</disposition>
<readPoint>
<id>urn:epc:id:sgln:0000000.11111.0</id>
</readPoint>
<bizLocation>
<id>urn:epc:id:sgln:0000000.11111.0</id>
</bizLocation>
</ObjectEvent>
</EventList>
</EPCISBody>
</epcis:EPCISDocument>
30 changes: 30 additions & 0 deletions importers/sample_files/DC1_02-sample_product_shipping.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE project>
<epcis:EPCISDocument xmlns:epcis="urn:epcglobal:epcis:xsd:1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creationDate="2005-07-11T11:30:47.0Z"
schemaVersion="1.2">
<EPCISBody>
<EventList>
<ObjectEvent id="shipping_product">
<eventTime>2019-10-12T12:45:00.000-06:00</eventTime>
<eventTimeZoneOffset>-06:00</eventTimeZoneOffset>
<epcList>
<epc>urn:epc:id:sgtin:111111111</epc>
</epcList>
<action>OBSERVE</action>
<bizStep>urn:epcglobal:cbv:bizstep:shipping</bizStep>
<disposition>urn:epcglobal:cbv:disp:in_progress</disposition>
<readPoint>
<id>urn:epc:id:sgln:0000000.22222.0</id>
</readPoint>
<bizLocation>
<id>urn:epc:id:sgln:0000000.22222.0</id>
</bizLocation>
<bizTransactionList>
<bizTransaction>sampleFarmAtDate12102019:0x475092045ff115c5eea7679d7edae8c97a64967c</bizTransaction>
</bizTransactionList>

</ObjectEvent>
</EventList>
</EPCISBody>
</epcis:EPCISDocument>
30 changes: 30 additions & 0 deletions importers/sample_files/DC2_01-sample_product_receiving.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE project>
<epcis:EPCISDocument xmlns:epcis="urn:epcglobal:epcis:xsd:1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creationDate="2005-07-11T11:30:47.0Z"
schemaVersion="1.2">
<EPCISBody>
<EventList>
<ObjectEvent id="receiving_product">
<eventTime>2019-10-12T15:00:00.000-06:00</eventTime>
<eventTimeZoneOffset>-06:00</eventTimeZoneOffset>
<epcList>
<epc>urn:epc:id:sgtin:111111111</epc>
</epcList>
<action>OBSERVE</action>
<bizStep>urn:epcglobal:cbv:bizstep:receiving</bizStep>
<disposition>urn:epcglobal:cbv:disp:in_progress</disposition>
<readPoint>
<id>urn:epc:id:sgln:0000000.33333.0</id>
</readPoint>
<bizLocation>
<id>urn:epc:id:sgln:0000000.33333.0</id>
</bizLocation>
<bizTransactionList>
<bizTransaction>sampleFarmAtDate12102019:0xfc41a6e359ee40996fe08f2d2e8728d2bc204442</bizTransaction>
</bizTransactionList>

</ObjectEvent>
</EventList>
</EPCISBody>
</epcis:EPCISDocument>
32 changes: 32 additions & 0 deletions importers/sample_files/DC2_02-sample_transformation_event.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE project>
<epcis:EPCISDocument schemaVersion="1.2"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creationDate="2013-06-04T14:59:02.099+02:00"
xmlns:epcis="urn:epcglobal:epcis:xsd:1">
<EPCISBody>
<EventList>
<extension>
<TransformationEvent id="transforming">
<eventTime>2019-09-18T10:30:00.000-06:00</eventTime>
<eventTimeZoneOffset>-06:00</eventTimeZoneOffset>
<inputEPCList>
<epc>urn:epc:id:sgtin:111111111</epc>
<epc>urn:epc:id:sgtin:222222222</epc>
</inputEPCList>
<outputEPCList>
<epc>urn:epc:id:sgtin:999999999</epc>
<epc>urn:epc:id:sgtin:888888888</epc>
</outputEPCList>
<bizStep>urn:epcglobal:cbv:bizstep:transforming</bizStep>
<disposition>urn:epcglobal:cbv:disp:in_progress</disposition>
<readPoint>
<id>urn:epc:id:sgln:0000000.44444.0</id>
</readPoint>
<bizLocation>
<id>urn:epc:id:sgln:0000000.44444.0</id>
</bizLocation>
</TransformationEvent>
</extension>
</EventList>
</EPCISBody>
</epcis:EPCISDocument>
30 changes: 30 additions & 0 deletions importers/sample_files/DC2_03-sample_batch_shipping.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE project>
<epcis:EPCISDocument xmlns:epcis="urn:epcglobal:epcis:xsd:1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creationDate="2005-07-11T11:30:47.0Z"
schemaVersion="1.2">
<EPCISBody>
<EventList>
<ObjectEvent id="shipping_batch">
<eventTime>2019-10-14T12:00:00.000-06:00</eventTime>
<eventTimeZoneOffset>-06:00</eventTimeZoneOffset>
<epcList>
<epc>urn:epc:id:sgtin:999999999</epc>
<epc>urn:epc:id:sgtin:777777777</epc>
</epcList>
<action>OBSERVE</action>
<bizStep>urn:epcglobal:cbv:bizstep:shipping</bizStep>
<disposition>urn:epcglobal:cbv:disp:in_progress</disposition>
<readPoint>
<id>urn:epc:id:sgln:0000000.55555.0</id>
</readPoint>
<bizLocation>
<id>urn:epc:id:sgln:0000000.55555.0</id>
</bizLocation>
<bizTransactionList>
<bizTransaction>sampleFarmAtDate14102019:0x75bd15b2f5a5f2ead02717973e1fdf1d4c8f914a</bizTransaction>
</bizTransactionList>
</ObjectEvent>
</EventList>
</EPCISBody>
</epcis:EPCISDocument>
29 changes: 29 additions & 0 deletions importers/sample_files/DC3_01-sample_batch_receiving.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE project>
<epcis:EPCISDocument xmlns:epcis="urn:epcglobal:epcis:xsd:1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creationDate="2005-07-11T11:30:47.0Z"
schemaVersion="1.2">
<EPCISBody>
<EventList>
<ObjectEvent id="receiving_batch">
<eventTime>2019-10-19T08:00:00.000-06:00</eventTime>
<eventTimeZoneOffset>-06:00</eventTimeZoneOffset>
<epcList>
<epc>urn:epc:id:sgtin:999999999</epc>
</epcList>
<action>OBSERVE</action>
<bizStep>urn:epcglobal:cbv:bizstep:receiving</bizStep>
<disposition>urn:epcglobal:cbv:disp:in_progress</disposition>
<readPoint>
<id>urn:epc:id:sgln:0000000.66666.0</id>
</readPoint>
<bizLocation>
<id>urn:epc:id:sgln:0000000.66666.0</id>
</bizLocation>
<bizTransactionList>
<bizTransaction>sampleFarmAtDate14102019:0x475092045ff115c5eea7679d7edae8c97a64967c</bizTransaction>
</bizTransactionList>
</ObjectEvent>
</EventList>
</EPCISBody>
</epcis:EPCISDocument>
27 changes: 27 additions & 0 deletions importers/sample_files/DC3_02-sample_batch_selling.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE project>
<epcis:EPCISDocument xmlns:epcis="urn:epcglobal:epcis:xsd:1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creationDate="2005-07-11T11:30:47.0Z"
schemaVersion="1.2">
<EPCISBody>
<EventList>
<ObjectEvent id="selling_batch">
<eventTime>2019-10-19T10:00:00.000-06:00</eventTime>
<eventTimeZoneOffset>-06:00</eventTimeZoneOffset>
<epcList>
<epc>urn:epc:id:sgtin:999999999</epc>
<epc>urn:epc:id:sgtin:123123123</epc>
</epcList>
<action>OBSERVE</action>
<bizStep>urn:epcglobal:cbv:bizstep:retail_selling</bizStep>
<disposition>urn:epcglobal:cbv:disp:retail_sold</disposition>
<readPoint>
<id>urn:epc:id:sgln:0000000.77777.0</id>
</readPoint>
<bizLocation>
<id>urn:epc:id:sgln:0000000.77777.0</id>
</bizLocation>
</ObjectEvent>
</EventList>
</EPCISBody>
</epcis:EPCISDocument>
105 changes: 30 additions & 75 deletions modules/Database/Arangojs.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,96 +143,51 @@ class ArangoJS {
LET trailObjects = (
FILTER startObjects[0] != null
FOR v, e, p IN 0..@depth ANY startObjects[0] ot_edges
FOR v, e, p IN 0..@depth ANY startObjects[0] ot_edges`;
if (Array.isArray(connectionTypes) && connectionTypes.length > 0) {
queryString += `
PRUNE (LENGTH(p.edges) == 2 && p.edges[-1].relationType == p.edges[-2].relationType) || (LENGTH(p.edges) > 2 && p.edges[-1].relationType == p.edges[-2].relationType && p.edges[-3].relationType != 'CONNECTOR_FOR')
OPTIONS {
bfs: true,
uniqueVertices: 'global',
uniqueEdges: 'path'
}
FILTER (
((LENGTH(p.edges) < 2) == true) ||
((p.edges[-1].relationType != p.edges[-2].relationType) == true) ||
((p.edges[-3].relationType == 'CONNECTOR_FOR') == true)
) == true
FILTER p.edges[*].relationType ALL in @connectionTypes`;
queryParams.connectionTypes = connectionTypes;
} else {
queryString += `
OPTIONS {
bfs: true,
uniqueVertices: 'global',
uniqueEdges: 'path'
}
uniqueVertices: 'global',
uniqueEdges: 'path'
}`;
}
queryString += `
RETURN DISTINCT v
)
FOR trailObject in trailObjects
FILTER trailObject != null
LET objectsRelated = (
FOR v, e in 1..1 OUTBOUND trailObject ot_edges
FILTER e.edgeType IN ['IdentifierRelation','dataRelation','otRelation']
FILTER e.edgeType IN ['IdentifierRelation','dataRelation','otRelation']
AND e.datasets != null
AND v.datasets != null
AND LENGTH(INTERSECTION(e.datasets, v.datasets, trailObject.datasets)) > 0
RETURN {
RETURN {
"vertex": v,
"edge": e
})
RETURN {
"rootObject": trailObject,
"relatedObjects": objectsRelated
}`;
if (Array.isArray(connectionTypes) && connectionTypes.length > 0) {
queryString = ` // Get identifier
LET identifierObjects = TO_ARRAY(DOCUMENT('ot_vertices', @identifierKeys))
// Fetch the start entity for trail
LET startObjects = UNIQUE(FLATTEN(
FOR identifierObject IN identifierObjects
FILTER identifierObject != null
LET identifiedObject = (
FOR v, e IN 1..1 OUTBOUND identifierObject ot_edges
FILTER e.edgeType == 'IdentifierRelation'
RETURN v
)
RETURN identifiedObject
))
LET trailObjects = (
FILTER startObjects[0] != null
FOR v, e, p IN 0..@depth ANY startObjects[0] ot_edges
OPTIONS {
bfs: true,
uniqueVertices: 'global',
uniqueEdges: 'path'
}
FILTER LENGTH(p.edges) < 2 ? true : (p.edges[-2].relationType != p.edges[-1].relationType)
FILTER p.edges[*].relationType ALL in @connectionTypes
RETURN DISTINCT { vertex: v, path: p.edges }
)
LET pairs = (
FOR object in trailObjects
FILTER LENGTH(object.path) > 2
let imaDuplikate = (
FOR relation in object.path
FILTER POSITION(object.path, relation, true) > 0
LET pozicija = ( RETURN POSITION(object.path, relation, true))
RETURN NTH(object.path, pozicija - 1).relationType == relation.relationType
}
)
FILTER POSITION(imaDuplikate, true)
RETURN object
)
let trailObjects2 = (for object in trailObjects
filter object not in pairs
return object.vertex
)
FOR trailObject in trailObjects2
FILTER trailObject != null
LET objectsRelated = (
FOR v, e in 1..1 OUTBOUND trailObject ot_edges
FILTER e.edgeType IN ['IdentifierRelation','dataRelation','otRelation']
AND e.datasets != null
AND v.datasets != null
AND LENGTH(INTERSECTION(e.datasets, v.datasets, trailObject.datasets)) > 0
RETURN {
"vertex": v,
"edge": e
})
RETURN {
"rootObject": trailObject,
"relatedObjects": objectsRelated
}`;
queryParams.connectionTypes = connectionTypes;
}
RETURN {
"rootObject": trailObject,
"relatedObjects": objectsRelated
}`;

const result = await this.runQuery(queryString, queryParams);
return result;
Expand Down
5 changes: 2 additions & 3 deletions modules/command/dh/dh-litigation-answer-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class DHLitigationAnswerCommand extends Command {
offerId,
objectIndex,
blockIndex,
dataSetId,
} = command.data;

const holdingData = await models.holding_data.findOne({
Expand All @@ -53,11 +52,11 @@ class DHLitigationAnswerCommand extends Command {
const litigationTimestamp = parseInt(timestamp, 10) * 1000; // seconds -> miliseconds

if (status === '1') {
if (litigationTimestamp + (litigation_interval_in_minutes * 60000) >= Date.now()) {
if (litigationTimestamp + (litigation_interval_in_minutes * 60 * 1000) >= Date.now()) {
const color = this.replicationService.castNumberToColor(holdingData.color);

const otObject = await this.importService.getImportedOtObject(
dataSetId,
holdingData.data_set_id,
objectIndex,
offerId,
color,
Expand Down
Loading

0 comments on commit 54628d3

Please sign in to comment.