use of org.apache.atlas.typesystem.types.HierarchicalTypeDefinition in project incubator-atlas by apache.
the class RestUtilsTest method convertV2toV1.
private List<HierarchicalTypeDefinition<ClassType>> convertV2toV1(List<AtlasEntityDef> toConvert) throws AtlasBaseException {
AtlasTypeRegistry reg = createRegistry(toConvert);
List<HierarchicalTypeDefinition<ClassType>> result = new ArrayList<>(toConvert.size());
for (int i = 0; i < toConvert.size(); i++) {
AtlasEntityDef entityDef = toConvert.get(i);
AtlasEntityType entity = reg.getEntityTypeByName(entityDef.getName());
HierarchicalTypeDefinition<ClassType> converted = TypeConverterUtil.toTypesDef(entity, reg).classTypesAsJavaList().get(0);
result.add(converted);
}
return result;
}
use of org.apache.atlas.typesystem.types.HierarchicalTypeDefinition in project incubator-atlas by apache.
the class TypeConverterUtil method enumToTypesDef.
private static TypesDef enumToTypesDef(AtlasEnumType enumType) {
TypesDef ret = null;
AtlasEnumDef enumDef = enumType.getEnumDef();
String enumName = enumDef.getName();
String enumDesc = enumDef.getDescription();
String enumVersion = enumDef.getTypeVersion();
EnumValue[] enumValues = getEnumValues(enumDef.getElementDefs());
if (enumName != null && enumValues != null && enumValues.length > 0) {
EnumTypeDefinition enumTypeDef = new EnumTypeDefinition(enumName, enumDesc, enumVersion, enumValues);
ret = TypesUtil.getTypesDef(ImmutableList.of(enumTypeDef), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.<HierarchicalTypeDefinition<ClassType>>of());
}
return ret;
}
use of org.apache.atlas.typesystem.types.HierarchicalTypeDefinition in project incubator-atlas by apache.
the class TypeConverterUtil method classificationToTypesDef.
private static TypesDef classificationToTypesDef(AtlasClassificationType classificationType, AtlasTypeRegistry registry) throws AtlasBaseException {
String typeName = classificationType.getClassificationDef().getName();
String typeDesc = classificationType.getClassificationDef().getDescription();
String typeVersion = classificationType.getClassificationDef().getTypeVersion();
ImmutableSet superTypes = ImmutableSet.copyOf(classificationType.getClassificationDef().getSuperTypes());
AttributeDefinition[] attributes = getAttributes(classificationType, registry);
HierarchicalTypeDefinition traitType = TypesUtil.createTraitTypeDef(typeName, typeDesc, typeVersion, superTypes, attributes);
TypesDef ret = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(traitType), ImmutableList.<HierarchicalTypeDefinition<ClassType>>of());
return ret;
}
use of org.apache.atlas.typesystem.types.HierarchicalTypeDefinition in project incubator-atlas by apache.
the class GraphBackedDiscoveryServiceTest method createTypesWithReservedKeywordAttributes.
private void createTypesWithReservedKeywordAttributes() throws Exception {
HierarchicalTypeDefinition orderType = createClassTypeDef("OrderType", null, createRequiredAttrDef("order", DataTypes.INT_TYPE));
HierarchicalTypeDefinition limitType = createClassTypeDef("LimitType", null, createOptionalAttrDef("limit", DataTypes.BOOLEAN_TYPE));
TypeSystem.getInstance().defineClassTypes(orderType, limitType);
}
use of org.apache.atlas.typesystem.types.HierarchicalTypeDefinition in project incubator-atlas by apache.
the class GraphBackedDiscoveryServiceTest method testSearchForTypeWithNoInstances.
@Test
public void testSearchForTypeWithNoInstances() throws Exception {
HierarchicalTypeDefinition EMPTY = createClassTypeDef("EmptyType", null, createRequiredAttrDef("a", DataTypes.INT_TYPE));
TypeSystem.getInstance().defineClassTypes(EMPTY);
String dslQuery = "EmptyType";
String jsonResults = searchByDSL(dslQuery);
assertNotNull(jsonResults);
JSONObject results = new JSONObject(jsonResults);
assertEquals(results.length(), 3);
JSONArray rows = results.getJSONArray("rows");
assertNotNull(rows);
// query should not return any rows
assertEquals(rows.length(), 0);
}
Aggregations