本文整理汇总了Java中org.kuali.rice.kew.rule.bo.RuleTemplateAttributeBo.setRuleTemplate方法的典型用法代码示例。如果您正苦于以下问题:Java RuleTemplateAttributeBo.setRuleTemplate方法的具体用法?Java RuleTemplateAttributeBo.setRuleTemplate怎么用?Java RuleTemplateAttributeBo.setRuleTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.kew.rule.bo.RuleTemplateAttributeBo
的用法示例。
在下文中一共展示了RuleTemplateAttributeBo.setRuleTemplate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fixAssociations
import org.kuali.rice.kew.rule.bo.RuleTemplateAttributeBo; //导入方法依赖的package包/类
/**
* Ensures that dependent objects have a reference to the specified rule template
* @param ruleTemplate the rule template whose associates to check
*/
private void fixAssociations(RuleTemplateBo ruleTemplate) {
// if it's a valid rule template instance
if (ruleTemplate != null && ruleTemplate.getId() != null) {
// for every rule template attribute
for (RuleTemplateAttributeBo ruleTemplateAttribute: ruleTemplate.getRuleTemplateAttributes()) {
// if the rule template is not set on the attribute, set it
if (ruleTemplateAttribute.getRuleTemplate() == null || ruleTemplateAttribute.getRuleTemplateId() == null) {
ruleTemplateAttribute.setRuleTemplate(ruleTemplate);
}
// if the rule attribute is set, load up the rule attribute and set the BO on the ruletemplateattribute association object
if (ruleTemplateAttribute.getRuleAttribute() == null) {
RuleAttributeService ruleAttributeService = (RuleAttributeService) KEWServiceLocator.getService(KEWServiceLocator.RULE_ATTRIBUTE_SERVICE);
ruleTemplateAttribute.setRuleAttribute(ruleAttributeService.findByRuleAttributeId(ruleTemplateAttribute.getRuleAttributeId()));
}
}
// for every rule template option
for (RuleTemplateOptionBo option: ruleTemplate.getRuleTemplateOptions()) {
// if the rule template is not set on the option, set it
if (option.getRuleTemplate() == null || option.getRuleTemplateId() == null) {
option.setRuleTemplate(ruleTemplate);
}
}
}
}
示例2: updateRuleTemplateAttributes
import org.kuali.rice.kew.rule.bo.RuleTemplateAttributeBo; //导入方法依赖的package包/类
/**
* Updates the attributes set on the RuleTemplate
* @param ruleTemplateElement the XML ruleTemplate element
* @param updatedRuleTemplate the RuleTemplate being updated
* @throws XmlException if there was a problem parsing the rule template attributes
*/
protected void updateRuleTemplateAttributes(Element ruleTemplateElement, RuleTemplateBo updatedRuleTemplate) throws XmlException {
// add any newly defined rule template attributes to the rule template,
// update the active and required flags of any existing ones.
// if this is an update of an existing rule template, related attribute objects will be present in this rule template object,
// otherwise none will be present (so they'll all be new)
Element attributesElement = ruleTemplateElement.getChild(ATTRIBUTES, RULE_TEMPLATE_NAMESPACE);
List<RuleTemplateAttributeBo> incomingAttributes = new ArrayList<RuleTemplateAttributeBo>();
if (attributesElement != null) {
incomingAttributes.addAll(parseRuleTemplateAttributes(attributesElement, updatedRuleTemplate));
}
// inactivate all current attributes
for (RuleTemplateAttributeBo currentRuleTemplateAttribute: updatedRuleTemplate.getRuleTemplateAttributes()) {
String ruleAttributeName = (currentRuleTemplateAttribute.getRuleAttribute() != null) ? currentRuleTemplateAttribute.getRuleAttribute().getName() : "(null)";
LOG.debug("Inactivating rule template attribute with id " + currentRuleTemplateAttribute.getId() + " and rule attribute with name " + ruleAttributeName);
currentRuleTemplateAttribute.setActive(Boolean.FALSE);
}
// NOTE: attributes are deactivated, not removed
// add/update any new attributes
for (RuleTemplateAttributeBo ruleTemplateAttribute: incomingAttributes) {
RuleTemplateAttributeBo potentialExistingTemplateAttribute = updatedRuleTemplate.getRuleTemplateAttribute(ruleTemplateAttribute);
if (potentialExistingTemplateAttribute != null) {
// template attribute exists on rule template already; update the options
potentialExistingTemplateAttribute.setActive(ruleTemplateAttribute.getActive());
potentialExistingTemplateAttribute.setRequired(ruleTemplateAttribute.getRequired());
} else {
// template attribute does not yet exist on template so add it
ruleTemplateAttribute.setRuleTemplate(updatedRuleTemplate);
updatedRuleTemplate.getRuleTemplateAttributes().add(ruleTemplateAttribute);
}
}
}
示例3: parseRuleTemplateAttribute
import org.kuali.rice.kew.rule.bo.RuleTemplateAttributeBo; //导入方法依赖的package包/类
/**
* Parses a rule template attribute
* @param element the attribute XML element
* @param ruleTemplate the ruleTemplate to update
* @return a parsed rule template attribute
* @throws XmlException if the attribute does not exist
*/
private RuleTemplateAttributeBo parseRuleTemplateAttribute(Element element, RuleTemplateBo ruleTemplate) throws XmlException {
String attributeName = element.getChildText(NAME, RULE_TEMPLATE_NAMESPACE);
String requiredValue = element.getChildText(REQUIRED, RULE_TEMPLATE_NAMESPACE);
String activeValue = element.getChildText(ACTIVE, RULE_TEMPLATE_NAMESPACE);
if (org.apache.commons.lang.StringUtils.isEmpty(attributeName)) {
throw new XmlException("Attribute name must be non-empty");
}
boolean required = DEFAULT_ATTRIBUTE_REQUIRED;
if (requiredValue != null) {
required = Boolean.parseBoolean(requiredValue);
}
boolean active = DEFAULT_ATTRIBUTE_ACTIVE;
if (activeValue != null) {
active = Boolean.parseBoolean(activeValue);
}
RuleAttribute ruleAttribute = KEWServiceLocator.getRuleAttributeService().findByName(attributeName);
if (ruleAttribute == null) {
throw new XmlException("Could not locate rule attribute for name '" + attributeName + "'");
}
RuleTemplateAttributeBo templateAttribute = new RuleTemplateAttributeBo();
templateAttribute.setRuleAttribute(ruleAttribute);
templateAttribute.setRuleAttributeId(ruleAttribute.getId());
templateAttribute.setRuleTemplate(ruleTemplate);
templateAttribute.setRequired(Boolean.valueOf(required));
templateAttribute.setActive(Boolean.valueOf(active));
templateAttribute.setDisplayOrder(new Integer(templateAttributeCounter++));
return templateAttribute;
}
示例4: setupRuleBaseValues
import org.kuali.rice.kew.rule.bo.RuleTemplateAttributeBo; //导入方法依赖的package包/类
private RuleBaseValues setupRuleBaseValues() {
final RuleBaseValues rbv = new RuleBaseValues();
rbv.setActive(Boolean.TRUE);
rbv.setCurrentInd(Boolean.TRUE);
rbv.setDescription("A test rule");
rbv.setDocTypeName("TestDocumentType");
rbv.setForceAction(Boolean.FALSE);
RuleResponsibilityBo ruleResponsibilityBo = new RuleResponsibilityBo();
ruleResponsibilityBo.setResponsibilityId("1234");
ruleResponsibilityBo.setRuleBaseValues(rbv);
ruleResponsibilityBo.setRuleResponsibilityName("user2");
ruleResponsibilityBo.setRuleResponsibilityType(KewApiConstants.RULE_RESPONSIBILITY_WORKFLOW_ID);
rbv.getRuleResponsibilities().add(ruleResponsibilityBo);
RuleTemplateBo ruleTemplate = new RuleTemplateBo();
ruleTemplate.setName("test");
ruleTemplate.setDescription("description");
rbv.setRuleTemplate(ruleTemplate);
RuleTemplateOptionBo ruleTemplateOptionBo = new RuleTemplateOptionBo();
ruleTemplateOptionBo.setCode("TST");
ruleTemplateOptionBo.setValue("VAL");
ruleTemplateOptionBo.setRuleTemplate(ruleTemplate);
ruleTemplate.getRuleTemplateOptions().add(ruleTemplateOptionBo);
RuleTemplateAttributeBo ruleTemplateAttributeBo = new RuleTemplateAttributeBo();
ruleTemplateAttributeBo.setActive(true);
ruleTemplateAttributeBo.setDefaultValue("testAttr");
ruleTemplateAttributeBo.setDisplayOrder(1);
ruleTemplateAttributeBo.setRequired(true);
ruleTemplateAttributeBo.setRuleTemplate(ruleTemplate);
RuleAttribute ruleAttribute = setupRuleAttribute();
ruleTemplateAttributeBo.setRuleAttribute(ruleAttribute);
ruleTemplate.getRuleTemplateAttributes().add(ruleTemplateAttributeBo);
RuleExpressionDef ruleExpressionDef = new RuleExpressionDef();
ruleExpressionDef.setExpression("test");
ruleExpressionDef.setType("TST");
rbv.setRuleExpressionDef(ruleExpressionDef);
RuleExtensionBo ext = new RuleExtensionBo();
RuleExtensionValue val = new RuleExtensionValue();
val.setKey("emptyvalue");
val.setValue("testing");
val.setExtension(ext);
ext.getExtensionValues().add(val);
ext.setRuleBaseValues(rbv);
ext.setRuleTemplateAttribute(ruleTemplateAttributeBo);
rbv.getRuleExtensions().add(ext);
return KRADServiceLocator.getDataObjectService().save(rbv);
}