本文整理汇总了Java中org.kuali.rice.kew.api.rule.Rule类的典型用法代码示例。如果您正苦于以下问题:Java Rule类的具体用法?Java Rule怎么用?Java Rule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Rule类属于org.kuali.rice.kew.api.rule包,在下文中一共展示了Rule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRuleByName
import org.kuali.rice.kew.api.rule.Rule; //导入依赖的package包/类
@Override
public Rule getRuleByName(String name) {
incomingParamCheck("name", name);
QueryByCriteria.Builder builder = QueryByCriteria.Builder.create();
builder.setPredicates(
equal("name", name),
equal("currentInd", Boolean.TRUE)
);
QueryResults<RuleBaseValues> results = getDataObjectService().findMatching(RuleBaseValues.class, builder.build());
if (results.getResults().isEmpty()) {
throw new RiceIllegalStateException("Rule with specified name: " + name + " does not exist");
}
if (results.getResults().size() > 1) {
throw new RiceIllegalStateException("Found more than one current rule with specified name " + name);
}
return RuleBaseValues.to(results.getResults().get(0));
}
示例2: findRules
import org.kuali.rice.kew.api.rule.Rule; //导入依赖的package包/类
@Override
public RuleQueryResults findRules(QueryByCriteria queryByCriteria) {
if (queryByCriteria == null) {
throw new RiceIllegalArgumentException("queryByCriteria is null");
}
QueryResults<RuleBaseValues> results = dataObjectService.findMatching(RuleBaseValues.class,
AttributeTransform.getInstance().apply(queryByCriteria));
RuleQueryResults.Builder builder = RuleQueryResults.Builder.create();
builder.setMoreResultsAvailable(results.isMoreResultsAvailable());
builder.setTotalRowCount(results.getTotalRowCount());
final List<Rule.Builder> ims = new ArrayList<Rule.Builder>();
for (RuleBaseValues bo : results.getResults()) {
ims.add(Rule.Builder.create(RuleBaseValues.to(bo)));
}
builder.setResults(ims);
return builder.build();
}
示例3: findRules
import org.kuali.rice.kew.api.rule.Rule; //导入依赖的package包/类
@Override
public RuleQueryResults findRules(QueryByCriteria queryByCriteria) {
if (queryByCriteria == null) {
throw new RiceIllegalArgumentException("queryByCriteria is null");
}
LookupCustomizer.Builder<RuleBaseValues> lc = LookupCustomizer.Builder.create();
lc.setPredicateTransform(AttributeTransform.getInstance());
GenericQueryResults<RuleBaseValues> results = criteriaLookupService.lookup(RuleBaseValues.class, queryByCriteria, lc.build());
RuleQueryResults.Builder builder = RuleQueryResults.Builder.create();
builder.setMoreResultsAvailable(results.isMoreResultsAvailable());
builder.setTotalRowCount(results.getTotalRowCount());
final List<Rule.Builder> ims = new ArrayList<Rule.Builder>();
for (RuleBaseValues bo : results.getResults()) {
ims.add(Rule.Builder.create(RuleBaseValues.to(bo)));
}
builder.setResults(ims);
return builder.build();
}
示例4: create
import org.kuali.rice.kew.api.rule.Rule; //导入依赖的package包/类
public static Builder create(RuleContract rule) {
if (rule == null) {
throw new IllegalArgumentException("contract was null");
}
Builder builder = new Builder();
builder.setRule(Rule.Builder.create(rule));
return builder;
}
示例5: getDuplicateRuleId
import org.kuali.rice.kew.api.rule.Rule; //导入依赖的package包/类
@Override
public String getDuplicateRuleId(RuleBaseValues rule) {
// TODO: this method is extremely slow, if we could implement a more optimized query here, that would help tremendously
Rule baseRule = RuleBaseValues.to(rule);
List<RuleResponsibility> responsibilities = baseRule.getRuleResponsibilities();
List<RuleExtension> extensions = baseRule.getRuleExtensions();
String docTypeName = baseRule.getDocTypeName();
String ruleTemplateName = baseRule.getRuleTemplateName();
//use api service to take advantage of caching
List<Rule> rules = KewApiServiceLocator.getRuleService().getRulesByTemplateNameAndDocumentTypeName(
ruleTemplateName, docTypeName);
for (Rule r : rules) {
if (ObjectUtils.equals(rule.isActive(), r.isActive()) &&
ObjectUtils.equals(docTypeName, r.getDocTypeName()) &&
ObjectUtils.equals(ruleTemplateName, r.getRuleTemplateName()) &&
CollectionUtils.collectionsEquivalent(responsibilities, r.getRuleResponsibilities()) &&
CollectionUtils.collectionsEquivalent(extensions, r.getRuleExtensions())) {
if (ObjectUtils.equals(baseRule.getRuleExpressionDef(), r.getRuleExpressionDef()) ||
(baseRule.getRuleExpressionDef() != null && r.getRuleExpressionDef() != null) &&
ObjectUtils.equals(baseRule.getRuleExpressionDef().getType(), r.getRuleExpressionDef().getType()) &&
ObjectUtils.equals(baseRule.getRuleExpressionDef().getExpression(), r.getRuleExpressionDef().getExpression())) {
// we have a duplicate
return r.getId();
}
}
}
return null;
}
示例6: getRule
import org.kuali.rice.kew.api.rule.Rule; //导入依赖的package包/类
@Override
public Rule getRule(String id) throws RiceIllegalArgumentException, RiceIllegalStateException{
incomingParamCheck("id", id);
RuleBaseValues rbv = getDataObjectService().find(RuleBaseValues.class, id);
if (rbv == null) {
throw new RiceIllegalStateException("Rule with specified id: " + id + " does not exist");
}
return RuleBaseValues.to(rbv);
}
示例7: getRulesByTemplateId
import org.kuali.rice.kew.api.rule.Rule; //导入依赖的package包/类
@Override
public List<Rule> getRulesByTemplateId(
@WebParam(name = "templateId") String templateId) throws RiceIllegalArgumentException {
incomingParamCheck("templateId", templateId);
QueryByCriteria.Builder builder = QueryByCriteria.Builder.create();
builder.setPredicates(equal("ruleTemplateId", templateId), equal("currentInd", Boolean.TRUE));
QueryResults<RuleBaseValues> results = getDataObjectService().findMatching(RuleBaseValues.class, builder.build());
final List<Rule> rules = new ArrayList<Rule>();
for (RuleBaseValues bo : results.getResults()) {
rules.add(Rule.Builder.create(bo).build());
}
return rules;
}
示例8: getRulesByTemplateNameAndDocumentTypeNameAndEffectiveDate
import org.kuali.rice.kew.api.rule.Rule; //导入依赖的package包/类
@Override
public List<Rule> getRulesByTemplateNameAndDocumentTypeNameAndEffectiveDate(String templateName, String documentTypeName,
DateTime effectiveDate)
throws RiceIllegalArgumentException {
QueryByCriteria.Builder query = QueryByCriteria.Builder.create();
List<Predicate> predicates = new ArrayList<Predicate>();
predicates.add(equal("ruleTemplate.name", templateName));
// Check all document types in ancestry
DocumentTypeService documentTypeService = KewApiServiceLocator.getDocumentTypeService();
org.kuali.rice.kew.api.doctype.DocumentType dt = documentTypeService.getDocumentTypeByName(documentTypeName);
List<String> documentTypeAncestryNames = new ArrayList<String>();
while (dt != null) {
documentTypeAncestryNames.add(dt.getName());
dt = dt.getParentId() == null ? null : documentTypeService.getDocumentTypeById(dt.getParentId());
}
predicates.add(in("docTypeName", documentTypeAncestryNames.toArray(
new String[documentTypeAncestryNames.size()])));
DateTime currentTime = new DateTime();
predicates.add(and(
or(isNull("fromDateValue"), lessThanOrEqual("fromDateValue", currentTime)),
or(isNull("toDateValue"), greaterThan("toDateValue", currentTime))
));
predicates.add(equal("active", Boolean.TRUE));
predicates.add(equal("delegateRule", Boolean.FALSE));
predicates.add(equal("templateRuleInd", Boolean.FALSE));
if (effectiveDate != null) {
predicates.add(
and(
or(isNull("activationDate"), lessThanOrEqual("activationDate", effectiveDate)),
or(isNull("deactivationDate"), greaterThan("deactivationDate", effectiveDate))
));
} else {
predicates.add(equal("currentInd", Boolean.TRUE));
}
Predicate p = and(predicates.toArray(new Predicate[]{}));
query.setPredicates(p);
return KewApiServiceLocator.getRuleService().findRules(query.build()).getResults();
}
示例9: getDuplicateRuleId
import org.kuali.rice.kew.api.rule.Rule; //导入依赖的package包/类
public String getDuplicateRuleId(RuleBaseValues rule) {
// TODO: this method is extremely slow, if we could implement a more optimized query here, that would help tremendously
Rule baseRule = RuleBaseValues.to(rule);
List<RuleResponsibility> responsibilities = baseRule.getRuleResponsibilities();
List<RuleExtension> extensions = baseRule.getRuleExtensions();
String docTypeName = baseRule.getDocTypeName();
String ruleTemplateName = baseRule.getRuleTemplateName();
//use api service to take advantage of caching
List<Rule> rules = KewApiServiceLocator.getRuleService().getRulesByTemplateNameAndDocumentTypeName(
ruleTemplateName, docTypeName);
for (Rule r : rules) {
if (ObjectUtils.equals(rule.isActive(), r.isActive()) &&
ObjectUtils.equals(docTypeName, r.getDocTypeName()) &&
ObjectUtils.equals(ruleTemplateName, r.getRuleTemplateName()) &&
CollectionUtils.collectionsEquivalent(responsibilities, r.getRuleResponsibilities()) &&
CollectionUtils.collectionsEquivalent(extensions, r.getRuleExtensions())) {
if (ObjectUtils.equals(baseRule.getRuleExpressionDef(), r.getRuleExpressionDef()) ||
(baseRule.getRuleExpressionDef() != null && r.getRuleExpressionDef() != null) &&
ObjectUtils.equals(baseRule.getRuleExpressionDef().getType(), r.getRuleExpressionDef().getType()) &&
ObjectUtils.equals(baseRule.getRuleExpressionDef().getExpression(), r.getRuleExpressionDef().getExpression())) {
// we have a duplicate
return r.getId();
}
}
}
return null;
}
示例10: getRule
import org.kuali.rice.kew.api.rule.Rule; //导入依赖的package包/类
@Override
public Rule getRule(String id) throws RiceIllegalArgumentException, RiceIllegalStateException{
incomingParamCheck("id", id);
Map<String, String> criteria = Collections.singletonMap("id", id);
RuleBaseValues rbv = this.businessObjectService.findByPrimaryKey(RuleBaseValues.class, criteria);
if (rbv == null) {
throw new RiceIllegalStateException("Rule with specified id: " + id + " does not exist");
}
return RuleBaseValues.to(rbv);
}
示例11: getRuleByName
import org.kuali.rice.kew.api.rule.Rule; //导入依赖的package包/类
@Override
public Rule getRuleByName(String name) {
incomingParamCheck("name", name);
Map<String, Object> criteria = new HashMap<String, Object>(2);
criteria.put("name", name);
criteria.put("currentInd", Boolean.TRUE);
RuleBaseValues rbv = this.businessObjectService.findByPrimaryKey(RuleBaseValues.class, criteria);
if (rbv == null) {
throw new RiceIllegalStateException("Rule with specified name: " + name + " does not exist");
}
return RuleBaseValues.to(rbv);
}
示例12: getRulesByTemplateId
import org.kuali.rice.kew.api.rule.Rule; //导入依赖的package包/类
@Override
public List<Rule> getRulesByTemplateId(
@WebParam(name = "templateId") String templateId) throws RiceIllegalArgumentException {
incomingParamCheck("templateId", templateId);
Map<String, Object> criteria = new HashMap<String, Object>();
criteria.put("ruleTemplateId", templateId);
criteria.put("currentInd", Boolean.TRUE);
Collection<RuleBaseValues> ruleValues = this.businessObjectService.findMatching(RuleBaseValues.class, criteria);
final List<Rule> rules = new ArrayList<Rule>();
for (RuleBaseValues bo : ruleValues) {
rules.add(Rule.Builder.create(bo).build());
}
return rules;
}
示例13: getRulesByTemplateNameAndDocumentTypeNameAndEffectiveDate
import org.kuali.rice.kew.api.rule.Rule; //导入依赖的package包/类
@Override
public List<Rule> getRulesByTemplateNameAndDocumentTypeNameAndEffectiveDate(String templateName, String documentTypeName,
DateTime effectiveDate)
throws RiceIllegalArgumentException {
QueryByCriteria.Builder query = QueryByCriteria.Builder.create();
List<Predicate> predicates = new ArrayList<Predicate>();
predicates.add(equal("ruleTemplate.name", templateName));
// Check all document types in ancestry
DocumentTypeService documentTypeService = KewApiServiceLocator.getDocumentTypeService();
org.kuali.rice.kew.api.doctype.DocumentType dt = documentTypeService.getDocumentTypeByName(documentTypeName);
List<String> documentTypeAncestryNames = new ArrayList<String>();
while (dt != null) {
documentTypeAncestryNames.add(dt.getName());
dt = dt.getParentId() == null ? null : documentTypeService.getDocumentTypeById(dt.getParentId());
}
predicates.add(in("docTypeName", documentTypeAncestryNames.toArray(
new String[documentTypeAncestryNames.size()])));
DateTime currentTime = new DateTime();
predicates.add(and(
or(isNull("fromDateValue"), lessThanOrEqual("fromDateValue", currentTime)),
or(isNull("toDateValue"), greaterThan("toDateValue", currentTime))
));
predicates.add(equal("active", new Integer(1))); //true
predicates.add(equal("delegateRule", new Integer(0))); //false
predicates.add(equal("templateRuleInd", new Integer(0))); //false
if (effectiveDate != null) {
predicates.add(
and(
or(isNull("activationDate"), lessThanOrEqual("activationDate", effectiveDate)),
or(isNull("deactivationDate"), greaterThan("deactivationDate", effectiveDate))
));
} else {
predicates.add(equal("currentInd", new Integer(1))); //true
}
Predicate p = and(predicates.toArray(new Predicate[]{}));
query.setPredicates(p);
return KewApiServiceLocator.getRuleService().findRules(query.build()).getResults();
}
示例14: getRule
import org.kuali.rice.kew.api.rule.Rule; //导入依赖的package包/类
/**
* Retrieve the rule which is being validated.
*/
@Override
public Rule getRule() {
return rule;
}
示例15: setRule
import org.kuali.rice.kew.api.rule.Rule; //导入依赖的package包/类
public void setRule(Rule.Builder rule) {
this.rule = rule;
}