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

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

machristie commented on a change in pull request #185: [AIRAVATA-2712] 
Refactoring App Catalog Implementation - UserResourceProfile
URL: https://github.com/apache/airavata/pull/185#discussion_r176861106
 
 

 ##########
 File path: 
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/UserResourceProfileRepository.java
 ##########
 @@ -0,0 +1,227 @@
+/**
+ *
+ * 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.userresourceprofile.UserComputeResourcePreference;
+import 
org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile;
+import 
org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference;
+import 
org.apache.airavata.registry.core.entities.appcatalog.UserComputeResourcePreferencePK;
+import 
org.apache.airavata.registry.core.entities.appcatalog.UserResourceProfileEntity;
+import 
org.apache.airavata.registry.core.entities.appcatalog.UserResourceProfilePK;
+import 
org.apache.airavata.registry.core.entities.appcatalog.UserStoragePreferencePK;
+import org.apache.airavata.registry.core.utils.DBConstants;
+import org.apache.airavata.registry.core.utils.ObjectMapperSingleton;
+import org.apache.airavata.registry.core.utils.QueryConstants;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.apache.airavata.registry.cpi.CompositeIdentifier;
+import org.apache.airavata.registry.cpi.UsrResourceProfile;
+import org.dozer.Mapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.Timestamp;
+import java.util.*;
+
+public class UserResourceProfileRepository extends 
AppCatAbstractRepository<UserResourceProfile, UserResourceProfileEntity, 
UserResourceProfilePK> implements UsrResourceProfile {
+    private final static Logger logger = 
LoggerFactory.getLogger(UserResourceProfileRepository.class);
+
+    public UserResourceProfileRepository() {
+        super(UserResourceProfile.class, UserResourceProfileEntity.class);
+    }
+
+    protected String saveUserResourceProfileData(UserResourceProfile 
userResourceProfile) throws AppCatalogException {
+        UserResourceProfileEntity userResourceProfileEntity = 
saveUserResourceProfile(userResourceProfile);
+        return userResourceProfileEntity.getUserId();
+    }
+
+    protected UserResourceProfileEntity 
saveUserResourceProfile(UserResourceProfile userResourceProfile) throws 
AppCatalogException {
+        String userId = userResourceProfile.getUserId();
+        String gatewayId = userResourceProfile.getGatewayID();
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        UserResourceProfileEntity userResourceProfileEntity = 
mapper.map(userResourceProfile, UserResourceProfileEntity.class);
+
+        if (userResourceProfileEntity.getUserComputeResourcePreferences() != 
null) {
+            logger.debug("Populating the Primary Key 
UserComputeResourcePreferences objects for the User Resource Profile");
+            
userResourceProfileEntity.getUserComputeResourcePreferences().forEach(userComputeResourcePreferenceEntity
 -> userComputeResourcePreferenceEntity.setUserId(userId));
 
 Review comment:
   No need to forEach twice, you can set both properties. Same on line 68.

----------------------------------------------------------------
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 - User Resource Profile
> --------------------------------------------------------------
>
>                 Key: AIRAVATA-2712
>                 URL: https://issues.apache.org/jira/browse/AIRAVATA-2712
>             Project: Airavata
>          Issue Type: Improvement
>          Components: Registry API
>            Reporter: Sneha Tilak
>            Assignee: Sneha Tilak
>            Priority: Major
>




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

Reply via email to