Examples of Rules


Examples of org.springframework.rules.Rules

        applicationServices.setRulesSource(new BusinessRulesSource());
    }

    private class BusinessRulesSource extends DefaultRulesSource {
        public BusinessRulesSource() {
            Rules rules = new Rules(BusinessObject.class);
            rules.add(BUSINESS_FIELD, rules.required());
            addRules(rules);
        }
View Full Code Here

Examples of org.springframework.rules.Rules

     * May be implemented in subclasses that need to register services with the global
     * application services instance.
     */
    protected void registerAdditionalServices( DefaultApplicationServices applicationServices ) {
        DefaultRulesSource rulesSource = new DefaultRulesSource();
        Rules rules = new Rules(TestBean.class);
        rules.add("field", rules.required());
        rulesSource.addRules(rules);

        applicationServices.setRulesSource(rulesSource);
    }
View Full Code Here

Examples of org.springframework.rules.Rules

    private Rules interfaceRules;

    protected void setUp() throws Exception {
        source = new DefaultRulesSource();
        interfaceRules = new Rules(TestInterface.class);
    }
View Full Code Here

Examples of org.springframework.rules.Rules

    // also clear results.
    if ((propertyName == null) || ((objectClass != null) && objectClass != object.getClass())) {
      clearMessages();
    }
    objectClass = object.getClass();
    Rules rules = null;
    if (object instanceof PropertyConstraintProvider) {
      PropertyConstraintProvider propertyConstraintProvider = (PropertyConstraintProvider) object;
      if (propertyName != null) {
        PropertyConstraint validationRule = propertyConstraintProvider.getPropertyConstraint(propertyName);
        checkRule(validationRule);
      }
      else {
        for (Iterator fieldNamesIter = formModel.getFieldNames().iterator(); fieldNamesIter.hasNext();) {
          PropertyConstraint validationRule = propertyConstraintProvider
              .getPropertyConstraint((String) fieldNamesIter.next());
          checkRule(validationRule);
        }
      }
    }
    else {
      if (getRulesSource() != null) {
        rules = getRulesSource().getRules(objectClass, getRulesContextId());
        if (rules != null) {
          for (Iterator i = rules.iterator(); i.hasNext();) {
            PropertyConstraint validationRule = (PropertyConstraint) i.next();
            if (propertyName == null) {
              if (formModel.hasValueModel(validationRule.getPropertyName())) {
                checkRule(validationRule);
              }
View Full Code Here

Examples of org.switchyard.component.rules.annotation.Rules

     */
    public ComponentModel scan(Class<?> rulesClass, SwitchYardNamespace switchyardNamespace) throws IOException {
        if (switchyardNamespace == null) {
            switchyardNamespace = SwitchYardNamespace.DEFAULT;
        }
        Rules rules = rulesClass.getAnnotation(Rules.class);
        Class<?> rulesInterface = rules.value();
        if (Rules.UndefinedRulesInterface.class.equals(rulesInterface)) {
            rulesInterface = rulesClass;
        }
        if (!rulesInterface.isInterface()) {
            throw RulesMessages.MESSAGES.rulesInterfaceGetNameIsAClassRulesOnlyAllowedOnInterfaces(rulesInterface.getName());
        }
        String rulesName = Strings.trimToNull(rules.name());
        if (rulesName == null) {
            rulesName = rulesInterface.getSimpleName();
        }
        ComponentModel componentModel = new V1ComponentModel();
        componentModel.setName(rulesName);
        RulesNamespace rulesNamespace = RulesNamespace.fromUri(rules.namespace());
        if (rulesNamespace == null) {
            rulesNamespace = RulesNamespace.DEFAULT;
            for (RulesNamespace value : RulesNamespace.values()) {
                if (value.versionMatches(switchyardNamespace)) {
                    rulesNamespace = value;
                    break;
                }
            }
        }
        RulesComponentImplementationModel componentImplementationModel = new V1RulesComponentImplementationModel(rulesNamespace.uri());
        OperationsModel operationsModel = new V1OperationsModel(rulesNamespace.uri());
        JavaService javaService = JavaService.fromClass(rulesInterface);
        for (Method method : rulesClass.getDeclaredMethods()) {
            RulesOperationType operationType = null;
            String eventId = null;
            Global[] globalMappingAnnotations = null;
            Input[] inputMappingAnnotations = null;
            Output[] outputMappingAnnotations = null;
            Fault[] faultMappingAnnotations = null;
            if (EXECUTE_FILTER.matches(method)) {
                operationType = RulesOperationType.EXECUTE;
                Execute executeAnnotation = method.getAnnotation(Execute.class);
                globalMappingAnnotations = executeAnnotation.globals();
                inputMappingAnnotations = executeAnnotation.inputs();
                outputMappingAnnotations = executeAnnotation.outputs();
                faultMappingAnnotations = executeAnnotation.faults();
            } else if (INSERT_FILTER.matches(method)) {
                operationType = RulesOperationType.INSERT;
                Insert insertAnnotation = method.getAnnotation(Insert.class);
                globalMappingAnnotations = insertAnnotation.globals();
                inputMappingAnnotations = insertAnnotation.inputs();
                outputMappingAnnotations = insertAnnotation.outputs();
                faultMappingAnnotations = insertAnnotation.faults();
            } else if (FIRE_ALL_RULES_FILTER.matches(method)) {
                operationType = RulesOperationType.FIRE_ALL_RULES;
                FireAllRules fireAllRulesAnnotation = method.getAnnotation(FireAllRules.class);
                globalMappingAnnotations = fireAllRulesAnnotation.globals();
                inputMappingAnnotations = fireAllRulesAnnotation.inputs();
                outputMappingAnnotations = fireAllRulesAnnotation.outputs();
                faultMappingAnnotations = fireAllRulesAnnotation.faults();
            } else if (FIRE_UNTIL_HALT_FILTER.matches(method)) {
                operationType = RulesOperationType.FIRE_UNTIL_HALT;
                FireUntilHalt fireUntilHaltAnnotation = method.getAnnotation(FireUntilHalt.class);
                eventId = Strings.trimToNull(fireUntilHaltAnnotation.eventId());
                globalMappingAnnotations = fireUntilHaltAnnotation.globals();
                inputMappingAnnotations = fireUntilHaltAnnotation.inputs();
                outputMappingAnnotations = fireUntilHaltAnnotation.outputs();
                faultMappingAnnotations = fireUntilHaltAnnotation.faults();
            }
            if (operationType != null) {
                ServiceOperation serviceOperation = javaService.getOperation(method.getName());
                if (serviceOperation != null) {
                    OperationModel operationModel = new V1RulesOperationModel(rulesNamespace.uri());
                    operationModel.setEventId(eventId);
                    operationModel.setName(serviceOperation.getName());
                    operationModel.setType(operationType);
                    operationModel.setGlobals(toGlobalsModel(globalMappingAnnotations, rulesNamespace));
                    operationModel.setInputs(toInputsModel(inputMappingAnnotations, rulesNamespace));
                    operationModel.setOutputs(toOutputsModel(outputMappingAnnotations, rulesNamespace));
                    operationModel.setFaults(toFaultsModel(faultMappingAnnotations, rulesNamespace));
                    operationsModel.addOperation(operationModel);
                }
            }
        }
        if (!operationsModel.getOperations().isEmpty()) {
            componentImplementationModel.setOperations(operationsModel);
        }
        componentImplementationModel.setChannels(toChannelsModel(rules.channels(), rulesNamespace, componentModel, switchyardNamespace));
        componentImplementationModel.setListeners(toListenersModel(rules.listeners(), rulesNamespace));
        componentImplementationModel.setLoggers(toLoggersModel(rules.loggers(), rulesNamespace));
        componentImplementationModel.setManifest(toManifestModel(rules.manifest(), rulesNamespace));
        componentImplementationModel.setProperties(toPropertiesModel(rules.properties(), rulesNamespace));
        componentModel.setImplementation(componentImplementationModel);
        ComponentServiceModel componentServiceModel = new V1ComponentServiceModel(switchyardNamespace.uri());
        InterfaceModel interfaceModel = new V1InterfaceModel(InterfaceModel.JAVA);
        interfaceModel.setInterface(rulesInterface.getName());
        componentServiceModel.setInterface(interfaceModel);
View Full Code Here

Examples of pdp.scrabble.ihm.Rules

    this.mainFrame.exit();
  }

 
  public void rules() { 
    Rules rules = new Rules(this.mainFrame);
    rules.showRules();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.