Author: chatellier Date: 2011-04-26 09:42:02 +0000 (Tue, 26 Apr 2011) New Revision: 3286 Log: Restauration du support "integer" pour les facteurs discrets Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/DomXMLParser.java Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/DomXMLParser.java =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/DomXMLParser.java 2011-04-26 09:22:00 UTC (rev 3285) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/DomXMLParser.java 2011-04-26 09:42:02 UTC (rev 3286) @@ -170,6 +170,69 @@ factor.setDomain(domain); } factorGroup.addFactor(factor); + } else if ("integer".equals(type)) { + Factor factor = new Factor(name); + factor.setPath(path); + Element fixedElement = factorElement.element("domain").element("fixed"); + if ("continuous".equals(property)) { + ContinuousDomain domain = null; + + if(property.equals("matrixcontinuous")) { + // matrix specific + MatrixContinuousDomain mdomain = new MatrixContinuousDomain(); + + Element coefficientElement = fixedElement.element("coefficient"); + mdomain.setCoefficient(Double.valueOf(coefficientElement.attributeValue("value"))); + mdomain.setOperator(coefficientElement.attributeValue("operator")); + + // matrix specific + Element matrixElement = fixedElement.element("mx"); + MatrixND matrix = MexicoHelper.getMatrixFromXml(matrixElement, topiaContext); + mdomain.setMatrix(matrix); + + domain = mdomain; + } + else if (property.equals("equationcontinuous")) { + // equation specific + + EquationContinuousDomain edomain = new EquationContinuousDomain(); + + Element coefficientElement = fixedElement.element("coefficient"); + edomain.setCoefficient(Double.valueOf(coefficientElement.attributeValue("value"))); + edomain.setOperator(coefficientElement.attributeValue("operator")); + + Element equationElement = fixedElement.element("equation"); + edomain.setReferenceValue(Double.valueOf(equationElement.attributeValue("reference"))); + edomain.setVariableName(equationElement.attributeValue("variable")); + + domain = edomain; + } + else { + // continous domain + domain = new ContinuousDomain(); + } + + domain.setCardinality(Integer.valueOf(fixedElement.attributeValue("cardinality"))); + + // <range max="1" min="3"/> + Element rangeElement = fixedElement.element("range"); + domain.setMinBound(Integer.valueOf(rangeElement.attributeValue("min"))); + domain.setMaxBound(Integer.valueOf(rangeElement.attributeValue("max"))); + + factor.setDomain(domain); + } else if ("discrete".equals(property)) { + DiscreteDomain domain = new DiscreteDomain(); + List<Element> valueElements = fixedElement.element( + "enumeration").elements("value"); + int label = 0; + for (Element valueElement : valueElements) { + domain.getValues().put(Integer.valueOf(label), + Integer.valueOf(valueElement.getTextTrim())); + ++label; + } + factor.setDomain(domain); + } + factorGroup.addFactor(factor); } else if ("rule".equals(type)) { Factor factor = new Factor(name); factor.setPath(path);