Java Code Examples for org.apache.atlas.AtlasErrorCode#RELATIONSHIPDEF_AGGREGATION_NO_CONTAINER
The following examples show how to use
org.apache.atlas.AtlasErrorCode#RELATIONSHIPDEF_AGGREGATION_NO_CONTAINER .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AtlasRelationshipType.java From atlas with Apache License 2.0 | 4 votes |
/** * Throw an exception so we can junit easily. * * This method assumes that the 2 ends are not null. * * @param relationshipDef * @throws AtlasBaseException */ public static void validateAtlasRelationshipDef(AtlasRelationshipDef relationshipDef) throws AtlasBaseException { AtlasRelationshipEndDef endDef1 = relationshipDef.getEndDef1(); AtlasRelationshipEndDef endDef2 = relationshipDef.getEndDef2(); RelationshipCategory relationshipCategory = relationshipDef.getRelationshipCategory(); String name = relationshipDef.getName(); boolean isContainer1 = endDef1.getIsContainer(); boolean isContainer2 = endDef2.getIsContainer(); if ((endDef1.getCardinality() == AtlasAttributeDef.Cardinality.LIST) || (endDef2.getCardinality() == AtlasAttributeDef.Cardinality.LIST)) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_LIST_ON_END, name); } if (isContainer1 && isContainer2) { // we support 0 or 1 of these flags. throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_DOUBLE_CONTAINERS, name); } if ((isContainer1 || isContainer2)) { // we have an isContainer defined in an end if (relationshipCategory == RelationshipCategory.ASSOCIATION) { // associations are not containment relationships - so do not allow an endpoint with isContainer throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_ASSOCIATION_AND_CONTAINER, name); } } else { // we do not have an isContainer defined on an end if (relationshipCategory == RelationshipCategory.COMPOSITION) { // COMPOSITION needs one end to be the container. throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_COMPOSITION_NO_CONTAINER, name); } else if (relationshipCategory == RelationshipCategory.AGGREGATION) { // AGGREGATION needs one end to be the container. throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_AGGREGATION_NO_CONTAINER, name); } } if (relationshipCategory == RelationshipCategory.COMPOSITION) { // composition children should not be multiple cardinality if (endDef1.getCardinality() == AtlasAttributeDef.Cardinality.SET && !endDef1.getIsContainer()) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_COMPOSITION_MULTIPLE_PARENTS, name); } if ((endDef2.getCardinality() == AtlasAttributeDef.Cardinality.SET) && !endDef2.getIsContainer()) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_COMPOSITION_MULTIPLE_PARENTS, name); } } }
Example 2
Source File: AtlasRelationshipType.java From incubator-atlas with Apache License 2.0 | 4 votes |
/** * Throw an exception so we can junit easily. * * This method assumes that the 2 ends are not null. * * @param relationshipDef * @throws AtlasBaseException */ public static void validateAtlasRelationshipDef(AtlasRelationshipDef relationshipDef) throws AtlasBaseException { AtlasRelationshipEndDef endDef1 = relationshipDef.getEndDef1(); AtlasRelationshipEndDef endDef2 = relationshipDef.getEndDef2(); RelationshipCategory relationshipCategory = relationshipDef.getRelationshipCategory(); String name = relationshipDef.getName(); boolean isContainer1 = endDef1.getIsContainer(); boolean isContainer2 = endDef2.getIsContainer(); if ((endDef1.getCardinality() == AtlasAttributeDef.Cardinality.LIST) || (endDef2.getCardinality() == AtlasAttributeDef.Cardinality.LIST)) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_LIST_ON_END, name); } if (isContainer1 && isContainer2) { // we support 0 or 1 of these flags. throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_DOUBLE_CONTAINERS, name); } if ((isContainer1 || isContainer2)) { // we have an isContainer defined in an end if (relationshipCategory == RelationshipCategory.ASSOCIATION) { // associations are not containment relationships - so do not allow an endpoint with isContainer throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_ASSOCIATION_AND_CONTAINER, name); } } else { // we do not have an isContainer defined on an end if (relationshipCategory == RelationshipCategory.COMPOSITION) { // COMPOSITION needs one end to be the container. throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_COMPOSITION_NO_CONTAINER, name); } else if (relationshipCategory == RelationshipCategory.AGGREGATION) { // AGGREGATION needs one end to be the container. throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_AGGREGATION_NO_CONTAINER, name); } } if (relationshipCategory == RelationshipCategory.COMPOSITION) { // composition children should not be multiple cardinality if (endDef1.getCardinality() == AtlasAttributeDef.Cardinality.SET && !endDef1.getIsContainer()) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_COMPOSITION_MULTIPLE_PARENTS, name); } if ((endDef2.getCardinality() == AtlasAttributeDef.Cardinality.SET) && !endDef2.getIsContainer()) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_COMPOSITION_MULTIPLE_PARENTS, name); } } }