Package org.springframework.ide.eclipse.quickfix.validator.helper

Examples of org.springframework.ide.eclipse.quickfix.validator.helper.BeansValidationContextHelper


    IProject project = file.getProject();
    ValidationRuleDefinition ruleDefinition = getValidationRule(project, BeanAliasRule.class);
    BeanAliasRule aliasRule = (BeanAliasRule) (ruleDefinition != null ? ruleDefinition.getRule() : null);

    BeansValidationContextHelper context = new BeansValidationContextHelper(attribute, parent, contextElement,
        project, reporter, validator, QuickfixProcessorFactory.ALIAS, false, reportError, config);

    if (aliasRule != null) {
      aliasRule.validate(beanAlias, context, null);
    }

    return context.getErrorFound();
  }
View Full Code Here


      Node factoryMethodAttr = parent.getAttributes().getNamedItem(BeansSchemaConstants.ATTR_FACTORY_METHOD);
      if (factoryMethodAttr != null) {
        parentBean.getBeanDefinition().setFactoryMethodName(factoryMethodAttr.getNodeValue());
      }

      BeansValidationContextHelper context = new BeansValidationContextHelper(attribute, parent, contextElement,
          project, reporter, validator, QuickfixProcessorFactory.FACTORY_BEAN, false, reportError, config);
      context.setCurrentRuleDefinition(ruleDefinition);
      rule.validate(parentBean, context, null);

      if (context.getErrorFound()) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

        BeansSchemaConstants.ATTR_FACTORY_BEAN);
    if (factoryBeanAttr != null) {
      parentBean.getBeanDefinition().setFactoryBeanName(factoryBeanAttr.getNodeValue());
    }

    BeansValidationContextHelper context = new BeansValidationContextHelper(attribute, parent, contextElement,
        project, reporter, validator, QuickfixProcessorFactory.FACTORY_METHOD, false, reportError, config);

    ITextRegion valueRegion = attribute.getValueRegion();

    AbstractBeanDefinition mergedBd = (AbstractBeanDefinition) BeansModelUtils.getMergedBeanDefinition(parentBean,
        context.getContextElement());

    // For non-factory beans validate it's init-method and destroy-method
    String mergedClassName = mergedBd.getBeanClassName();
    if (valueRegion != null && mergedClassName != null) {
      // add rename refactoring option
      validator.createAndAddEmptyMessage(valueRegion, parent, "", reporter,
          QuickfixProcessorFactory.RENAME_METHOD, null, new ValidationProblemAttribute("CLASS",
              mergedClassName));
    }

    if (rule != null) {
      context.setCurrentRuleDefinition(ruleDefinition);
      rule.validate(parentBean, context, null);

      if (context.getErrorFound()) {
        return true;
      }
    }

    return false;
View Full Code Here

        .getRule()
        : null);

    BeanHelper parentBean = new BeanHelper(parent, file, project);

    BeansValidationContextHelper context = new BeansValidationContextHelper(attribute, parent, contextElement,
        project, reporter, validator, QuickfixProcessorFactory.INIT_DESTROY_METHOD, false, reportError, config);

    AbstractBeanDefinition beanDefinition = (AbstractBeanDefinition) parentBean.getBeanDefinition();
    if (attribute.getNodeName().equals(BeansSchemaConstants.ATTR_INIT_METHOD)) {
      beanDefinition.setInitMethodName(attribute.getNodeValue());
    }
    else if (attribute.getNodeName().equals(BeansSchemaConstants.ATTR_DESTROY_METHOD)) {
      beanDefinition.setDestroyMethodName(attribute.getNodeValue());
    }

    // add rename refactoring option
    AbstractBeanDefinition mergedBd = (AbstractBeanDefinition) BeansModelUtils.getMergedBeanDefinition(parentBean,
        context.getContextElement());

    // For non-factory beans validate it's init-method and
    // destroy-method
    String mergedClassName = mergedBd.getBeanClassName();
    if (valueRegion != null && mergedClassName != null) {

      validator.createAndAddEmptyMessage(valueRegion, parent, "", reporter,
          QuickfixProcessorFactory.RENAME_METHOD, null, new ValidationProblemAttribute("CLASS",
              mergedClassName), new ValidationProblemAttribute("METHOD", attribute.getNodeValue()));
    }

    if (initDestroyMethodRule != null) {
      context.setCurrentRuleDefinition(initRuleDefinition);
      initDestroyMethodRule.validate(parentBean, context, null);
    }

    if (context.getErrorFound()) {
      return true;
    }

    ValidationRuleDefinition depracationRuleDefinition = getValidationRule(project, BeanDeprecationRule.class);
    BeanDeprecationRule deprecationRule = (BeanDeprecationRule) (depracationRuleDefinition != null ? depracationRuleDefinition
        .getRule()
        : null);

    context = new BeansValidationContextHelper(attribute, parent, config, project, reporter, validator,
        QuickfixProcessorFactory.DEPRECATED, false, reportError, config);

    if (deprecationRule != null) {
      context.setCurrentRuleDefinition(depracationRuleDefinition);
      deprecationRule.validate(parentBean, context, null);
    }

    return context.getErrorFound();

  }
View Full Code Here

      return false;
    }

    BeanHelper parentBean = new BeanHelper(parentBeanNode, file, project);

    BeansValidationContextHelper context = new BeansValidationContextHelper(attribute, parent, contextElement,
        project, reporter, validator, QuickfixProcessorFactory.PROPERTY, false, reportError, config);
    BeanPropertyHelper property = new BeanPropertyHelper(parent, file, parentBean);

    if (propertyRule != null) {
      context.setCurrentRuleDefinition(propertyRuleDefinition);
      propertyRule.validate(property, context, null);
    }

    if (context.getErrorFound()) {
      return true;
    }

    context = new BeansValidationContextHelper(attribute, parent, contextElement, project, reporter, validator,
        QuickfixProcessorFactory.DEPRECATED, false, reportError, config);

    ITextRegion valueRegion = attribute.getValueRegion();

    AbstractBeanDefinition mergedBd = (AbstractBeanDefinition) BeansModelUtils.getMergedBeanDefinition(parentBean,
        context.getContextElement());

    // For non-factory beans validate it's init-method and
    // destroy-method
    String mergedClassName = mergedBd.getBeanClassName();

    if (valueRegion != null && mergedClassName != null) {
      // add rename refactoring option
      validator.createAndAddEmptyMessage(valueRegion, parent, "", reporter,
          QuickfixProcessorFactory.RENAME_PROPERTY, null, new ValidationProblemAttribute("CLASS",
              mergedClassName));
    }

    if (deprecationRule != null) {
      context.setCurrentRuleDefinition(depracationRuleDefinition);
      deprecationRule.validate(property, context, null);
    }

    return context.getErrorFound();
  }
View Full Code Here

    ValidationRuleDefinition ruleDefinition = getValidationRule(project, BeanClassRule.class);
    BeanClassRule classRule = (BeanClassRule) (ruleDefinition != null ? ruleDefinition.getRule() : null);

    if (classRule != null) {
      BeansValidationContextHelper classContext = new BeansValidationContextHelper(attribute, parent,
          contextElement, project, reporter, validator, QuickfixProcessorFactory.CLASS, false, reportError,
          config);

      classContext.setCurrentRuleDefinition(ruleDefinition);
      classRule.validate(parentBean, classContext, null);

      BeansValidationContextHelper deprecatedContext = new BeansValidationContextHelper(attribute, parent,
          contextElement, project, reporter, validator, QuickfixProcessorFactory.DEPRECATED, false,
          reportError, config);
      ruleDefinition = getValidationRule(project, BeanDeprecationRule.class);
      BeanDeprecationRule deprecationRule = (BeanDeprecationRule) (ruleDefinition != null ? ruleDefinition
          .getRule() : null);

      if (deprecationRule != null) {
        classContext.setCurrentRuleDefinition(ruleDefinition);
        deprecationRule.validate(parentBean, deprecatedContext, null);
      }

      Set<String> problemIdToIgnore = new HashSet<String>();
      problemIdToIgnore.add("MISSING_CONSTRUCTOR_ARG_NAME");
      BeansValidationContextHelper constructorArgContext = new BeansValidationContextHelper(attribute, parent,
          contextElement, project, reporter, validator, QuickfixProcessorFactory.CONSTRUCTOR_ARG, true,
          reportError, config, problemIdToIgnore);
      ruleDefinition = getValidationRule(project, BeanConstructorArgumentRule.class);
      BeanConstructorArgumentRule argRule = (BeanConstructorArgumentRule) (ruleDefinition != null ? ruleDefinition
          .getRule() : null);
      if (argRule != null) {
        constructorArgContext.setCurrentRuleDefinition(ruleDefinition);
        argRule.validate(parentBean, constructorArgContext, null);
      }

      BeansValidationContextHelper requiredContext = new BeansValidationContextHelper(attribute, parent,
          contextElement, project, reporter, validator, QuickfixProcessorFactory.REQUIRED_PROPERTY, false,
          reportError, config);
      ruleDefinition = getValidationRule(project, RequiredPropertyRule.class);
      RequiredPropertyRule requiredRule = (RequiredPropertyRule) (ruleDefinition != null ? ruleDefinition
          .getRule() : null);
      if (requiredRule != null) {
        requiredContext.setCurrentRuleDefinition(ruleDefinition);
        requiredRule.validate(parentBean, classContext, null);
      }

      return classContext.getErrorFound() | deprecatedContext.getErrorFound()
          | constructorArgContext.getErrorFound();
View Full Code Here

    ValidationRuleDefinition ruleDefinition = getValidationRule(project, BeanConstructorArgumentRule.class);
    BeanConstructorArgumentRule constructorArgRule = (BeanConstructorArgumentRule) (ruleDefinition != null ? ruleDefinition
        .getRule() : null);

    if (constructorArgRule != null) {
      BeansValidationContextHelper constructorArgContext = new BeansValidationContextHelper(attribute, parent,
          contextElement, project, reporter, validator, QuickfixProcessorFactory.CONSTRUCTOR_ARG, false,
          reportError, config);
      ruleDefinition = getValidationRule(project, BeanConstructorArgumentRule.class);
      BeanConstructorArgumentRule argRule = (BeanConstructorArgumentRule) (ruleDefinition != null ? ruleDefinition
          .getRule() : null);
      if (argRule != null) {
        constructorArgContext.setCurrentRuleDefinition(ruleDefinition);

        // NodeList childNodes = parentNode.getChildNodes();
        // int counter = 0;
        // for(int i=0; i<childNodes.getLength(); i++) {
        // Node childNode = childNodes.item(i);
        // String localName = childNode.getLocalName();
        // if (localName != null) {
        // if
        // (localName.equals(BeansSchemaConstants.ELEM_CONSTRUCTOR_ARG))
        // {
        // // BeanConstructorArgumentHelper currConstructorArg = new
        // BeanConstructorArgumentHelper(counter, (IDOMNode) childNode,
        // file, parentBean);
        // counter++;
        // if (childNode.equals(parent)) {
        // BeanConstructorArgumentHelper constructorArg = new
        // BeanConstructorArgumentHelper(counter, (IDOMNode) childNode,
        // file, parentBean);
        // }
        // }
        // }
        // }

        argRule.validate(parentBean, constructorArgContext, null);
      }

      return constructorArgContext.getErrorFound();
    }

    return false;
  }
View Full Code Here

TOP

Related Classes of org.springframework.ide.eclipse.quickfix.validator.helper.BeansValidationContextHelper

Copyright © 2018 www.massapicom. 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.