public String getQualifiedAttributeName(String attrName) throws AtlasBaseException { if (allAttributes.containsKey(attrName)) { return allAttributes.get(attrName).getQualifiedName(); } else if (relationshipAttributes.containsKey(attrName)) { return relationshipAttributes.get(attrName).getQualifiedName(); } throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_ATTRIBUTE, attrName, entityDef.getName()); }
public String getQualifiedAttributeName(String attrName) throws AtlasBaseException { if (allAttributes.containsKey(attrName)) { return allAttributes.get(attrName).getQualifiedName(); } else if (relationshipAttributes.containsKey(attrName)) { return relationshipAttributes.get(attrName).getQualifiedName(); } throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_ATTRIBUTE, attrName, entityDef.getName()); }
@Override public AtlasEntity createDefaultValue(Object defaultValue) { AtlasEntity ret = new AtlasEntity(entityDef.getName()); populateDefaultValues(ret); return ret; }
@Override public AtlasEntity createDefaultValue() { AtlasEntity ret = new AtlasEntity(entityDef.getName()); populateDefaultValues(ret); return ret; }
@Override public AtlasEntity createDefaultValue() { AtlasEntity ret = new AtlasEntity(entityDef.getName()); populateDefaultValues(ret); return ret; }
@Override public AtlasEntity createDefaultValue(Object defaultValue){ AtlasEntity ret = new AtlasEntity(entityDef.getName()); populateDefaultValues(ret); return ret; } @Override
@Override public AtlasEntityDef update(AtlasEntityDef entityDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasEntityDefStoreV1.update({})", entityDef); } validateType(entityDef); AtlasEntityDef ret = StringUtils.isNotBlank(entityDef.getGuid()) ? updateByGuid(entityDef.getGuid(), entityDef) : updateByName(entityDef.getName(), entityDef); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasEntityDefStoreV1.update({}): {}", entityDef, ret); } return ret; }
@Override public AtlasEntityDef update(AtlasEntityDef entityDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasEntityDefStoreV1.update({})", entityDef); } validateType(entityDef); AtlasEntityDef ret = StringUtils.isNotBlank(entityDef.getGuid()) ? updateByGuid(entityDef.getGuid(), entityDef) : updateByName(entityDef.getName(), entityDef); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasEntityDefStoreV1.update({}): {}", entityDef, ret); } return ret; }
private void updateEntityDef(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException { for (AtlasEntityDef def : typeDefinitionMap.getEntityDefs()) { AtlasEntityDef existing = typeRegistry.getEntityDefByName(def.getName()); if (existing != null && addAttributes(existing, def)) { typeDefStore.updateEntityDefByName(existing.getName(), existing); result.incrementMeticsCounter("typedef:entitydef:update"); } } }
private void updateEntityDef(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException { for (AtlasEntityDef def: typeDefinitionMap.getEntityDefs()) { AtlasEntityDef existing = typeRegistry.getEntityDefByName(def.getName()); if(existing != null && addAttributes(existing, def)) { typeDefStore.updateEntityDefByName(existing.getName(), existing); result.incrementMeticsCounter("typedef:entitydef:update"); } } }
@Override public AtlasEntityDef create(AtlasEntityDef entityDef, AtlasVertex preCreateResult) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasEntityDefStoreV1.create({}, {})", entityDef, preCreateResult); } AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_CREATE, entityDef), "create entity-def ", entityDef.getName()); AtlasVertex vertex = (preCreateResult == null) ? preCreate(entityDef) : preCreateResult; updateVertexAddReferences(entityDef, vertex); AtlasEntityDef ret = toEntityDef(vertex); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasEntityDefStoreV1.create({}, {}): {}", entityDef, preCreateResult, ret); } return ret; }
public static AtlasEntity newEntity(AtlasEntityDef entityDef, AtlasTypeRegistry typesRegistry) { AtlasEntity ret = null; AtlasEntityType entityType = typesRegistry.getEntityTypeByName(entityDef.getName()); if (entityType != null) { ret = entityType.createDefaultValue(); } else { LOG.error("failed to get entity-type {}", entityDef.getName()); } return ret; }
public static AtlasEntity newEntity(AtlasEntityDef entityDef, AtlasTypeRegistry typesRegistry) { AtlasEntity ret = null; AtlasEntityType entityType = typesRegistry.getEntityTypeByName(entityDef.getName()); if (entityType != null) { ret = entityType.createDefaultValue(); } else { LOG.error("failed to get entity-type {}", entityDef.getName()); } return ret; }
private static TypesDef structToTypesDef(AtlasStructType structType, AtlasTypeRegistry registry) throws AtlasBaseException { String typeName = structType.getStructDef().getName(); String typeDesc = structType.getStructDef().getDescription(); String typeVersion = structType.getStructDef().getTypeVersion(); AttributeDefinition[] attributes = getAttributes(structType, registry); StructTypeDefinition structTypeDef = TypesUtil.createStructTypeDef(typeName, typeDesc, typeVersion, attributes); TypesDef ret = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.of(structTypeDef), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.<HierarchicalTypeDefinition<ClassType>>of()); return ret; }
private void updateClassificationDef(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException { for (AtlasClassificationDef def: typeDefinitionMap.getClassificationDefs()) { AtlasClassificationDef existing = typeRegistry.getClassificationDefByName(def.getName()); if(existing != null && addAttributes(existing, def)) { typeDefStore.updateClassificationDefByName(existing.getName(), existing); result.incrementMeticsCounter("typedef:classification:update"); } } }
private void assertTraitMap(TypesDefScrubber typesDefScrubber, AtlasTypesDef td, int classificationIndex, String expectedStructName, int attrIndex) { String label = typesDefScrubber.getEdgeLabel(td.getEntityDefs().get(0).getName(), td.getEntityDefs().get(0).getAttributeDefs().get(attrIndex).getName()); assertTrue(typesDefScrubber.getTraitToTypeMap().containsKey(label)); assertEquals(typesDefScrubber.getTraitToTypeMap().get(label).getTypeName(), td.getClassificationDefs().get(classificationIndex).getName()); assertEquals(typesDefScrubber.getTraitToTypeMap().get(label).getLegacyTypeName(), expectedStructName); }
private void assertTraitMap(TypesDefScrubber typesDefScrubber, AtlasTypesDef td, int classificationIndex, String expectedStructName, int attrIndex) { String label = typesDefScrubber.getEdgeLabel(td.getEntityDefs().get(0).getName(), td.getEntityDefs().get(0).getAttributeDefs().get(attrIndex).getName()); assertTrue(typesDefScrubber.getTraitToTypeMap().containsKey(label)); assertEquals(typesDefScrubber.getTraitToTypeMap().get(label).getTypeName(), td.getClassificationDefs().get(classificationIndex).getName()); assertEquals(typesDefScrubber.getTraitToTypeMap().get(label).getLegacyTypeName(), expectedStructName); }
@Test public void testEntitySerDe() throws AtlasBaseException { AtlasEntityDef entityDef = ModelTestUtil.getEntityDef(); AtlasTypeRegistry typeRegistry = ModelTestUtil.getTypesRegistry(); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityDef.getName()); assertNotNull(entityType); AtlasEntity ent1 = entityType.createDefaultValue(); String jsonString = AtlasType.toJson(ent1); AtlasEntity ent2 = AtlasType.fromJson(jsonString, AtlasEntity.class); entityType.normalizeAttributeValues(ent2); assertEquals(ent2, ent1, "Incorrect serialization/deserialization of AtlasEntity"); }
@Test public void testEntitySerDeWithSuperTypes() throws AtlasBaseException { AtlasEntityDef entityDef = ModelTestUtil.getEntityDefWithSuperTypes(); AtlasTypeRegistry typeRegistry = ModelTestUtil.getTypesRegistry(); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityDef.getName()); assertNotNull(entityType); AtlasEntity ent1 = entityType.createDefaultValue(); String jsonString = AtlasType.toJson(ent1); AtlasEntity ent2 = AtlasType.fromJson(jsonString, AtlasEntity.class); entityType.normalizeAttributeValues(ent2); assertEquals(ent2, ent1, "Incorrect serialization/deserialization of AtlasEntity with superTypes"); } }
@Test public void testEntitySerDeWithSuperType() throws AtlasBaseException { AtlasEntityDef entityDef = ModelTestUtil.getEntityDefWithSuperType(); AtlasTypeRegistry typeRegistry = ModelTestUtil.getTypesRegistry(); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityDef.getName()); assertNotNull(entityType); AtlasEntity ent1 = entityType.createDefaultValue(); String jsonString = AtlasType.toJson(ent1); AtlasEntity ent2 = AtlasType.fromJson(jsonString, AtlasEntity.class); entityType.normalizeAttributeValues(ent2); assertEquals(ent2, ent1, "Incorrect serialization/deserialization of AtlasEntity with superType"); }