If simple type has conditions attached to it, emit enumeration facets.

@param xsdDataItem COBOL data item decorated with XSD attributes
@param restriction the current set of constraints
762763
protected void addEnumerationFacets(final XsdDataItem xsdDataItem,
            final XmlSchemaSimpleTypeRestriction restriction) {
        if (getConfig().mapConditionsToFacets()) {
            boolean hasValueThru = false;
            for (XsdDataItem child : xsdDataItem.getChildren()) {
                if (child.getDataEntryType() == DataEntryType.CONDITION) {
                    for (String conditionValue : child.getConditionLiterals()) {
                        restriction.getFacets().add(
                                createEnumerationFacet(ValueUtil
                                        .resolveFigurative(conditionValue,
                                                xsdDataItem
                                                        .getMaxStorageLength(),
                                                getConfig().quoteIsQuote())));
                    }
                    for (Range conditionRange : child.getConditionRanges()) {
                        if (hasValueThru) {
                            _log.warn(xsdDataItem.getCobolName()
                                    + " has several VALUE THRU statements."
                                    + " Cannot translate to XSD."
                                    + " Only the first one will be converted."
                                    + " Ignoring: " + conditionRange.toString());
                            break;
                        }
                        restriction.getFacets().add(
                                createMinInclusiveFacet(ValueUtil
                                        .resolveFigurative(conditionRange
                                                .getFrom(), xsdDataItem
                                                .getMaxStorageLength(),
                                                getConfig().quoteIsQuote())));
                        restriction.getFacets().add(
                                createMaxInclusiveFacet(ValueUtil
                                        .resolveFigurative(conditionRange
                                                .getTo(), xsdDataItem
                                                .getMaxStorageLength(),
                                                getConfig().quoteIsQuote())));
                        hasValueThru = true;
                    }

                }
            }
        }
    }
491578
private static void loadRestrictionsToAttribute(XsdAttribute attribute, MethodVisitor mVisitor, String javaType, boolean hasEnum) {
        getAttributeRestrictions(attribute).forEach(restriction -> loadRestrictionToAttribute(mVisitor, restriction, javaType, hasEnum ? 1 : 0));

        mVisitor.visitInsn(RETURN);
        mVisitor.visitMaxs(4, hasEnum ? 2 : 1);
        mVisitor.visitEnd();
    }
244113
void setExtensionsState(Map<String, Boolean> extensionsState) {
        if (extensionsState == null) {
            throw new IllegalArgumentException("Parameter extensionsState must not be null.");
        }

        ((HierarchicalConfiguration) getConfig()).clearTree(ALL_EXTENSIONS_KEY);
        int enabledCount = 0;
        for (Iterator<Map.Entry<String, Boolean>> it = extensionsState.entrySet().iterator(); it.hasNext();) {
            Map.Entry<String, Boolean> entry = it.next();
            if (entry.getKey() == null || entry.getValue() == null) {
                continue;
            }

            // Don't persist if enabled, extensions are enabled by default.
            if (!entry.getValue()) {
                String elementBaseKey = ALL_EXTENSIONS_KEY + "(" + enabledCount + ").";
                getConfig().setProperty(elementBaseKey + EXTENSION_NAME_KEY, entry.getKey());
                getConfig().setProperty(elementBaseKey + EXTENSION_ENABLED_KEY, Boolean.FALSE);

                enabledCount++;
            }
        }
        this.extensionsState = Collections.unmodifiableMap(extensionsState);
    }
762154
static void validateExtends(EntityType entityType) {
    EntityType entityTypeExtends = entityType.getExtends();
    if (entityTypeExtends != null && !entityTypeExtends.isAbstract()) {
      throw new MolgenisValidationException(
          new ConstraintViolation(
              format(
                  "EntityType [%s] is not abstract; EntityType [%s] can't extend it",
                  entityTypeExtends.getId(), entityType.getId())));
    }
  }
63555
void enforceRowConstraints(Session session, Object[] data) {

        for (int i = 0; i < defaultColumnMap.length; i++) {
            Type type = colTypes[i];

            data[i] = type.convertToTypeLimits(session, data[i]);

            if (type.isDomainType()) {
                Constraint[] constraints =
                    type.userTypeModifier.getConstraints();

                for (int j = 0; j < constraints.length; j++) {
                    constraints[j].checkCheckConstraint(session, this,
                                                        data[i]);
                }
            }

            if (data[i] == null) {
                if (colNotNull[i]) {
                    Constraint c = getNotNullConstraintForColumn(i);

                    if (c == null) {
                        if (getColumn(i).isPrimaryKey()) {
                            c = this.getPrimaryConstraint();
                        }
                    }

                    String[] info = new String[] {
                        c.getName().name, tableName.name
                    };

                    throw Error.error(ErrorCode.X_23503, ErrorCode.CONSTRAINT,
                                      info);
                }
            }
        }
    }
1371888
@Override
    public void validateElementStart(String localName, String uri, String prefix)
        throws XMLStreamException
    {
        // Ok, can we find the element definition?
        mTmpKey.reset(prefix, localName);
        DTDElement elem = mElemSpecs.get(mTmpKey);
        // whether it's found or not, let's add a stack frame:
        int elemCount = mElemCount++;
        if (elemCount >= mElems.length) {
            mElems = (DTDElement[]) DataUtil.growArrayBy50Pct(mElems);
        }

        mElems[elemCount] = mCurrElem = elem;
        mAttrCount = 0;
        mIdAttrIndex = -2; // -2 as a "don't know yet" marker

        /* but if not found, can not obtain any type information. Not
         * a validation problem though, since we are doing none...
         * Oh, also, unlike with real validation, not having actual element
         * information is ok; can still have attributes!
         */
        if (elem == null) { // || !elem.isDefined())
            mCurrAttrDefs = NO_ATTRS;
            mHasAttrDefaults = false;
            mCurrDefaultAttrs = null;
            mHasNormalizableAttrs = false;
            return;
        }

        // If element found, does it have any attributes?
        mCurrAttrDefs = elem.getAttributes();
        if (mCurrAttrDefs == null) {
            mCurrAttrDefs = NO_ATTRS;
            mHasAttrDefaults = false;
            mCurrDefaultAttrs = null;
            mHasNormalizableAttrs = false;
            return;
        }

        // Any normalization needed?
        mHasNormalizableAttrs = mNormAttrs || elem.attrsNeedValidation();

        // Any default values?
        mHasAttrDefaults = elem.hasAttrDefaultValues();
        if (mHasAttrDefaults) {
            /* Special count also contains ones with #REQUIRED value, but
             * that's a minor sub-optimality...
             */
            int specCount = elem.getSpecialCount();
            BitSet bs = mTmpDefaultAttrs;
            if (bs == null) {
                mTmpDefaultAttrs = bs = new BitSet(specCount);
            } else {
                bs.clear();
            }
            mCurrDefaultAttrs = bs;
        } else {
            mCurrDefaultAttrs = null;
        }
    }
1362785
public ChainingXmlWriter register(String parameterName, ICalDataType dataType) {
		parameterDataTypes.put(parameterName, dataType);
		return this;
	}
1294476
private void validateNodeType(NodeTypeData nodeType) throws RepositoryException
   {
      if (nodeType == null)
      {
         throw new RepositoryException("NodeType object " + nodeType + " is null");
      }

      if (nodeType.getName() == null)
      {
         throw new RepositoryException("NodeType implementation class " + nodeType.getClass().getName()
            + " is not supported in this method");
      }

      for (InternalQName sname : nodeType.getDeclaredSupertypeNames())
      {
         if (!nodeType.getName().equals(Constants.NT_BASE) && nodeType.getName().equals(sname))
         {
            throw new RepositoryException("Invalid super type name" + sname.getAsString());
         }
      }

      for (PropertyDefinitionData pdef : nodeType.getDeclaredPropertyDefinitions())
      {
         if (!pdef.getDeclaringNodeType().equals(nodeType.getName()))
         {
            throw new RepositoryException("Invalid declared node type in property definitions with name "
               + pdef.getName().getAsString() + " not registred");
         }
         
         // validate default values
         try
         {
            validateValueDefaults(pdef.getRequiredType(), pdef.getDefaultValues());
         }
         catch (ValueFormatException e)
         {
            throw new ValueFormatException("Default value is incompatible with Property type "
               + PropertyType.nameFromValue(pdef.getRequiredType()) + " of " + pdef.getName().getAsString()
               + " in nodetype " + nodeType.getName().getAsString(), e);
         }
         
         try
         {
            validateValueConstraints(pdef.getRequiredType(), pdef.getValueConstraints());
         }
         catch (ValueFormatException e)
         {
            throw new ValueFormatException("Constraints is incompatible with Property type "
               + PropertyType.nameFromValue(pdef.getRequiredType()) + " of " + pdef.getName().getAsString()
               + " in nodetype " + nodeType.getName().getAsString(), e);
         }
      }

      for (NodeDefinitionData cndef : nodeType.getDeclaredChildNodeDefinitions())
      {
         if (!cndef.getDeclaringNodeType().equals(nodeType.getName()))
         {
            throw new RepositoryException("Invalid declared node type in child node definitions with name "
               + cndef.getName().getAsString() + " not registred");
         }
      }
   }
83535
private static boolean propertyFilter(final Triple t, final IRI ixnModel) {
        return typeMap.getOrDefault(ixnModel, LdpConstraints::basicConstraints).test(t);
    }
827369
def also_restrict_to(self, restriction):
        
        if type(restriction) != list:
            restriction = [ restriction ]
        self._also_restriction = restriction
907299
@Override
    public VoltXMLElement voltGetIndexXML(Session session, String tableName,
            Map<String, VoltXMLElement> indexConstraintMapping)
                    throws org.hsqldb_voltpatches.HSQLInterface.HSQLParseException {
        org.hsqldb_voltpatches.VoltXMLElement index = new org.hsqldb_voltpatches.VoltXMLElement("index");

        // Add any expressions to the XML representation of the index,
        // and compute a hash that will help uniquify the generated name,
        // if a name was not provided.
        int exprHash = 0;
        if (exprs != null) {
            org.hsqldb_voltpatches.VoltXMLElement indexedExprs = new org.hsqldb_voltpatches.VoltXMLElement("exprs");
            index.children.add(indexedExprs);
            String hashExprString = new String();
            String sep = "";
            for (org.hsqldb_voltpatches.Expression expression : exprs) {
                org.hsqldb_voltpatches.VoltXMLElement xml = expression.voltGetExpressionXML(session, (Table) table);
                indexedExprs.children.add(xml);
                hashExprString += sep + expression.getSQL();
                sep = ",";
            }

            byte[] bytes = hashExprString.getBytes();
            for (int ii = 0; ii < bytes.length; ii++) {
                exprHash = 31 * exprHash + bytes[ii];
            }
        }

        String hsqlIndexName = getName().name;
        String voltdbIndexName = null;
        boolean isHashIndex = false;

        if (indexConstraintMapping.containsKey(hsqlIndexName)) {
            // This is an index backing a constraint.
            VoltXMLElement constraintXml = indexConstraintMapping.get(hsqlIndexName);
            indexConstraintMapping.remove(hsqlIndexName);

            boolean isAutoName = constraintXml.attributes.get("nameisauto").equals("true");

            // This is either a [ASSUME]UNIQUE constraint or a PK.
            String constraintType = constraintXml.attributes.get("constrainttype");
            String hsqlConstraintName = constraintXml.attributes.get("name");

            if (!isAutoName) {
                isHashIndex = isNameRequestingHashIndex(hsqlConstraintName);
                voltdbIndexName = HSQLInterface.AUTO_GEN_NAMED_CONSTRAINT_IDX + hsqlConstraintName;
            }
            else {
                String prefix = null;
                boolean isPrimaryKey = constraintType.equals("PRIMARY_KEY");
                if (isPrimaryKey) {
                    prefix = HSQLInterface.AUTO_GEN_PRIMARY_KEY_PREFIX;
                }
                else {
                    prefix = HSQLInterface.AUTO_GEN_UNIQUE_IDX_PREFIX;
                }

                String namePart = tableName + "_" + StringUtils.join(getColumnNameList().toArray(), "_");
                if (exprs != null) {
                    namePart += "_" + java.lang.Math.abs(exprHash % 100000);
                }

                voltdbIndexName = prefix + namePart;

                // Also name the constraint here based on our naming scheme.
                String voltdbConstraintName = null;
                if (isPrimaryKey) {
                    voltdbConstraintName = HSQLInterface.AUTO_GEN_CONSTRAINT_PREFIX + "_PK_" + namePart;
                }
                else {
                    voltdbConstraintName = HSQLInterface.AUTO_GEN_CONSTRAINT_PREFIX + "_CT_" + namePart;

                }

                constraintXml.attributes.put("name", voltdbConstraintName);
            }

            // Update the index name in the constraint.
            constraintXml.attributes.put("index", voltdbIndexName);
        }
        else {
            // This is an index created via CREATE INDEX
            isHashIndex = isNameRequestingHashIndex(hsqlIndexName);
            voltdbIndexName = hsqlIndexName;
        }

        index.attributes.put("name", voltdbIndexName);
        index.attributes.put("ishashindex", isHashIndex ? "true" : "false");

        index.attributes.put("assumeunique", isAssumeUnique() ? "true" : "false");
        index.attributes.put("unique", isUnique() ? "true" : "false");
        index.attributes.put("migrating", isMigrating() ? "true" : "false");
        assert ! (isMigrating() && (isUnique() || isAssumeUnique())) :
                "Cannot create a MIGRATING index that is also UNIQUE or ASSUMEUNIQUE";

        Object[] columnList = getColumnNameList().toArray();
        index.attributes.put("columns", StringUtils.join(columnList, ","));

        if (predicate != null) {
            org.hsqldb_voltpatches.VoltXMLElement partialExpr = new org.hsqldb_voltpatches.VoltXMLElement("predicate");
            index.children.add(partialExpr);
            org.hsqldb_voltpatches.VoltXMLElement xml = predicate.voltGetExpressionXML(session, (Table) table);
            partialExpr.children.add(xml);
        }

        return index;
    }
101439
function (oProperty, oEntitySet) {
			var aFilterRestrictions,
				sFilterRestrictionValue = mFilterRestrictions[oProperty["sap:filter-restriction"]];

			if (!sFilterRestrictionValue) {
				if (Log.isLoggable(iWARNING, sLoggingModule)) {
					Log.warning("Unsupported sap:filter-restriction: "
							+ oProperty["sap:filter-restriction"],
						oEntitySet.entityType + "." + oProperty.name, sLoggingModule);
				}
				return;
			}

			aFilterRestrictions =
				oEntitySet["com.sap.vocabularies.Common.v1.FilterExpressionRestrictions"] || [];

			aFilterRestrictions.push({
				"Property" : { "PropertyPath" : oProperty.name},
				"AllowedExpressions" : {
					"EnumMember" : "com.sap.vocabularies.Common.v1.FilterExpressionType/"
						+ sFilterRestrictionValue
				}
			});
			oEntitySet["com.sap.vocabularies.Common.v1.FilterExpressionRestrictions"] =
				aFilterRestrictions;
		}
1353738
private Object toEnum(ParameterType parameterType, String enumTextValue, String paramName, boolean hardFailEnumDeserialisation) {
        try {
            return EnumUtils.readEnum(parameterType.getImplementationClass(), enumTextValue, hardFailEnumDeserialisation);
        } catch (Exception e) {
            throw XMLTranscriptionInput.exceptionDuringDeserialisation(parameterType, paramName, e, false);
        }
    }
618664
private String getDataType(String[] items) {
        for (String item : items) {
            if (XsdDatatypeEnum.ENTITIES.isDataType(item)) {
                return item;
            }
        }
        return items[0];
    }
1053959
public BDD restrict(final Collection<Literal> restriction) {
    final BDD resBDD = this.factory.build(this.factory.getF().and(restriction));
    return new BDD(this.factory.underlyingKernel().restrict(index(), resBDD.index()), this.factory);
  }
348477
public void write(EnumType type) throws XMLStreamException {

        LOG.debug("Writing type {} of type {}", type.getName(), type.getMetaType());

        xmlWriter.writeStartElement(ENUM_TYPE);
        xmlWriter.writeAttribute(NAME, type.getName());
        for (EnumMember member : type.getMembers()) {
            xmlWriter.writeStartElement(ENUM_MEMBER);
            xmlWriter.writeAttribute(NAME, member.getName());
            xmlWriter.writeEndElement();
        }
        xmlWriter.writeEndElement();
    }
1360370
public static void validateAgainstSchema(final String sbeSchemaFilename, final String xsdFilename)
        throws Exception
    {
        final ParserOptions.Builder optionsBuilder = ParserOptions.builder()
            .xsdFilename(System.getProperty(VALIDATION_XSD))
            .xIncludeAware(Boolean.parseBoolean(System.getProperty(XINCLUDE_AWARE)))
            .stopOnError(Boolean.parseBoolean(System.getProperty(VALIDATION_STOP_ON_ERROR)))
            .warningsFatal(Boolean.parseBoolean(System.getProperty(VALIDATION_WARNINGS_FATAL)))
            .suppressOutput(Boolean.parseBoolean(System.getProperty(VALIDATION_SUPPRESS_OUTPUT)));

        final Path path = Paths.get(sbeSchemaFilename);
        try (InputStream in = new BufferedInputStream(Files.newInputStream(path)))
        {
            final InputSource inputSource = new InputSource(in);
            if (path.toAbsolutePath().getParent() != null)
            {
                inputSource.setSystemId(path.toUri().toString());
            }

            XmlSchemaParser.validate(xsdFilename, inputSource, optionsBuilder.build());
        }
    }