http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/impl/DataCatalogImpl.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/impl/DataCatalogImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/impl/DataCatalogImpl.java deleted file mode 100644 index f596980..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/impl/DataCatalogImpl.java +++ /dev/null @@ -1,286 +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.data.catalog.impl; - -import org.apache.airavata.model.data.resource.DataReplicaLocationModel; -import org.apache.airavata.model.data.resource.DataResourceModel; -import org.apache.airavata.registry.core.data.catalog.model.DataReplicaLocation; -import org.apache.airavata.registry.core.data.catalog.utils.DataCatalogJPAUtils; -import org.apache.airavata.registry.core.data.catalog.model.DataResource; -import org.apache.airavata.registry.core.data.catalog.utils.ThriftDataModelConversion; -import org.apache.airavata.registry.cpi.DataCatalog; -import org.apache.airavata.registry.cpi.DataCatalogException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.EntityManager; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -public class DataCatalogImpl implements DataCatalog { - - private final static Logger logger = LoggerFactory.getLogger(DataCatalogImpl.class); - - @Override - public String registerResource(DataResourceModel resourceModel) throws DataCatalogException { - String resourceId = UUID.randomUUID().toString(); - resourceModel.setResourceId(resourceId); - long currentTime = System.currentTimeMillis(); - resourceModel.setCreationTime(currentTime); - resourceModel.setLastModifiedTime(currentTime); - if(resourceModel.getReplicaLocations() != null){ - resourceModel.getReplicaLocations().stream().forEach(r-> { - r.setResourceId(resourceId); - r.setReplicaId(UUID.randomUUID().toString()); - r.setCreationTime(currentTime); - r.setLastModifiedTime(currentTime); - }); - } - resourceModel.setCreationTime(System.currentTimeMillis()); - resourceModel.setLastModifiedTime(System.currentTimeMillis()); - DataResource dataResource = ThriftDataModelConversion.getDataResource(resourceModel); - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - em.persist(dataResource); - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return resourceId; - } - - @Override - public boolean removeResource(String resourceId) throws DataCatalogException { - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - DataResource dataResource = em.find(DataResource.class, resourceId); - if(dataResource == null) - return false; - em.getTransaction().begin(); - em.remove(dataResource); - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return true; - } - - @Override - public boolean updateResource(DataResourceModel resourceModel) throws DataCatalogException { - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - DataResource dataResource = em.find(DataResource.class, resourceModel.getResourceId()); - if(dataResource == null) - return false; - em.getTransaction().begin(); - resourceModel.setCreationTime(dataResource.getCreationTime().getTime()); - resourceModel.setLastModifiedTime(System.currentTimeMillis()); - em.merge(ThriftDataModelConversion.getUpdatedDataResource(resourceModel, dataResource)); - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return true; - } - - @Override - public DataResourceModel getResource(String resourceId) throws DataCatalogException { - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - DataResource dataResource = em.find(DataResource.class, resourceId); - return ThriftDataModelConversion.getDataResourceModel(dataResource); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public String registerReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws DataCatalogException { - String replicaId = UUID.randomUUID().toString(); - dataReplicaLocationModel.setReplicaId(replicaId); - long currentTime = System.currentTimeMillis(); - dataReplicaLocationModel.setCreationTime(currentTime); - dataReplicaLocationModel.setLastModifiedTime(currentTime); - dataReplicaLocationModel.setCreationTime(System.currentTimeMillis()); - dataReplicaLocationModel.setLastModifiedTime(System.currentTimeMillis()); - DataReplicaLocation replicaLocation = ThriftDataModelConversion.getDataReplicaLocation(dataReplicaLocationModel); - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - em.getTransaction().begin(); - em.persist(replicaLocation); - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return replicaId; - } - - @Override - public boolean removeReplicaLocation(String replicaId) throws DataCatalogException { - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - DataReplicaLocation replicaLocation = em.find(DataReplicaLocation.class, replicaId); - if(replicaLocation == null) - return false; - em.getTransaction().begin(); - em.remove(replicaLocation); - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return true; - } - - @Override - public boolean updateReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel) throws DataCatalogException { - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - DataReplicaLocation dataReplicaLocation = em.find(DataReplicaLocation.class, dataReplicaLocationModel.getReplicaId()); - if(dataReplicaLocation == null) - return false; - em.getTransaction().begin(); - dataReplicaLocationModel.setCreationTime(dataReplicaLocation.getCreationTime().getTime()); - dataReplicaLocationModel.setLastModifiedTime(System.currentTimeMillis()); - em.merge(ThriftDataModelConversion.getUpdatedDataReplicaLocation(dataReplicaLocationModel, dataReplicaLocation)); - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - return true; - } - - @Override - public DataReplicaLocationModel getReplicaLocation(String replicaId) throws DataCatalogException { - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - DataReplicaLocation replicaLocation = em.find(DataReplicaLocation.class, replicaId); - return ThriftDataModelConversion.getDataReplicaLocationModel(replicaLocation); - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(e); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()) { - em.getTransaction().rollback(); - } - em.close(); - } - } - } - - @Override - public List<DataReplicaLocationModel> getAllReplicaLocations(String resourceId) throws DataCatalogException { - EntityManager em = null; - try { - em = DataCatalogJPAUtils.getEntityManager(); - DataResource dataResource = em.find(DataResource.class, resourceId); - if(dataResource == null) - return null; - ArrayList<DataReplicaLocationModel> dataReplicaLocationModels = new ArrayList<>(); - dataResource.getDataReplicaLocations().stream().forEach(rl->dataReplicaLocationModels - .add(ThriftDataModelConversion.getDataReplicaLocationModel(rl))); - return dataReplicaLocationModels; - } catch (Exception e) { - logger.error(e.getMessage(), e); - throw new DataCatalogException(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/5881af94/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/Configuration.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/Configuration.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/Configuration.java deleted file mode 100644 index e4ad0ec..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/Configuration.java +++ /dev/null @@ -1,55 +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.data.catalog.model; - -import org.apache.airavata.registry.core.app.catalog.model.Configuration_PK; - -import javax.persistence.*; -import java.io.Serializable; - -@Entity -@Table(name ="CONFIGURATION") -@IdClass(Configuration_PK.class) -public class Configuration implements Serializable { - @Id - @Column(name = "CONFIG_KEY") - private String config_key; - - @Id - @Column(name = "CONFIG_VAL") - private String config_val; - - public String getConfig_key() { - return config_key; - } - - public String getConfig_val() { - return config_val; - } - - public void setConfig_key(String config_key) { - this.config_key = config_key; - } - - public void setConfig_val(String config_val) { - this.config_val = config_val; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaLocation.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaLocation.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaLocation.java deleted file mode 100644 index ea58824..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaLocation.java +++ /dev/null @@ -1,169 +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.data.catalog.model; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.*; -import java.sql.Timestamp; -import java.util.Collection; - -@Entity -@Table(name = "DATA_REPLICA_LOCATION") -public class DataReplicaLocation { - private final static Logger logger = LoggerFactory.getLogger(DataReplicaLocation.class); - private String replicaId; - private String resourceId; - private String replicaName; - private String replicaDescription; - private String storageResourceId; - private String fileAbsolutePath; - private String replicaLocationCategory; - private String replicaPersistentType; - private Timestamp creationTime; - private Timestamp lastModifiedTime; - private Timestamp validUntilTime; - - private DataResource dataResource; - private Collection<DataReplicaMetaData> dataReplicaMetaData; - - @Id - @Column(name = "REPLICA_ID") - public String getReplicaId() { - return replicaId; - } - - public void setReplicaId(String replicaId) { - this.replicaId = replicaId; - } - - @Column(name = "RESOURCE_ID") - public String getResourceId() { - return resourceId; - } - - public void setResourceId(String resourceId) { - this.resourceId = resourceId; - } - - - @Column(name = "REPLICA_NAME") - public String getReplicaName() { - return replicaName; - } - - public void setReplicaName(String replicaName) { - this.replicaName = replicaName; - } - - @Column(name = "REPLICA_DESCRIPTION") - public String getReplicaDescription() { - return replicaDescription; - } - - public void setReplicaDescription(String replicaDescription) { - this.replicaDescription = replicaDescription; - } - - @Column(name = "STORAGE_RESOURCE_ID") - public String getStorageResourceId() { - return storageResourceId; - } - - public void setStorageResourceId(String storageResourceId) { - this.storageResourceId = storageResourceId; - } - - @Column(name = "FILE_ABSOLUTE_PATH") - public String getFileAbsolutePath() { - return fileAbsolutePath; - } - - public void setFileAbsolutePath(String fileAbsolutePath) { - this.fileAbsolutePath = fileAbsolutePath; - } - - @Column(name = "CREATION_TIME") - public Timestamp getCreationTime() { - return creationTime; - } - - public void setCreationTime(Timestamp creationTime) { - this.creationTime = creationTime; - } - - @Column(name = "LAST_MODIFIED_TIME") - public Timestamp getLastModifiedTime() { - return lastModifiedTime; - } - - public void setLastModifiedTime(Timestamp lastModifiedTime) { - this.lastModifiedTime = lastModifiedTime; - } - - @Column(name = "VALID_UNTIL_TIME") - public Timestamp getValidUntilTime() { - return validUntilTime; - } - - public void setValidUntilTime(Timestamp validUntilTime) { - this.validUntilTime = validUntilTime; - } - - - @Column(name = "REPLICA_LOCATION_CATEGORY") - public String getReplicaLocationCategory() { - return replicaLocationCategory; - } - - public void setReplicaLocationCategory(String replicaLocationCategory) { - this.replicaLocationCategory = replicaLocationCategory; - } - - @Column(name = "REPLICA_PERSISTENT_TYPE") - public String getReplicaPersistentType() { - return replicaPersistentType; - } - - public void setReplicaPersistentType(String replicaPersistentType) { - this.replicaPersistentType = replicaPersistentType; - } - - @ManyToOne - @JoinColumn(name = "RESOURCE_ID", referencedColumnName = "RESOURCE_ID") - public DataResource getDataResource() { - return dataResource; - } - - public void setDataResource(DataResource dataResource) { - this.dataResource = dataResource; - } - - @OneToMany(mappedBy = "dataReplicaLocation", cascade = {CascadeType.ALL}) - public Collection<DataReplicaMetaData> getDataReplicaMetaData() { - return dataReplicaMetaData; - } - - public void setDataReplicaMetaData(Collection<DataReplicaMetaData> dataReplicaMetaData) { - this.dataReplicaMetaData = dataReplicaMetaData; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaMetaData.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaMetaData.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaMetaData.java deleted file mode 100644 index e9a2203..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaMetaData.java +++ /dev/null @@ -1,77 +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.data.catalog.model; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.*; - -@Entity -@Table(name = "DATA_REPLICA_METADATA") -@IdClass(DataReplicaMetaData_PK.class) -public class DataReplicaMetaData { - private final static Logger logger = LoggerFactory.getLogger(DataReplicaMetaData.class); - private String replicaId; - private String key; - private String value; - - private DataReplicaLocation dataReplicaLocation; - - @Id - @Column(name = "REPLICA_ID") - public String getReplicaId() { - return replicaId; - } - - public void setReplicaId(String replicaId) { - this.replicaId = replicaId; - } - - @Id - @Column(name = "METADATA_KEY") - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - @Column(name = "METADATA_VALUE") - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - @ManyToOne - @JoinColumn(name = "REPLICA_ID", referencedColumnName = "REPLICA_ID") - public DataReplicaLocation getDataReplicaLocation() { - return dataReplicaLocation; - } - - public void setDataReplicaLocation(DataReplicaLocation dataReplicaLocation) { - this.dataReplicaLocation = dataReplicaLocation; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaMetaData_PK.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaMetaData_PK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaMetaData_PK.java deleted file mode 100644 index 617cc41..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataReplicaMetaData_PK.java +++ /dev/null @@ -1,59 +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.data.catalog.model; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.Serializable; - -public class DataReplicaMetaData_PK implements Serializable { - private final static Logger logger = LoggerFactory.getLogger(DataReplicaMetaData_PK.class); - - private String replicaId; - private String key; - - public String getReplicaId() { - return replicaId; - } - - public void setReplicaId(String replicaId) { - this.replicaId = replicaId; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - @Override - public boolean equals(Object o) { - return false; - } - - @Override - public int hashCode() { - return 1; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResource.java deleted file mode 100644 index c570212..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResource.java +++ /dev/null @@ -1,177 +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.data.catalog.model; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.*; -import java.sql.Timestamp; -import java.util.Collection; - -@Entity -@Table(name = "DATA_RESOURCE") -public class DataResource { - private final static Logger logger = LoggerFactory.getLogger(DataResource.class); - private String resourceId; - private String gatewayId; - private String resourceName; - private String resourceDescription; - private String dataResourceType; - private String ownerName; - private String parentResourceId; - private int resourceSize; - private Timestamp creationTime; - private Timestamp lastModifiedTime; - - private DataResource parentResource; - private Collection<DataReplicaLocation> dataReplicaLocations; - private Collection<DataResourceMetaData> dataResourceMetaData; - private Collection<DataResource> childDataResources; - - @Id - @Column(name = "RESOURCE_ID") - public String getResourceId() { - return resourceId; - } - - public void setResourceId(String resourceId) { - this.resourceId = resourceId; - } - - @Column(name = "GATEWAY_ID") - public String getGatewayId() { - return gatewayId; - } - - public void setGatewayId(String gatewayId) { - this.gatewayId = gatewayId; - } - - @Column(name = "RESOURCE_NAME") - public String getResourceName() { - return resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - @Column(name = "RESOURCE_DESCRIPTION") - public String getResourceDescription() { - return resourceDescription; - } - - public void setResourceDescription(String resourceDescription) { - this.resourceDescription = resourceDescription; - } - - @Column(name = "OWNER_NAME") - public String getOwnerName() { - return ownerName; - } - - public void setOwnerName(String ownerName) { - this.ownerName = ownerName; - } - - @Column(name = "PARENT_RESOURCE_ID") - public String getParentResourceId() { - return parentResourceId; - } - - public void setParentResourceId(String parentResourceId) { - this.parentResourceId = parentResourceId; - } - - @Column(name = "RESOURCE_TYPE") - public String getDataResourceType() { - return dataResourceType; - } - - public void setDataResourceType(String dataResourceType) { - this.dataResourceType = dataResourceType; - } - - @Column(name = "RESOURCE_SIZE") - public int getResourceSize() { - return resourceSize; - } - - public void setResourceSize(int resourceSize) { - this.resourceSize = resourceSize; - } - - @Column(name = "CREATION_TIME") - public Timestamp getCreationTime() { - return creationTime; - } - - public void setCreationTime(Timestamp creationTime) { - this.creationTime = creationTime; - } - - @Column(name = "LAST_MODIFIED_TIME") - public Timestamp getLastModifiedTime() { - return lastModifiedTime; - } - - public void setLastModifiedTime(Timestamp lastModifiedTime) { - this.lastModifiedTime = lastModifiedTime; - } - - @OneToMany(mappedBy = "dataResource", cascade = {CascadeType.ALL}) - public Collection<DataReplicaLocation> getDataReplicaLocations() { - return dataReplicaLocations; - } - - public void setDataReplicaLocations(Collection<DataReplicaLocation> dataReplicaLocations) { - this.dataReplicaLocations = dataReplicaLocations; - } - - @OneToMany(mappedBy = "dataResource", cascade = {CascadeType.ALL}) - public Collection<DataResourceMetaData> getDataResourceMetaData() { - return dataResourceMetaData; - } - - public void setDataResourceMetaData(Collection<DataResourceMetaData> dataResourceMetaData) { - this.dataResourceMetaData = dataResourceMetaData; - } - - @ManyToOne - @JoinColumn(name = "PARENT_RESOURCE_ID", referencedColumnName = "RESOURCE_ID") - public DataResource getParentResource() { - return parentResource; - } - - public void setParentResource(DataResource parentResource) { - this.parentResource = parentResource; - } - - @OneToMany(mappedBy = "parentResource", cascade = {CascadeType.ALL}) - public Collection<DataResource> getChildDataResources() { - return childDataResources; - } - - public void setChildDataResources(Collection<DataResource> childDataResources) { - this.childDataResources = childDataResources; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResourceMetaData.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResourceMetaData.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResourceMetaData.java deleted file mode 100644 index d703bac..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResourceMetaData.java +++ /dev/null @@ -1,77 +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.data.catalog.model; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.*; - -@Entity -@Table(name = "DATA_RESOURCE_METADATA") -@IdClass(DataResourceMetaData_PK.class) -public class DataResourceMetaData { - private final static Logger logger = LoggerFactory.getLogger(DataResourceMetaData.class); - private String resourceId; - private String key; - private String value; - - private DataResource dataResource; - - @Id - @Column(name = "RESOURCE_ID") - public String getResourceId() { - return resourceId; - } - - public void setResourceId(String resourceId) { - this.resourceId = resourceId; - } - - @Id - @Column(name = "METADATA_KEY") - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - @Column(name = "METADATA_VALUE") - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - @ManyToOne - @JoinColumn(name = "RESOURCE_ID", referencedColumnName = "RESOURCE_ID") - public DataResource getDataResource() { - return dataResource; - } - - public void setDataResource(DataResource dataResource) { - this.dataResource = dataResource; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResourceMetaData_PK.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResourceMetaData_PK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResourceMetaData_PK.java deleted file mode 100644 index 60545fe..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/model/DataResourceMetaData_PK.java +++ /dev/null @@ -1,59 +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.data.catalog.model; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.Serializable; - -public class DataResourceMetaData_PK implements Serializable { - private final static Logger logger = LoggerFactory.getLogger(DataResourceMetaData_PK.class); - - private String resourceId; - private String key; - - public String getResourceId() { - return resourceId; - } - - public void setResourceId(String resourceId) { - this.resourceId = resourceId; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - @Override - public boolean equals(Object o) { - return false; - } - - @Override - public int hashCode() { - return 1; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogConstants.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogConstants.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogConstants.java deleted file mode 100644 index c9e18f6..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogConstants.java +++ /dev/null @@ -1,49 +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.data.catalog.utils; - -public class DataCatalogConstants { - // table names - public static final String DATA_RESOURCE = "DataResource"; - public static final String DATA_REPLICA_LOCATION = "DataReplicaLocation"; - public static final String CONFIGURATION = "Configuration"; - - // DataResource Table - public final class DataResourceConstants { - public static final String RESOURCE_ID = "resourceId"; - public static final String RESOURCE_NAME = "resourceName"; - public static final String RESOURCE_DESCRIPTION = "resourceDescription"; - public static final String RESOURCE_SIZE = "resourceSize"; - public static final String CREATION_TIME = "creationTime"; - public static final String LAST_MODIFIED_TIME = "lastModifiedTime"; - } - - // Users table - public final class DataReplicaLocationConstants { - public static final String REPLICA_ID = "replicaId"; - public static final String RESOURCE_ID = "resourceId"; - public static final String DATA_LOCATIONS = "dataLocations"; - public static final String REPLICA_NAME = "replicaName"; - public static final String REPLICA_DESCRIPTION = "replicaDescription"; - public static final String CREATION_TIME = "creationTime"; - public static final String LAST_MODIFIED_TIME = "lastModifiedTime"; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogJPAUtils.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogJPAUtils.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogJPAUtils.java deleted file mode 100644 index b8257cb..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogJPAUtils.java +++ /dev/null @@ -1,82 +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.data.catalog.utils; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.common.utils.ServerSettings; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.*; -import java.util.HashMap; -import java.util.Map; - -public class DataCatalogJPAUtils { - private final static Logger logger = LoggerFactory.getLogger(DataCatalogJPAUtils.class); - - private static final String PERSISTENCE_UNIT_NAME = "datacatalog_data"; - private static final String DATACATALOG_JDBC_DRIVER = "datacatalog.jdbc.driver"; - private static final String DATACATALOG_JDBC_URL = "datacatalog.jdbc.url"; - private static final String DATACATALOG_JDBC_USER = "datacatalog.jdbc.user"; - private static final String DATACATALOG_JDBC_PWD = "datacatalog.jdbc.password"; - private static final String DATACATALOG_VALIDATION_QUERY = "datacatalog.validationQuery"; - - @PersistenceUnit(unitName="datacatalog_data") - protected static EntityManagerFactory factory; - - @PersistenceContext(unitName="datacatalog_data") - private static EntityManager dataCatEntityManager; - - public static EntityManager getEntityManager() throws ApplicationSettingsException { - if (factory == null) { - String connectionProperties = "DriverClassName=" + readServerProperties(DATACATALOG_JDBC_DRIVER) + "," + - "Url=" + readServerProperties(DATACATALOG_JDBC_URL) + "?autoReconnect=true," + - "Username=" + readServerProperties(DATACATALOG_JDBC_USER) + "," + - "Password=" + readServerProperties(DATACATALOG_JDBC_PWD) + - ",validationQuery=" + readServerProperties(DATACATALOG_VALIDATION_QUERY); - System.out.println(connectionProperties); - Map<String, String> properties = new HashMap<String, String>(); - properties.put("openjpa.ConnectionDriverName", "org.apache.commons.dbcp.BasicDataSource"); - properties.put("openjpa.ConnectionProperties", connectionProperties); - properties.put("openjpa.DynamicEnhancementAgent", "true"); - properties.put("openjpa.RuntimeUnenhancedClasses", "unsupported"); - properties.put("openjpa.RemoteCommitProvider","sjvm"); - properties.put("openjpa.Log","DefaultLevel=INFO, Runtime=INFO, Tool=INFO, SQL=INFO"); - properties.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)"); - properties.put("openjpa.jdbc.QuerySQLCache", "false"); - properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, PrettyPrintLineLength=72," + - " PrintParameters=true, MaxActive=10, MaxIdle=5, MinIdle=2, MaxWait=31536000, autoReconnect=true"); - factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, properties); - } - dataCatEntityManager = factory.createEntityManager(); - return dataCatEntityManager; - } - - private static String readServerProperties (String propertyName) throws ApplicationSettingsException { - try { - return ServerSettings.getSetting(propertyName); - } catch (ApplicationSettingsException e) { - logger.error("Unable to read airavata-server.properties...", e); - throw new ApplicationSettingsException("Unable to read airavata-server.properties..."); - } - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogQueryGenerator.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogQueryGenerator.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogQueryGenerator.java deleted file mode 100644 index 4ddf8d3..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/DataCatalogQueryGenerator.java +++ /dev/null @@ -1,111 +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.data.catalog.utils; - -import org.apache.airavata.registry.cpi.ResultOrderType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.EntityManager; -import javax.persistence.Query; -import java.util.HashMap; -import java.util.Map; - -public class DataCatalogQueryGenerator { - - private final static Logger logger = LoggerFactory.getLogger(DataCatalogQueryGenerator.class); - private String tableName; - private Map<String,Object> matches=new HashMap<String, Object>(); - private static final String SELECT_OBJ="p"; - private static final String DELETE_OBJ="p"; - private static final String TABLE_OBJ="p"; - - public DataCatalogQueryGenerator(String tableName, Object[]... params) { - setTableName(tableName); - for (Object[] param : params) { - addMatch(param[0].toString(), param[1]); - } - } - - public String getTableName() { - return tableName; - } - - public void setTableName(String tableName) { - this.tableName = tableName; - } - - public void addMatch(String colName, Object matchValue){ - matches.put(colName, matchValue); - } - - public void setParameter(String colName, Object matchValue){ - addMatch(colName, matchValue); - } - - public Query selectQuery(EntityManager entityManager){ - String queryString="SELECT "+ SELECT_OBJ + " FROM " +getTableName()+" "+TABLE_OBJ; - return generateQueryWithParameters(entityManager, queryString); - } - - public Query selectQuery(EntityManager entityManager, String orderByColumn, - ResultOrderType resultOrderType){ - String order = (resultOrderType == ResultOrderType.ASC) ? "ASC" : "DESC"; - String orderByClause = " ORDER BY " + SELECT_OBJ + "." + orderByColumn + " " + order; - String queryString="SELECT "+ SELECT_OBJ + " FROM " +getTableName()+" "+TABLE_OBJ; - return generateQueryWithParameters(entityManager, queryString, orderByClause); - } - - public Query deleteQuery(EntityManager entityManager){ - String queryString="Delete FROM "+getTableName()+" "+TABLE_OBJ; - return generateQueryWithParameters(entityManager, queryString); - } - - private Query generateQueryWithParameters(EntityManager entityManager, String queryString) { - return generateQueryWithParameters(entityManager, queryString, ""); - } - - private Query generateQueryWithParameters(EntityManager entityManager, - String queryString, String orderByClause) { - Map<String,Object> queryParameters=new HashMap<String, Object>(); - if (matches.size()>0){ - String matchString = ""; - int paramCount=0; - for (String colName : matches.keySet()) { - String paramName="param"+paramCount; - queryParameters.put(paramName, matches.get(colName)); - if (!matchString.equals("")){ - matchString+=" AND "; - } - matchString+=TABLE_OBJ+"."+colName+" =:"+paramName; - paramCount++; - } - queryString+=" WHERE "+matchString; - } - queryString += orderByClause; - Query query = entityManager.createQuery(queryString); - for (String paramName : queryParameters.keySet()) { - query.setParameter(paramName, queryParameters.get(paramName)); - } - return query; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/ThriftDataModelConversion.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/ThriftDataModelConversion.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/ThriftDataModelConversion.java deleted file mode 100644 index 7658631..0000000 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/data/catalog/utils/ThriftDataModelConversion.java +++ /dev/null @@ -1,213 +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.data.catalog.utils; - -import org.apache.airavata.model.data.resource.*; -import org.apache.airavata.registry.core.data.catalog.model.DataReplicaLocation; -import org.apache.airavata.registry.core.data.catalog.model.DataReplicaMetaData; -import org.apache.airavata.registry.core.data.catalog.model.DataResource; -import org.apache.airavata.registry.core.data.catalog.model.DataResourceMetaData; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -public class ThriftDataModelConversion { - - private final static Logger logger = LoggerFactory.getLogger(ThriftDataModelConversion.class); - - public static DataResourceModel getDataResourceModel(DataResource dataResource){ - if (dataResource != null) { - DataResourceModel dataResourceModel = new DataResourceModel(); - dataResourceModel.setResourceId(dataResource.getResourceId()); - dataResourceModel.setGatewayId(dataResource.getGatewayId()); - dataResourceModel.setParentResourceId(dataResource.getParentResourceId()); - dataResourceModel.setResourceName(dataResource.getResourceName()); - if(dataResource.getDataResourceType() != null) - dataResourceModel.setDataResourceType(DataResourceType.valueOf(dataResource.getDataResourceType())); - else - dataResourceModel.setDataResourceType(DataResourceType.FILE); - dataResourceModel.setResourceDescription(dataResource.getResourceDescription()); - dataResourceModel.setOwnerName(dataResource.getOwnerName()); - dataResourceModel.setResourceSize(dataResource.getResourceSize()); - if(dataResource.getCreationTime() != null) - dataResourceModel.setCreationTime(dataResource.getCreationTime().getTime()); - if(dataResource.getLastModifiedTime() != null) - dataResourceModel.setLastModifiedTime(dataResource.getLastModifiedTime().getTime()); - dataResourceModel.setResourceMetadata(getResourceMetaData(dataResource.getDataResourceMetaData())); - if(dataResource.getDataReplicaLocations() != null){ - ArrayList<DataReplicaLocationModel> dataReplicaLocationModels = new ArrayList<>(); - dataResource.getDataReplicaLocations().stream().forEach(r->dataReplicaLocationModels - .add(getDataReplicaLocationModel(r))); - dataResourceModel.setReplicaLocations(dataReplicaLocationModels); - } - if(dataResourceModel.getDataResourceType().equals(DataResourceType.COLLECTION) && dataResource.getChildDataResources() != null){ - ArrayList<DataResourceModel> childDataResources = new ArrayList<>(); - dataResource.getChildDataResources().stream().forEach(r->childDataResources.add(getDataResourceModel(r))); - dataResourceModel.setChildResources(childDataResources); - } - return dataResourceModel; - } - return null; - } - - public static DataResource getDataResource(DataResourceModel dataResourceModel){ - if(dataResourceModel != null){ - DataResource dataResource = new DataResource(); - return getUpdatedDataResource(dataResourceModel, dataResource); - } - return null; - } - - public static DataResource getUpdatedDataResource(DataResourceModel dataResourceModel, DataResource dataResource){ - dataResource.setResourceId(dataResourceModel.getResourceId()); - dataResource.setGatewayId(dataResourceModel.getGatewayId()); - dataResource.setResourceName(dataResourceModel.getResourceName()); - dataResource.setParentResourceId(dataResourceModel.getParentResourceId()); - if(dataResourceModel.getDataResourceType() != null) - dataResource.setDataResourceType(dataResourceModel.getDataResourceType().toString()); - else - dataResource.setDataResourceType(DataResourceType.FILE.toString()); - dataResource.setResourceDescription(dataResourceModel.getResourceDescription()); - dataResource.setOwnerName(dataResourceModel.getOwnerName()); - dataResource.setResourceSize(dataResourceModel.getResourceSize()); - if(dataResourceModel.getCreationTime() > 0) - dataResource.setCreationTime(new Timestamp(dataResourceModel.getCreationTime())); - if(dataResourceModel.getLastModifiedTime() > 0) - dataResource.setLastModifiedTime(new Timestamp(dataResourceModel.getLastModifiedTime())); - ArrayList<DataResourceMetaData> dataResourceMetaData = new ArrayList<>(); - if(dataResourceModel.getResourceMetadata() != null) { - dataResourceModel.getResourceMetadata().keySet().stream().forEach(k -> { - String v = dataResourceModel.getResourceMetadata().get(k); - DataResourceMetaData temp = new DataResourceMetaData(); - temp.setResourceId(dataResource.getResourceId()); - temp.setKey(k); - temp.setValue(v); - dataResourceMetaData.add(temp); - }); - dataResource.setDataResourceMetaData(dataResourceMetaData); - } - if(dataResourceModel.getReplicaLocations() != null){ - ArrayList<DataReplicaLocation> dataReplicaLocations = new ArrayList<>(); - dataResourceModel.getReplicaLocations().stream().forEach(r->{ - DataReplicaLocation dataReplicaLocationModel = getDataReplicaLocation(r); - dataReplicaLocationModel.setResourceId(dataResourceModel.getResourceId()); - dataReplicaLocations.add(dataReplicaLocationModel); - }); - dataResource.setDataReplicaLocations(dataReplicaLocations); - } - if(dataResourceModel.getDataResourceType() == DataResourceType.COLLECTION && dataResourceModel.getChildResources() != null){ - ArrayList<DataResource> childDataResources = new ArrayList<>(); - dataResourceModel.getChildResources().stream().forEach(r->childDataResources.add(getDataResource(r))); - dataResource.setChildDataResources(childDataResources); - } - return dataResource; - } - - public static DataReplicaLocationModel getDataReplicaLocationModel(DataReplicaLocation replicaLocation){ - if (replicaLocation != null) { - DataReplicaLocationModel replicaLocationModel = new DataReplicaLocationModel(); - replicaLocationModel.setReplicaId(replicaLocation.getReplicaId()); - replicaLocationModel.setResourceId(replicaLocation.getResourceId()); - replicaLocationModel.setReplicaName(replicaLocation.getReplicaName()); - replicaLocationModel.setReplicaDescription(replicaLocation.getReplicaDescription()); - replicaLocationModel.setStorageResourceId(replicaLocation.getStorageResourceId()); - if(replicaLocation.getValidUntilTime() != null) - replicaLocationModel.setValidUntilTime(replicaLocation.getValidUntilTime().getTime()); - replicaLocationModel.setFileAbsolutePath(replicaLocation.getFileAbsolutePath()); - if(replicaLocation.getCreationTime() != null) - replicaLocationModel.setCreationTime(replicaLocation.getCreationTime().getTime()); - if(replicaLocation.getLastModifiedTime() != null) - replicaLocationModel.setLastModifiedTime(replicaLocation.getLastModifiedTime().getTime()); - if(replicaLocation.getReplicaLocationCategory() != null) - replicaLocationModel.setReplicaLocationCategory(ReplicaLocationCategory.valueOf(replicaLocation - .getReplicaLocationCategory().toString())); - if(replicaLocation.getReplicaPersistentType() != null) - replicaLocationModel.setReplicaPersistentType(ReplicaPersistentType.valueOf(replicaLocation - .getReplicaPersistentType().toString())); - replicaLocationModel.setReplicaMetadata(getReplicaMetaData(replicaLocation.getDataReplicaMetaData())); - return replicaLocationModel; - } - return null; - } - - public static DataReplicaLocation getDataReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel){ - if(dataReplicaLocationModel != null){ - DataReplicaLocation dataReplicaLocation = new DataReplicaLocation(); - return getUpdatedDataReplicaLocation(dataReplicaLocationModel, dataReplicaLocation); - } - return null; - } - - public static DataReplicaLocation getUpdatedDataReplicaLocation(DataReplicaLocationModel dataReplicaLocationModel, - DataReplicaLocation dataReplicaLocation){ - dataReplicaLocation.setReplicaId(dataReplicaLocationModel.getReplicaId()); - dataReplicaLocation.setResourceId(dataReplicaLocationModel.getResourceId()); - dataReplicaLocation.setReplicaName(dataReplicaLocationModel.getReplicaName()); - dataReplicaLocation.setReplicaDescription(dataReplicaLocationModel.getReplicaDescription()); - dataReplicaLocation.setStorageResourceId(dataReplicaLocationModel.getStorageResourceId()); - dataReplicaLocation.setFileAbsolutePath(dataReplicaLocationModel.getFileAbsolutePath()); - if(dataReplicaLocationModel.getValidUntilTime() > 0) - dataReplicaLocation.setValidUntilTime(new Timestamp(dataReplicaLocationModel.getValidUntilTime())); - if(dataReplicaLocationModel.getCreationTime() > 0) - dataReplicaLocation.setCreationTime(new Timestamp(dataReplicaLocationModel.getCreationTime())); - if(dataReplicaLocationModel.getLastModifiedTime() > 0) - dataReplicaLocation.setLastModifiedTime(new Timestamp(dataReplicaLocationModel.getLastModifiedTime())); - if(dataReplicaLocationModel.getReplicaLocationCategory() != null) - dataReplicaLocation.setReplicaLocationCategory(dataReplicaLocationModel.getReplicaLocationCategory().toString()); - if(dataReplicaLocationModel.getReplicaPersistentType() != null) - dataReplicaLocation.setReplicaPersistentType(dataReplicaLocationModel.getReplicaPersistentType().toString()); - ArrayList<DataReplicaMetaData> dataReplicaMetadata = new ArrayList<>(); - if(dataReplicaLocation.getDataReplicaMetaData() != null){ - dataReplicaLocationModel.getReplicaMetadata().keySet().stream().forEach(k -> { - String v = dataReplicaLocationModel.getReplicaMetadata().get(k); - DataReplicaMetaData temp = new DataReplicaMetaData(); - temp.setReplicaId(dataReplicaLocationModel.getResourceId()); - temp.setKey(k); - temp.setValue(v); - dataReplicaMetadata.add(temp); - }); - dataReplicaLocation.setDataReplicaMetaData(dataReplicaMetadata); - } - return dataReplicaLocation; - } - - public static Map<String, String> getResourceMetaData(Collection<DataResourceMetaData> dataResourceMetaData){ - HashMap<String, String> metadata = new HashMap<>(); - if(dataResourceMetaData!=null && !dataResourceMetaData.isEmpty()) { - dataResourceMetaData.stream().forEach(m -> metadata.put(m.getKey(),m.getValue())); - } - return metadata; - } - - public static Map<String, String> getReplicaMetaData(Collection<DataReplicaMetaData> dataReplicaMetaData){ - HashMap<String, String> metadata = new HashMap<>(); - if(dataReplicaMetaData!=null && !dataReplicaMetaData.isEmpty()) { - dataReplicaMetaData.stream().forEach(m -> metadata.put(m.getKey(),m.getValue())); - } - return metadata; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/RegistryFactory.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/RegistryFactory.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/RegistryFactory.java index 41a9f13..40cd4f9 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/RegistryFactory.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/RegistryFactory.java @@ -24,7 +24,6 @@ package org.apache.airavata.registry.core.experiment.catalog.impl; import org.apache.airavata.common.exception.ApplicationSettingsException; import org.apache.airavata.common.utils.ServerSettings; import org.apache.airavata.registry.core.app.catalog.impl.AppCatalogImpl; -import org.apache.airavata.registry.core.data.catalog.impl.DataCatalogImpl; import org.apache.airavata.registry.core.impl.RegistryImpl; import org.apache.airavata.registry.cpi.*; import org.slf4j.Logger; @@ -33,7 +32,6 @@ import org.slf4j.LoggerFactory; public class RegistryFactory { private static ExperimentCatalog experimentCatalog; private static AppCatalog appCatalog; - private static DataCatalog replicaCatalog; private static Registry registry; private static Logger logger = LoggerFactory.getLogger(RegistryFactory.class); @@ -100,19 +98,6 @@ public class RegistryFactory { return appCatalog; } - public static DataCatalog getDataCatalog() throws DataCatalogException { - try { - if (replicaCatalog == null) { - replicaCatalog = new DataCatalogImpl(); - } - } catch (Exception e) { - logger.error("Unable to create data catalog instance", e); - throw new DataCatalogException(e); - } - return replicaCatalog; - } - - public static ExperimentCatalog getLoggingRegistry() { if(experimentCatalog == null) { experimentCatalog = new LoggingExperimentCatalogImpl(); http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/impl/RegistryImpl.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/impl/RegistryImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/impl/RegistryImpl.java index 5207fee..87b178b 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/impl/RegistryImpl.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/impl/RegistryImpl.java @@ -22,7 +22,6 @@ package org.apache.airavata.registry.core.impl; import org.apache.airavata.registry.core.app.catalog.impl.AppCatalogImpl; -import org.apache.airavata.registry.core.data.catalog.impl.DataCatalogImpl; import org.apache.airavata.registry.core.experiment.catalog.impl.ExperimentCatalogImpl; import org.apache.airavata.registry.cpi.*; @@ -41,9 +40,4 @@ public class RegistryImpl implements Registry { public AppCatalog getAppCatalog() throws RegistryException { return new AppCatalogImpl(); } - - @Override - public DataCatalog getDataCatalog() throws RegistryException { - return new DataCatalogImpl(); - } } http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/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 da544c9..9f18c2a 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 @@ -95,13 +95,4 @@ <class>org.apache.airavata.registry.core.experiment.catalog.model.JobStatus</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> </persistence-unit> - <persistence-unit name="datacatalog_data"> - <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> - <class>org.apache.airavata.registry.core.data.catalog.model.DataResource</class> - <class>org.apache.airavata.registry.core.data.catalog.model.DataReplicaLocation</class> - <class>org.apache.airavata.registry.core.data.catalog.model.DataResourceMetaData</class> - <class>org.apache.airavata.registry.core.data.catalog.model.DataReplicaMetaData</class> - <class>org.apache.airavata.registry.core.data.catalog.model.Configuration</class> - <exclude-unlisted-classes>true</exclude-unlisted-classes> - </persistence-unit> </persistence> http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/main/resources/datacatalog-derby.sql ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/resources/datacatalog-derby.sql b/modules/registry/registry-core/src/main/resources/datacatalog-derby.sql deleted file mode 100644 index 2f39a54..0000000 --- a/modules/registry/registry-core/src/main/resources/datacatalog-derby.sql +++ /dev/null @@ -1,77 +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. - * - */ - -CREATE TABLE DATA_RESOURCE -( - RESOURCE_ID VARCHAR (255), - GATEWAY_ID VARCHAR (255), - RESOURCE_NAME VARCHAR (255), - RESOURCE_DESCRIPTION VARCHAR (1024), - PARENT_RESOURCE_ID VARCHAR (255), - OWNER_NAME VARCHAR (255), - RESOURCE_SIZE INTEGER , - CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - LAST_MODIFIED_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', - PRIMARY KEY (RESOURCE_ID) -); - -CREATE TABLE DATA_REPLICA_LOCATION -( - REPLICA_ID VARCHAR (255), - RESOURCE_ID VARCHAR (255) NOT NULL, - REPLICA_NAME VARCHAR (255), - REPLICA_DESCRIPTION VARCHAR (1024), - STORAGE_RESOURCE_ID VARCHAR (255), - FILE_ABSOLUTE_PATH VARCHAR (4096), - CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - LAST_MODIFIED_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', - VALID_UNTIL_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00', - PRIMARY KEY (REPLICA_ID), - FOREIGN KEY (RESOURCE_ID) REFERENCES DATA_RESOURCE(RESOURCE_ID) ON DELETE CASCADE -); - -CREATE TABLE DATA_RESOURCE_METADATA -( - RESOURCE_ID VARCHAR(255), - METADATA_KEY VARCHAR(255), - METADATA_VALUE VARCHAR(2048), - PRIMARY KEY(RESOURCE_ID, METADATA_KEY), - FOREIGN KEY (RESOURCE_ID) REFERENCES DATA_RESOURCE(RESOURCE_ID) ON DELETE CASCADE -); - -CREATE TABLE DATA_REPLICA_METADATA -( - REPLICA_ID VARCHAR(255), - METADATA_KEY VARCHAR(255), - METADATA_VALUE VARCHAR(2048), - PRIMARY KEY(REPLICA_ID, METADATA_KEY), - FOREIGN KEY (REPLICA_ID) REFERENCES DATA_REPLICA_LOCATION(REPLICA_ID) ON DELETE CASCADE -); - - -CREATE TABLE CONFIGURATION -( - CONFIG_KEY VARCHAR(255), - CONFIG_VAL VARCHAR(255), - PRIMARY KEY(CONFIG_KEY, CONFIG_VAL) -); - -INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL) VALUES('data_catalog_version', '0.16'); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/main/resources/datacatalog-mysql.sql ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/resources/datacatalog-mysql.sql b/modules/registry/registry-core/src/main/resources/datacatalog-mysql.sql deleted file mode 100644 index 04b6715..0000000 --- a/modules/registry/registry-core/src/main/resources/datacatalog-mysql.sql +++ /dev/null @@ -1,76 +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. - * - */ - -CREATE TABLE DATA_RESOURCE -( - RESOURCE_ID VARCHAR (255), - GATEWAY_ID VARCHAR (255), - RESOURCE_NAME VARCHAR (255), - RESOURCE_DESCRIPTION VARCHAR (255), - OWNER_NAME VARCHAR (255), - PARENT_RESOURCE_ID VARCHAR (255), - RESOURCE_SIZE INT, - CREATION_TIME TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00', - LAST_MODIFIED_TIME TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (RESOURCE_ID) -); - -CREATE TABLE DATA_REPLICA_LOCATION -( - REPLICA_ID VARCHAR (255), - RESOURCE_ID VARCHAR (255) NOT NULL, - REPLICA_NAME VARCHAR (255), - REPLICA_DESCRIPTION VARCHAR (255), - STORAGE_RESOURCE_ID VARCHAR (255), - FILE_ABSOLUTE_PATH VARCHAR (255), - CREATION_TIME TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00', - LAST_MODIFIED_TIME TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - VALID_UNTIL_TIME TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00', - PRIMARY KEY (REPLICA_ID), - FOREIGN KEY (RESOURCE_ID) REFERENCES DATA_RESOURCE(RESOURCE_ID) ON DELETE CASCADE -); - -CREATE TABLE DATA_RESOURCE_METADATA -( - RESOURCE_ID VARCHAR(255), - METADATA_KEY VARCHAR(255), - METADATA_VALUE VARCHAR(255), - PRIMARY KEY(RESOURCE_ID, METADATA_KEY), - FOREIGN KEY (RESOURCE_ID) REFERENCES DATA_RESOURCE(RESOURCE_ID) ON DELETE CASCADE -); - -CREATE TABLE DATA_REPLICA_METADATA -( - REPLICA_ID VARCHAR(255), - METADATA_KEY VARCHAR(255), - METADATA_VALUE VARCHAR(255), - PRIMARY KEY(REPLICA_ID, METADATA_KEY), - FOREIGN KEY (REPLICA_ID) REFERENCES DATA_REPLICA_LOCATION(REPLICA_ID) ON DELETE CASCADE -); - -CREATE TABLE CONFIGURATION -( - CONFIG_KEY VARCHAR(255), - CONFIG_VAL VARCHAR(255), - PRIMARY KEY(CONFIG_KEY, CONFIG_VAL) -); - -INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL) VALUES('data_catalog_version', '0.16'); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/5881af94/modules/registry/registry-core/src/test/java/org/apache/airavata/data/catalog/DataCatalogTest.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/data/catalog/DataCatalogTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/data/catalog/DataCatalogTest.java deleted file mode 100644 index b8cc159..0000000 --- a/modules/registry/registry-core/src/test/java/org/apache/airavata/data/catalog/DataCatalogTest.java +++ /dev/null @@ -1,219 +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.data.catalog; - -import org.apache.airavata.data.catalog.util.Initialize; -import org.apache.airavata.model.data.resource.*; -import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory; -import org.apache.airavata.registry.cpi.DataCatalog; -import org.apache.airavata.registry.cpi.DataCatalogException; -import org.junit.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.List; -import java.util.UUID; - -public class DataCatalogTest { - private final static Logger logger = LoggerFactory.getLogger(DataCatalogTest.class); - private static Initialize initialize; - private static DataCatalog datacatalog; - private static DataResourceModel dataResourceModel; - private static DataReplicaLocationModel replicaLocationModel; - - @BeforeClass - public static void setUp() { - try { - System.out.println("********** SET UP ************"); - initialize = new Initialize("datacatalog-derby.sql"); - initialize.initializeDB(); - datacatalog = RegistryFactory.getDataCatalog(); - dataResourceModel = new DataResourceModel(); - dataResourceModel.setResourceName("test-file.txt"); - HashMap<String, String> resMetadata = new HashMap<>(); - resMetadata.put("name", "name"); - dataResourceModel.setResourceMetadata(resMetadata); - - replicaLocationModel = new DataReplicaLocationModel(); - replicaLocationModel.setReplicaName("1-st-replica"); - replicaLocationModel.setReplicaLocationCategory(ReplicaLocationCategory.COMPUTE_RESOURCE); - replicaLocationModel.setReplicaPersistentType(ReplicaPersistentType.PERSISTENT); - HashMap<String, String> rMetadata = new HashMap<>(); - rMetadata.put("name", "name"); - replicaLocationModel.setReplicaMetadata(rMetadata); - dataResourceModel.addToReplicaLocations(replicaLocationModel); - } catch (DataCatalogException e) { - logger.error(e.getMessage(), e); - } - } - - @AfterClass - public static void tearDown() throws Exception { - System.out.println("********** TEAR DOWN ************"); - initialize.stopDerbyServer(); - } - - @Test - public void testPublishDataResource(){ - try { - String resourceId = datacatalog.registerResource(dataResourceModel); - org.junit.Assert.assertNotNull(resourceId); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testRemoveDataResource(){ - try { - boolean result = datacatalog.removeResource("234234234"); - Assert.assertFalse(result); - String resourceId = datacatalog.registerResource(dataResourceModel); - Assert.assertNotNull(resourceId); - result = datacatalog.removeResource(resourceId); - Assert.assertTrue(result); - result = datacatalog.removeResource(resourceId); - Assert.assertFalse(result); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testGetDataResource(){ - try { - dataResourceModel.setDataResourceType(DataResourceType.COLLECTION); - String resourceId = datacatalog.registerResource(dataResourceModel); - Assert.assertNotNull(resourceId); - DataResourceModel persistedCopy = datacatalog.getResource(resourceId); - Assert.assertNotNull(persistedCopy); - dataResourceModel.setParentResourceId(resourceId); - dataResourceModel.setDataResourceType(DataResourceType.FILE); - datacatalog.registerResource(dataResourceModel); - datacatalog.registerResource(dataResourceModel); - persistedCopy = datacatalog.getResource(resourceId); - Assert.assertTrue(persistedCopy.getChildResources().size()==2); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testUpdateDataResource(){ - try { - dataResourceModel.setResourceId(UUID.randomUUID().toString()); - boolean result = datacatalog.updateResource(dataResourceModel); - Assert.assertFalse(result); - datacatalog.registerResource(dataResourceModel); - dataResourceModel.setResourceName("updated-name"); - datacatalog.updateResource(dataResourceModel); - dataResourceModel = datacatalog.getResource(dataResourceModel.getResourceId()); - Assert.assertTrue(dataResourceModel.getResourceName().equals("updated-name")); - Assert.assertTrue(dataResourceModel.getResourceMetadata().size()==1); - dataResourceModel.getResourceMetadata().put("name2","name2"); - datacatalog.updateResource(dataResourceModel); - dataResourceModel = datacatalog.getResource(dataResourceModel.getResourceId()); - Assert.assertTrue(dataResourceModel.getResourceMetadata().size()==2); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testPublishReplicaLocation(){ - try { - String resourceId = datacatalog.registerResource(dataResourceModel); - replicaLocationModel.setResourceId(resourceId); - String replicaId = datacatalog.registerReplicaLocation(replicaLocationModel); - Assert.assertNotNull(replicaId);; - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testRemoveReplicaLocation(){ - try { - String resourceId = datacatalog.registerResource(dataResourceModel); - replicaLocationModel.setResourceId(resourceId); - String replicaId = datacatalog.registerReplicaLocation(replicaLocationModel); - boolean result = datacatalog.removeReplicaLocation(replicaId); - Assert.assertTrue(result); - result = datacatalog.removeReplicaLocation(replicaLocationModel.getReplicaId()); - Assert.assertFalse(result); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testGetReplicaLocation(){ - try { - String resourceId = datacatalog.registerResource(dataResourceModel); - replicaLocationModel.setResourceId(resourceId); - String replicaId = datacatalog.registerReplicaLocation(replicaLocationModel); - DataReplicaLocationModel persistedCopy = datacatalog.getReplicaLocation(replicaId); - Assert.assertNotNull(persistedCopy); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testUpdateReplicaLocation(){ - try { - String resourceId = datacatalog.registerResource(dataResourceModel); - replicaLocationModel.setResourceId(resourceId); - String replicaId = datacatalog.registerReplicaLocation(replicaLocationModel); - DataReplicaLocationModel persistedCopy = datacatalog.getReplicaLocation(replicaId); - persistedCopy.setReplicaDescription("updated-description"); - datacatalog.updateReplicaLocation(persistedCopy); - persistedCopy = datacatalog.getReplicaLocation(replicaId); - Assert.assertTrue(persistedCopy.getReplicaDescription().equals("updated-description")); - Assert.assertEquals(persistedCopy.getReplicaLocationCategory(), replicaLocationModel.getReplicaLocationCategory()); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } - - @Test - public void testGetAllReplicaLocations(){ - try { - String resourceId = datacatalog.registerResource(dataResourceModel); - replicaLocationModel.setResourceId(resourceId); - datacatalog.registerReplicaLocation(replicaLocationModel); - List<DataReplicaLocationModel> replicaLocationModelList = datacatalog.getAllReplicaLocations(resourceId); - Assert.assertNotNull(replicaLocationModelList.get(0).getReplicaId()); - } catch (DataCatalogException e) { - e.printStackTrace(); - Assert.fail(); - } - } -} \ No newline at end of file
