You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by GitBox <gi...@apache.org> on 2021/07/02 08:43:11 UTC

[GitHub] [ofbiz-framework] SebastianEcomify opened a new pull request #306: Improved: Convert RoutingServices.xml mini-lang to groovy (OFBIZ-11855)

SebastianEcomify opened a new pull request #306:
URL: https://github.com/apache/ofbiz-framework/pull/306


   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ofbiz-framework] sonarcloud[bot] commented on pull request #306: Improved: Convert RoutingServices.xml mini-lang to groovy (OFBIZ-11855)

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on pull request #306:
URL: https://github.com/apache/ofbiz-framework/pull/306#issuecomment-872832375


   Kudos, SonarCloud Quality Gate passed!
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_ofbiz-framework&pullRequest=306&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_ofbiz-framework&pullRequest=306&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_ofbiz-framework&pullRequest=306&resolved=false&types=BUG)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_ofbiz-framework&pullRequest=306&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_ofbiz-framework&pullRequest=306&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_ofbiz-framework&pullRequest=306&resolved=false&types=VULNERABILITY)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=apache_ofbiz-framework&pullRequest=306&resolved=false&types=SECURITY_HOTSPOT) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=apache_ofbiz-framework&pullRequest=306&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_ofbiz-framework&pullRequest=306&resolved=false&types=SECURITY_HOTSPOT)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_ofbiz-framework&pullRequest=306&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_ofbiz-framework&pullRequest=306&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_ofbiz-framework&pullRequest=306&resolved=false&types=CODE_SMELL)
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo.png' alt='No Coverage information' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_ofbiz-framework&pullRequest=306) No Coverage information  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_ofbiz-framework&pullRequest=306&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_ofbiz-framework&pullRequest=306&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ofbiz-framework] priyasharma1 commented on a change in pull request #306: Improved: Convert RoutingServices.xml mini-lang to groovy (OFBIZ-11855)

Posted by GitBox <gi...@apache.org>.
priyasharma1 commented on a change in pull request #306:
URL: https://github.com/apache/ofbiz-framework/pull/306#discussion_r688456719



##########
File path: applications/manufacturing/groovyScripts/routing/RoutingServices.groovy
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.
+ */
+
+import java.sql.Timestamp
+
+import org.apache.ofbiz.base.util.UtilDateTime
+import org.apache.ofbiz.entity.GenericValue
+import org.apache.ofbiz.entity.util.EntityQuery
+
+/**
+ * "Get the product's routing and routing tasks
+ * @return
+ */
+def getProductRouting() {
+    Map result = success()
+    Timestamp filterDate = null
+    GenericValue routingGS = null
+    GenericValue routing = null
+    List tasks = null
+    Map lookupRouting = [productId: parameters.productId, workEffortGoodStdTypeId: "ROU_PROD_TEMPLATE"]
+    // If applicableDate has been passed use the value with all filter-by-date calls
+    if (parameters.applicableDate) {
+        filterDate = parameters.applicableDate
+    }
+    else {
+        filterDate = UtilDateTime.nowTimestamp()
+    }
+
+    // If a workEffortId has been passed, use it to look up the desired routing
+    if (parameters.workEffortId) {
+
+        lookupRouting.workEffortId = parameters.workEffortId
+        routingGS = from("WorkEffortGoodStandard").where(lookupRouting).filterByDate(filterDate).queryFirst()
+
+        // If the routing is not associated with our product and it's a variant, then check to see if it's virtual product has the routing
+        if (!routingGS) {
+            GenericValue virtualProductAssoc = from("ProductAssoc").where(productIdTo: parameters.productId, productAssocTypeId: "PRODUCT_VARIANT").filterByDate().queryFirst()
+            if (virtualProductAssoc) {
+                lookupRouting.productId = virtualProductAssoc.productId
+                // Consider the validity against a date passed as (optional) parameter
+                routingGS = from("WorkEffortGoodStandard").where(lookupRouting).filterByDate(filterDate).queryFirst()
+            }
+        }
+    }
+    // No workEffortId has been passed, so retrieve the first routing found for this product
+    else {
+        // Consider the validity against a date passed as (optional) parameter
+        // TODO: we should consider the quantity to select the best routing
+        routingGS = from("WorkEffortGoodStandard").where(lookupRouting).filterByDate(filterDate).queryFirst()
+        // If there are no routings associated with our product and it's a variant, then check to see if it's virtual product has a routing
+        if (!routingGS) {
+            GenericValue virtualProductAssoc = from("ProductAssoc").where(productIdTo: parameters.productId, productAssocTypeId: "PRODUCT_VARIANT").filterByDate(filterDate).queryFirst()
+            if (virtualProductAssoc) {
+                lookupRouting.productId = virtualProductAssoc.productId
+                lookupRouting.workEffortGoodStdTypeId = "ROU_PROD_TEMPLATE"
+                // Consider the validity against a date passed as (optional) parameter
+                // TODO: we should consider the quantity to select the best routing
+                routingGS = from("WorkEffortGoodStandard").where(lookupRouting).filterByDate(filterDate).queryFirst()
+            }
+        }
+    }
+    if (routingGS) {
+        lookupRouting.clear()
+        lookupRouting.workEffortId = routingGS.workEffortId
+        routing = from("WorkEffort").where(lookupRouting).queryOne()
+    }
+    else {
+        // The default routing is used when no explicit routing is associated to the product and the ignoreDefaultRouting is not equals to Y
+        if (!parameters.ignoreDefaultRouting || parameters.ignoreDefaultRouting.equals("N")) {
+            lookupRouting.clear()
+            lookupRouting.workEffortId = "DEFAULT_ROUTING"
+            routing = from("WorkEffort").where(lookupRouting).queryOne()
+        }
+    }
+    if (routing) {
+        Map lookupTasks = [workEffortIdFrom: routing.workEffortId, workEffortAssocTypeId: "ROUTING_COMPONENT"]
+        List tasksOrder = ["sequenceNum"]

Review comment:
       Hi @SebastianEcomify ,
   Perhaps we can skip this list and instead use orderBy("sequenceNum") on the next line




-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ofbiz-framework] nmalin commented on pull request #306: Improved: Convert RoutingServices.xml mini-lang to groovy (OFBIZ-11855)

Posted by GitBox <gi...@apache.org>.
nmalin commented on pull request #306:
URL: https://github.com/apache/ofbiz-framework/pull/306#issuecomment-916997398


   Thanks @SebastianEcomify I merged it in trunk after some groovy simplification. @priyasharma1 I included your remark on code modification.


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ofbiz-framework] nmalin closed pull request #306: Improved: Convert RoutingServices.xml mini-lang to groovy (OFBIZ-11855)

Posted by GitBox <gi...@apache.org>.
nmalin closed pull request #306:
URL: https://github.com/apache/ofbiz-framework/pull/306


   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org