Java Code Examples for org.apache.atlas.model.typedef.AtlasTypesDef#isEmpty()
The following examples show how to use
org.apache.atlas.model.typedef.AtlasTypesDef#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InverseReferenceUpdateV1Test.java From incubator-atlas with Apache License 2.0 | 6 votes |
@BeforeClass public void setUp() throws Exception { metadataService = TestUtils.addSessionCleanupWrapper(metadataService); AtlasTypesDef[] testTypesDefs = new AtlasTypesDef[] { TestUtilsV2.defineDeptEmployeeTypes(), TestUtilsV2.defineInverseReferenceTestTypes() }; for (AtlasTypesDef typesDef : testTypesDefs) { AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesDef, typeRegistry); if (!typesToCreate.isEmpty()) { typeDefStore.createTypesDef(typesToCreate); } } deptEntity = TestUtilsV2.createDeptEg2(); init(); EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(deptEntity), false); for (AtlasEntityHeader entityHeader : response.getCreatedEntities()) { nameIdMap.put((String)entityHeader.getAttribute(NAME), AtlasTypeUtil.getAtlasObjectId(entityHeader)); } }
Example 2
Source File: ExportServiceTest.java From atlas with Apache License 2.0 | 6 votes |
@BeforeClass public void setupSampleData() throws AtlasBaseException { AtlasTypesDef sampleTypes = TestUtilsV2.defineDeptEmployeeTypes(); AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(sampleTypes, typeRegistry); if (!typesToCreate.isEmpty()) { typeDefStore.createTypesDef(typesToCreate); } AtlasEntity.AtlasEntitiesWithExtInfo deptEg2 = TestUtilsV2.createDeptEg2(); AtlasEntityStream entityStream = new AtlasEntityStream(deptEg2); EntityMutationResponse emr = entityStore.createOrUpdate(entityStream, false); assertNotNull(emr); assertNotNull(emr.getCreatedEntities()); assertTrue(emr.getCreatedEntities().size() > 0); }
Example 3
Source File: AtlasRelationshipStoreV2Test.java From atlas with Apache License 2.0 | 6 votes |
@BeforeClass public void setUp() throws Exception { new GraphBackedSearchIndexer(typeRegistry); // create employee relationship types AtlasTypesDef employeeTypes = getDepartmentEmployeeTypes(); typeDefStore.createTypesDef(employeeTypes); AtlasEntitiesWithExtInfo employeeInstances = getDepartmentEmployeeInstances(); EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(employeeInstances), false); for (AtlasEntityHeader entityHeader : response.getCreatedEntities()) { employeeNameIdMap.put((String) entityHeader.getAttribute(NAME), getAtlasObjectId(entityHeader)); } init(); AtlasTypesDef typesDef = getInverseReferenceTestTypes(); AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesDef, typeRegistry); if (!typesToCreate.isEmpty()) { typeDefStore.createTypesDef(typesToCreate); } }
Example 4
Source File: InverseReferenceUpdateV2Test.java From atlas with Apache License 2.0 | 6 votes |
@BeforeClass public void setUp() throws Exception { RequestContext.clear(); RequestContext.get().setUser(TestUtilsV2.TEST_USER, null); AtlasTypesDef[] testTypesDefs = new AtlasTypesDef[] { TestUtilsV2.defineDeptEmployeeTypes(), TestUtilsV2.defineInverseReferenceTestTypes() }; for (AtlasTypesDef typesDef : testTypesDefs) { AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesDef, typeRegistry); if (!typesToCreate.isEmpty()) { typeDefStore.createTypesDef(typesToCreate); } } deptEntity = TestUtilsV2.createDeptEg2(); init(); EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(deptEntity), false); for (AtlasEntityHeader entityHeader : response.getCreatedEntities()) { nameIdMap.put((String)entityHeader.getAttribute(NAME), AtlasTypeUtil.getAtlasObjectId(entityHeader)); } }
Example 5
Source File: ExportServiceTest.java From incubator-atlas with Apache License 2.0 | 6 votes |
@BeforeClass public void setupSampleData() throws AtlasBaseException { entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier, graphMapper);; AtlasTypesDef sampleTypes = TestUtilsV2.defineDeptEmployeeTypes(); AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(sampleTypes, typeRegistry); if (!typesToCreate.isEmpty()) { typeDefStore.createTypesDef(typesToCreate); } AtlasEntity.AtlasEntitiesWithExtInfo hrDept = TestUtilsV2.createDeptEg2(); AtlasEntityStream entityStream = new AtlasEntityStream(hrDept); entityStore.createOrUpdate(entityStream, false); LOG.debug("==> setupSampleData: ", AtlasEntity.dumpObjects(hrDept.getEntities(), null).toString()); }
Example 6
Source File: TestEntitiesREST.java From incubator-atlas with Apache License 2.0 | 6 votes |
@BeforeClass public void setUp() throws Exception { AtlasTypesDef[] testTypesDefs = new AtlasTypesDef[] { TestUtilsV2.defineHiveTypes() }; for (AtlasTypesDef typesDef : testTypesDefs) { AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesDef, typeRegistry); if (!typesToCreate.isEmpty()) { typeStore.createTypesDef(typesToCreate); } } dbEntity = TestUtilsV2.createDBEntity(); tableEntity = TestUtilsV2.createTableEntity(dbEntity); final AtlasEntity colEntity = TestUtilsV2.createColumnEntity(tableEntity); columns = new ArrayList<AtlasEntity>() {{ add(colEntity); }}; tableEntity.setAttribute("columns", getObjIdList(columns)); }
Example 7
Source File: AtlasTypeRegistry.java From atlas with Apache License 2.0 | 5 votes |
public void removeTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException { if (null != typesDef && !typesDef.isEmpty()) { removeTypesWithNoRefResolve(typesDef.getEnumDefs()); removeTypesWithNoRefResolve(typesDef.getStructDefs()); removeTypesWithNoRefResolve(typesDef.getClassificationDefs()); removeTypesWithNoRefResolve(typesDef.getEntityDefs()); removeTypesWithNoRefResolve(typesDef.getRelationshipDefs()); removeTypesWithNoRefResolve(typesDef.getBusinessMetadataDefs()); } resolveReferences(); }
Example 8
Source File: AtlasTypeRegistry.java From incubator-atlas with Apache License 2.0 | 5 votes |
public void removeTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException { if (null != typesDef && !typesDef.isEmpty()) { removeTypesWithNoRefResolve(typesDef.getEnumDefs()); removeTypesWithNoRefResolve(typesDef.getStructDefs()); removeTypesWithNoRefResolve(typesDef.getClassificationDefs()); removeTypesWithNoRefResolve(typesDef.getEntityDefs()); removeTypesWithNoRefResolve(typesDef.getRelationshipDefs()); resolveReferences(); } }
Example 9
Source File: AtlasEntityStoreV1Test.java From incubator-atlas with Apache License 2.0 | 5 votes |
@BeforeClass public void setUp() throws Exception { metadataService = TestUtils.addSessionCleanupWrapper(metadataService); new GraphBackedSearchIndexer(typeRegistry); AtlasTypesDef[] testTypesDefs = new AtlasTypesDef[] { TestUtilsV2.defineDeptEmployeeTypes(), TestUtilsV2.defineHiveTypes() }; for (AtlasTypesDef typesDef : testTypesDefs) { AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesDef, typeRegistry); if (!typesToCreate.isEmpty()) { typeDefStore.createTypesDef(typesToCreate); } } deptEntity = TestUtilsV2.createDeptEg2(); dbEntity = TestUtilsV2.createDBEntityV2(); tblEntity = TestUtilsV2.createTableEntityV2(dbEntity.getEntity()); AtlasTypesDef typesDef11 = new AtlasTypesDef(); List primitiveEntityDef = new ArrayList<AtlasEntityDef>(); primitiveEntityDef.add(TestUtilsV2.createPrimitiveEntityDef()); typesDef11.setEntityDefs(primitiveEntityDef); typeDefStore.createTypesDef( typesDef11 ); primitiveEntity = TestUtilsV2.createprimitiveEntityV2(); }
Example 10
Source File: ImportServiceTestUtils.java From incubator-atlas with Apache License 2.0 | 5 votes |
private static void createTypesAsNeeded(AtlasTypesDef typesFromJson, AtlasTypeDefStore typeDefStore, AtlasTypeRegistry typeRegistry) throws AtlasBaseException { AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesFromJson, typeRegistry); if (!typesToCreate.isEmpty()) { typeDefStore.createTypesDef(typesToCreate); } }
Example 11
Source File: ZipFileResourceTestUtils.java From incubator-atlas with Apache License 2.0 | 5 votes |
private static void createTypesAsNeeded(AtlasTypesDef typesFromJson, AtlasTypeDefStore typeDefStore, AtlasTypeRegistry typeRegistry) throws AtlasBaseException { AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesFromJson, typeRegistry); if (!typesToCreate.isEmpty()) { typeDefStore.createTypesDef(typesToCreate); } }
Example 12
Source File: ImportTypeDefProcessor.java From incubator-atlas with Apache License 2.0 | 5 votes |
public void processTypes(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException { setGuidToEmpty(typeDefinitionMap); typeAttributeDifference.updateTypes(typeDefinitionMap, result); AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typeDefinitionMap, this.typeRegistry); if (!typesToCreate.isEmpty()) { typeDefStore.createTypesDef(typesToCreate); updateMetricsForTypesDef(typesToCreate, result); } }
Example 13
Source File: AtlasEntityTestBase.java From atlas with Apache License 2.0 | 5 votes |
protected void createTypesDef(AtlasTypesDef[] testTypesDefs) throws AtlasBaseException { for (AtlasTypesDef typesDef : testTypesDefs) { AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesDef, typeRegistry); if (!typesToCreate.isEmpty()) { typeDefStore.createTypesDef(typesToCreate); } } }
Example 14
Source File: TestLoadModelUtils.java From atlas with Apache License 2.0 | 5 votes |
public static void createTypesAsNeeded(AtlasTypesDef typesFromJson, AtlasTypeDefStore typeDefStore, AtlasTypeRegistry typeRegistry) throws AtlasBaseException { if(typesFromJson == null) { return; } AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesFromJson, typeRegistry); if (typesToCreate != null && !typesToCreate.isEmpty()) { typeDefStore.createTypesDef(typesToCreate); } }
Example 15
Source File: ImportTypeDefProcessor.java From atlas with Apache License 2.0 | 5 votes |
public void processTypes(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException { setGuidToEmpty(typeDefinitionMap); AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typeDefinitionMap, this.typeRegistry); if (!typesToCreate.isEmpty()) { typeDefStore.createTypesDef(typesToCreate); updateMetricsForTypesDef(typesToCreate, result); } typeAttributeDifference.updateTypes(typeDefinitionMap, result); }
Example 16
Source File: AtlasTypeDefStoreInitializer.java From incubator-atlas with Apache License 2.0 | 4 votes |
private void initializeStore(String typesDirName) { File typesDir = new File(typesDirName); File[] typeDefFiles = typesDir.exists() ? typesDir.listFiles() : null; if (typeDefFiles == null || typeDefFiles.length == 0) { LOG.info("Types directory {} does not exist or not readable or has no typedef files", typesDirName); return; } // sort the files by filename Arrays.sort(typeDefFiles); for (File typeDefFile : typeDefFiles) { if (!typeDefFile.isFile()) { continue; } try { String jsonStr = new String(Files.readAllBytes(typeDefFile.toPath()), StandardCharsets.UTF_8); AtlasTypesDef typesDef = AtlasType.fromJson(jsonStr, AtlasTypesDef.class); if (typesDef == null || typesDef.isEmpty()) { LOG.info("No type in file {}", typeDefFile.getAbsolutePath()); continue; } AtlasTypesDef typesToCreate = getTypesToCreate(typesDef, atlasTypeRegistry); AtlasTypesDef typesToUpdate = getTypesToUpdate(typesDef, atlasTypeRegistry); if (!typesToCreate.isEmpty() || !typesToUpdate.isEmpty()) { atlasTypeDefStore.createUpdateTypesDef(typesToCreate, typesToUpdate); LOG.info("Created/Updated types defined in file {}", typeDefFile.getAbsolutePath()); } else { LOG.info("No new type in file {}", typeDefFile.getAbsolutePath()); } } catch (Throwable t) { LOG.error("error while registering types in file {}", typeDefFile.getAbsolutePath(), t); } } applyTypePatches(typesDirName); }
Example 17
Source File: TestEntitiesREST.java From atlas with Apache License 2.0 | 4 votes |
@BeforeClass public void setUp() throws Exception { AtlasTypesDef[] testTypesDefs = new AtlasTypesDef[] { TestUtilsV2.defineHiveTypes() }; for (AtlasTypesDef typesDef : testTypesDefs) { AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesDef, typeRegistry); if (!typesToCreate.isEmpty()) { typeStore.createTypesDef(typesToCreate); } } loadGlossaryType(); createEntities(); createGlossary(); createTerms(); initTagMap(); registerEntities(); addTagTo(CLASSIFICATION, TABLE_TYPE); }
Example 18
Source File: AdminPurgeTest.java From atlas with Apache License 2.0 | 4 votes |
@Test public void testDeleteEntitiesDoesNotLookupDeletedEntity() throws Exception { AtlasTypesDef sampleTypes = TestUtilsV2.defineDeptEmployeeTypes(); AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(sampleTypes, typeRegistry); if (!typesToCreate.isEmpty()) { typeDefStore.createTypesDef(typesToCreate); } AtlasEntity.AtlasEntitiesWithExtInfo deptEg2 = TestUtilsV2.createDeptEg2(); AtlasEntityStream entityStream = new AtlasEntityStream(deptEg2); EntityMutationResponse emr = entityStore.createOrUpdate(entityStream, false); pauseForIndexCreation(); assertNotNull(emr); assertNotNull(emr.getCreatedEntities()); assertTrue(emr.getCreatedEntities().size() > 0); List<String> guids = emr.getCreatedEntities().stream() .map(p -> new String(p.getGuid())).collect(Collectors.toList()); EntityMutationResponse response = entityStore.deleteByIds(guids); pauseForIndexCreation(); List<AtlasEntityHeader> responseDeletedEntities = response.getDeletedEntities(); assertNotNull(responseDeletedEntities); responseDeletedEntities.sort((l,r) -> l.getGuid().compareTo(r.getGuid())); List<AtlasEntityHeader> toBeDeletedEntities = emr.getCreatedEntities(); toBeDeletedEntities.sort((l,r) -> l.getGuid().compareTo(r.getGuid())); Assert.assertEquals(responseDeletedEntities.size(), emr.getCreatedEntities().size()); for(int index = 0 ; index < responseDeletedEntities.size(); index++) Assert.assertEquals(responseDeletedEntities.get(index).getGuid(), emr.getCreatedEntities().get(index).getGuid()); Date startTimestamp = new Date(); response = entityStore.purgeByIds(new HashSet<>(guids)); pauseForIndexCreation(); List<AtlasEntityHeader> responsePurgedEntities = response.getPurgedEntities(); responsePurgedEntities.sort((l,r) -> l.getGuid().compareTo(r.getGuid())); Assert.assertEquals(responsePurgedEntities.size(), responseDeletedEntities.size()); for(int index = 0 ; index < responsePurgedEntities.size(); index++) Assert.assertEquals(responsePurgedEntities.get(index).getGuid(), responseDeletedEntities.get(index).getGuid()); auditService.add(DEFAULT_USER, AtlasAuditEntry.AuditOperation.PURGE, CLIENT_HOST, startTimestamp, new Date(), guids.toString(), response.getPurgedEntitiesIds(), response.getPurgedEntities().size()); AuditSearchParameters auditParameterNull = createAuditParameter("audit-search-parameter-without-filter"); assertAuditEntry(auditService, auditParameterNull); AuditSearchParameters auditSearchParameters = createAuditParameter("audit-search-parameter-purge"); assertAuditEntry(auditService, auditSearchParameters); }
Example 19
Source File: AtlasTypeDefStoreInitializer.java From atlas with Apache License 2.0 | 4 votes |
/** * Load all the model files in the supplied folder followed by the contents of the patches folder. * @param typesDir */ private void loadModelsInFolder(File typesDir, AtlasPatchRegistry patchRegistry) { LOG.info("==> AtlasTypeDefStoreInitializer({})", typesDir); String typesDirName = typesDir.getName(); File[] typeDefFiles = typesDir.exists() ? typesDir.listFiles() : null; if (typeDefFiles == null || typeDefFiles.length == 0) { LOG.info("Types directory {} does not exist or not readable or has no typedef files", typesDirName ); } else { // sort the files by filename Arrays.sort(typeDefFiles); for (File typeDefFile : typeDefFiles) { if (typeDefFile.isFile()) { try { String jsonStr = new String(Files.readAllBytes(typeDefFile.toPath()), StandardCharsets.UTF_8); AtlasTypesDef typesDef = AtlasType.fromJson(jsonStr, AtlasTypesDef.class); if (typesDef == null || typesDef.isEmpty()) { LOG.info("No type in file {}", typeDefFile.getAbsolutePath()); continue; } AtlasTypesDef typesToCreate = getTypesToCreate(typesDef, typeRegistry); AtlasTypesDef typesToUpdate = getTypesToUpdate(typesDef, typeRegistry, true); if (!typesToCreate.isEmpty() || !typesToUpdate.isEmpty()) { typeDefStore.createUpdateTypesDef(typesToCreate, typesToUpdate); LOG.info("Created/Updated types defined in file {}", typeDefFile.getAbsolutePath()); } else { LOG.info("No new type in file {}", typeDefFile.getAbsolutePath()); } } catch (Throwable t) { LOG.error("error while registering types in file {}", typeDefFile.getAbsolutePath(), t); } } } applyTypePatches(typesDir.getPath(), patchRegistry); } LOG.info("<== AtlasTypeDefStoreInitializer({})", typesDir); }