details: https://code.openbravo.com/erp/stable/2.50/rev/074104a1d8e2 changeset: 9570:074104a1d8e2 user: Antonio Moreno <antonio.moreno <at> openbravo.com> date: Wed Jul 13 13:18:53 2011 +0200 summary: Related to issue 16743. Reformat file
details: https://code.openbravo.com/erp/stable/2.50/rev/43a7836496f5 changeset: 9571:43a7836496f5 user: Antonio Moreno <antonio.moreno <at> openbravo.com> date: Wed Jul 13 13:33:25 2011 +0200 summary: Fixed issue 16743.Datasets shouldn't have formal changes when reexported. Two changes have been made: - Children BaseOBObjects will be sorted in the same way as their parents already were. - List properties will now be generated with a defined order, as the Entities will now be created following a defined order diffstat: src/org/openbravo/base/model/ModelProvider.java | 16 +++++++++++----- src/org/openbravo/dal/xml/EntityXMLConverter.java | 8 ++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diffs (79 lines): diff -r eb0bd3712933 -r 43a7836496f5 src/org/openbravo/base/model/ModelProvider.java --- a/src/org/openbravo/base/model/ModelProvider.java Mon Jul 11 16:12:53 2011 +0200 +++ b/src/org/openbravo/base/model/ModelProvider.java Wed Jul 13 13:33:25 2011 +0200 @@ -21,6 +21,8 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -147,6 +149,11 @@ log.debug("Read model from db"); tables = list(session, Table.class); + Collections.sort(tables, new Comparator<Table>() { + public int compare(Table t1, Table t2) { + return t1.getName().compareTo(t2.getName()); + } + }); referencesById = new HashMap<String, Reference>(); final List<Reference> references = list(session, Reference.class); @@ -202,7 +209,7 @@ entitiesByTableName = new HashMap<String, Entity>(); entitiesByTableId = new HashMap<String, Entity>(); entitiesWithTreeType = new ArrayList<Entity>(); - for (final Table t : tablesByTableName.values()) { + for (final Table t : tables) { log.debug("Building model for table " + t.getTableName()); final Entity e = new Entity(); e.initialize(t); @@ -384,10 +391,9 @@ final Column thatColumn = c.getReferenceType(); if (thatColumn == null) { if (!OBPropertiesProvider.isFriendlyWarnings()) { - log - .error("Property " - + thisProp - + " is mapped incorrectly, there is no referenced column for it, removing from the mapping"); + log.error("Property " + + thisProp + + " is mapped incorrectly, there is no referenced column for it, removing from the mapping"); } thisProp.getEntity().getProperties().remove(thisProp); if (thisProp.getEntity().getIdProperties().remove(thisProp)) { diff -r eb0bd3712933 -r 43a7836496f5 src/org/openbravo/dal/xml/EntityXMLConverter.java --- a/src/org/openbravo/dal/xml/EntityXMLConverter.java Mon Jul 11 16:12:53 2011 +0200 +++ b/src/org/openbravo/dal/xml/EntityXMLConverter.java Wed Jul 13 13:33:25 2011 +0200 @@ -23,6 +23,7 @@ import java.io.Writer; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; @@ -58,6 +59,7 @@ import org.openbravo.model.ad.utility.DataSetTable; import org.openbravo.model.ad.utility.TreeNode; import org.openbravo.service.dataset.DataSetService; +import org.openbravo.service.dataset.DataSetService.BaseOBIDHexComparator; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; @@ -417,8 +419,10 @@ xmlHandler.startElement("", "", p.getName(), propertyAttrs); // get all the children and export each child - final Collection<?> c = (Collection<?>) value; - for (final Object o : c) { + final Collection<BaseOBObject> c = (Collection<BaseOBObject>) value; + List<BaseOBObject> childObjects = new ArrayList<BaseOBObject>(c); + Collections.sort(childObjects, new BaseOBIDHexComparator()); + for (final Object o : childObjects) { // embed in the parent if (isOptionEmbedChildren()) { export((BaseOBObject) o, false); ------------------------------------------------------------------------------ AppSumo Presents a FREE Video for the SourceForge Community by Eric Ries, the creator of the Lean Startup Methodology on "Lean Startup Secrets Revealed." This video shows you how to validate your ideas, optimize your ideas and identify your business strategy. http://p.sf.net/sfu/appsumosfdev2dev _______________________________________________ Openbravo-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
