本文整理汇总了Java中org.apache.atlas.model.typedef.AtlasEntityDef类的典型用法代码示例。如果您正苦于以下问题:Java AtlasEntityDef类的具体用法?Java AtlasEntityDef怎么用?Java AtlasEntityDef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AtlasEntityDef类属于org.apache.atlas.model.typedef包,在下文中一共展示了AtlasEntityDef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUTF8
import org.apache.atlas.model.typedef.AtlasEntityDef; //导入依赖的package包/类
@Test
public void testUTF8() throws Exception {
String classType = randomString();
String attrName = random();
String attrValue = random();
AtlasEntityDef classTypeDef = AtlasTypeUtil
.createClassTypeDef(classType, ImmutableSet.<String>of(),
AtlasTypeUtil.createUniqueRequiredAttrDef(attrName, "string"));
AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
atlasTypesDef.getEntityDefs().add(classTypeDef);
createType(atlasTypesDef);
AtlasEntity instance = new AtlasEntity(classType);
instance.setAttribute(attrName, attrValue);
AtlasEntityHeader entity = createEntity(instance);
assertNotNull(entity);
assertNotNull(entity.getGuid());
AtlasEntity entityByGuid = getEntityByGuid(entity.getGuid());
assertEquals(entityByGuid.getAttribute(attrName), attrValue);
}
示例2: testDuplicateCreate
import org.apache.atlas.model.typedef.AtlasEntityDef; //导入依赖的package包/类
@Test
public void testDuplicateCreate() throws Exception {
AtlasEntityDef type = createClassTypeDef(randomString(),
ImmutableSet.<String>of(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"));
AtlasTypesDef typesDef = new AtlasTypesDef();
typesDef.getEntityDefs().add(type);
AtlasTypesDef created = clientV2.createAtlasTypeDefs(typesDef);
assertNotNull(created);
try {
created = clientV2.createAtlasTypeDefs(typesDef);
fail("Expected 409");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.CONFLICT.getStatusCode());
}
}
示例3: testGetDefinition
import org.apache.atlas.model.typedef.AtlasEntityDef; //导入依赖的package包/类
@Test(dependsOnMethods = "testCreate")
public void testGetDefinition() throws Exception {
if (CollectionUtils.isNotEmpty(typeDefinitions.getEnumDefs())) {
for (AtlasEnumDef atlasEnumDef : typeDefinitions.getEnumDefs()) {
verifyByNameAndGUID(atlasEnumDef);
}
}
if (CollectionUtils.isNotEmpty(typeDefinitions.getStructDefs())) {
for (AtlasStructDef structDef : typeDefinitions.getStructDefs()) {
verifyByNameAndGUID(structDef);
}
}
if (CollectionUtils.isNotEmpty(typeDefinitions.getClassificationDefs())) {
for (AtlasClassificationDef classificationDef : typeDefinitions.getClassificationDefs()) {
verifyByNameAndGUID(classificationDef);
}
}
if (CollectionUtils.isNotEmpty(typeDefinitions.getEntityDefs())) {
for (AtlasEntityDef entityDef : typeDefinitions.getEntityDefs()) {
verifyByNameAndGUID(entityDef);
}
}
}
示例4: convertV1toV2
import org.apache.atlas.model.typedef.AtlasEntityDef; //导入依赖的package包/类
private List<AtlasEntityDef> convertV1toV2(List<HierarchicalTypeDefinition<ClassType>> types)
throws AtlasBaseException {
ImmutableList<HierarchicalTypeDefinition<ClassType>> classTypeList = ImmutableList
.<HierarchicalTypeDefinition<ClassType>> builder().addAll(types).build();
TypesDef toConvert = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition> of(),
ImmutableList.<StructTypeDefinition> of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>> of(),
classTypeList);
String json = TypesSerialization.toJson(toConvert);
AtlasTypeRegistry emptyRegistry = new AtlasTypeRegistry();
AtlasTypesDef converted = TypeConverterUtil.toAtlasTypesDef(json, emptyRegistry);
List<AtlasEntityDef> convertedEntityDefs = converted.getEntityDefs();
return convertedEntityDefs;
}
示例5: createTraitType
import org.apache.atlas.model.typedef.AtlasEntityDef; //导入依赖的package包/类
private void createTraitType(AtlasClassificationDef classificationDef) throws AtlasBaseException {
try {
typeDefStore.getClassificationDefByName(classificationDef.getName());
} catch (AtlasBaseException tne) {
//Type not found . Create
if (tne.getAtlasErrorCode() == AtlasErrorCode.TYPE_NAME_NOT_FOUND) {
AtlasTypesDef typesDef = new AtlasTypesDef(ImmutableList.<AtlasEnumDef>of(), ImmutableList.<AtlasStructDef>of(),
ImmutableList.of(classificationDef),
ImmutableList.<AtlasEntityDef>of());
typeDefStore.createTypesDef(typesDef);
} else {
throw tne;
}
}
}
示例6: toAtlasEntityDefs
import org.apache.atlas.model.typedef.AtlasEntityDef; //导入依赖的package包/类
private static List<AtlasEntityDef> toAtlasEntityDefs(List<HierarchicalTypeDefinition<ClassType>> classTypeDefinitions,
AtlasTypeRegistry registry) throws AtlasBaseException {
List<AtlasEntityDef> atlasEntityDefs = new ArrayList<AtlasEntityDef>();
for (HierarchicalTypeDefinition<ClassType> classType : classTypeDefinitions) {
List<AtlasAttributeDef> attrDefs = new ArrayList<AtlasAttributeDef>();
AtlasEntityDef atlasEntityDef = new AtlasEntityDef();
String classTypeDefName = classType.typeName;
atlasEntityDef.setName(classTypeDefName);
atlasEntityDef.setDescription(classType.typeDescription);
atlasEntityDef.setTypeVersion(classType.typeVersion);
atlasEntityDef.setSuperTypes(classType.superTypes);
AttributeDefinition[] attrDefinitions = classType.attributeDefinitions;
for (AttributeDefinition oldAttr : attrDefinitions) {
AtlasAttributeDef newAttr = toAtlasAttributeDef(oldAttr);
attrDefs.add(newAttr);
}
atlasEntityDef.setAttributeDefs(attrDefs);
atlasEntityDefs.add(atlasEntityDef);
}
return atlasEntityDefs;
}
示例7: create
import org.apache.atlas.model.typedef.AtlasEntityDef; //导入依赖的package包/类
@Override
public AtlasEntityDef create(AtlasEntityDef entityDef, Object preCreateResult) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasEntityDefStoreV1.create({}, {})", entityDef, preCreateResult);
}
AtlasVertex vertex;
if (preCreateResult == null || !(preCreateResult instanceof AtlasVertex)) {
vertex = preCreate(entityDef);
} else {
vertex = (AtlasVertex)preCreateResult;
}
updateVertexAddReferences(entityDef, vertex);
AtlasEntityDef ret = toEntityDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasEntityDefStoreV1.create({}, {}): {}", entityDef, preCreateResult, ret);
}
return ret;
}
示例8: getAll
import org.apache.atlas.model.typedef.AtlasEntityDef; //导入依赖的package包/类
@Override
public List<AtlasEntityDef> getAll() throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasEntityDefStoreV1.getAll()");
}
List<AtlasEntityDef> ret = new ArrayList<>();
Iterator<AtlasVertex> vertices = typeDefStore.findTypeVerticesByCategory(TypeCategory.CLASS);
while (vertices.hasNext()) {
ret.add(toEntityDef(vertices.next()));
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasEntityDefStoreV1.getAll(): count={}", ret.size());
}
return ret;
}
示例9: getByName
import org.apache.atlas.model.typedef.AtlasEntityDef; //导入依赖的package包/类
@Override
public AtlasEntityDef getByName(String name) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasEntityDefStoreV1.getByName({})", name);
}
AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);
if (vertex == null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
}
vertex.getProperty(Constants.TYPE_CATEGORY_PROPERTY_KEY, TypeCategory.class);
AtlasEntityDef ret = toEntityDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasEntityDefStoreV1.getByName({}): {}", name, ret);
}
return ret;
}
示例10: getByGuid
import org.apache.atlas.model.typedef.AtlasEntityDef; //导入依赖的package包/类
@Override
public AtlasEntityDef getByGuid(String guid) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasEntityDefStoreV1.getByGuid({})", guid);
}
AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.CLASS);
if (vertex == null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
}
AtlasEntityDef ret = toEntityDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasEntityDefStoreV1.getByGuid({}): {}", guid, ret);
}
return ret;
}
示例11: update
import org.apache.atlas.model.typedef.AtlasEntityDef; //导入依赖的package包/类
@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;
}
示例12: init
import org.apache.atlas.model.typedef.AtlasEntityDef; //导入依赖的package包/类
@BeforeClass
public void init() throws AtlasBaseException {
typeTest = new AtlasEntityDef(TEST_TYPE);
typeTest1 = new AtlasEntityDef(TEST_TYPE1);
typeTest2 = new AtlasEntityDef(TEST_TYPE2);
typeTest3 = new AtlasEntityDef(TEST_TYPE3);
typeWithSubTypes = new AtlasEntityDef(TEST_TYPE_WITH_SUB_TYPES);
typeTest1.addSuperType(TEST_TYPE_WITH_SUB_TYPES);
typeTest2.addSuperType(TEST_TYPE_WITH_SUB_TYPES);
typeTest3.addSuperType(TEST_TYPE_WITH_SUB_TYPES);
AtlasTypeRegistry.AtlasTransientTypeRegistry ttr = typeRegistry.lockTypeRegistryForUpdate();
ttr.addType(typeTest);
ttr.addType(typeWithSubTypes);
ttr.addType(typeTest1);
ttr.addType(typeTest2);
ttr.addType(typeTest3);
typeRegistry.releaseTypeRegistryForUpdate(ttr, true);
}
示例13: defineInverseReferenceTestTypes
import org.apache.atlas.model.typedef.AtlasEntityDef; //导入依赖的package包/类
public static AtlasTypesDef defineInverseReferenceTestTypes() {
AtlasEntityDef aDef = AtlasTypeUtil.createClassTypeDef("A", ImmutableSet.<String>of(),
AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"),
new AtlasAttributeDef("b", "B", true, Cardinality.SINGLE, 0, 1, false, false, Collections.<AtlasConstraintDef>emptyList()), // 1-1
new AtlasAttributeDef("oneB", "B", true, Cardinality.SINGLE, 0, 1, false, false, Collections.<AtlasConstraintDef>emptyList()), // 1-*
new AtlasAttributeDef("manyB", AtlasBaseTypeDef.getArrayTypeName("B"), true, Cardinality.SINGLE, 0, 1, false, false, Collections.<AtlasConstraintDef>emptyList()),
new AtlasAttributeDef("mapToB", AtlasBaseTypeDef.getMapTypeName("string", "B"), true, Cardinality.SINGLE, 0, 1, false, false,
Collections.<AtlasConstraintDef>singletonList(new AtlasConstraintDef(
AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, Collections.<String, Object>singletonMap(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, "mappedFromA"))))); // *-*
AtlasEntityDef bDef = AtlasTypeUtil.createClassTypeDef("B", ImmutableSet.<String>of(),
AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"),
new AtlasAttributeDef("a", "A", true, Cardinality.SINGLE, 0, 1, false, false,
Collections.<AtlasConstraintDef>singletonList(new AtlasConstraintDef(
AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, Collections.<String, Object>singletonMap(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, "b")))),
new AtlasAttributeDef("manyA", AtlasBaseTypeDef.getArrayTypeName("A"), true, Cardinality.SINGLE, 0, 1, false, false,
Collections.<AtlasConstraintDef>singletonList(new AtlasConstraintDef(
AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, Collections.<String, Object>singletonMap(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, "oneB")))),
new AtlasAttributeDef("manyToManyA", AtlasBaseTypeDef.getArrayTypeName("A"), true, Cardinality.SINGLE, 0, 1, false, false,
Collections.<AtlasConstraintDef>singletonList(new AtlasConstraintDef(
AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, Collections.<String, Object>singletonMap(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, "manyB")))),
new AtlasAttributeDef("mappedFromA", "A", true, Cardinality.SINGLE, 0, 1, false, false, Collections.<AtlasConstraintDef>emptyList()));
return new AtlasTypesDef(ImmutableList.<AtlasEnumDef>of(), ImmutableList.<AtlasStructDef>of(), ImmutableList.<AtlasClassificationDef>of(), ImmutableList.<AtlasEntityDef>of(aDef, bDef));
}
示例14: simpleType
import org.apache.atlas.model.typedef.AtlasEntityDef; //导入依赖的package包/类
public static AtlasTypesDef simpleType(){
AtlasEntityDef superTypeDefinition =
AtlasTypeUtil.createClassTypeDef("h_type", ImmutableSet.<String>of(),
AtlasTypeUtil.createOptionalAttrDef("attr", "string"));
AtlasStructDef structTypeDefinition = new AtlasStructDef("s_type", "structType", "1.0",
Arrays.asList(AtlasTypeUtil.createRequiredAttrDef("name", "string")));
AtlasClassificationDef traitTypeDefinition =
AtlasTypeUtil.createTraitTypeDef("t_type", "traitType", ImmutableSet.<String>of());
AtlasEnumDef enumTypeDefinition = new AtlasEnumDef("e_type", "enumType", "1.0",
Arrays.asList(new AtlasEnumElementDef("ONE", "Element Description", 1)));
return AtlasTypeUtil.getTypesDef(ImmutableList.of(enumTypeDefinition), ImmutableList.of(structTypeDefinition),
ImmutableList.of(traitTypeDefinition), ImmutableList.of(superTypeDefinition));
}
示例15: simpleTypeUpdated
import org.apache.atlas.model.typedef.AtlasEntityDef; //导入依赖的package包/类
public static AtlasTypesDef simpleTypeUpdated(){
AtlasEntityDef superTypeDefinition =
AtlasTypeUtil.createClassTypeDef("h_type", ImmutableSet.<String>of(),
AtlasTypeUtil.createOptionalAttrDef("attr", "string"));
AtlasEntityDef newSuperTypeDefinition =
AtlasTypeUtil.createClassTypeDef("new_h_type", ImmutableSet.<String>of(),
AtlasTypeUtil.createOptionalAttrDef("attr", "string"));
AtlasStructDef structTypeDefinition = new AtlasStructDef("s_type", "structType", "1.0",
Arrays.asList(AtlasTypeUtil.createRequiredAttrDef("name", "string")));
AtlasClassificationDef traitTypeDefinition =
AtlasTypeUtil.createTraitTypeDef("t_type", "traitType", ImmutableSet.<String>of());
AtlasEnumDef enumTypeDefinition = new AtlasEnumDef("e_type", "enumType",
Arrays.asList(new AtlasEnumElementDef("ONE", "Element Description", 1)));
return AtlasTypeUtil.getTypesDef(ImmutableList.of(enumTypeDefinition), ImmutableList.of(structTypeDefinition),
ImmutableList.of(traitTypeDefinition), ImmutableList.of(superTypeDefinition, newSuperTypeDefinition));
}