use of org.apache.atlas.typesystem.exception.TypeNotFoundException in project incubator-atlas by apache.
the class DefaultMetadataServiceTest method setUp.
@BeforeTest
public void setUp() throws Exception {
typeDefChangeListener = (DefaultMetadataService) metadataService;
metadataService = TestUtils.addSessionCleanupWrapper(metadataService);
if (auditRepository instanceof HBaseBasedAuditRepository) {
HBaseTestUtils.startCluster();
((HBaseBasedAuditRepository) auditRepository).start();
}
TestUtils.resetRequestContext();
RequestContext.get().setUser("testuser");
TypesDef typesDef = TestUtils.defineHiveTypes();
try {
metadataService.getTypeDefinition(TestUtils.TABLE_TYPE);
} catch (TypeNotFoundException e) {
metadataService.createType(TypesSerialization.toJson(typesDef));
}
String dbGUid = TestUtils.createInstance(metadataService, db);
table = createTableEntity(dbGUid);
String tableGuid = TestUtils.createInstance(metadataService, table);
String tableDefinitionJson = metadataService.getEntityDefinition(TestUtils.TABLE_TYPE, NAME, (String) table.get(NAME));
table = InstanceSerialization.fromJsonReferenceable(tableDefinitionJson, true);
tableId = new Id(tableGuid, 0, TestUtils.TABLE_TYPE);
}
use of org.apache.atlas.typesystem.exception.TypeNotFoundException in project incubator-atlas by apache.
the class GraphHelper method deserializeClassInstances.
public static ITypedReferenceableInstance[] deserializeClassInstances(TypeSystem typeSystem, String entityInstanceDefinition) throws AtlasException {
try {
JSONArray referableInstances = new JSONArray(entityInstanceDefinition);
ITypedReferenceableInstance[] instances = new ITypedReferenceableInstance[referableInstances.length()];
for (int index = 0; index < referableInstances.length(); index++) {
Referenceable entityInstance = InstanceSerialization.fromJsonReferenceable(referableInstances.getString(index), true);
ITypedReferenceableInstance typedInstrance = getTypedReferenceableInstance(typeSystem, entityInstance);
instances[index] = typedInstrance;
}
return instances;
} catch (ValueConversionException | TypeNotFoundException e) {
throw e;
} catch (Exception e) {
// exception from deserializer
LOG.error("Unable to deserialize json={}", entityInstanceDefinition, e);
throw new IllegalArgumentException("Unable to deserialize json", e);
}
}
use of org.apache.atlas.typesystem.exception.TypeNotFoundException in project incubator-atlas by apache.
the class DefaultMetadataService method createTraitInstance.
@Override
public ITypedStruct createTraitInstance(Struct traitInstance) throws AtlasException {
try {
final String entityTypeName = ParamChecker.notEmpty(traitInstance.getTypeName(), "entity type");
TraitType traitType = typeSystem.getDataType(TraitType.class, entityTypeName);
return traitType.convert(traitInstance, Multiplicity.REQUIRED);
} catch (TypeNotFoundException e) {
throw e;
} catch (Exception e) {
throw new AtlasException("Error deserializing trait instance", e);
}
}
use of org.apache.atlas.typesystem.exception.TypeNotFoundException in project incubator-atlas by apache.
the class GraphHelperTest method setUp.
@BeforeClass
public void setUp() throws Exception {
typeSystem = TypeSystem.getInstance();
typeSystem.reset();
new GraphBackedSearchIndexer(typeRegistry);
TypesDef typesDef = TestUtils.defineHiveTypes();
try {
metadataService.getTypeDefinition(TestUtils.TABLE_TYPE);
} catch (TypeNotFoundException e) {
metadataService.createType(TypesSerialization.toJson(typesDef));
}
TestUtils.defineDeptEmployeeTypes(typeSystem);
}
Aggregations