Checks the given model.

@param modelDef   The model
@param checkLevel The amount of checks to perform
@exception ConstraintException If a constraint has been violated
778369
public void check(ModelDef modelDef, String checkLevel) throws ConstraintException
    {
        ensureReferencedKeys(modelDef, checkLevel);
        checkReferenceForeignkeys(modelDef, checkLevel);
        checkCollectionForeignkeys(modelDef, checkLevel);
        checkKeyModifications(modelDef, checkLevel);
    }
192025
@Override
    public void validateDefault(InputProblemReporter rep, boolean normalize)
        throws XMLStreamException
    {
        String normStr = validateDefaultName(rep, normalize);
        if (normalize) {
            mDefValue.setValue(normStr);
        }

        // Ok, but was it declared?

        /* 03-Dec-2004, TSa: This is rather ugly -- need to know we
         *   actually really get a DTD reader, and DTD reader needs
         *   to expose a special method... but it gets things done.
         */
        EntityDecl ent = ((MinimalDTDReader) rep).findEntity(normStr);
        checkEntity(rep, normStr, ent);
    }
427182
def check(ctx, meta_model_file, model_file, ignore_case):
    
    debug = ctx.obj['debug']
    check_model(meta_model_file, model_file, debug, ignore_case)
1320066
public void check(FieldDescriptorDef fieldDef, String checkLevel) throws ConstraintException
    {
        ensureColumn(fieldDef, checkLevel);
        ensureJdbcType(fieldDef, checkLevel);
        ensureConversion(fieldDef, checkLevel);
        ensureLength(fieldDef, checkLevel);
        ensurePrecisionAndScale(fieldDef, checkLevel);
        checkLocking(fieldDef, checkLevel);
        checkSequenceName(fieldDef, checkLevel);
        checkId(fieldDef, checkLevel);
        if (fieldDef.isAnonymous())
        {
            checkAnonymous(fieldDef, checkLevel);
        }
        else
        {
            checkReadonlyAccessForNativePKs(fieldDef, checkLevel);
        }
    }
117412
private void ensureColumn(FieldDescriptorDef fieldDef, String checkLevel)
    {
        if (!fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_COLUMN))
        {
            String javaname = fieldDef.getName();

            if (fieldDef.isNested())
            {    
                int pos = javaname.indexOf("::");

                // we convert nested names ('_' for '::')
                if (pos > 0)
                {
                    StringBuffer newJavaname = new StringBuffer(javaname.substring(0, pos));
                    int          lastPos     = pos + 2;

                    do
                    {
                        pos = javaname.indexOf("::", lastPos);
                        newJavaname.append("_");
                        if (pos > 0)
                        {    
                            newJavaname.append(javaname.substring(lastPos, pos));
                            lastPos = pos + 2;
                        }
                        else
                        {
                            newJavaname.append(javaname.substring(lastPos));
                        }
                    }
                    while (pos > 0);
                    javaname = newJavaname.toString();
                }
            }
            fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_COLUMN, javaname);
        }
    }
1339258
@Override
	public void check() throws JMSException
	{
		if (name == null)
			throw new InvalidDescriptorException("Missing bridge property : 'name'");
		if (enabled == null)
			throw new InvalidDescriptorException("Missing bridge property : 'enabled'");
		if (retryInterval == null)
			throw new InvalidDescriptorException("Missing bridge property : 'retryInterval'");
		if (getRetryInterval() < 0)
			throw new InvalidDescriptorException("Bridge property 'retryInterval' should be >= 0");
		if (commitSourceFirst == null)
			throw new InvalidDescriptorException("Missing bridge property : 'commitSourceFirst'");
		if (producerTransacted == null)
			throw new InvalidDescriptorException("Missing bridge property : 'producerTransacted'");
		if (consumerTransacted == null)
			throw new InvalidDescriptorException("Missing bridge property : 'consumerTransacted'");
		if (!isConsumerTransacted())
		{
			if (consumerAcknowledgeMode == -1)
				throw new InvalidDescriptorException("Missing bridge property : 'consumerAcknowledgeMode'");
		}
		if (producerDeliveryMode == -1)
			throw new InvalidDescriptorException("Missing bridge property : 'producerDeliveryMode'");
		
		source.check();
		target.check();
		sourceDestination.check();
		targetDestination.check();
	}
345926
def check_constraints(self, instance):
        '''
        
        '''
        recalc_fields = []
        for constraint in self.constraints:
            try:
                constraint(self.model, instance)
            except constraints.InvalidConstraint as e:
                recalc_fields.extend(e.fields)
        return recalc_fields
1144642
private Set<String> checkModel(final ModelNode model, TransformationContext context) throws OperationFailedException {
        final Set<String> attributes = new HashSet<String>();
        AttributeTransformationRequirementChecker checker;
        for (final String attribute : attributeNames) {
            if (model.hasDefined(attribute)) {
                if (attributeCheckers != null && (checker = attributeCheckers.get(attribute)) != null) {
                    if (checker.isAttributeTransformationRequired(attribute, model.get(attribute), context)) {
                        attributes.add(attribute);
                    }
                } else if (SIMPLE_EXPRESSIONS.isAttributeTransformationRequired(attribute, model.get(attribute), context)) {
                    attributes.add(attribute);
                }
            }
        }
        return attributes;
    }
919205
public void check(ReconfigurationPlan p) throws SatConstraintViolationException {
        if (checkers.isEmpty()) {
            return;
        }

        checkModel(p.getOrigin(), true);

        if (!p.getActions().isEmpty()) {
            PriorityQueue<Action> starts = new PriorityQueue<>(p.getActions().size(), STARTS_CMP);
            PriorityQueue<Action> ends = new PriorityQueue<>(p.getActions().size(), ENDS_CMP);
            starts.addAll(p.getActions());
            ends.addAll(p.getActions());

            //Starts the actions
            int curMoment = starts.peek().getStart();
            while (!starts.isEmpty() || !ends.isEmpty()) {
                Action a = ends.peek();
                while (a != null && a.getEnd() == curMoment) {
                    ends.remove();
                    startingEvent = false;
                    visitAndThrowOnViolation(a);
                    visitEvents(a, Action.Hook.POST);
                    a = ends.peek();
                }
                a = starts.peek();

                while (a != null && a.getStart() == curMoment) {
                    starts.remove();
                    startingEvent = true;
                    visitEvents(a, Action.Hook.PRE);
                    visitAndThrowOnViolation(a);
                    a = starts.peek();
                }
                int nextEnd = Integer.MAX_VALUE;
                if (!ends.isEmpty()) {
                    nextEnd = ends.peek().getEnd();
                }
                int nextStart = Integer.MAX_VALUE;
                if (!starts.isEmpty()) {
                    nextStart = starts.peek().getStart();
                }

                curMoment = Math.min(nextEnd, nextStart);
            }
        }
        Model mo = p.getResult();
        if (mo == null) {
            throw new InconsistentSolutionException(p.getOrigin(), p, "The resulting reconfiguration plan is not applyable");
        }
        checkModel(mo, false);
    }
4305
private void ensurePrecisionAndScale(FieldDescriptorDef fieldDef, String checkLevel)
    {
        fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_PRECISION, null);
        fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_SCALE, null);
        if (!fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_PRECISION))
        {
            String defaultPrecision = JdbcTypeHelper.getDefaultPrecisionFor(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));

            if (defaultPrecision != null)
            {
                LogHelper.warn(true,
                               FieldDescriptorConstraints.class,
                               "ensureLength",
                               "The field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" has no precision setting though its jdbc type requires it (in most databases); using default precision of "+defaultPrecision);
                fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_PRECISION, defaultPrecision);
            }
            else if (fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_SCALE))
            {
                fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_PRECISION, "1");
            }
        }
        if (!fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_SCALE))
         {
            String defaultScale = JdbcTypeHelper.getDefaultScaleFor(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));

            if (defaultScale != null)
            {
                LogHelper.warn(true,
                               FieldDescriptorConstraints.class,
                               "ensureLength",
                               "The field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" has no scale setting though its jdbc type requires it (in most databases); using default scale of "+defaultScale);
                fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_SCALE, defaultScale);
            }
            else if (fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_PRECISION) || fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_PRECISION))
            {
                fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_SCALE, "0");
            }
        }
    }
106307
private void addIndex(IndexDescriptorDef indexDescDef, TableDef tableDef)
    {
        IndexDef indexDef = tableDef.getIndex(indexDescDef.getName());

        if (indexDef == null)
        {
            indexDef = new IndexDef(indexDescDef.getName(),
                                    indexDescDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_UNIQUE, false));
            tableDef.addIndex(indexDef);
        }

        try
        {
            String             fieldNames = indexDescDef.getProperty(PropertyHelper.OJB_PROPERTY_FIELDS);
            ArrayList          fields     = ((ClassDescriptorDef)indexDescDef.getOwner()).getFields(fieldNames);
            FieldDescriptorDef fieldDef;

            for (Iterator it = fields.iterator(); it.hasNext();)
            {
                fieldDef = (FieldDescriptorDef)it.next();
                indexDef.addColumn(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN));
            }
        }
        catch (NoSuchFieldException ex)
        {
            // won't happen if we already checked the constraints
        }
    }
819923
@Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        List<String> emailAddresses = EmailAddressesParser.parse(value);
        List<String> badAddresses = null;
        for (String ea : emailAddresses) {
            if (!EMAIL_VALIDATOR.isValid(ea, null)) {
                if (badAddresses == null) {
                    badAddresses = new LinkedList<String>();
                }

                badAddresses.add(ea);
            }
        }

        if (badAddresses != null) {
            context.disableDefaultConstraintViolation();
            context.buildConstraintViolationWithTemplate(MessageFormat.format(constraintAnnotation.message(),
                                                                              StringUtils.join(badAddresses, ", ")))
                   .addConstraintViolation();
        }
        return (badAddresses == null);
    }
844614
@SuppressWarnings("unchecked")
	public ValidationPlanResult execute(ValidationCheck check, Object target) throws ValidationEngineException {
		
		
		if (check == null)
		{
			return validationPlanResult;
		}
		try
		{
		 check.setEmblEntryValidationPlanProperty(planProperty);
		 if(planProperty.enproConnection.get()!=null&&entryDAOUtils==null)
		 {
			 entryDAOUtils=new EntryDAOUtilsImpl(planProperty.enproConnection.get(),true);
		 }
		 check.setEntryDAOUtils(entryDAOUtils);
		 if(planProperty.eraproConnection.get()!=null&&eraproDAOUtils==null)
		 {
			 eraproDAOUtils = new EraproDAOUtilsImpl(planProperty.eraproConnection.get());
		 }
		 
		check.setEraproDAOUtils(eraproDAOUtils);
		}catch(Exception e)
		{
			throw new ValidationEngineException(e);
		}
		//long start= System.currentTimeMillis();
		Class<? extends ValidationCheck> checkClass = check.getClass();
		ExcludeScope excludeScopeAnnotation = checkClass.getAnnotation(ExcludeScope.class);
		RemoteExclude remoteExclude = checkClass.getAnnotation(RemoteExclude.class);
		Description descAnnotation = checkClass.getAnnotation(Description.class);
		GroupIncludeScope groupIncludeAnnotation = checkClass.getAnnotation(GroupIncludeScope.class);

		if(remoteExclude!=null&&remote)
		{
			return validationPlanResult;
		}
        if (excludeScopeAnnotation != null && isInValidationScope(excludeScopeAnnotation.validationScope())) {
			return validationPlanResult;
		}
        
        if(groupIncludeAnnotation!=null && !isInValidationScopeGroup(groupIncludeAnnotation.group()))
        {
        	return validationPlanResult;
        }


        // inject data sets
        /*if(null != checkDataSetAnnotation) {
			Stream.of(checkDataSetAnnotation.dataSetNames()).forEach( dsName -> GlobalDataSets.loadIfNotExist(dsName, dataManager, fileManager, devMode));
        }
*/
        validationPlanResult.append(check.check(target));

        if (excludeScopeAnnotation != null) {
            demoteSeverity(validationPlanResult, excludeScopeAnnotation.maxSeverity());
        }
        if(groupIncludeAnnotation!=null)
        {
        	demoteSeverity(validationPlanResult, groupIncludeAnnotation.maxSeverity());
        }

//        System.out.println(this.result.count());
        
        return validationPlanResult;
	}
392678
private static Constraint loadConstraint(Annotation context) {
        Constraint constraint = null;
        final ServiceLoader<Constraint> constraints = ServiceLoader.load(Constraint.class);

        for (Constraint aConstraint : constraints) {
            try {
                aConstraint.getClass().getDeclaredMethod("check", context.annotationType());
                constraint = aConstraint;
                break;
            } catch (NoSuchMethodException e) {
                // Look for next implementation if method not found with required signature.
            }
        }

        if (constraint == null) {
            throw new IllegalStateException("Couldn't found any implementation of " + Constraint.class.getName());
        }
        return constraint;
    }
1009602
protected function determineModelState(ModelInterface $model, $level)
    {
        $model->setMeta(DCGE::TREE_VIEW_LEVEL, $level);
        $model->setMeta(
            $model::SHOW_CHILDREN,
            $this->getTreeNodeStates()->isModelOpen(
                $model->getProviderName(),
                $model->getId()
            )
        );
    }
1218077
private void ensureReferencedFKs(ModelDef modelDef, CollectionDescriptorDef collDef) throws ConstraintException
    {
        String             elementClassName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
        ClassDescriptorDef elementClassDef  = modelDef.getClass(elementClassName);
        String             fkFieldNames     = collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
        ArrayList          missingFields    = new ArrayList();
        SequencedHashMap   fkFields         = new SequencedHashMap();

        // first we gather all field names
        for (CommaListIterator it = new CommaListIterator(fkFieldNames); it.hasNext();)
        {
            String             fieldName = (String)it.next();
            FieldDescriptorDef fieldDef  = elementClassDef.getField(fieldName);

            if (fieldDef == null)
            {
                missingFields.add(fieldName);
            }
            fkFields.put(fieldName, fieldDef);
        }

        // next we traverse all sub types and gather fields as we go
        for (Iterator it = elementClassDef.getAllExtentClasses(); it.hasNext() && !missingFields.isEmpty();)
        {
            ClassDescriptorDef subTypeDef = (ClassDescriptorDef)it.next();

            for (int idx = 0; idx < missingFields.size();)
            {
                FieldDescriptorDef fieldDef = subTypeDef.getField((String)missingFields.get(idx));

                if (fieldDef != null)
                {
                    fkFields.put(fieldDef.getName(), fieldDef);
                    missingFields.remove(idx);
                }
                else
                {
                    idx++;
                }
            }
        }
        if (!missingFields.isEmpty())
        {
            throw new ConstraintException("Cannot find field "+missingFields.get(0).toString()+" in the hierarchy with root type "+
                                          elementClassDef.getName()+" which is used as foreignkey in collection "+
                                          collDef.getName()+" in "+collDef.getOwner().getName());
        }

        // copy the found fields into the element class
        ensureFields(elementClassDef, fkFields.values());
    }
1199666
public boolean isConstraintError(SQLException e) {
        if (e != null) {
            String sqlstate = e.getSQLState();
            if (sqlstate != null) {
                return sqlstate.startsWith(SQLSTATE_CONSTRAINT_VIOLATION_CLASS_CODE);
            }
        }
        return false;
    }