Validation rules exclusive to relation types

@param relationType The relationTypes to validate
423936
private void validateRelationType(RelationType relationType) {
        ValidateGlobalRules.validateHasMinimumRoles(relationType).ifPresent(errorsFound::add);
        errorsFound.addAll(ValidateGlobalRules.validateRelationTypesToRolesSchema(relationType));
    }
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())));
    }
  }
1214682
public void relationManagement() {
        Map<String, Object> topologyTemplate = (Map<String, Object>) template.get(TOPOLOGY_TEMPLATE);
        Map<String, Object> nodeTemplates = (Map<String, Object>) topologyTemplate.get(NODE_TEMPLATES);

        for (Map.Entry<String, Object> nodeTemplateEntry : nodeTemplates.entrySet()) {
            Map<String, Object> nodeTemplate = (Map<String, Object>) nodeTemplateEntry.getValue();
            List<Map<String, Object>> requirements = (List<Map<String, Object>>) nodeTemplate.get(REQUIREMENTS);
            List<Map<String, Object>> fixedRequirements = MutableList.of();
            if (requirements != null) {
                for (Map<String, Object> requirement : requirements) {
                    if (requirement.containsKey(HOST)) {
                        fixedRequirements.add(requirement);
                    }

                    //TODO: delete when relations will be supported
                    else if(requirement.containsKey("dbConnection")
                            ||(requirement.containsKey("endpoint_configuration"))){
                        fixedRequirements.add(requirement);
                    }

                }
                if (fixedRequirements.isEmpty()) {
                    nodeTemplate.remove(REQUIREMENTS);
                } else {
                    nodeTemplate.put(REQUIREMENTS, fixedRequirements);
                }
            }
        }
    }
1123172
public void setRelationId(String relationId) {

        try {
            m_relationId = new CmsUUID(relationId);
        } catch (Throwable e) {
            setThrowable(e);
        }
    }
1074778
public void setRelation_ref(Relation v) {
    if (RelationMention_Type.featOkTst && ((RelationMention_Type)jcasType).casFeat_relation_ref == null)
      jcasType.jcas.throwFeatMissing("relation_ref", "de.julielab.jules.types.ace.RelationMention");
    jcasType.ll_cas.ll_setRefValue(addr, ((RelationMention_Type)jcasType).casFeatCode_relation_ref, jcasType.ll_cas.ll_getFSRef(v));}
1005894
private void checkForeignKeyMapping(List<String> errors, Config config) {
        for (Entity entity : config.getProject().getEntities().getList()) {
            for (Relation relation : entity.getRelations().getList()) {
                if (relation.isInverse() || relation.isIntermediate()) {
                    continue;
                }

                for (AttributePair attributePair : relation.getAttributePairs()) {
                    if (attributePair.getFromAttribute().getMappedType() != attributePair.getToAttribute().getMappedType()) {
                        String errorMsg = "Inconsistent types: Column " + attributePair.getFromAttribute().getFullColumnName() + "["
                                + attributePair.getFromAttribute().getJdbcType() + "] references column " + attributePair.getToAttribute().getFullColumnName()
                                + "[" + attributePair.getToAttribute().getJdbcType() + "]. " + "You should really fix your SQL schema.";
                        if (attributePair.getFromAttribute().isInCpk()) {
                            // we may get compile failure as the property is mapped (inside the cpk)
                            log.warn(errorMsg + ". To avoid this error you can force the mapped type using configuration.");
                        } else {
                            // we should not get compile failure as the property is not mapped.
                            log.warn(errorMsg);
                        }
                    }
                }
            }
        }
    }
928754
private void setRelationToEntity(Object entity, Object relationEntity, Relation relation)
    {
        if (relation.getTargetEntity().isAssignableFrom(getEntity(relationEntity).getClass()))
        {

            if (relation.isUnary())
            {
                PropertyAccessorHelper.set(entity, relation.getProperty(), getEntity(relationEntity));
            }
            else
            {
                Object associationObject = PropertyAccessorHelper.getObject(entity, relation.getProperty());
                if (associationObject == null || ProxyHelper.isProxyOrCollection(associationObject))
                {
                    associationObject = PropertyAccessorHelper.getCollectionInstance(relation.getProperty());
                    PropertyAccessorHelper.set(entity, relation.getProperty(), associationObject);
                }

                ((Collection) associationObject).add(getEntity(relationEntity));
            }
        }
    }
794652
function initRelations (args) {
    // create map of relations
    this.relations = {}
    // get relations from args
    var relations = requireValidOptionalObject(args.relations)
    // validate and add relations
    _.each(relations, (relation, relatedModelName) => {
        this.relations[relatedModelName] = relation
    })
}
1230230
public function theFollowingBlogPostsAreInRelationWithTheFollowingTerms($relationType, TableNode $table)
    {
        static $id = 1;

        $relationTypeMappings = array('category' => 'Categories', 'post_tag' => 'Tags');
        $termsField = $relationTypeMappings[$relationType];

        $termsTable = new TableNode('|Name|Slug|');
        $termTaxonomiesTable = new TableNode('|Term|Taxonomy|Count|');
        $termRelationshipsTable = new TableNode('|Post|Term|Order|');

        $terms = array();
        $termTaxonomies = array();
        foreach ($table->getHash() as $row) {
            $postTerms = explode(',', $row[$termsField]);
            foreach ($postTerms as $term) {
                $term = trim($term);
                $terms[$term] = array($term, $term);

                if (!isset($termTaxonomies[$term])) {
                    $termTaxonomies[$term] = array($term, $relationType, 1);
                } else {
                    $termTaxonomies[$term][2]++;
                }

                $termRelationshipsTable->addRow(array($row['Title'], $term, $id++));
            }
        }

        foreach ($terms as $term) {
            $termsTable->addRow($term);
        }

        foreach ($termTaxonomies as $termTaxonomy) {
            $termTaxonomiesTable->addRow($termTaxonomy);
        }

        $this->getPhabric()->insertFromTable('Term', $termsTable);
        $this->getPhabric()->insertFromTable('TermTaxonomy', $termTaxonomiesTable);
        $this->getPhabric()->insertFromTable('TermRelationship', $termRelationshipsTable);
    }
1183304
private void validateNameAndTypeArePresent(final List<TriggerDependencyBean> dependencies) {
    for (final TriggerDependencyBean dep : dependencies) {
      Preconditions.checkNotNull(dep.getName(), "dependency name is required");
      Preconditions.checkNotNull(dep.getType(), "dependency type is required for " + dep.getName());
    }
  }
1164994
private void addRelatedType(JSType type, JSTypeBitSet related) {
    computeRelatedTypesForNonUnionType(type);
    related.or(relatedBitsets.get(type));
  }
1172400
public Map<String, Map<String, Map<String, Map<String, ?>>>> validationConstraints(String type) {
		return getEntity(invokeGet(Utils.formatMessage("_constraints/{0}", type), null), Map.class);
	}
726613
public boolean isRelation(DE9IMRelation.Type relationType) {
		for (Type t : types) if (t.equals(relationType)) return true;
		return false;
	}
1252661
public function hasRelatedErrors($relationName = null)
    {
        if ($relationName === null) {
            foreach ($this->_relatedErrors as $errors) {
                if (!empty($errors)) {
                    return true;
                }
            }
            return false;
        } else {
            return !empty($this->_relatedErrors[$relationName]);
        }
    }
195933
private void validateKeyTypes(int[] keyFieldIndices) {
		final TypeInformation<?>[] types = getFieldTypes();
		for (int keyFieldIndex : keyFieldIndices) {
			final TypeInformation<?> type = types[keyFieldIndex];
			if (!TypeCheckUtils.isSimpleStringRepresentation(type)) {
				throw new ValidationException(
					"Only simple types that can be safely converted into a string representation " +
						"can be used as keys. But was: " + type);
			}
		}
	}
1333870
protected void validate(String operationType) throws Exception
	{
		super.validate(operationType);

		MPSString id_validator = new MPSString();
		id_validator.setConstraintIsReq(MPSConstants.DELETE_CONSTRAINT, true);
		id_validator.setConstraintIsReq(MPSConstants.MODIFY_CONSTRAINT, true);
		id_validator.validate(operationType, id, "\"id\"");
		
		MPSString category_validator = new MPSString();
		category_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 1024);
		category_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		category_validator.validate(operationType, category, "\"category\"");
		
		MPSString entity_validator = new MPSString();
		entity_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 1024);
		entity_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		entity_validator.validate(operationType, entity, "\"entity\"");
		
		MPSString severity_validator = new MPSString();
		severity_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 32);
		severity_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		severity_validator.validate(operationType, severity, "\"severity\"");
		
		MPSString source_validator = new MPSString();
		source_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 128);
		source_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		source_validator.validate(operationType, source, "\"source\"");
		
		MPSString failureobj_validator = new MPSString();
		failureobj_validator.setConstraintCharSetRegEx(MPSConstants.GENERIC_CONSTRAINT,"[ a-zA-Z0-9_#.:@=-]+");
		failureobj_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 128);
		failureobj_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		failureobj_validator.validate(operationType, failureobj, "\"failureobj\"");
		
		MPSInt source_event_id_validator = new MPSInt();
		source_event_id_validator.validate(operationType, source_event_id, "\"source_event_id\"");
		
		MPSInt timestamp_validator = new MPSInt();
		timestamp_validator.validate(operationType, timestamp, "\"timestamp\"");
		
		MPSString message_validator = new MPSString();
		message_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 4096);
		message_validator.validate(operationType, message, "\"message\"");
		
		MPSString operation_type_validator = new MPSString();
		operation_type_validator.setConstraintCharSetRegEx(MPSConstants.GENERIC_CONSTRAINT,"[ a-zA-Z0-9_#.:@=-]+");
		operation_type_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 32);
		operation_type_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		operation_type_validator.validate(operationType, operation_type, "\"operation_type\"");
		
		MPSInt trap_id_validator = new MPSInt();
		trap_id_validator.validate(operationType, trap_id, "\"trap_id\"");
		
		MPSString history_validator = new MPSString();
		history_validator.setConstraintCharSetRegEx(MPSConstants.GENERIC_CONSTRAINT,"[ a-zA-Z0-9_#.:@=-]+");
		history_validator.validate(operationType, history, "\"history\"");
		
	}
1182274
public void validate(EntityType entityType) {
    validateEntityId(entityType);
    validateEntityLabel(entityType);
    validatePackage(entityType);
    validateExtends(entityType);
    validateOwnAttributes(entityType);

    Map<String, Attribute> ownAllAttrMap =
        stream(entityType.getOwnAllAttributes())
            .collect(toLinkedMap(Attribute::getIdentifier, Function.identity()));

    validateOwnIdAttribute(entityType, ownAllAttrMap);
    validateOwnLabelAttribute(entityType, ownAllAttrMap);
    validateOwnLookupAttributes(entityType, ownAllAttrMap);
    validateLabelAttribute(entityType);
    validateBackend(entityType);
  }