| 1 | |
package org.kuali.rice.krms.impl.repository |
| 2 | |
|
| 3 | |
|
| 4 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase |
| 5 | |
|
| 6 | |
import org.kuali.rice.krms.api.repository.proposition.PropositionDefinition; |
| 7 | |
import org.kuali.rice.krms.api.repository.proposition.PropositionDefinitionContract; |
| 8 | |
|
| 9 | |
|
| 10 | |
public class PropositionBo extends PersistableBusinessObjectBase implements PropositionDefinitionContract { |
| 11 | |
|
| 12 | |
def String id |
| 13 | |
def String description |
| 14 | |
def String ruleId |
| 15 | |
def String typeId |
| 16 | |
def String propositionTypeCode |
| 17 | |
|
| 18 | |
def List<PropositionParameterBo> parameters |
| 19 | |
|
| 20 | |
|
| 21 | |
def String compoundOpCode |
| 22 | |
def List<PropositionBo> compoundComponents |
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
static PropositionDefinition to(PropositionBo bo) { |
| 30 | 6 | if (bo == null) { return null } |
| 31 | 4 | return org.kuali.rice.krms.api.repository.proposition.PropositionDefinition.Builder.create(bo).build() |
| 32 | |
} |
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
static PropositionBo from(PropositionDefinition im) { |
| 40 | 37 | if (im == null) { return null } |
| 41 | |
|
| 42 | 37 | PropositionBo bo = new PropositionBo() |
| 43 | 37 | bo.id = im.id |
| 44 | 37 | bo.description = im.description |
| 45 | |
|
| 46 | |
|
| 47 | 37 | setRuleIdRecursive(im.ruleId, bo) |
| 48 | |
|
| 49 | 37 | bo.typeId = im.typeId |
| 50 | 37 | bo.propositionTypeCode = im.propositionTypeCode |
| 51 | 37 | bo.parameters = new ArrayList<PropositionParameterBo>() |
| 52 | 37 | for ( parm in im.parameters){ |
| 53 | 108 | bo.parameters.add (PropositionParameterBo.from(parm)) |
| 54 | |
} |
| 55 | 37 | bo.compoundOpCode = im.compoundOpCode |
| 56 | 37 | bo.compoundComponents = new ArrayList<PropositionBo>() |
| 57 | 37 | for (prop in im.compoundComponents){ |
| 58 | 2 | bo.compoundComponents.add (PropositionBo.from(prop)) |
| 59 | |
} |
| 60 | 37 | bo.versionNumber = im.versionNumber |
| 61 | 37 | return bo |
| 62 | |
} |
| 63 | |
|
| 64 | |
private static void setRuleIdRecursive(String ruleId, PropositionBo prop) { |
| 65 | 37 | prop.ruleId = ruleId; |
| 66 | 37 | if (prop.compoundComponents != null) for (PropositionBo child : prop.compoundComponents) if (child != null) { |
| 67 | 0 | setRuleIdRecursive(ruleId, child); |
| 68 | |
} |
| 69 | |
} |
| 70 | |
|
| 71 | |
} |