Repository: airavata Updated Branches: refs/heads/develop c116140c8 -> 13b50f7a5
http://git-wip-us.apache.org/repos/asf/airavata/blob/13b50f7a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/StorageResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/StorageResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/StorageResource.java index 51f0ec9..67469a2 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/StorageResource.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/StorageResource.java @@ -31,13 +31,10 @@ import java.sql.Timestamp; @Entity @Table(name = "STORAGE_RESOURCE") public class StorageResource implements Serializable { - - @Column(name = "RESOURCE_DESCRIPTION") - private String resourceDescription; - - @Id - @Column(name = "RESOURCE_ID") - private String resourceId; + + @Id + @Column(name = "STORAGE_RESOURCE_ID") + private String storageResourceId; @Column(name = "HOST_NAME") private String hostName; @@ -51,6 +48,9 @@ public class StorageResource implements Serializable { @Column(name = "ENABLED") private boolean enabled; + @Column(name = "DESCRIPTION") + private String description; + public Timestamp getCreationTime() { return creationTime; } @@ -67,15 +67,31 @@ public class StorageResource implements Serializable { this.updateTime = updateTime; } - public String getResourceDescription() { - return resourceDescription; - } - - public String getResourceId() { - return resourceId; - } - - public String getHostName() { + public String getStorageResourceId() { + return storageResourceId; + } + + public void setStorageResourceId(String storageResourceId) { + this.storageResourceId = storageResourceId; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getHostName() { return hostName; } @@ -87,14 +103,6 @@ public class StorageResource implements Serializable { this.enabled = enabled; } - public void setResourceDescription(String resourceDescription) { - this.resourceDescription=resourceDescription; - } - - public void setResourceId(String resourceId) { - this.resourceId=resourceId; - } - public void setHostName(String hostName) { this.hostName=hostName; } http://git-wip-us.apache.org/repos/asf/airavata/blob/13b50f7a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java index 926bfae..3402afd 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java @@ -25,6 +25,7 @@ public abstract class AppCatAbstractResource implements AppCatalogResource { // table names public static final String COMPUTE_RESOURCE = "ComputeResource"; public static final String STORAGE_RESOURCE = "StorageResource"; + public static final String STORAGE_INTERFACE = "StorageInterface"; public static final String HOST_ALIAS = "HostAlias"; public static final String HOST_IPADDRESS = "HostIPAddress"; public static final String GSISSH_SUBMISSION = "GSISSHSubmission"; @@ -54,7 +55,7 @@ public abstract class AppCatAbstractResource implements AppCatalogResource { public static final String WORKFLOW_OUTPUT = "WorkflowOutput"; public static final String GATEWAY_PROFILE = "GatewayProfile"; public static final String COMPUTE_RESOURCE_PREFERENCE = "ComputeResourcePreference"; - public static final String DATA_STORAGE_PREFERENCE = "DataStoragePreference"; + public static final String STORAGE_PREFERENCE = "StoragePreference"; public static final String BATCH_QUEUE = "BatchQueue"; public static final String COMPUTE_RESOURCE_FILE_SYSTEM = "ComputeResourceFileSystem"; public static final String JOB_SUBMISSION_INTERFACE = "JobSubmissionInterface"; @@ -80,12 +81,7 @@ public abstract class AppCatAbstractResource implements AppCatalogResource { public static final String HOST_NAME = "hostName"; } - // Storage Resource Table - public final class StorageResourceConstants { - public static final String RESOURCE_DESCRIPTION = "resourceDescription"; - public static final String RESOURCE_ID = "resourceId"; - public static final String HOST_NAME = "hostName"; - } + // Host Alias Table public final class HostAliasConstants { @@ -293,11 +289,6 @@ public abstract class AppCatAbstractResource implements AppCatalogResource { public static final String ALLOCATION_PROJECT_NUMBER = "projectNumber"; } - public final class DataStoragePreferenceConstants { - public static final String GATEWAY_ID = "gatewayId"; - public static final String DATA_MOVEMENT_ID = "dataMovementId"; - } - // Batch Queue Table public final class BatchQueueConstants { public static final String COMPUTE_RESOURCE_ID = "computeResourceId"; @@ -331,6 +322,24 @@ public abstract class AppCatAbstractResource implements AppCatalogResource { public static final String DATA_MOVEMENT_INTERFACE_ID = "dataMovementInterfaceId"; public static final String PRIORITY_ORDER = "priorityOrder"; } + + // Storage Resource Table + public final class StorageResourceConstants { + public static final String RESOURCE_DESCRIPTION = "resourceDescription"; + public static final String RESOURCE_ID = "resourceId"; + public static final String HOST_NAME = "hostName"; + } + + public final class StoragePreferenceConstants { + public static final String GATEWAY_ID = "gatewayId"; + public static final String STORAGE_ID = "storageResourceId"; + } + + public final class StorageInterfaceConstants { + public static final String STORAGE_RESOURCE_ID = "storageResourceId"; + public static final String DATA_MOVEMENT_PROTOCOL = "dataMovementProtocol"; + public static final String DATA_MOVEMENT_ID = "dataMovementInterfaceId"; + } // Resource Job Manager Table public final class ResourceJobManagerConstants { http://git-wip-us.apache.org/repos/asf/airavata/blob/13b50f7a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataStoragePreferenceResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataStoragePreferenceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataStoragePreferenceResource.java deleted file mode 100644 index 482589d..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataStoragePreferenceResource.java +++ /dev/null @@ -1,323 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.registry.core.app.catalog.resources; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.registry.core.app.catalog.model.*; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType; -import org.apache.airavata.registry.cpi.AppCatalogException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.EntityManager; -import javax.persistence.Query; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class DataStoragePreferenceResource extends AppCatAbstractResource { - private final static Logger logger = LoggerFactory.getLogger(DataStoragePreferenceResource.class); - private String gatewayId; - private String dataMoveId; - private String loginUserName; - private String fsRootLocation; - private String resourceCSToken; - - private GatewayProfileResource gatewayProfile; - - public String getLoginUserName() { - return loginUserName; - } - - public void setLoginUserName(String loginUserName) { - this.loginUserName = loginUserName; - } - - public String getGatewayId() { - return gatewayId; - } - - public void setGatewayId(String gatewayId) { - this.gatewayId = gatewayId; - } - - public GatewayProfileResource getGatewayProfile() { - return gatewayProfile; - } - - public void setGatewayProfile(GatewayProfileResource gatewayProfile) { - this.gatewayProfile = gatewayProfile; - } - - public String getResourceCSToken() { - return resourceCSToken; - } - - public void setResourceCSToken(String resourceCSToken) { - this.resourceCSToken = resourceCSToken; - } - - public String getDataMoveId() { - return dataMoveId; - } - - public void setDataMoveId(String dataMoveId) { - this.dataMoveId = dataMoveId; - } - - public String getFsRootLocation() { - return fsRootLocation; - } - - public void setFsRootLocation(String fsRootLocation) { - this.fsRootLocation = fsRootLocation; - } - - @Override - public void remove(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map) { - ids = (HashMap) identifier; - } else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(DATA_STORAGE_PREFERENCE); - generator.setParameter(DataStoragePreferenceConstants.DATA_MOVEMENT_ID, ids.get(DataStoragePreferenceConstants.DATA_MOVEMENT_ID)); - generator.setParameter(DataStoragePreferenceConstants.GATEWAY_ID, ids.get(DataStoragePreferenceConstants.GATEWAY_ID)); - - Query q = generator.deleteQuery(em); - q.executeUpdate(); - em.getTransaction().commit(); - em.close(); - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public AppCatalogResource get(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map) { - ids = (HashMap) identifier; - } else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(DATA_STORAGE_PREFERENCE); - generator.setParameter(DataStoragePreferenceConstants.GATEWAY_ID, ids.get(DataStoragePreferenceConstants.GATEWAY_ID)); - generator.setParameter(DataStoragePreferenceConstants.DATA_MOVEMENT_ID, ids.get(DataStoragePreferenceConstants.DATA_MOVEMENT_ID)); - Query q = generator.selectQuery(em); - DataStoragePreference preference = (DataStoragePreference) q.getSingleResult(); - DataStoragePreferenceResource preferenceResource = - (DataStoragePreferenceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.DATA_STORAGE_PREFERENCE, preference); - em.getTransaction().commit(); - em.close(); - return preferenceResource; - } catch (ApplicationSettingsException e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException { - List<AppCatalogResource> preferenceResourceList = new ArrayList<AppCatalogResource>(); - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - Query q; - AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(DATA_STORAGE_PREFERENCE); - List results; - if (fieldName.equals(DataStoragePreferenceConstants.DATA_MOVEMENT_ID)) { - generator.setParameter(DataStoragePreferenceConstants.DATA_MOVEMENT_ID, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - DataStoragePreference preference = (DataStoragePreference) result; - if (preference.getDataMovementID()!=null) { - DataStoragePreferenceResource preferenceResource = (DataStoragePreferenceResource) AppCatalogJPAUtils - .getResource( - AppCatalogResourceType.DATA_STORAGE_PREFERENCE, - preference); - preferenceResourceList.add(preferenceResource); - } - } - } - } else if (fieldName.equals(DataStoragePreferenceConstants.GATEWAY_ID)) { - generator.setParameter(DataStoragePreferenceConstants.GATEWAY_ID, value); - q = generator.selectQuery(em); - results = q.getResultList(); - if (results.size() != 0) { - for (Object result : results) { - DataStoragePreference preference = (DataStoragePreference) result; - if (preference.getDataMovementID()!=null) { - DataStoragePreferenceResource preferenceResource = - (DataStoragePreferenceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.DATA_STORAGE_PREFERENCE, preference); - preferenceResourceList.add(preferenceResource); - } - } - } - } else { - em.getTransaction().commit(); - em.close(); - logger.error("Unsupported field name for data storage preference Resource.", new IllegalArgumentException()); - throw new IllegalArgumentException("Unsupported field name for data storage preference Resource."); - } - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return preferenceResourceList; - } - - @Override - public List<AppCatalogResource> getAll() throws AppCatalogException { - return null; - } - - @Override - public List<String> getAllIds() throws AppCatalogException { - return null; - } - - @Override - public List<String> getIds(String fieldName, Object value) throws AppCatalogException { - logger.error("Unsupported for objects with a composite identifier"); - throw new AppCatalogException("Unsupported for objects with a composite identifier"); - } - - @Override - public void save() throws AppCatalogException { - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - DataStoragePreference existingPreference = em.find(DataStoragePreference.class, new DataStoragePreferencePK(gatewayId, dataMoveId)); - em.close(); - - em = AppCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - DataMovementInterface dataMovementInterface = em.find(DataMovementInterface.class, dataMoveId); - GatewayProfile gatewayProf = em.find(GatewayProfile.class, gatewayId); - if (existingPreference != null) { - existingPreference.setDataMovementID(dataMoveId); - existingPreference.setGatewayId(gatewayId); - existingPreference.setGatewayProfile(gatewayProf); - existingPreference.setLoginUserName(loginUserName); - existingPreference.setComputeResourceCSToken(resourceCSToken); - existingPreference.setFsRootLocation(fsRootLocation); - em.merge(existingPreference); - } else { - DataStoragePreference resourcePreference = new DataStoragePreference(); - resourcePreference.setDataMovementID(dataMoveId); - resourcePreference.setGatewayId(gatewayId); - resourcePreference.setGatewayProfile(gatewayProf); - resourcePreference.setLoginUserName(loginUserName); - resourcePreference.setComputeResourceCSToken(resourceCSToken); - resourcePreference.setFsRootLocation(fsRootLocation); - em.persist(resourcePreference); - } - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public boolean isExists(Object identifier) throws AppCatalogException { - HashMap<String, String> ids; - if (identifier instanceof Map) { - ids = (HashMap) identifier; - } else { - logger.error("Identifier should be a map with the field name and it's value"); - throw new AppCatalogException("Identifier should be a map with the field name and it's value"); - } - - EntityManager em = null; - try { - em = AppCatalogJPAUtils.getEntityManager(); - DataStoragePreference existingPreference = em.find(DataStoragePreference.class, - new DataStoragePreferencePK(ids.get(DataStoragePreferenceConstants.GATEWAY_ID), - ids.get(DataStoragePreferenceConstants.DATA_MOVEMENT_ID))); - em.close(); - return existingPreference != null; - }catch (Exception e) { - logger.error(e.getMessage(), e); - throw new AppCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13b50f7a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageInterfaceResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageInterfaceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageInterfaceResource.java new file mode 100644 index 0000000..20ece9e --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageInterfaceResource.java @@ -0,0 +1,326 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.airavata.registry.core.app.catalog.resources; + +import org.apache.airavata.common.exception.ApplicationSettingsException; +import org.apache.airavata.common.utils.AiravataUtils; +import org.apache.airavata.registry.core.app.catalog.model.*; +import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils; +import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator; +import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType; +import org.apache.airavata.registry.cpi.AppCatalogException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.EntityManager; +import javax.persistence.Query; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class StorageInterfaceResource extends AppCatAbstractResource { + private final static Logger logger = LoggerFactory.getLogger(StorageInterfaceResource.class); + private String storageResourceId; + private StorageResourceResource storageResourceResource; + private String dataMovementProtocol; + private String dataMovementInterfaceId; + private Timestamp createdTime; + private Timestamp updatedTime; + + public Timestamp getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(Timestamp createdTime) { + this.createdTime = createdTime; + } + + public Timestamp getUpdatedTime() { + return updatedTime; + } + + public void setUpdatedTime(Timestamp updatedTime) { + this.updatedTime = updatedTime; + } + + @Override + public void remove(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map) { + ids = (HashMap<String, String>) identifier; + } else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(DATA_MOVEMENT_INTERFACE); + generator.setParameter(StorageInterfaceConstants.STORAGE_RESOURCE_ID, ids.get(StorageInterfaceConstants.STORAGE_RESOURCE_ID)); + generator.setParameter(StorageInterfaceConstants.DATA_MOVEMENT_ID, ids.get(StorageInterfaceConstants.DATA_MOVEMENT_ID)); + Query q = generator.deleteQuery(em); + q.executeUpdate(); + em.getTransaction().commit(); + em.close(); + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public AppCatalogResource get(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map) { + ids = (HashMap<String, String>) identifier; + } else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(DATA_MOVEMENT_INTERFACE); + generator.setParameter(StorageInterfaceConstants.STORAGE_RESOURCE_ID, ids.get(StorageInterfaceConstants.STORAGE_RESOURCE_ID)); + generator.setParameter(StorageInterfaceConstants.DATA_MOVEMENT_ID, ids.get(StorageInterfaceConstants.DATA_MOVEMENT_ID)); + Query q = generator.selectQuery(em); + StorageInterface storageInterface = (StorageInterface) q.getSingleResult(); + StorageInterfaceResource storageInterfaceResource = (StorageInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.STORAGE_INTERFACE, storageInterface); + em.getTransaction().commit(); + em.close(); + return storageInterfaceResource; + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException { + List<AppCatalogResource> storageInterfaceResources = new ArrayList<AppCatalogResource>(); + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(STORAGE_INTERFACE); + Query q; + if ((fieldName.equals(StorageInterfaceConstants.STORAGE_RESOURCE_ID)) || (fieldName.equals(StorageInterfaceConstants.DATA_MOVEMENT_PROTOCOL)) || (fieldName.equals(StorageInterfaceConstants.DATA_MOVEMENT_ID))) { + generator.setParameter(fieldName, value); + q = generator.selectQuery(em); + List<?> results = q.getResultList(); + for (Object result : results) { + StorageInterface storageInterface = (StorageInterface) result; + StorageInterfaceResource storageInterfaceResource = (StorageInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.STORAGE_INTERFACE, storageInterface); + storageInterfaceResources.add(storageInterfaceResource); + } + } else { + em.getTransaction().commit(); + em.close(); + logger.error("Unsupported field name for Data Movement Interface Resource.", new IllegalArgumentException()); + throw new IllegalArgumentException("Unsupported field name for Data Movement Interface Resource."); + } + em.getTransaction().commit(); + em.close(); + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return storageInterfaceResources; + } + + @Override + public List<AppCatalogResource> getAll() throws AppCatalogException { + return null; + } + + @Override + public List<String> getAllIds() throws AppCatalogException { + return null; + } + + @Override + public List<String> getIds(String fieldName, Object value) throws AppCatalogException { + List<String> storageInterfaceResourceIDs = new ArrayList<String>(); + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(STORAGE_INTERFACE); + Query q; + if ((fieldName.equals(StorageInterfaceConstants.STORAGE_RESOURCE_ID)) || (fieldName.equals(StorageInterfaceConstants.DATA_MOVEMENT_PROTOCOL)) || (fieldName.equals(StorageInterfaceConstants.DATA_MOVEMENT_ID))) { + generator.setParameter(fieldName, value); + q = generator.selectQuery(em); + List<?> results = q.getResultList(); + for (Object result : results) { + StorageInterface storageInterface = (StorageInterface) result; + StorageInterfaceResource storageInterfaceResource = (StorageInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.STORAGE_INTERFACE, storageInterface); + storageInterfaceResourceIDs.add(storageInterfaceResource.getStorageResourceId()); + } + } else { + em.getTransaction().commit(); + em.close(); + logger.error("Unsupported field name for Storage Interface Resource.", new IllegalArgumentException()); + throw new IllegalArgumentException("Unsupported field name for Storage Interface Resource."); + } + em.getTransaction().commit(); + em.close(); + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return storageInterfaceResourceIDs; + } + + @Override + public void save() throws AppCatalogException { + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + StorageInterface existingStorageInterface = em.find(StorageInterface.class, new StorageInterface_PK(storageResourceId, dataMovementInterfaceId)); + em.close(); + StorageInterface storageInterface; + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + if (existingStorageInterface == null) { + storageInterface = new StorageInterface(); + storageInterface.setCreationTime(AiravataUtils.getCurrentTimestamp()); + } else { + storageInterface = existingStorageInterface; + storageInterface.setUpdateTime(AiravataUtils.getCurrentTimestamp()); + } + storageInterface.setStorageResourceId(getStorageResourceId()); + StorageResource storageResource = em.find(StorageResource.class, getStorageResourceId()); + storageInterface.setStorageResource(storageResource); + storageInterface.setDataMovementProtocol(getDataMovementProtocol()); + storageInterface.setDataMovementInterfaceId(getDataMovementInterfaceId()); + if (existingStorageInterface == null) { + em.persist(storageInterface); + } else { + em.merge(storageInterface); + } + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public boolean isExists(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map) { + ids = (HashMap<String, String>) identifier; + } else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + StorageInterface storageInterface = em.find(StorageInterface.class, new StorageInterface_PK(ids.get(StorageInterfaceConstants.STORAGE_RESOURCE_ID), ids.get(StorageInterfaceConstants.DATA_MOVEMENT_ID))); + em.close(); + return storageInterface != null; + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + public String getDataMovementProtocol() { + return dataMovementProtocol; + } + + public String getDataMovementInterfaceId() { + return dataMovementInterfaceId; + } + + public void setDataMovementProtocol(String dataMovementProtocol) { + this.dataMovementProtocol=dataMovementProtocol; + } + + public void setDataMovementInterfaceId(String dataMovementInterfaceId) { + this.dataMovementInterfaceId=dataMovementInterfaceId; + } + + public String getStorageResourceId() { + return storageResourceId; + } + + public void setStorageResourceId(String storageResourceId) { + this.storageResourceId = storageResourceId; + } + + public StorageResourceResource getStorageResourceResource() { + return storageResourceResource; + } + + public void setStorageResourceResource(StorageResourceResource storageResourceResource) { + this.storageResourceResource = storageResourceResource; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/13b50f7a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StoragePreferenceResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StoragePreferenceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StoragePreferenceResource.java new file mode 100644 index 0000000..ae32eca --- /dev/null +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StoragePreferenceResource.java @@ -0,0 +1,322 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.airavata.registry.core.app.catalog.resources; + +import org.apache.airavata.common.exception.ApplicationSettingsException; +import org.apache.airavata.registry.core.app.catalog.model.*; +import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils; +import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator; +import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType; +import org.apache.airavata.registry.cpi.AppCatalogException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.EntityManager; +import javax.persistence.Query; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class StoragePreferenceResource extends AppCatAbstractResource { + private final static Logger logger = LoggerFactory.getLogger(StoragePreferenceResource.class); + private String gatewayId; + private String storageResourceId; + private String loginUserName; + private String fsRootLocation; + private String resourceCSToken; + + private GatewayProfileResource gatewayProfile; + + public String getLoginUserName() { + return loginUserName; + } + + public void setLoginUserName(String loginUserName) { + this.loginUserName = loginUserName; + } + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + public GatewayProfileResource getGatewayProfile() { + return gatewayProfile; + } + + public void setGatewayProfile(GatewayProfileResource gatewayProfile) { + this.gatewayProfile = gatewayProfile; + } + + public String getResourceCSToken() { + return resourceCSToken; + } + + public void setResourceCSToken(String resourceCSToken) { + this.resourceCSToken = resourceCSToken; + } + + public String getFsRootLocation() { + return fsRootLocation; + } + + public void setFsRootLocation(String fsRootLocation) { + this.fsRootLocation = fsRootLocation; + } + + public String getStorageResourceId() { + return storageResourceId; + } + + public void setStorageResourceId(String storageResourceId) { + this.storageResourceId = storageResourceId; + } + + @Override + public void remove(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map) { + ids = (HashMap) identifier; + } else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(STORAGE_PREFERENCE); + generator.setParameter(StoragePreferenceConstants.STORAGE_ID, ids.get(StoragePreferenceConstants.STORAGE_ID)); + generator.setParameter(StoragePreferenceConstants.GATEWAY_ID, ids.get(StoragePreferenceConstants.GATEWAY_ID)); + + Query q = generator.deleteQuery(em); + q.executeUpdate(); + em.getTransaction().commit(); + em.close(); + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public AppCatalogResource get(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map) { + ids = (HashMap) identifier; + } else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(STORAGE_PREFERENCE); + generator.setParameter(StoragePreferenceConstants.GATEWAY_ID, ids.get(StoragePreferenceConstants.GATEWAY_ID)); + generator.setParameter(StoragePreferenceConstants.STORAGE_ID, ids.get(StoragePreferenceConstants.STORAGE_ID)); + Query q = generator.selectQuery(em); + StoragePreference preference = (StoragePreference) q.getSingleResult(); + StoragePreferenceResource preferenceResource = + (StoragePreferenceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.STORAGE_PREFERENCE, preference); + em.getTransaction().commit(); + em.close(); + return preferenceResource; + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException { + List<AppCatalogResource> preferenceResourceList = new ArrayList<AppCatalogResource>(); + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + Query q; + AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(STORAGE_PREFERENCE); + List results; + if (fieldName.equals(StoragePreferenceConstants.STORAGE_ID)) { + generator.setParameter(StoragePreferenceConstants.STORAGE_ID, value); + q = generator.selectQuery(em); + results = q.getResultList(); + if (results.size() != 0) { + for (Object result : results) { + StoragePreference preference = (StoragePreference) result; + if (preference.getStorageResourceId()!=null) { + StoragePreferenceResource preferenceResource = (StoragePreferenceResource) AppCatalogJPAUtils + .getResource( + AppCatalogResourceType.STORAGE_PREFERENCE, + preference); + preferenceResourceList.add(preferenceResource); + } + } + } + } else if (fieldName.equals(StoragePreferenceConstants.GATEWAY_ID)) { + generator.setParameter(StoragePreferenceConstants.GATEWAY_ID, value); + q = generator.selectQuery(em); + results = q.getResultList(); + if (results.size() != 0) { + for (Object result : results) { + StoragePreference preference = (StoragePreference) result; + if (preference.getStorageResourceId()!=null) { + StoragePreferenceResource preferenceResource = + (StoragePreferenceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.STORAGE_PREFERENCE, preference); + preferenceResourceList.add(preferenceResource); + } + } + } + } else { + em.getTransaction().commit(); + em.close(); + logger.error("Unsupported field name for data storage preference Resource.", new IllegalArgumentException()); + throw new IllegalArgumentException("Unsupported field name for data storage preference Resource."); + } + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + return preferenceResourceList; + } + + @Override + public List<AppCatalogResource> getAll() throws AppCatalogException { + return null; + } + + @Override + public List<String> getAllIds() throws AppCatalogException { + return null; + } + + @Override + public List<String> getIds(String fieldName, Object value) throws AppCatalogException { + logger.error("Unsupported for objects with a composite identifier"); + throw new AppCatalogException("Unsupported for objects with a composite identifier"); + } + + @Override + public void save() throws AppCatalogException { + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + StoragePreference existingPreference = em.find(StoragePreference.class, new StoragePreferencePK(gatewayId, storageResourceId)); + em.close(); + + em = AppCatalogJPAUtils.getEntityManager(); + em.getTransaction().begin(); + GatewayProfile gatewayProf = em.find(GatewayProfile.class, gatewayId); + if (existingPreference != null) { + existingPreference.setStorageResourceId(storageResourceId); + existingPreference.setGatewayId(gatewayId); + existingPreference.setGatewayProfile(gatewayProf); + existingPreference.setLoginUserName(loginUserName); + existingPreference.setComputeResourceCSToken(resourceCSToken); + existingPreference.setFsRootLocation(fsRootLocation); + em.merge(existingPreference); + } else { + StoragePreference resourcePreference = new StoragePreference(); + resourcePreference.setStorageResourceId(storageResourceId); + resourcePreference.setGatewayId(gatewayId); + resourcePreference.setGatewayProfile(gatewayProf); + resourcePreference.setLoginUserName(loginUserName); + resourcePreference.setComputeResourceCSToken(resourceCSToken); + resourcePreference.setFsRootLocation(fsRootLocation); + em.persist(resourcePreference); + } + em.getTransaction().commit(); + em.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } + + @Override + public boolean isExists(Object identifier) throws AppCatalogException { + HashMap<String, String> ids; + if (identifier instanceof Map) { + ids = (HashMap) identifier; + } else { + logger.error("Identifier should be a map with the field name and it's value"); + throw new AppCatalogException("Identifier should be a map with the field name and it's value"); + } + + EntityManager em = null; + try { + em = AppCatalogJPAUtils.getEntityManager(); + StoragePreference existingPreference = em.find(StoragePreference.class, + new StoragePreferencePK(ids.get(StoragePreferenceConstants.GATEWAY_ID), + ids.get(StoragePreferenceConstants.STORAGE_ID))); + em.close(); + return existingPreference != null; + }catch (Exception e) { + logger.error(e.getMessage(), e); + throw new AppCatalogException(e); + } finally { + if (em != null && em.isOpen()) { + if (em.getTransaction().isActive()) { + em.getTransaction().rollback(); + } + em.close(); + } + } + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/13b50f7a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageResourceResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageResourceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageResourceResource.java index 868c5ab..1d7039a 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageResourceResource.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageResourceResource.java @@ -40,7 +40,7 @@ import java.util.List; public class StorageResourceResource extends AppCatAbstractResource { private final static Logger logger = LoggerFactory.getLogger(StorageResourceResource.class); private String resourceDescription; - private String resourceId; + private String storageResourceId; private String hostName; private Timestamp createdTime; private Timestamp updatedTime; @@ -204,7 +204,7 @@ public class StorageResourceResource extends AppCatAbstractResource { List<?> results = q.getResultList(); for (Object result : results) { StorageResource storageResource = (StorageResource) result; - storageResourceResources.add(storageResource.getResourceId()); + storageResourceResources.add(storageResource.getStorageResourceId()); } em.getTransaction().commit(); em.close(); @@ -238,7 +238,7 @@ public class StorageResourceResource extends AppCatAbstractResource { for (Object result : results) { StorageResource storageResource = (StorageResource) result; StorageResourceResource storageResourceResource = (StorageResourceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.STORAGE_RESOURCE, storageResource); - storageResourceResourceIDs.add(storageResourceResource.getResourceId()); + storageResourceResourceIDs.add(storageResourceResource.getStorageResourceId()); } } else { em.getTransaction().commit(); @@ -267,7 +267,7 @@ public class StorageResourceResource extends AppCatAbstractResource { EntityManager em = null; try { em = AppCatalogJPAUtils.getEntityManager(); - StorageResource existingStorageResource = em.find(StorageResource.class, resourceId); + StorageResource existingStorageResource = em.find(StorageResource.class, storageResourceId); em.close(); StorageResource storageResource; em = AppCatalogJPAUtils.getEntityManager(); @@ -279,8 +279,8 @@ public class StorageResourceResource extends AppCatAbstractResource { storageResource = existingStorageResource; storageResource.setUpdateTime(AiravataUtils.getCurrentTimestamp()); } - storageResource.setResourceDescription(getResourceDescription()); - storageResource.setResourceId(getResourceId()); + storageResource.setDescription(getResourceDescription()); + storageResource.setStorageResourceId(getStorageResourceId()); storageResource.setHostName(getHostName()); storageResource.setEnabled(isEnabled()); if (existingStorageResource == null) { @@ -328,10 +328,6 @@ public class StorageResourceResource extends AppCatAbstractResource { return resourceDescription; } - public String getResourceId() { - return resourceId; - } - public String getHostName() { return hostName; } @@ -340,11 +336,15 @@ public class StorageResourceResource extends AppCatAbstractResource { this.resourceDescription=resourceDescription; } - public void setResourceId(String resourceId) { - this.resourceId=resourceId; - } - public void setHostName(String hostName) { this.hostName=hostName; } + + public String getStorageResourceId() { + return storageResourceId; + } + + public void setStorageResourceId(String storageResourceId) { + this.storageResourceId = storageResourceId; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/13b50f7a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java index 59a4c25..50af371 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java @@ -280,13 +280,27 @@ public class AppCatalogJPAUtils { logger.error("Object should be a Compute Resource Preference.", new IllegalArgumentException()); throw new IllegalArgumentException("Object should be a Compute Resource Preference."); } - case DATA_STORAGE_PREFERENCE: - if (o instanceof DataStoragePreference){ - return createDataStoragePref((DataStoragePreference) o); + case STORAGE_PREFERENCE: + if (o instanceof StoragePreference){ + return createStoragePref((StoragePreference) o); }else { logger.error("Object should be a data storage Preference.", new IllegalArgumentException()); throw new IllegalArgumentException("Object should be a data storage Preference."); } + case STORAGE_RESOURCE: + if (o instanceof StorageResource){ + return createStorageResource((StorageResource) o); + }else { + logger.error("Object should be a storage resource.", new IllegalArgumentException()); + throw new IllegalArgumentException("Object should be a storage resource."); + } + case STORAGE_INTERFACE: + if (o instanceof StorageInterface){ + return createStorageInterface((StorageInterface) o); + }else { + logger.error("Object should be a storage interface.", new IllegalArgumentException()); + throw new IllegalArgumentException("Object should be a storage interface."); + } case APPLICATION_INPUT: if (o instanceof ApplicationIntInput){ return createApplicationInput((ApplicationIntInput) o); @@ -898,11 +912,11 @@ public class AppCatalogJPAUtils { return resource; } - private static AppCatalogResource createDataStoragePref(DataStoragePreference o) { - DataStoragePreferenceResource resource = new DataStoragePreferenceResource(); + private static AppCatalogResource createStoragePref(StoragePreference o) { + StoragePreferenceResource resource = new StoragePreferenceResource(); if (o != null) { resource.setGatewayId(o.getGatewayId()); - resource.setDataMoveId(o.getDataMovementID()); + resource.setStorageResourceId(o.getStorageResourceId()); resource.setLoginUserName(o.getLoginUserName()); resource.setResourceCSToken(o.getComputeResourceCSToken()); resource.setFsRootLocation(o.getFsRootLocation()); @@ -911,6 +925,28 @@ public class AppCatalogJPAUtils { return resource; } + private static AppCatalogResource createStorageResource(StorageResource o) { + StorageResourceResource resource = new StorageResourceResource(); + if (o != null) { + resource.setStorageResourceId(o.getStorageResourceId()); + resource.setHostName(o.getHostName()); + resource.setEnabled(o.getEnabled()); + resource.setResourceDescription(o.getDescription()); + } + return resource; + } + + private static AppCatalogResource createStorageInterface(StorageInterface o) { + StorageInterfaceResource resource = new StorageInterfaceResource(); + if (o != null) { + resource.setStorageResourceId(o.getStorageResourceId()); + resource.setDataMovementInterfaceId(o.getDataMovementInterfaceId()); + resource.setDataMovementInterfaceId(o.getDataMovementInterfaceId()); + resource.setStorageResourceResource((StorageResourceResource)createStorageResource(o.getStorageResource())); + } + return resource; + } + private static AppCatalogResource createModuleLoadCmd(ModuleLoadCmd o) { ModuleLoadCmdResource moduleLoadCmdResource = new ModuleLoadCmdResource(); if (o != null){ http://git-wip-us.apache.org/repos/asf/airavata/blob/13b50f7a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java index 0f31464..3f5193c 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java @@ -23,7 +23,6 @@ package org.apache.airavata.registry.core.app.catalog.util; public enum AppCatalogResourceType { COMPUTE_RESOURCE, - STORAGE_RESOURCE, HOST_ALIAS, HOST_IPADDRESS, GSISSH_SUBMISSION, @@ -51,7 +50,9 @@ public enum AppCatalogResourceType { APPLICATION_OUTPUT, GATEWAY_PROFILE, COMPUTE_RESOURCE_PREFERENCE, - DATA_STORAGE_PREFERENCE, + STORAGE_PREFERENCE, + STORAGE_RESOURCE, + STORAGE_INTERFACE, BATCH_QUEUE, COMPUTE_RESOURCE_FILE_SYSTEM, JOB_SUBMISSION_INTERFACE, http://git-wip-us.apache.org/repos/asf/airavata/blob/13b50f7a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java index aa681be..e096a0d 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java @@ -34,8 +34,8 @@ import org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager; import org.apache.airavata.model.appcatalog.computeresource.UnicoreDataMovement; import org.apache.airavata.model.appcatalog.computeresource.UnicoreJobSubmission; import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference; -import org.apache.airavata.model.appcatalog.gatewayprofile.DataStoragePreference; import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile; +import org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference; import org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription; import org.apache.airavata.model.application.io.DataType; import org.apache.airavata.model.application.io.InputDataObjectType; @@ -60,7 +60,7 @@ public class AppCatalogThriftConversion { StorageResourceResource resource = new StorageResourceResource(); resource.setHostName(description.getHostName()); resource.setResourceDescription(description.getStorageResourceDescription()); - resource.setResourceId(description.getStorageResourceId()); + resource.setStorageResourceId(description.getStorageResourceId()); resource.setEnabled(description.isEnabled()); return resource; } @@ -115,7 +115,7 @@ public class AppCatalogThriftConversion { public static StorageResourceDescription getStorageDescription (StorageResourceResource resource) throws AppCatalogException { StorageResourceDescription description = new StorageResourceDescription(); - description.setStorageResourceId(resource.getResourceId()); + description.setStorageResourceId(resource.getStorageResourceId()); description.setHostName(resource.getHostName()); description.setStorageResourceDescription(resource.getResourceDescription()); description.setEnabled(resource.isEnabled()); @@ -798,20 +798,20 @@ public class AppCatalogThriftConversion { return preferences; } - public static DataStoragePreference getDataStoragePreference (DataStoragePreferenceResource resource){ - DataStoragePreference preference = new DataStoragePreference(); - preference.setDataMovememtResourceId(resource.getDataMoveId()); + public static StoragePreference getDataStoragePreference (StoragePreferenceResource resource){ + StoragePreference preference = new StoragePreference(); + preference.setStorageResourceId(resource.getStorageResourceId()); preference.setFileSystemRootLocation(resource.getFsRootLocation()); preference.setLoginUserName(resource.getLoginUserName()); preference.setResourceSpecificCredentialStoreToken(resource.getResourceCSToken()); return preference; } - public static List<DataStoragePreference> getDataStoragePreferences (List<AppCatalogResource> resources){ - List<DataStoragePreference> preferences = new ArrayList<DataStoragePreference>(); + public static List<StoragePreference> getDataStoragePreferences (List<AppCatalogResource> resources){ + List<StoragePreference> preferences = new ArrayList<StoragePreference>(); if (resources != null && !resources.isEmpty()){ for (AppCatalogResource resource : resources){ - preferences.add(getDataStoragePreference((DataStoragePreferenceResource)resource)); + preferences.add(getDataStoragePreference((StoragePreferenceResource)resource)); } } return preferences; @@ -841,12 +841,12 @@ public class AppCatalogThriftConversion { return inputResources; } - public static GatewayResourceProfile getGatewayResourceProfile(GatewayProfileResource gw, List<ComputeResourcePreference> preferences, List<DataStoragePreference> storagePreferences){ + public static GatewayResourceProfile getGatewayResourceProfile(GatewayProfileResource gw, List<ComputeResourcePreference> preferences, List<StoragePreference> storagePreferences){ GatewayResourceProfile gatewayProfile = new GatewayResourceProfile(); gatewayProfile.setGatewayID(gw.getGatewayID()); gatewayProfile.setCredentialStoreToken(gw.getCredentialStoreToken()); gatewayProfile.setComputeResourcePreferences(preferences); - gatewayProfile.setDataStoragePreferences(storagePreferences); + gatewayProfile.setStoragePreferences(storagePreferences); return gatewayProfile; } http://git-wip-us.apache.org/repos/asf/airavata/blob/13b50f7a/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml b/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml index 092ce1d..f867e93 100644 --- a/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml +++ b/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml @@ -54,7 +54,7 @@ <class>org.apache.airavata.registry.core.app.catalog.model.ComputeResourceFileSystem</class> <class>org.apache.airavata.registry.core.app.catalog.model.JobSubmissionInterface</class> <class>org.apache.airavata.registry.core.app.catalog.model.DataMovementInterface</class> - <class>org.apache.airavata.registry.core.app.catalog.model.DataStoragePreference</class> + <class>org.apache.airavata.registry.core.app.catalog.model.StoragePreference</class> <class>org.apache.airavata.registry.core.app.catalog.model.ResourceJobManager</class> <class>org.apache.airavata.registry.core.app.catalog.model.JobManagerCommand</class> <class>org.apache.airavata.registry.core.app.catalog.model.LocalSubmission</class> http://git-wip-us.apache.org/repos/asf/airavata/blob/13b50f7a/modules/registry/registry-core/src/main/resources/appcatalog-derby.sql ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/resources/appcatalog-derby.sql b/modules/registry/registry-core/src/main/resources/appcatalog-derby.sql index 6de76d6..cdea976 100644 --- a/modules/registry/registry-core/src/main/resources/appcatalog-derby.sql +++ b/modules/registry/registry-core/src/main/resources/appcatalog-derby.sql @@ -398,12 +398,11 @@ CREATE TABLE STORAGE_RESOURCE PRIMARY KEY (STORAGE_RESOURCE_ID) ); -CREATE TABLE DATA_STORAGE_INTERFACE +CREATE TABLE STORAGE_INTERFACE ( STORAGE_RESOURCE_ID VARCHAR (255) NOT NULL, - DATA_MOVEMENT_PROTOCOL VARCHAR (255) NOT NULL, DATA_MOVEMENT_INTERFACE_ID VARCHAR (255) NOT NULL, - PRIORITY_ORDER INTEGER, + DATA_MOVEMENT_PROTOCOL VARCHAR (255) NOT NULL, CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, UPDATE_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (STORAGE_RESOURCE_ID,DATA_MOVEMENT_INTERFACE_ID), @@ -429,14 +428,14 @@ CREATE TABLE LOCAL_SUBMISSION FOREIGN KEY (RESOURCE_JOB_MANAGER_ID) REFERENCES RESOURCE_JOB_MANAGER(RESOURCE_JOB_MANAGER_ID) ); -CREATE TABLE DATA_STORAGE_PREFERENCE +CREATE TABLE STORAGE_PREFERENCE ( GATEWAY_ID VARCHAR(255), - DATA_MOVEMENT_ID VARCHAR(255), + STORAGE_RESOURCE_ID VARCHAR(255), LOGIN_USERNAME VARCHAR(255), FS_ROOT_LOCATION VARCHAR(255), RESOURCE_CS_TOKEN VARCHAR(255), - PRIMARY KEY(GATEWAY_ID,DATA_MOVEMENT_ID), + PRIMARY KEY(GATEWAY_ID,STORAGE_RESOURCE_ID), FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY_PROFILE(GATEWAY_ID) ON DELETE CASCADE ); http://git-wip-us.apache.org/repos/asf/airavata/blob/13b50f7a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/GwyResourceProfile.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/GwyResourceProfile.java b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/GwyResourceProfile.java index aeee0fc..7e32663 100644 --- a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/GwyResourceProfile.java +++ b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/GwyResourceProfile.java @@ -20,8 +20,8 @@ package org.apache.airavata.registry.cpi; import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference; -import org.apache.airavata.model.appcatalog.gatewayprofile.DataStoragePreference; import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile; +import org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference; import java.util.List; @@ -70,7 +70,7 @@ public interface GwyResourceProfile { * @return ComputeResourcePreference */ ComputeResourcePreference getComputeResourcePreference (String gatewayId, String hostId) throws AppCatalogException; - DataStoragePreference getDataStoragePreference (String gatewayId, String dataMoveId) throws AppCatalogException; + StoragePreference getStoragePreference(String gatewayId, String dataMoveId) throws AppCatalogException; /** * @@ -78,7 +78,7 @@ public interface GwyResourceProfile { * @return */ List<ComputeResourcePreference> getAllComputeResourcePreferences (String gatewayId) throws AppCatalogException; - List<DataStoragePreference> getAllDataStoragePreferences (String gatewayId) throws AppCatalogException; + List<StoragePreference> getAllStoragePreferences(String gatewayId) throws AppCatalogException; List<String> getGatewayProfileIds (String gatewayName) throws AppCatalogException; List<GatewayResourceProfile> getAllGatewayProfiles () throws AppCatalogException; http://git-wip-us.apache.org/repos/asf/airavata/blob/13b50f7a/thrift-interface-descriptions/airavata-api/airavata_api.thrift ---------------------------------------------------------------------- diff --git a/thrift-interface-descriptions/airavata-api/airavata_api.thrift b/thrift-interface-descriptions/airavata-api/airavata_api.thrift index 7bce41a..1129d1d 100644 --- a/thrift-interface-descriptions/airavata-api/airavata_api.thrift +++ b/thrift-interface-descriptions/airavata-api/airavata_api.thrift @@ -2138,9 +2138,9 @@ service Airavata { 3: airavata_errors.AiravataSystemException ase, 4: airavata_errors.AuthorizationException ae) - bool addGatewayDataStoragePreference(1: required security_model.AuthzToken authzToken, 2: required string gatewayID, + bool addGatewayStoragePreference(1: required security_model.AuthzToken authzToken, 2: required string gatewayID, 3: required string dataMoveId, - 4: required gateway_resource_profile_model.DataStoragePreference dataStoragePreference) + 4: required gateway_resource_profile_model.StoragePreference storagePreference) throws (1: airavata_errors.InvalidRequestException ire, 2: airavata_errors.AiravataClientException ace, 3: airavata_errors.AiravataSystemException ase, @@ -2166,7 +2166,7 @@ service Airavata { 3: airavata_errors.AiravataSystemException ase, 4: airavata_errors.AuthorizationException ae) - gateway_resource_profile_model.DataStoragePreference getGatewayDataStoragePreference(1: required security_model.AuthzToken authzToken, + gateway_resource_profile_model.StoragePreference getGatewayStoragePreference(1: required security_model.AuthzToken authzToken, 2: required string gatewayID, 3: required string dataMoveId) throws (1: airavata_errors.InvalidRequestException ire, @@ -2192,8 +2192,8 @@ service Airavata { 4: airavata_errors.AuthorizationException ae) - list<gateway_resource_profile_model.DataStoragePreference> - getAllGatewayDataStoragePreferences(1: required security_model.AuthzToken authzToken, 2: required string gatewayID) + list<gateway_resource_profile_model.StoragePreference> + getAllGatewayStoragePreferences(1: required security_model.AuthzToken authzToken, 2: required string gatewayID) throws (1: airavata_errors.InvalidRequestException ire, 2: airavata_errors.AiravataClientException ace, 3: airavata_errors.AiravataSystemException ase, @@ -2233,9 +2233,9 @@ service Airavata { 3: airavata_errors.AiravataSystemException ase, 4: airavata_errors.AuthorizationException ae) - bool updateGatewayDataStoragePreference(1: required security_model.AuthzToken authzToken, 2: required string gatewayID, - 3: required string dataMoveId, - 4: required gateway_resource_profile_model.DataStoragePreference dataStoragePreference) + bool updateGatewayStoragePreference(1: required security_model.AuthzToken authzToken, 2: required string gatewayID, + 3: required string storageId, + 4: required gateway_resource_profile_model.StoragePreference storagePreference) throws (1: airavata_errors.InvalidRequestException ire, 2: airavata_errors.AiravataClientException ace, 3: airavata_errors.AiravataSystemException ase, @@ -2261,8 +2261,8 @@ service Airavata { 3: airavata_errors.AiravataSystemException ase, 4: airavata_errors.AuthorizationException ae) - bool deleteGatewayDataStoragePreference(1: required security_model.AuthzToken authzToken, 2: required string gatewayID, - 3: required string dataMoveId) + bool deleteGatewayStoragePreference(1: required security_model.AuthzToken authzToken, 2: required string gatewayID, + 3: required string storageId) throws (1: airavata_errors.InvalidRequestException ire, 2: airavata_errors.AiravataClientException ace, 3: airavata_errors.AiravataSystemException ase, http://git-wip-us.apache.org/repos/asf/airavata/blob/13b50f7a/thrift-interface-descriptions/airavata-api/gateway_resource_profile_model.thrift ---------------------------------------------------------------------- diff --git a/thrift-interface-descriptions/airavata-api/gateway_resource_profile_model.thrift b/thrift-interface-descriptions/airavata-api/gateway_resource_profile_model.thrift index df78e5f..36474e0 100644 --- a/thrift-interface-descriptions/airavata-api/gateway_resource_profile_model.thrift +++ b/thrift-interface-descriptions/airavata-api/gateway_resource_profile_model.thrift @@ -71,8 +71,8 @@ struct ComputeResourcePreference { 9: optional string resourceSpecificCredentialStoreToken } -struct DataStoragePreference { - 1: required string dataMovememtResourceId, +struct StoragePreference { + 1: required string storageResourceId, 2: optional string loginUserName, 3: optional string fileSystemRootLocation, 4: optional string resourceSpecificCredentialStoreToken @@ -95,5 +95,5 @@ struct GatewayResourceProfile { 1: required string gatewayID, 2: optional string credentialStoreToken, 3: optional list<ComputeResourcePreference> computeResourcePreferences - 4: optional list<DataStoragePreference> dataStoragePreferences + 4: optional list<StoragePreference> storagePreferences }
