Skip to content
This repository has been archived by the owner on Mar 31, 2019. It is now read-only.

Commit

Permalink
#31: Generate Item_QueryList script
Browse files Browse the repository at this point in the history
  • Loading branch information
kovax committed Jan 15, 2019
1 parent 039a479 commit 5be26d8
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class CRUDGenerator {

generateDSL(new File(moduleDir, "${vars.item}.groovy"), 'item_groovy.tmpl', vars)
generateDSL(new File(scriptDir, "${vars.item}_Aggregate.groovy"), 'item_aggregate_groovy.tmpl', vars)
generateDSL(new File(scriptDir, "${vars.item}_QueryList.groovy"), 'item_queryList_groovy.tmpl', vars)
generateDSL(new File(workflowDir, "${vars.item}_Workflow_0.xml"), 'item_workflow_xml.tmpl', vars)

if (generateStateWf) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ def @{item}AggregateScript = Script('@{item}_Aggregate', 0) {
script('groovy', moduleDir+'/script/@{item}_Aggregate.groovy')
}

def @{item}QueryListScript = Script('@{item}_QueryList', 0) {
input('item', 'org.cristalise.kernel.entity.proxy.ItemProxy')
output('@{item}Map', 'java.util.Map')
script('groovy', moduleDir+'/script/@{item}_QueryList.groovy')
}

Activity('@{item}_Aggregate', 0) {
Property('OutcomeInit': 'Empty')
Property('Agent Role': 'UserCode')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import org.cristalise.kernel.entity.proxy.AgentProxy
import org.cristalise.kernel.lookup.DomainPath
import org.cristalise.kernel.process.Gateway
import org.cristalise.kernel.property.Property

//--------------------------------------------------
// item, agent and job are injected by the Script class
// automatically so these declaration are only needed
// to write the script with code completion.
// COMMENT OUT before you run the module generators
//--------------------------------------------------
// ItemProxy item
// AgentProxy agent
// Job job
//--------------------------------------------------

def properties = [new Property('Type', '@{item}'), new Property('State', 'ACTIVE')]

def result = Gateway.getLookup().search(new DomainPath(), properties, 0, 100)
def @{item}Map = [];

for (DomainPath dp: result.rows) {
map.put(dp.name, dp.itemPath.UUID)
}

return @{item}Map
6 changes: 6 additions & 0 deletions src/test/module/TestItem.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ def TestItemAggregateScript = Script('TestItem_Aggregate', 0) {
script('groovy', moduleDir+'/script/TestItem_Aggregate.groovy')
}

def TestItemQueryListScript = Script('TestItem_QueryList', 0) {
input('item', 'org.cristalise.kernel.entity.proxy.ItemProxy')
output('TestItemMap', 'java.util.Map')
script('groovy', moduleDir+'/script/TestItem_QueryList.groovy')
}

Activity('TestItem_Aggregate', 0) {
Property('OutcomeInit': 'Empty')
Property('Agent Role': 'UserCode')
Expand Down
26 changes: 26 additions & 0 deletions src/test/module/script/TestItem_QueryList.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import org.cristalise.kernel.entity.proxy.AgentProxy
import org.cristalise.kernel.lookup.DomainPath
import org.cristalise.kernel.process.Gateway
import org.cristalise.kernel.property.Property

//--------------------------------------------------
// item, agent and job are injected by the Script class
// automatically so these declaration are only needed
// to write the script with code completion.
// COMMENT OUT before you run the module generators
//--------------------------------------------------
// ItemProxy item
// AgentProxy agent
// Job job
//--------------------------------------------------

def properties = [new Property('Type', 'TestItem'), new Property('State', 'ACTIVE')]

def result = Gateway.getLookup().search(new DomainPath(), properties, 0, 100)
def TestItemMap = [];

for (DomainPath dp: result.rows) {
map.put(dp.name, dp.itemPath.UUID)
}

return TestItemMap
32 changes: 32 additions & 0 deletions src/test/resources/boot/SC/TestItem_QueryList_0.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<cristalscript>
<param name='item' type='org.cristalise.kernel.entity.proxy.ItemProxy' />
<output name='TestItemMap' type='java.util.Map' />
<script language='groovy' name='TestItem_QueryList'><![CDATA[ import org.cristalise.kernel.entity.proxy.AgentProxy
import org.cristalise.kernel.lookup.DomainPath
import org.cristalise.kernel.process.Gateway
import org.cristalise.kernel.property.Property
//--------------------------------------------------
// item, agent and job are injected by the Script class
// automatically so these declaration are only needed
// to write the script with code completion.
// COMMENT OUT before you run the module generators
//--------------------------------------------------
// ItemProxy item
// AgentProxy agent
// Job job
//--------------------------------------------------
def properties = [new Property('Type', 'TestItem'), new Property('State', 'ACTIVE')]
def result = Gateway.getLookup().search(new DomainPath(), properties, 0, 100)
def TestItemMap = [];
for (DomainPath dp: result.rows) {
map.put(dp.name, dp.itemPath.UUID)
}
return TestItemMap
]]></script>
</cristalscript>
1 change: 1 addition & 0 deletions src/test/resources/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<Schema name="TestItem_Details" version="0"/>
</Activity>
<ScriptResource name="TestItem_Aggregate" version="0"/>
<ScriptResource name="TestItem_QueryList" version="0"/>
<Activity name="TestItem_Aggregate" version="0">
<Schema name="TestItem" version="0"/>
<Script name="TestItem_Aggregate" version="0"/>
Expand Down

0 comments on commit 5be26d8

Please sign in to comment.