Search in sources :

Example 6 with AtlasUserProfile

use of org.apache.atlas.model.profile.AtlasUserProfile in project atlas by apache.

the class AtlasUserProfileDTO method from.

public AtlasUserProfile from(AtlasEntity entity) {
    AtlasUserProfile profile = new AtlasUserProfile();
    profile.setGuid(entity.getGuid());
    profile.setName((String) entity.getAttribute(PROPERTY_USER_NAME));
    profile.setFullName((String) entity.getAttribute(PROPERTY_FULL_NAME));
    return profile;
}
Also used : AtlasUserProfile(org.apache.atlas.model.profile.AtlasUserProfile)

Example 7 with AtlasUserProfile

use of org.apache.atlas.model.profile.AtlasUserProfile in project atlas by apache.

the class AtlasUserProfileDTO method from.

public AtlasUserProfile from(AtlasEntity entity) {
    AtlasUserProfile profile = new AtlasUserProfile();
    profile.setGuid(entity.getGuid());
    profile.setName((String) entity.getAttribute(PROPERTY_USER_NAME));
    profile.setFullName((String) entity.getAttribute(PROPERTY_FULL_NAME));
    return profile;
}
Also used : AtlasUserProfile(org.apache.atlas.model.profile.AtlasUserProfile)

Example 8 with AtlasUserProfile

use of org.apache.atlas.model.profile.AtlasUserProfile in project atlas by apache.

the class AtlasUserProfileDTO method from.

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;
}
Also used : AtlasUserProfile(org.apache.atlas.model.profile.AtlasUserProfile) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasUserSavedSearch(org.apache.atlas.model.profile.AtlasUserSavedSearch) AbstractDataTransferObject(org.apache.atlas.repository.ogm.AbstractDataTransferObject) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 9 with AtlasUserProfile

use of org.apache.atlas.model.profile.AtlasUserProfile in project atlas by apache.

the class UserProfileService method deleteUserProfile.

public void deleteUserProfile(String userName) throws AtlasBaseException {
    AtlasUserProfile profile = getUserProfile(userName);
    dataAccess.delete(profile.getGuid());
}
Also used : AtlasUserProfile(org.apache.atlas.model.profile.AtlasUserProfile)

Example 10 with AtlasUserProfile

use of org.apache.atlas.model.profile.AtlasUserProfile in project atlas by apache.

the class UserProfileServiceTest method createsNewProfile.

@Test(dependsOnMethods = "filterInternalType")
public void createsNewProfile() throws AtlasBaseException {
    for (int i = 0; i < NUM_USERS; i++) {
        AtlasUserProfile expected = getAtlasUserProfile(i);
        AtlasUserProfile actual = userProfileService.saveUserProfile(expected);
        assertNotNull(actual);
        assertEquals(expected.getName(), actual.getName());
        assertEquals(expected.getFullName(), actual.getFullName());
        assertNotNull(actual.getGuid());
    }
}
Also used : AtlasUserProfile(org.apache.atlas.model.profile.AtlasUserProfile) Test(org.testng.annotations.Test)

Aggregations

AtlasUserProfile (org.apache.atlas.model.profile.AtlasUserProfile)10 AtlasUserSavedSearch (org.apache.atlas.model.profile.AtlasUserSavedSearch)5 Test (org.testng.annotations.Test)3 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)2 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)2 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)2 AbstractDataTransferObject (org.apache.atlas.repository.ogm.AbstractDataTransferObject)1