private final static Logger logger = LoggerFactory.getLogger(GwyResourceProfileImpl.class);
@Override
public String addGatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile gatewayProfile) throws AppCatalogException {
try {
GatewayProfileResource profileResource = new GatewayProfileResource();
profileResource.setGatewayName(gatewayProfile.getGatewayName());
profileResource.setGatewayID(AppCatalogUtils.getID(gatewayProfile.getGatewayName()));
profileResource.setGatewayDesc(gatewayProfile.getGatewayDescription());
profileResource.save();
gatewayProfile.setGatewayID(profileResource.getGatewayID());
List<ComputeResourcePreference> computeResourcePreferences = gatewayProfile.getComputeResourcePreferences();
if (computeResourcePreferences != null && !computeResourcePreferences.isEmpty()){
for (ComputeResourcePreference preference : computeResourcePreferences ){
ComputeHostPreferenceResource resource = new ComputeHostPreferenceResource();
resource.setGatewayProfile(profileResource);
resource.setResourceId(preference.getComputeResourceId());
ComputeResourceResource computeHostResource = new ComputeResourceResource();
resource.setComputeHostResource((ComputeResourceResource)computeHostResource.get(preference.getComputeResourceId()));
resource.setGatewayId(profileResource.getGatewayID());
resource.setOverrideByAiravata(preference.isOverridebyAiravata());
resource.setPreferredJobProtocol(preference.getPreferredJobSubmissionProtocol());
resource.setPreferedDMProtocol(preference.getPreferredDataMovementProtocol());
resource.setBatchQueue(preference.getPreferredBatchQueue());
resource.setProjectNumber(preference.getAllocationProjectNumber());
resource.setScratchLocation(preference.getScratchLocation());
resource.save();
}
}
return profileResource.getGatewayID();
}catch (Exception e) {
logger.error("Error while saving gateway profile...", e);
throw new AppCatalogException(e);
}
}