Author: jleroux
Date: Sat Sep 10 09:27:54 2016
New Revision: 1760139

URL: http://svn.apache.org/viewvc?rev=1760139&view=rev
Log:
Fix for "The entity description labels are considered not used by the Label 
Manager"
OFBIZ-8154

We had 5237 "Not Used Labels". I wondered if they were all real. There is 
actually a huge bunch of *.description.* labels and alike which are certainly 
used, notably automatically by the widget dropdowns. 
This commit removes them from the "Only Not Used Labels" result. Net result: 
from 5237 to decent 2188 "Not Used Labels", this begins to be useful...

It only begins because I removed from the "Not Used Labels" a number of other 
cases similar to the obvious *.description.* labels. those are
.transitionName.
.partyRelationshipName.
.geoName.
.categoryName.
.ProductPromoCondition..
.ProductPromoOperatorEquality..
.Example. // TODO check all is used here

But a number of others need to be verified, at least:
FormFieldTitle_???
FieldDescription.ProductStore.???
FieldDescription.ProdCatalog.???
HumanResServices.???
.portalPageName.???
ProductShipmentUomAbbreviation_???
ProductStoreGroup.productStoreGroupName._NA_???
TemporalExpression_???

Also to look at:
FormFieldTitle_timesheetPartyId x2
Labels after WorkEffortWorkEffortIdEmpty

Modified:
    
ofbiz/trunk/framework/webtools/groovyScripts/labelmanager/LabelManager.groovy
    
ofbiz/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelManagerFactory.java
    
ofbiz/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java

Modified: 
ofbiz/trunk/framework/webtools/groovyScripts/labelmanager/LabelManager.groovy
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/groovyScripts/labelmanager/LabelManager.groovy?rev=1760139&r1=1760138&r2=1760139&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/webtools/groovyScripts/labelmanager/LabelManager.groovy 
(original)
+++ 
ofbiz/trunk/framework/webtools/groovyScripts/labelmanager/LabelManager.groovy 
Sat Sep 10 09:27:54 2016
@@ -22,7 +22,7 @@ import org.apache.ofbiz.webtools.labelma
 
 LabelManagerFactory factory = LabelManagerFactory.getInstance();
 context.factory = factory;
-factory.findMatchingLabels(parameters.labelComponentName, 
parameters.labelFileName, parameters.labelKey, parameters.labelLocaleName)
+factory.findMatchingLabels(parameters.labelComponentName, 
parameters.labelFileName, parameters.labelKey, parameters.labelLocaleName, 
"Y".equals(parameters.onlyNotUsedLabels))
 context.labels = factory.getLabels();
 context.labelsList = factory.getLabelsList();
 context.localesFound = factory.getLocalesFound();

Modified: 
ofbiz/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelManagerFactory.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelManagerFactory.java?rev=1760139&r1=1760138&r2=1760139&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelManagerFactory.java
 (original)
+++ 
ofbiz/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/LabelManagerFactory.java
 Sat Sep 10 09:27:54 2016
@@ -101,7 +101,8 @@ public class LabelManagerFactory {
         }
     }
 
-    public void findMatchingLabels(String component, String fileName, String 
key, String locale) throws MalformedURLException, SAXException, 
ParserConfigurationException, IOException, GeneralException {
+    public void findMatchingLabels(String component, String fileName, String 
key, String locale, boolean onlyNotUsedLabels) 
+            throws MalformedURLException, SAXException, 
ParserConfigurationException, IOException, GeneralException {
         if (UtilValidate.isEmpty(component) && UtilValidate.isEmpty(fileName) 
&& UtilValidate.isEmpty(key) && UtilValidate.isEmpty(locale)) {
             // Important! Don't allow unparameterized queries - doing so will 
result in loading the entire project into memory
             return;
@@ -123,6 +124,18 @@ public class LabelManagerFactory {
                 if (propertyNode instanceof Element) {
                     Element propertyElem = (Element) propertyNode;
                     String labelKey = 
UtilCodec.canonicalize(propertyElem.getAttribute("key"));
+                    if (onlyNotUsedLabels 
+                            && (labelKey.contains(".description.") 
+                                    || labelKey.contains(".transitionName.")
+                                    || 
labelKey.contains(".partyRelationshipName.")
+                                    || labelKey.contains(".geoName.")
+                                    || labelKey.contains(".categoryName.")
+                                    || 
labelKey.contains(".ProductPromoCondition..")
+                                    || 
labelKey.contains(".ProductPromoOperatorEquality..")
+                                    || labelKey.contains(".Example.") // TODO 
check all is used here
+                                    )) { 
+                        continue; // OFBIZ-8154
+                    }
                     String labelComment = "";
                     for (Node valueNode : 
UtilXml.childNodeList(propertyElem.getFirstChild())) {
                         if (valueNode instanceof Element) {

Modified: 
ofbiz/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java?rev=1760139&r1=1760138&r2=1760139&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java
 (original)
+++ 
ofbiz/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java
 Sat Sep 10 09:27:54 2016
@@ -75,7 +75,7 @@ public class SaveLabelsToXmlFile {
                 return 
ServiceUtil.returnFailure(UtilProperties.getMessage(resource, 
"saveLabelsToXmlFile.exceptionDuringSaveLabelsToXmlFile", locale));
             }
             synchronized(SaveLabelsToXmlFile.class) {
-                factory.findMatchingLabels(null, fileName, null, null);
+                factory.findMatchingLabels(null, fileName, null, null, false);
                 Map<String, LabelInfo> labels = factory.getLabels();
                 Set<String> labelsList = factory.getLabelsList();
                 Set<String> localesFound = factory.getLocalesFound();


Reply via email to