protected AtlasStructDef(TypeCategory category, String name, String description, String typeVersion, List<AtlasAttributeDef> attributeDefs, Map<String, String> options) { super(category, name, description, typeVersion, options); setAttributeDefs(attributeDefs); }
protected AtlasStructDef(TypeCategory category, String name, String description, String typeVersion, List<AtlasAttributeDef> attributeDefs, Map<String, String> options) { super(category, name, description, typeVersion, options); setAttributeDefs(attributeDefs); }
public AtlasStructDef(AtlasStructDef other) { super(other); setAttributeDefs(other != null ? other.getAttributeDefs() : null); }
public AtlasStructDef(AtlasStructDef other) { super(other); setAttributeDefs(other != null ? other.getAttributeDefs() : null); }
public static AtlasStructDef toStructDef(AtlasVertex vertex, AtlasStructDef structDef, AtlasTypeDefGraphStoreV2 typeDefStore) throws AtlasBaseException { AtlasStructDef ret = (structDef != null) ? structDef : new AtlasStructDef(); typeDefStore.vertexToTypeDef(vertex, ret); List<AtlasAttributeDef> attributeDefs = new ArrayList<>(); String typePropertyKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(ret); String encodedTypePropertyKey = AtlasGraphUtilsV2.encodePropertyKey(typePropertyKey); List<String> attrNames = vertex.getProperty(encodedTypePropertyKey, List.class); if (CollectionUtils.isNotEmpty(attrNames)) { for (String attrName : attrNames) { String attrPropertyKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(ret, attrName); String encodedAttrPropertyKey = AtlasGraphUtilsV2.encodePropertyKey(attrPropertyKey); String attrJson = vertex.getProperty(encodedAttrPropertyKey, String.class); attributeDefs.add(toAttributeDefFromJson(structDef, AtlasType.fromJson(attrJson, Map.class), typeDefStore)); } } ret.setAttributeDefs(attributeDefs); return ret; }
public static AtlasStructDef toStructDef(AtlasVertex vertex, AtlasStructDef structDef, AtlasTypeDefGraphStoreV2 typeDefStore) throws AtlasBaseException { AtlasStructDef ret = (structDef != null) ? structDef : new AtlasStructDef(); typeDefStore.vertexToTypeDef(vertex, ret); List<AtlasAttributeDef> attributeDefs = new ArrayList<>(); String typePropertyKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(ret); String encodedTypePropertyKey = AtlasGraphUtilsV2.encodePropertyKey(typePropertyKey); List<String> attrNames = vertex.getProperty(encodedTypePropertyKey, List.class); if (CollectionUtils.isNotEmpty(attrNames)) { for (String attrName : attrNames) { String attrPropertyKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(ret, attrName); String encodedAttrPropertyKey = AtlasGraphUtilsV2.encodePropertyKey(attrPropertyKey); String attrJson = vertex.getProperty(encodedAttrPropertyKey, String.class); attributeDefs.add(toAttributeDefFromJson(structDef, AtlasType.fromJson(attrJson, Map.class), typeDefStore)); } } ret.setAttributeDefs(attributeDefs); return ret; }
@Test public void testStructDefSetAttributeDefs() { AtlasStructDef structDef = ModelTestUtil.newStructDef(); List<AtlasAttributeDef> oldAttributes = structDef.getAttributeDefs(); List<AtlasAttributeDef> newttributes = ModelTestUtil.newAttributeDefsWithAllBuiltInTypes("newAttributes"); structDef.setAttributeDefs(newttributes); for (AtlasAttributeDef attributeDef : oldAttributes) { assertFalse(structDef.hasAttribute(attributeDef.getName())); } for (AtlasAttributeDef attributeDef : newttributes) { assertTrue(structDef.hasAttribute(attributeDef.getName())); } } }
@Test public void testStructDefSetAttributeDefs() { AtlasStructDef structDef = ModelTestUtil.newStructDef(); List<AtlasAttributeDef> oldAttributes = structDef.getAttributeDefs(); List<AtlasAttributeDef> newttributes = ModelTestUtil.newAttributeDefsWithAllBuiltInTypes("newAttributes"); structDef.setAttributeDefs(newttributes); for (AtlasAttributeDef attributeDef : oldAttributes) { assertFalse(structDef.hasAttribute(attributeDef.getName())); } for (AtlasAttributeDef attributeDef : newttributes) { assertTrue(structDef.hasAttribute(attributeDef.getName())); } } }
public static AtlasStructDef newStructDef(AtlasTypeRegistry typesRegistry) { int structDefIdx = IDX_STRUCT_DEF.getAndIncrement(); AtlasStructDef ret = new AtlasStructDef(); ret.setName(PREFIX_STRUCT_DEF + structDefIdx); ret.setDescription(ret.getName()); ret.setAttributeDefs(newAttributeDefsWithAllBuiltInTypes(PREFIX_ATTRIBUTE_NAME)); AtlasTransientTypeRegistry ttr = null; boolean commit = false; try { ttr = typesRegistry.lockTypeRegistryForUpdate(); ttr.addType(ret); commit = true; } catch (AtlasBaseException excp) { LOG.error("failed to create struct-def", excp); ret = null; } finally { typesRegistry.releaseTypeRegistryForUpdate(ttr, commit); } return ret; }
public static AtlasStructDef newStructDef(AtlasTypeRegistry typesRegistry) { int structDefIdx = IDX_STRUCT_DEF.getAndIncrement(); AtlasStructDef ret = new AtlasStructDef(); ret.setName(PREFIX_STRUCT_DEF + structDefIdx); ret.setDescription(ret.getName()); ret.setAttributeDefs(newAttributeDefsWithAllBuiltInTypes(PREFIX_ATTRIBUTE_NAME)); AtlasTransientTypeRegistry ttr = null; boolean commit = false; try { ttr = typesRegistry.lockTypeRegistryForUpdate(); ttr.addType(ret); commit = true; } catch (AtlasBaseException excp) { LOG.error("failed to create struct-def", excp); ret = null; } finally { typesRegistry.releaseTypeRegistryForUpdate(ttr, commit); } return ret; }