use of easik.xml.xsd.nodes.types.XSDType in project fql by CategoricalData.
the class XSDExporter method createConstraint.
/**
* Add an annotation explaining the product.
* <p/>
* Today, this is simply done by creating an annotation. For example in the
* standard product constraint in constraints.easik gives this annotation:
*
* <pre>
* <xs:annotation>
* <xs:documentation>
* ForAll.elem1 in (P1), ForAll.elem2 in (P2)
* Exists.p=(elem1,elem2) in Product
* </xs:documentation>
* </xs:annotation>
* </pre>
*
* @param prod
* the product diagram constraint.
*/
private void createConstraint(final ProductConstraint<SketchFrame, SketchGraphModel, Sketch, EntityNode, SketchEdge> prod) {
final List<ModelPath<SketchFrame, SketchGraphModel, Sketch, EntityNode, SketchEdge>> paths = prod.getPaths();
final EntityNode dom = paths.get(0).getDomain();
final XSDType domType = dom.getXsdType();
final List<String> elts = new ArrayList<>(paths.size());
int id = 0;
@SuppressWarnings("unused") final String keyrefName = Easik.getInstance().getSettings().getProperty("xml_keyref_name");
final List<String> values = new ArrayList<>(paths.size());
for (final ModelPath<SketchFrame, SketchGraphModel, Sketch, EntityNode, SketchEdge> path : paths) {
id++;
final LinkedList<SketchEdge> tmpPath = new LinkedList<>(path.getEdges());
tmpPath.removeFirst();
final String elem = "elem" + id;
elts.add(elem);
if (tmpPath.size() == 0) {
values.add("ForAll." + elem + " in (" + path.getCoDomain().getName() + ')');
} else {
values.add("ForAll." + elem + " in " + xmlJoinPath(tmpPath, true));
}
}
final String documentation = EasikTools.join(", ", values);
final String elements = "Exists.p=(" + EasikTools.join(",", elts) + ") in " + dom.getName();
domType.addAnnotation(new XSDAnnotation(documentation + lineSep + elements));
}
Aggregations