[ 
https://issues.apache.org/jira/browse/AIRAVATA-2619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16434151#comment-16434151
 ] 

ASF GitHub Bot commented on AIRAVATA-2619:
------------------------------------------

DImuthuUpe commented on a change in pull request #182: [AIRAVATA-2619] 
Refactoring App Catalog implementation - StorageResource
URL: https://github.com/apache/airavata/pull/182#discussion_r180818018
 
 

 ##########
 File path: 
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/StorageResourceRepository.java
 ##########
 @@ -0,0 +1,197 @@
+/*
+ * 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.repositories.appcatalog;
+
+import 
org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription;
+import org.apache.airavata.model.commons.airavata_commonsConstants;
+import 
org.apache.airavata.registry.core.entities.appcatalog.StorageInterfaceEntity;
+import 
org.apache.airavata.registry.core.entities.appcatalog.StorageInterfacePK;
+import 
org.apache.airavata.registry.core.entities.appcatalog.StorageResourceEntity;
+import org.apache.airavata.registry.core.utils.AppCatalogUtils;
+import org.apache.airavata.registry.core.utils.DBConstants;
+import org.apache.airavata.registry.core.utils.QueryConstants;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.apache.airavata.registry.cpi.StorageResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by skariyat on 3/12/18.
+ */
+public class StorageResourceRepository extends 
AppCatAbstractRepository<StorageResourceDescription, StorageResourceEntity, 
String> implements StorageResource {
+
+    private final static Logger logger = 
LoggerFactory.getLogger(StorageResourceRepository.class);
+
+
+    public StorageResourceRepository() {
+        super(StorageResourceDescription.class, StorageResourceEntity.class);
+    }
+
+
+    @Override
+    public String addStorageResource(StorageResourceDescription description) 
throws AppCatalogException {
+        try {
+            final String storageResourceId = 
AppCatalogUtils.getID(description.getHostName());
+            if (description.getStorageResourceDescription().equals("") || 
description.getStorageResourceId().equals(airavata_commonsConstants.DEFAULT_ID))
 {
+                description.setStorageResourceId(storageResourceId);
+            }
+            description.setCreationTime(System.currentTimeMillis());
+            if (description.getDataMovementInterfaces() != null) {
+                description.getDataMovementInterfaces().stream().forEach(dm -> 
dm.setStorageResourceId(description.getStorageResourceId()));
+            }
+            StorageResourceDescription storageResourceDescription = 
create(description);
+            return storageResourceDescription.getStorageResourceId();
+        } catch (Exception e) {
+            logger.error("Error while saving storage resource...", e);
+            throw new AppCatalogException(e);
+        }
+    }
+
+    @Override
+    public void updateStorageResource(String storageResourceId, 
StorageResourceDescription updatedStorageResource) throws AppCatalogException {
+        try {
+            updatedStorageResource.setUpdateTime(System.currentTimeMillis());
+            if (updatedStorageResource.getDataMovementInterfaces() != null) {
+                
updatedStorageResource.getDataMovementInterfaces().stream().forEach(dm -> 
dm.setStorageResourceId(updatedStorageResource.getStorageResourceId()));
+            }
+            update(updatedStorageResource);
+        } catch (Exception e) {
+            logger.error("Error while updating storage resource...", e);
+            throw new AppCatalogException(e);
+        }
+    }
+
+    @Override
+    public StorageResourceDescription getStorageResource(String resourceId) 
throws AppCatalogException {
+        try {
+            return get(resourceId);
+        } catch (Exception e) {
+            logger.error("Error while retrieving storage resource...", e);
+            throw new AppCatalogException(e);
+        }
+    }
+
+    @Override
+    public List<StorageResourceDescription> getStorageResourceList(Map<String, 
String> filters) throws AppCatalogException {
+        try {
+            if (filters.containsKey(DBConstants.StorageResource.HOST_NAME)) {
+                Map<String,Object> queryParameters = new HashMap<>();
+                queryParameters.put(DBConstants.ComputeResource.HOST_NAME, 
filters.get(DBConstants.StorageResource.HOST_NAME));
+                List<StorageResourceDescription> 
storageResourceDescriptionList = select(QueryConstants.FIND_STORAGE_RESOURCE, 
-1, 0, queryParameters);
+
+                return storageResourceDescriptionList;
+            }
 
 Review comment:
   } else {

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Refactoring App Catalog implementation
> --------------------------------------
>
>                 Key: AIRAVATA-2619
>                 URL: https://issues.apache.org/jira/browse/AIRAVATA-2619
>             Project: Airavata
>          Issue Type: Sub-task
>            Reporter: Sachin Kariyattin
>            Assignee: Sachin Kariyattin
>            Priority: Major
>
> The app catalog module contains the following Impl classes.
> {quote}ApplicationDeploymentImpl
>  ApplicationInterfaceImpl
>  ComputeResourceImpl
>  GwyResourceProfileImpl
>  StorageResourceImpl
>  UsrResourceProfileImpl
> {quote}
> This task involves creating a repository class for app catalog and include 
> all the methods from the Impl classes mentioned above. As a modular approach 
> is being followed, to start of, only methods GwyResourceProfileImpl will be 
> considered. So the RegistryServiceHandler methods only with respect to 
> GwyResourceProfileImpl will be modified. Subsequently all methods related to 
> app catalog will be refactored.
> *Progress*:
>  * Implemeted GatewayResourceProfileRepository.
>  * Implemented ComputeResourceRepository.
>  * Implemented StorageResourceRepository.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to