pbankonier commented on a change in pull request #3294: Set default service 
offering over api and ui
URL: https://github.com/apache/cloudstack/pull/3294#discussion_r279278663
 
 

 ##########
 File path: 
engine/schema/src/main/java/com/cloud/service/dao/ServiceOfferingDaoImpl.java
 ##########
 @@ -289,4 +294,33 @@ public ServiceOfferingVO findDefaultSystemOffering(String 
offeringName, Boolean
         }
         return serviceOffering;
     }
+
+    @Override
+    public long removeUniqueName(String uniqueName){
+      SearchCriteria<ServiceOfferingVO> sc = UniqueNameSearch.create();
+      sc.setParameters("name", uniqueName);
+      List<ServiceOfferingVO> vos = search(sc, null, null, false);
+      if (vos.size() != 0) {
+        ServiceOfferingVO seVo = vos.get(0);
+        seVo.setUniqueName(null);
+        seVo.setDefaultUse(false);
+        update(seVo.getId(), seVo);
+        return seVo.getId();
+      } else {
+        return 0;
+      }
+    }
+
+    @Override
+    public void resetUniqueName(long id, String uniqueName){
+      SearchCriteria<ServiceOfferingVO> sc = IdSearch.create();
+      sc.setParameters("id", id);
+      List<ServiceOfferingVO> vos = search(sc, null, null, false);
+      if (vos.size() != 0) {
+        ServiceOfferingVO seVo = vos.get(0);
+        seVo.setUniqueName(uniqueName);
+        seVo.setDefaultUse(true);
 
 Review comment:
   I implemented this function so the uniquename and default status of the 
previously default service offering gets reset to the old values when 
persisting the new one fails.

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


With regards,
Apache Git Services

Reply via email to