use of org.apache.atlas.type.AtlasTypeRegistry 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.type.AtlasTypeRegistry in project incubator-atlas by apache.
the class GraphBackedMetadataRepositoryDeleteTestBase method setUp.
@BeforeClass
public void setUp() throws Exception {
typeSystem = TypeSystem.getInstance();
typeSystem.reset();
new GraphBackedSearchIndexer(new AtlasTypeRegistry());
final GraphBackedMetadataRepository delegate = new GraphBackedMetadataRepository(getDeleteHandler(typeSystem), atlasGraph);
repositoryService = TestUtils.addTransactionWrapper(delegate);
TestUtils.defineDeptEmployeeTypes(typeSystem);
TestUtils.createHiveTypes(typeSystem);
// Define type for map value.
HierarchicalTypeDefinition<ClassType> mapValueDef = TypesUtil.createClassTypeDef("CompositeMapValue", ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE));
// Define type with map where the value is a composite class reference to MapValue.
HierarchicalTypeDefinition<ClassType> mapOwnerDef = TypesUtil.createClassTypeDef("CompositeMapOwner", ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE), new AttributeDefinition("map", DataTypes.mapTypeName(DataTypes.STRING_TYPE.getName(), "CompositeMapValue"), Multiplicity.OPTIONAL, true, null));
TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.of(mapOwnerDef, mapValueDef));
typeSystem.defineTypes(typesDef);
compositeMapOwnerType = typeSystem.getDataType(ClassType.class, "CompositeMapOwner");
compositeMapValueType = typeSystem.getDataType(ClassType.class, "CompositeMapValue");
}
use of org.apache.atlas.type.AtlasTypeRegistry in project incubator-atlas by apache.
the class GraphBackedMetadataRepositoryTest method setUp.
@BeforeClass
public void setUp() throws Exception {
typeSystem = TypeSystem.getInstance();
typeSystem.reset();
assertTrue(repositoryService instanceof GraphBackedMetadataRepository);
repositoryService = TestUtils.addTransactionWrapper(repositoryService);
new GraphBackedSearchIndexer(new AtlasTypeRegistry());
TestUtils.defineDeptEmployeeTypes(typeSystem);
TestUtils.createHiveTypes(typeSystem);
}
use of org.apache.atlas.type.AtlasTypeRegistry in project incubator-atlas by apache.
the class GraphBackedDiscoveryServiceTest method addIndexesForNewTypes.
private void addIndexesForNewTypes(Collection<String> oldTypeNames, final TypeSystem typeSystem) throws AtlasException {
Set<String> newTypeNames = new HashSet<>();
newTypeNames.addAll(typeSystem.getTypeNames());
newTypeNames.removeAll(oldTypeNames);
Collection<IDataType> newTypes = new ArrayList<>();
for (String name : newTypeNames) {
try {
newTypes.add(typeSystem.getDataType(IDataType.class, name));
} catch (AtlasException e) {
e.printStackTrace();
}
}
//We need to commit the transaction before creating the indices to release the locks held by the transaction.
//otherwise, the index commit will fail while waiting for the those locks to be released.
AtlasGraphProvider.getGraphInstance().commit();
GraphBackedSearchIndexer idx = new GraphBackedSearchIndexer(new AtlasTypeRegistry());
idx.onAdd(newTypes);
}
use of org.apache.atlas.type.AtlasTypeRegistry in project incubator-atlas by apache.
the class TestUtils method setupGraphProvider.
/**
* Triggers the Atlas initialization process using the specified MetadataRepository.
* This causes the built-in types and their indices to be created.
*/
public static void setupGraphProvider(MetadataRepository repo) throws AtlasException {
TypeCache typeCache = null;
try {
typeCache = AtlasRepositoryConfiguration.getTypeCache().newInstance();
} catch (Throwable t) {
typeCache = new DefaultTypeCache();
}
final GraphBackedSearchIndexer indexer = new GraphBackedSearchIndexer(new AtlasTypeRegistry());
Configuration config = ApplicationProperties.get();
ITypeStore typeStore = new GraphBackedTypeStore(AtlasGraphProvider.getGraphInstance());
DefaultMetadataService defaultMetadataService = new DefaultMetadataService(repo, typeStore, new HashSet<TypesChangeListener>() {
{
add(indexer);
}
}, new HashSet<EntityChangeListener>(), TypeSystem.getInstance(), config, typeCache, // Fixme: Can we work with Noop
new InMemoryEntityAuditRepository());
//commit the created types
getGraph().commit();
}
Aggregations