Java Code Examples for org.apache.atlas.model.typedef.AtlasEntityDef#getName()
The following examples show how to use
org.apache.atlas.model.typedef.AtlasEntityDef#getName() .
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: AtlasEntityDefStoreV2.java From atlas with Apache License 2.0 | 5 votes |
@Override public AtlasEntityDef updateByName(String name, AtlasEntityDef entityDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasEntityDefStoreV1.updateByName({}, {})", name, entityDef); } AtlasEntityDef existingDef = typeRegistry.getEntityDefByName(name); AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_UPDATE, existingDef), "update entity-def ", name); validateType(entityDef); AtlasType type = typeRegistry.getType(entityDef.getName()); if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.ENTITY) { throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, entityDef.getName(), TypeCategory.CLASS.name()); } AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS); if (vertex == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name); } updateVertexPreUpdate(entityDef, (AtlasEntityType)type, vertex); updateVertexAddReferences(entityDef, vertex); AtlasEntityDef ret = toEntityDef(vertex); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasEntityDefStoreV1.updateByName({}, {}): {}", name, entityDef, ret); } return ret; }
Example 2
Source File: AtlasEntityDefStoreV2.java From atlas with Apache License 2.0 | 5 votes |
@Override public AtlasEntityDef updateByGuid(String guid, AtlasEntityDef entityDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasEntityDefStoreV1.updateByGuid({})", guid); } AtlasEntityDef existingDef = typeRegistry.getEntityDefByGuid(guid); AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_UPDATE, existingDef), "update entity-def ", (existingDef != null ? existingDef.getName() : guid)); validateType(entityDef); AtlasType type = typeRegistry.getTypeByGuid(guid); if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.ENTITY) { throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, entityDef.getName(), TypeCategory.CLASS.name()); } AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.CLASS); if (vertex == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid); } updateVertexPreUpdate(entityDef, (AtlasEntityType)type, vertex); updateVertexAddReferences(entityDef, vertex); AtlasEntityDef ret = toEntityDef(vertex); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasEntityDefStoreV1.updateByGuid({}): {}", guid, ret); } return ret; }
Example 3
Source File: AtlasEntityDefStoreV1.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Override public AtlasVertex preCreate(AtlasEntityDef entityDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasEntityDefStoreV1.preCreate({})", entityDef); } validateType(entityDef); AtlasType type = typeRegistry.getType(entityDef.getName()); if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.ENTITY) { throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, entityDef.getName(), TypeCategory.CLASS.name()); } AtlasVertex ret = typeDefStore.findTypeVertexByName(entityDef.getName()); if (ret != null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_ALREADY_EXISTS, entityDef.getName()); } ret = typeDefStore.createTypeVertex(entityDef); updateVertexPreCreate(entityDef, (AtlasEntityType)type, ret); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasEntityDefStoreV1.preCreate({}): {}", entityDef, ret); } return ret; }
Example 4
Source File: AtlasEntityDefStoreV1.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Override public AtlasEntityDef updateByName(String name, AtlasEntityDef entityDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasEntityDefStoreV1.updateByName({}, {})", name, entityDef); } validateType(entityDef); AtlasType type = typeRegistry.getType(entityDef.getName()); if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.ENTITY) { throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, entityDef.getName(), TypeCategory.CLASS.name()); } AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS); if (vertex == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name); } updateVertexPreUpdate(entityDef, (AtlasEntityType)type, vertex); updateVertexAddReferences(entityDef, vertex); AtlasEntityDef ret = toEntityDef(vertex); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasEntityDefStoreV1.updateByName({}, {}): {}", name, entityDef, ret); } return ret; }
Example 5
Source File: AtlasEntityDefStoreV1.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Override public AtlasEntityDef updateByGuid(String guid, AtlasEntityDef entityDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasEntityDefStoreV1.updateByGuid({})", guid); } validateType(entityDef); AtlasType type = typeRegistry.getTypeByGuid(guid); if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.ENTITY) { throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, entityDef.getName(), TypeCategory.CLASS.name()); } AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.CLASS); if (vertex == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid); } updateVertexPreUpdate(entityDef, (AtlasEntityType)type, vertex); updateVertexAddReferences(entityDef, vertex); AtlasEntityDef ret = toEntityDef(vertex); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasEntityDefStoreV1.updateByGuid({}): {}", guid, ret); } return ret; }
Example 6
Source File: AtlasEntity.java From atlas with Apache License 2.0 | 4 votes |
public AtlasEntity(AtlasEntityDef entityDef) { this(entityDef != null ? entityDef.getName() : null, null); }
Example 7
Source File: AtlasEntityHeader.java From atlas with Apache License 2.0 | 4 votes |
public AtlasEntityHeader(AtlasEntityDef entityDef) { this(entityDef != null ? entityDef.getName() : null, null); }
Example 8
Source File: AtlasDeleteHandlerV1Test.java From incubator-atlas with Apache License 2.0 | 4 votes |
@Test public void testLowerBoundsIgnoredWhenDeletingCompositeEntitesOwnedByMap() throws Exception { // Define MapValueReferencer type with required reference to CompositeMapValue. AtlasStructDef.AtlasAttributeDef[] mapValueAttributes = new AtlasStructDef.AtlasAttributeDef[]{ new AtlasStructDef.AtlasAttributeDef("refToMapValue", "CompositeMapValue", false, AtlasStructDef.AtlasAttributeDef.Cardinality.SINGLE, 1, 1, false, false, Collections.<AtlasStructDef.AtlasConstraintDef>emptyList()) }; AtlasEntityDef mapValueDef = new AtlasEntityDef("MapValueReferencer", "RequiredMapValue_description", "1.0", Arrays.asList(mapValueAttributes), Collections.<String>emptySet()); AtlasStructDef.AtlasAttributeDef[] mapContainerAttributes = new AtlasStructDef.AtlasAttributeDef[]{ new AtlasStructDef.AtlasAttributeDef("requiredMap", "map<string,MapValueReferencer>", false, AtlasStructDef.AtlasAttributeDef.Cardinality.SINGLE, 1, 1, false, false, new ArrayList<AtlasStructDef.AtlasConstraintDef>() {{ add(new AtlasStructDef.AtlasConstraintDef(AtlasStructDef.AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF)); }}) }; AtlasEntityDef mapContainerDef = new AtlasEntityDef("MapValueReferencerContainer", "MapValueReferencerContainer_description", "1.0", Arrays.asList(mapContainerAttributes), Collections.<String>emptySet()); AtlasTypesDef typesDef = AtlasTypeUtil.getTypesDef(ImmutableList.<AtlasEnumDef>of(), ImmutableList.<AtlasStructDef>of(), ImmutableList.<AtlasClassificationDef>of(), ImmutableList.<AtlasEntityDef>of(mapValueDef, mapContainerDef)); typeDefStore.createTypesDef(typesDef); // Create instances of CompositeMapOwner and CompositeMapValue. // Set MapOwner.map with one entry that references MapValue instance. AtlasEntity.AtlasEntityWithExtInfo entityDefinition = createMapOwnerAndValueEntities(); String mapOwnerGuid = entityDefinition.getEntity().getGuid(); // Verify MapOwner.map attribute has expected value. ITypedReferenceableInstance mapOwnerInstance = metadataService.getEntityDefinition(mapOwnerGuid); Object object = mapOwnerInstance.get("map"); Assert.assertNotNull(object); Assert.assertTrue(object instanceof Map); Map<String, ITypedReferenceableInstance> map = (Map<String, ITypedReferenceableInstance>)object; Assert.assertEquals(map.size(), 1); ITypedReferenceableInstance mapValueInstance = map.get("value1"); Assert.assertNotNull(mapValueInstance); String mapValueGuid = mapValueInstance.getId()._getId(); // Create instance of MapValueReferencerContainer RequestContextV1.clear(); AtlasEntity mapValueReferencer = new AtlasEntity(mapValueDef.getName()); mapValueReferencer.setAttribute("refToMapValue", new AtlasObjectId(mapValueInstance.getId()._getId(), mapValueInstance.getTypeName())); AtlasEntity.AtlasEntitiesWithExtInfo entities = new AtlasEntity.AtlasEntitiesWithExtInfo(); entities.addEntity(mapValueReferencer); List<AtlasEntityHeader> createEntitiesResult = entityStore.createOrUpdate(new AtlasEntityStream(entities), false).getCreatedEntities(); Assert.assertEquals(createEntitiesResult.size(), 1); // Create instance of MapValueReferencer, and update mapValueReferencerContainer // to reference it. AtlasEntity mapValueReferenceContainer = new AtlasEntity(mapContainerDef.getName()); entities = new AtlasEntity.AtlasEntitiesWithExtInfo(); entities.addEntity(mapValueReferenceContainer); entities.addReferredEntity(mapValueReferencer); mapValueReferenceContainer.setAttribute("requiredMap", Collections.singletonMap("value1", AtlasTypeUtil.getAtlasObjectId(mapValueReferencer))); RequestContextV1.clear(); EntityMutationResponse updateEntitiesResult = entityStore.createOrUpdate(new AtlasEntityStream(entities), false); String mapValueReferencerContainerGuid = updateEntitiesResult.getCreatedEntitiesByTypeName("MapValueReferencerContainer").get(0).getGuid(); String mapValueReferencerGuid = updateEntitiesResult.getUpdatedEntitiesByTypeName("MapValueReferencer").get(0).getGuid(); Assert.assertEquals(updateEntitiesResult.getCreatedEntities().size(), 1); Assert.assertEquals(updateEntitiesResult.getUpdatedEntities().size(), 1); Assert.assertEquals(updateEntitiesResult.getUpdatedEntities().get(0).getGuid(), mapValueReferencerGuid); // Delete map owner and map referencer container. A total of 4 entities should be deleted, // including the composite entities. The lower bound constraint on MapValueReferencer.refToMapValue // should not be enforced on the composite MapValueReferencer since it is being deleted. EntityMutationResponse deleteEntitiesResult = entityStore.deleteByIds(Arrays.asList(mapOwnerGuid, mapValueReferencerContainerGuid)); Assert.assertEquals(deleteEntitiesResult.getDeletedEntities().size(), 4); Assert.assertTrue(extractGuids(deleteEntitiesResult.getDeletedEntities()).containsAll( Arrays.asList(mapOwnerGuid, mapValueGuid, mapValueReferencerContainerGuid, mapValueReferencerGuid))); }
Example 9
Source File: AtlasEntity.java From incubator-atlas with Apache License 2.0 | 4 votes |
public AtlasEntity(AtlasEntityDef entityDef) { this(entityDef != null ? entityDef.getName() : null, null); }
Example 10
Source File: AtlasEntityHeader.java From incubator-atlas with Apache License 2.0 | 4 votes |
public AtlasEntityHeader(AtlasEntityDef entityDef) { this(entityDef != null ? entityDef.getName() : null, null); }
Example 11
Source File: AtlasEntityDefStoreV2.java From atlas with Apache License 2.0 | 3 votes |
@Override public AtlasVertex preCreate(AtlasEntityDef entityDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasEntityDefStoreV1.preCreate({})", entityDef); } validateType(entityDef); AtlasType type = typeRegistry.getType(entityDef.getName()); if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.ENTITY) { throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, entityDef.getName(), TypeCategory.CLASS.name()); } AtlasVertex ret = typeDefStore.findTypeVertexByName(entityDef.getName()); if (ret != null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_ALREADY_EXISTS, entityDef.getName()); } ret = typeDefStore.createTypeVertex(entityDef); updateVertexPreCreate(entityDef, (AtlasEntityType)type, ret); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasEntityDefStoreV1.preCreate({}): {}", entityDef, ret); } return ret; }