use of org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference in project airavata by apache.
the class UsrResourceProfileImpl method getAllUserResourceProfiles.
@Override
public List<UserResourceProfile> getAllUserResourceProfiles() throws AppCatalogException {
try {
List<UserResourceProfile> gatewayResourceProfileList = new ArrayList<UserResourceProfile>();
UserResourceProfileResource profileResource = new UserResourceProfileResource();
List<AppCatalogResource> resourceList = profileResource.getAll();
if (resourceList != null && !resourceList.isEmpty()) {
for (AppCatalogResource resource : resourceList) {
UserResourceProfileResource userProfileResource = (UserResourceProfileResource) resource;
List<UserComputeResourcePreference> computeResourcePreferences = getAllUserComputeResourcePreferences(userProfileResource.getUserId(), userProfileResource.getGatewayID());
List<UserStoragePreference> dataStoragePreferences = getAllUserStoragePreferences(userProfileResource.getUserId(), userProfileResource.getGatewayID());
UserResourceProfile gatewayResourceProfile = AppCatalogThriftConversion.getUserResourceProfile(userProfileResource, computeResourcePreferences, dataStoragePreferences);
gatewayResourceProfileList.add(gatewayResourceProfile);
}
}
return gatewayResourceProfileList;
} catch (Exception e) {
logger.error("Error while retrieving user resource profiles...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference 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);
}
}
use of org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference in project airavata by apache.
the class UsrResourceProfileImpl method addUserResourceProfile.
@Override
public String addUserResourceProfile(org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile userResourceProfile) throws AppCatalogException {
try {
UserResourceProfileResource profileResource = new UserResourceProfileResource();
if (!userResourceProfile.getUserId().equals("")) {
profileResource.setUserId(userResourceProfile.getUserId());
}
if (!userResourceProfile.getGatewayID().equals("")) {
profileResource.setGatewayID(userResourceProfile.getGatewayID());
}
if (userResourceProfile.getCredentialStoreToken() != null) {
profileResource.setCredentialStoreToken(userResourceProfile.getCredentialStoreToken());
}
if (userResourceProfile.getIdentityServerTenant() != null) {
profileResource.setIdentityServerTenant(userResourceProfile.getIdentityServerTenant());
}
if (userResourceProfile.getIdentityServerPwdCredToken() != null) {
profileResource.setIdentityServerPwdCredToken(userResourceProfile.getIdentityServerPwdCredToken());
}
profileResource.setUserId(userResourceProfile.getUserId());
profileResource.setGatewayID(userResourceProfile.getGatewayID());
profileResource.save();
List<UserComputeResourcePreference> userComputeResourcePreferences = userResourceProfile.getUserComputeResourcePreferences();
if (userComputeResourcePreferences != null && !userComputeResourcePreferences.isEmpty()) {
for (UserComputeResourcePreference preference : userComputeResourcePreferences) {
UserComputeHostPreferenceResource resource = new UserComputeHostPreferenceResource();
resource.setUserResourceProfileResource(profileResource);
resource.setResourceId(preference.getComputeResourceId());
ComputeResourceResource computeHostResource = new ComputeResourceResource();
resource.setComputeHostResource((ComputeResourceResource) computeHostResource.get(preference.getComputeResourceId()));
resource.setGatewayId(profileResource.getGatewayID());
resource.setUserId(profileResource.getUserId());
resource.setLoginUserName(preference.getLoginUserName());
resource.setResourceCSToken(preference.getResourceSpecificCredentialStoreToken());
resource.setBatchQueue(preference.getPreferredBatchQueue());
resource.setProjectNumber(preference.getAllocationProjectNumber());
resource.setScratchLocation(preference.getScratchLocation());
resource.setQualityOfService(preference.getQualityOfService());
resource.setReservation(preference.getReservation());
if (preference.getReservationStartTime() > 0) {
resource.setReservationStartTime(AiravataUtils.getTime(preference.getReservationStartTime()));
}
if (preference.getReservationEndTime() > 0) {
resource.setReservationEndTime(AiravataUtils.getTime(preference.getReservationEndTime()));
}
resource.setValidated(preference.isValidated());
resource.save();
}
}
List<UserStoragePreference> dataStoragePreferences = userResourceProfile.getUserStoragePreferences();
if (dataStoragePreferences != null && !dataStoragePreferences.isEmpty()) {
for (UserStoragePreference storagePreference : dataStoragePreferences) {
UserStoragePreferenceResource resource = new UserStoragePreferenceResource();
resource.setStorageResourceId(storagePreference.getStorageResourceId());
resource.setGatewayId(profileResource.getGatewayID());
resource.setUserId(profileResource.getUserId());
resource.setFsRootLocation(storagePreference.getFileSystemRootLocation());
resource.setLoginUserName(storagePreference.getLoginUserName());
resource.setResourceCSToken(storagePreference.getResourceSpecificCredentialStoreToken());
resource.setUserResourceProfileResource(profileResource);
resource.save();
}
}
return profileResource.getGatewayID();
} catch (Exception e) {
logger.error("Error while saving gateway profile...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference in project airavata by apache.
the class AppCatalogThriftConversion method getUserDataStoragePreference.
public static UserStoragePreference getUserDataStoragePreference(UserStoragePreferenceResource resource) {
UserStoragePreference preference = new UserStoragePreference();
preference.setStorageResourceId(resource.getStorageResourceId());
preference.setFileSystemRootLocation(resource.getFsRootLocation());
preference.setLoginUserName(resource.getLoginUserName());
preference.setResourceSpecificCredentialStoreToken(resource.getResourceCSToken());
return preference;
}
Aggregations