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

Commit

Permalink
#39: fixing DependencyDesscription generation
Browse files Browse the repository at this point in the history
  • Loading branch information
kovax committed Feb 4, 2019
1 parent 39f1989 commit b54d948
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.cristalise.kernel.process.Gateway

import groovy.transform.CompileStatic
import org.cristalise.kernel.process.resource.BuiltInResources
import org.cristalise.kernel.property.PropertyDescriptionList
import org.cristalise.kernel.utils.Logger


Expand Down Expand Up @@ -57,8 +58,16 @@ class DependencyDelegate {
public void Member(Map attrs, Closure cl = null) {
assert attrs && attrs.itemPath

String iPathStr
ItemPath itemPath = new ItemPath()
String iPathStr = (String)attrs.itemPath

if (attrs.itemPath instanceof PropertyDescriptionList) {
def propDesc = (PropertyDescriptionList)attrs.itemPath
//FIXME module namespace is hardcoded
iPathStr = "/desc/Property/testns/${propDesc.name}"
}
else
iPathStr = (String)attrs.itemPath

assert iPathStr

Expand All @@ -69,8 +78,8 @@ class DependencyDelegate {
Logger.warning "Unable to find the domain path. ${e.localizedMessage}"
}

if (iPathStr.startsWith(BuiltInResources.COMP_ACT_DESC_RESOURCE.typeRoot))
itemPath.path[0] = iPathStr
//NOTE: this is a kind of hack so the DSL
if (!ItemPath.isUUID(iPathStr)) itemPath.path[0] = iPathStr

def member = dependency.addMember(itemPath)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.cristalise.kernel.entity.imports.ImportDependencyMember
import org.cristalise.kernel.entity.imports.ImportItem
import org.cristalise.kernel.entity.imports.ImportOutcome
import org.cristalise.kernel.lifecycle.CompositeActivityDef
import org.cristalise.kernel.lookup.ItemPath
import org.cristalise.kernel.process.resource.BuiltInResources

import groovy.transform.CompileStatic
Expand Down Expand Up @@ -105,13 +106,18 @@ class ItemDelegate extends PropertyDelegate {
DependencyMember member = DependencyMember.cast(mem)
String itemPath = member.itemPath.stringPath

if (itemPath.contains(BuiltInResources.COMP_ACT_DESC_RESOURCE.typeRoot) && itemPath.startsWith(ENTITY_PATTERN))
//
if (itemPath.startsWith(ENTITY_PATTERN) && !ItemPath.isUUID(itemPath))
itemPath = itemPath.replaceFirst(ENTITY_PATTERN, StringUtils.EMPTY)

ImportDependencyMember imem = new ImportDependencyMember(itemPath)
imem.props = member.properties
idep.dependencyMemberList << imem
}

if (dependency.getProperties().size() > 0) {
idep.props = dependency.getProperties()
}

newItem.dependencyList.add(idep)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package org.cristalise.dsl.test.collection

import org.cristalise.dsl.collection.DependencyBuilder
import org.cristalise.kernel.test.utils.CristalTestSetup;

import spock.lang.Specification


Expand All @@ -48,7 +47,9 @@ class CollectionBuilderSpecs extends Specification implements CristalTestSetup {
then:
builder.dependency.properties.size() == 1
builder.dependency.members.list.size() == 1

builder.dependency.members.list[0].childUUID
// builder.dependency.members.list[0].childUUID == 'b9415b57-3a4a-4b31-825a-d307d1280ac0'

builder.dependency.members.list[0].properties.size() == 2
builder.dependency.members.list[0].properties['version'] == 0
builder.dependency.members.list[0].properties['toto'] == true
Expand Down

0 comments on commit b54d948

Please sign in to comment.