Search in sources :

Example 11 with CompositeIdentifier

use of org.apache.airavata.registry.cpi.CompositeIdentifier in project airavata by apache.

the class UsrResourceProfileImpl method getUserStoragePreference.

@Override
public UserStoragePreference getUserStoragePreference(String userId, String gatewayId, String storageId) throws AppCatalogException {
    try {
        UserStoragePreferenceResource prefResource = new UserStoragePreferenceResource();
        CompositeIdentifier ids = new CompositeIdentifier(userId, gatewayId);
        List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.UserComputeResourcePreferenceConstants.USER_ID, ids);
        for (AppCatalogResource resource : computePrefList) {
            UserStoragePreferenceResource dsP = (UserStoragePreferenceResource) resource;
            if (dsP.getStorageResourceId() != null && !dsP.getStorageResourceId().equals("")) {
                if (dsP.getStorageResourceId().equals(storageId)) {
                    return AppCatalogThriftConversion.getUserDataStoragePreference(dsP);
                }
            }
        }
    } catch (Exception e) {
        logger.error("Error while retrieving user data storage preference...", e);
        throw new AppCatalogException(e);
    }
    return null;
}
Also used : AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) CompositeIdentifier(org.apache.airavata.registry.cpi.CompositeIdentifier) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 12 with CompositeIdentifier

use of org.apache.airavata.registry.cpi.CompositeIdentifier in project airavata by apache.

the class UsrResourceProfileImpl method getAllUserComputeResourcePreferences.

/**
 * @param userId
 * @return
 */
@Override
public List<UserComputeResourcePreference> getAllUserComputeResourcePreferences(String userId, String gatewayID) throws AppCatalogException {
    try {
        UserComputeHostPreferenceResource prefResource = new UserComputeHostPreferenceResource();
        CompositeIdentifier ids = new CompositeIdentifier(userId, gatewayID);
        List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.UserComputeResourcePreferenceConstants.USER_ID, ids);
        return AppCatalogThriftConversion.getUserComputeResourcePreferences(computePrefList);
    } catch (Exception e) {
        logger.error("Error while retrieving compute resource preference...", e);
        throw new AppCatalogException(e);
    }
}
Also used : AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) CompositeIdentifier(org.apache.airavata.registry.cpi.CompositeIdentifier) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 13 with CompositeIdentifier

use of org.apache.airavata.registry.cpi.CompositeIdentifier in project airavata by apache.

the class UsrResourceProfileImpl method isUserResourceProfileExists.

@Override
public boolean isUserResourceProfileExists(String userId, String gatewayId) throws AppCatalogException {
    try {
        UserResourceProfileResource resource = new UserResourceProfileResource();
        CompositeIdentifier ids = new CompositeIdentifier(userId, gatewayId);
        return resource.isExists(ids);
    } catch (Exception e) {
        logger.error("Error while retrieving user resource profile...", e);
        throw new AppCatalogException(e);
    }
}
Also used : AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) CompositeIdentifier(org.apache.airavata.registry.cpi.CompositeIdentifier) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 14 with CompositeIdentifier

use of org.apache.airavata.registry.cpi.CompositeIdentifier in project airavata by apache.

the class UsrResourceProfileImpl method getAllUserStoragePreferences.

@Override
public List<UserStoragePreference> getAllUserStoragePreferences(String userId, String gatewayID) throws AppCatalogException {
    try {
        UserStoragePreferenceResource prefResource = new UserStoragePreferenceResource();
        CompositeIdentifier ids = new CompositeIdentifier(userId, gatewayID);
        List<AppCatalogResource> dataStoragePrefList = prefResource.get(AppCatAbstractResource.UserStoragePreferenceConstants.USER_ID, ids);
        return AppCatalogThriftConversion.getUserDataStoragePreferences(dataStoragePrefList);
    } catch (Exception e) {
        logger.error("Error while retrieving data storage preference...", e);
        throw new AppCatalogException(e);
    }
}
Also used : AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) CompositeIdentifier(org.apache.airavata.registry.cpi.CompositeIdentifier) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 15 with CompositeIdentifier

use of org.apache.airavata.registry.cpi.CompositeIdentifier in project airavata by apache.

the class UsrResourceProfileImpl method getUserResourceProfile.

@Override
public UserResourceProfile getUserResourceProfile(String userId, String gatewayId) throws AppCatalogException {
    try {
        UserResourceProfileResource resource = new UserResourceProfileResource();
        CompositeIdentifier ids = new CompositeIdentifier(userId, gatewayId);
        UserResourceProfileResource uResource = (UserResourceProfileResource) resource.get(ids);
        UserComputeHostPreferenceResource prefResource = new UserComputeHostPreferenceResource();
        List<AppCatalogResource> usercomputePrefList = prefResource.get(AppCatAbstractResource.UserComputeResourcePreferenceConstants.USER_ID, ids);
        List<UserComputeResourcePreference> userComputeResourcePreferences = AppCatalogThriftConversion.getUserComputeResourcePreferences(usercomputePrefList);
        List<UserStoragePreference> dataStoragePreferences = getAllUserStoragePreferences(userId, gatewayId);
        if (uResource != null) {
            return AppCatalogThriftConversion.getUserResourceProfile(uResource, userComputeResourcePreferences, dataStoragePreferences);
        } else {
            return AppCatalogThriftConversion.createNullUserResourceProfile(userId, gatewayId);
        }
    } catch (Exception e) {
        logger.error("Error while retrieving user resource profile...", e);
        throw new AppCatalogException(e);
    }
}
Also used : AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) CompositeIdentifier(org.apache.airavata.registry.cpi.CompositeIdentifier) UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) UserStoragePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Aggregations

AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)22 CompositeIdentifier (org.apache.airavata.registry.cpi.CompositeIdentifier)22 EntityManager (javax.persistence.EntityManager)12 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)12 Query (javax.persistence.Query)10 AppCatalogQueryGenerator (org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)10 ArrayList (java.util.ArrayList)4 List (java.util.List)4 UserStoragePreference (org.apache.airavata.registry.core.app.catalog.model.UserStoragePreference)3 UserComputeResourcePreference (org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference)2 UserStoragePreference (org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference)2 UserResourceProfile (org.apache.airavata.registry.core.app.catalog.model.UserResourceProfile)2 UserStoragePreferencePK (org.apache.airavata.registry.core.app.catalog.model.UserStoragePreferencePK)1