final AtlasEntity.AtlasEntityWithExtInfo entityExt = searchEntityDef(id); final AtlasEntity entity = entityExt.getEntity(); if (AtlasEntity.Status.DELETED.equals(entity.getStatus())) { return null;
public static boolean isActive(AtlasEntity entity) { return entity != null ? entity.getStatus() == ACTIVE : false; }
final AtlasEntity.AtlasEntityWithExtInfo entityExt = searchEntityDef(id); final AtlasEntity entity = entityExt.getEntity(); if (AtlasEntity.Status.DELETED.equals(entity.getStatus())) { return null;
private void verifyExportForHrDataForConnected(ZipSource zipSource) throws IOException, AtlasBaseException { assertNotNull(zipSource.getCreationOrder()); assertTrue(zipSource.getCreationOrder().size() == 2); assertTrue(zipSource.hasNext()); AtlasEntity entity = zipSource.next(); assertNotNull(entity); assertTrue(entity.getTypeName().equals("Department")); assertEquals(entity.getStatus(), AtlasEntity.Status.ACTIVE); verifyTypeDefs(zipSource); }
private void verifyExportForHrData(ZipSource zipSource) throws IOException, AtlasBaseException { assertNotNull(zipSource.getCreationOrder()); assertTrue(zipSource.getCreationOrder().size() == 1); assertTrue(zipSource.hasNext()); AtlasEntity entity = zipSource.next(); assertNotNull(entity); assertTrue(entity.getTypeName().equals("Department")); assertEquals(entity.getStatus(), AtlasEntity.Status.ACTIVE); verifyTypeDefs(zipSource); }
private void verifyExportForFullEmployeeData(ZipSource zipSource) throws AtlasBaseException { final List<String> expectedEntityTypes = Arrays.asList(new String[]{"Manager", "Employee", "Department"}); assertNotNull(zipSource.getCreationOrder()); assertTrue(zipSource.hasNext()); while (zipSource.hasNext()) { AtlasEntity entity = zipSource.next(); assertNotNull(entity); assertEquals(AtlasEntity.Status.ACTIVE, entity.getStatus()); assertTrue(expectedEntityTypes.contains(entity.getTypeName())); } verifyTypeDefs(zipSource); }
private void verifyExportForHrDataForConnected(ZipSource zipSource) throws IOException, AtlasBaseException { assertNotNull(zipSource.getCreationOrder()); assertTrue(zipSource.getCreationOrder().size() == 2); assertTrue(zipSource.hasNext()); AtlasEntity entity = zipSource.next(); assertNotNull(entity); assertTrue(entity.getTypeName().equals("Department")); assertEquals(entity.getStatus(), AtlasEntity.Status.ACTIVE); verifyTypeDefs(zipSource); }
private void verifyExportForHrData(ZipSource zipSource) throws IOException, AtlasBaseException { assertNotNull(zipSource.getCreationOrder()); assertTrue(zipSource.getCreationOrder().size() == 1); assertTrue(zipSource.hasNext()); AtlasEntity entity = zipSource.next(); assertNotNull(entity); assertTrue(entity.getTypeName().equals("Department")); assertEquals(entity.getStatus(), AtlasEntity.Status.ACTIVE); verifyTypeDefs(zipSource); }
private void verifyExportForEmployeeData(ZipSource zipSource) throws AtlasBaseException { final List<String> expectedEntityTypes = Arrays.asList(new String[]{"Manager", "Employee", "Department"}); assertNotNull(zipSource.getCreationOrder()); assertEquals(zipSource.getCreationOrder().size(), 2); assertTrue(zipSource.hasNext()); while (zipSource.hasNext()) { AtlasEntity entity = zipSource.next(); assertNotNull(entity); assertEquals(AtlasEntity.Status.ACTIVE, entity.getStatus()); assertTrue(expectedEntityTypes.contains(entity.getTypeName())); } verifyTypeDefs(zipSource); }
if (!loadDeleted && entityWithExtInfo.getEntity().getStatus() == AtlasEntity.Status.DELETED) { throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_DELETED, guid);
public AtlasUserProfile from(AtlasEntityWithExtInfo entityWithExtInfo) { AtlasUserProfile userProfile = from(entityWithExtInfo.getEntity()); Object savedSearches = entityWithExtInfo.getEntity().getAttribute(PROPERTY_SAVED_SEARCHES); if (savedSearches instanceof Collection) { for (Object o : (Collection) savedSearches) { if (o instanceof AtlasObjectId) { AtlasObjectId ssObjId = (AtlasObjectId) o; AtlasEntity ssEntity = entityWithExtInfo.getReferredEntity(ssObjId.getGuid()); if (ssEntity != null && ssEntity.getStatus() == AtlasEntity.Status.ACTIVE) { AtlasUserSavedSearch savedSearch = savedSearchDTO.from(ssEntity); userProfile.getSavedSearches().add(savedSearch); } } } } return userProfile; }
public AtlasUserProfile from(AtlasEntityWithExtInfo entityWithExtInfo) { AtlasUserProfile userProfile = from(entityWithExtInfo.getEntity()); Object savedSearches = entityWithExtInfo.getEntity().getAttribute(PROPERTY_SAVED_SEARCHES); if (savedSearches instanceof Collection) { for (Object o : (Collection) savedSearches) { if (o instanceof AtlasObjectId) { AtlasObjectId ssObjId = (AtlasObjectId) o; AtlasEntity ssEntity = entityWithExtInfo.getReferredEntity(ssObjId.getGuid()); if (ssEntity != null && ssEntity.getStatus() == AtlasEntity.Status.ACTIVE) { AtlasUserSavedSearch savedSearch = savedSearchDTO.from(ssEntity); userProfile.getSavedSearches().add(savedSearch); } } } } return userProfile; }
public void updateSystemAttributes(AtlasVertex vertex, AtlasEntity entity) { if (entity.getStatus() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, STATE_PROPERTY_KEY, entity.getStatus().name()); } if (entity.getCreateTime() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, TIMESTAMP_PROPERTY_KEY, entity.getCreateTime().getTime()); } if (entity.getUpdateTime() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, MODIFICATION_TIMESTAMP_PROPERTY_KEY, entity.getUpdateTime().getTime()); } if (StringUtils.isNotEmpty(entity.getCreatedBy())) { AtlasGraphUtilsV2.setEncodedProperty(vertex, CREATED_BY_KEY, entity.getCreatedBy()); } if (StringUtils.isNotEmpty(entity.getUpdatedBy())) { AtlasGraphUtilsV2.setEncodedProperty(vertex, MODIFIED_BY_KEY, entity.getUpdatedBy()); } if (StringUtils.isNotEmpty(entity.getHomeId())) { AtlasGraphUtilsV2.setEncodedProperty(vertex, HOME_ID_KEY, entity.getHomeId()); } if (entity.isProxy() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, IS_PROXY_KEY, entity.isProxy()); } }
public void updateSystemAttributes(AtlasVertex vertex, AtlasEntity entity) { if (entity.getStatus() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, STATE_PROPERTY_KEY, entity.getStatus().name()); } if (entity.getVersion() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, VERSION_PROPERTY_KEY, entity.getVersion()); } if (entity.getCreateTime() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, TIMESTAMP_PROPERTY_KEY, entity.getCreateTime().getTime()); } if (entity.getUpdateTime() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, MODIFICATION_TIMESTAMP_PROPERTY_KEY, entity.getUpdateTime().getTime()); } if (StringUtils.isNotEmpty(entity.getCreatedBy())) { AtlasGraphUtilsV2.setEncodedProperty(vertex, CREATED_BY_KEY, entity.getCreatedBy()); } if (StringUtils.isNotEmpty(entity.getUpdatedBy())) { AtlasGraphUtilsV2.setEncodedProperty(vertex, MODIFIED_BY_KEY, entity.getUpdatedBy()); } if (StringUtils.isNotEmpty(entity.getHomeId())) { AtlasGraphUtilsV2.setEncodedProperty(vertex, HOME_ID_KEY, entity.getHomeId()); } if (entity.isProxy() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, IS_PROXY_KEY, entity.isProxy()); } if (entity.getProvenanceType() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, PROVENANCE_TYPE_KEY, entity.getProvenanceType()); } }
public AtlasEntity(AtlasEntity other) { super(other); if (other != null) { setGuid(other.getGuid()); setStatus(other.getStatus()); setCreatedBy(other.getCreatedBy()); setUpdatedBy(other.getUpdatedBy()); setCreateTime(other.getCreateTime()); setUpdateTime(other.getUpdateTime()); setVersion(other.getVersion()); setClassifications(other.getClassifications()); } }
public AtlasEntity(AtlasEntity other) { super(other); if (other != null) { setGuid(other.getGuid()); setHomeId(other.getHomeId()); setIsProxy(other.isProxy()); setStatus(other.getStatus()); setCreatedBy(other.getCreatedBy()); setUpdatedBy(other.getUpdatedBy()); setCreateTime(other.getCreateTime()); setUpdateTime(other.getUpdateTime()); setVersion(other.getVersion()); setClassifications(other.getClassifications()); } }
@Test public void testSetObjectIdAttrToNull() throws Exception { final AtlasEntity dbEntity = TestUtilsV2.createDBEntity(); final AtlasEntity db2Entity = TestUtilsV2.createDBEntity(); entityStore.createOrUpdate(new AtlasEntityStream(dbEntity), false); entityStore.createOrUpdate(new AtlasEntityStream(db2Entity), false); final AtlasEntity tableEntity = TestUtilsV2.createTableEntity(dbEntity); tableEntity.setAttribute("databaseComposite", AtlasTypeUtil.getAtlasObjectId(db2Entity)); final EntityMutationResponse tblCreationResponse = entityStore.createOrUpdate(new AtlasEntityStream(tableEntity), false); final AtlasEntityHeader createdTblHeader = tblCreationResponse.getCreatedEntityByTypeNameAndAttribute(TABLE_TYPE, NAME, (String) tableEntity.getAttribute(NAME)); final AtlasEntity createdTblEntity = getEntityFromStore(createdTblHeader); init(); createdTblEntity.setAttribute("databaseComposite", null); final EntityMutationResponse tblUpdateResponse = entityStore.createOrUpdate(new AtlasEntityStream(createdTblEntity), true); final AtlasEntityHeader updatedTblHeader = tblUpdateResponse.getFirstEntityPartialUpdated(); final AtlasEntity updatedTblEntity = getEntityFromStore(updatedTblHeader); final AtlasEntity deletedDb2Entity = getEntityFromStore(db2Entity.getGuid()); assertEquals(deletedDb2Entity.getStatus(), AtlasEntity.Status.DELETED); }
@Test public void testSetObjectIdAttrToNull() throws Exception { final AtlasEntity dbEntity = TestUtilsV2.createDBEntity(); final AtlasEntity db2Entity = TestUtilsV2.createDBEntity(); entityStore.createOrUpdate(new AtlasEntityStream(dbEntity), false); entityStore.createOrUpdate(new AtlasEntityStream(db2Entity), false); final AtlasEntity tableEntity = TestUtilsV2.createTableEntity(dbEntity); tableEntity.setAttribute("databaseComposite", AtlasTypeUtil.getAtlasObjectId(db2Entity)); final EntityMutationResponse tblCreationResponse = entityStore.createOrUpdate(new AtlasEntityStream(tableEntity), false); final AtlasEntityHeader createdTblHeader = tblCreationResponse.getCreatedEntityByTypeNameAndAttribute(TABLE_TYPE, NAME, (String) tableEntity.getAttribute(NAME)); final AtlasEntity createdTblEntity = getEntityFromStore(createdTblHeader); init(); createdTblEntity.setAttribute("databaseComposite", null); final EntityMutationResponse tblUpdateResponse = entityStore.createOrUpdate(new AtlasEntityStream(createdTblEntity), true); final AtlasEntityHeader updatedTblHeader = tblUpdateResponse.getFirstEntityPartialUpdated(); final AtlasEntity updatedTblEntity = getEntityFromStore(updatedTblHeader); final AtlasEntity deletedDb2Entity = getEntityFromStore(db2Entity.getGuid()); assertEquals(deletedDb2Entity.getStatus(), AtlasEntity.Status.DELETED); }