* Configuration document validation cycles.
*/
private transient List<ProjectSettingsValidationCycle> _concycles;
+ /**
+ * Document type mappings to file formats which should be imported into SALOME during check-out.
+ */
+ private transient Map<String, List<String>> _mapimport;
// Temporary attributes initialized from the configuration file for populating the database with object types
/**
return result;
}
+ /**
+ * Check if a file of the given format should be imported during check-in of a document of the given type.
+ *
+ * @param type
+ * document type
+ * @param format
+ * file format
+ * @return true if file should be imported
+ */
+ public boolean doImport(final String type, final String format) {
+ return (_mapimport.containsKey(type) && _mapimport.get(type).contains(
+ format));
+ }
+
/**
* Initialize the database: create all necessary default staff defined in the configuration file.
*/
// Validations tag
_concycles = loadValidationCycles(children, resultype);
+ _mapimport = loadFormatMappings(children);
+
if (!getDatabase().getCheckedDB().isInitialized()) {
// Load object type definitions
// Documents tag
}
}
+ /**
+ * Load mappings of document types to lists of importable file formats.
+ *
+ * @param children
+ * XML nodes
+ * @return map of document type names to lists of file formats
+ */
+ private Map<String, List<String>> loadFormatMappings(
+ final Map<String, Node> children) {
+ Map<String, List<String>> res = new HashMap<String, List<String>>();
+ Element maps = (Element) children.get("mappings");
+ Element doc, imp;
+ String type, format;
+ List<String> formats;
+ NodeList docs, imports;
+ if (maps != null) {
+ // Read document types
+ docs = maps.getElementsByTagName("document");
+ for (int i = 0; i < docs.getLength(); i++) {
+ doc = (Element) docs.item(i);
+ type = doc.getAttribute("type");
+ if (!type.isEmpty()) {
+ // Read file formats for the document type
+ imports = doc.getElementsByTagName("import");
+ formats = new ArrayList<String>();
+ for (int j = 0; j < imports.getLength(); j++) {
+ imp = (Element) imports.item(j);
+ format = imp.getAttribute("format");
+ if (!format.isEmpty()) {
+ formats.add(format);
+ }
+ }
+ if (!formats.isEmpty()) {
+ res.put(type, formats);
+ }
+ }
+ }
+ }
+ return res;
+ }
+
/**
* Load a step from the given XML node. Return the next step's number.
*
final List<String> resultype) {
int res = snum;
if ("step".equals(node.getNodeName())) {
-
- String name = ((Element)node).getAttribute("name");
+
+ String name = ((Element) node).getAttribute("name");
HashMap<String, Node> tags = XDOM.getNamedChildNodes(node);
NamedNodeMap natr = tags.get("storage").getAttributes();
if (slist != null) {
uses = _mapuse.get(type);
step = mapresult.get(type);
-
+
tprop.clear();
tprop.setName(type).setStep(
slist.toArray(new ProjectSettingsService.Step[slist
if (uses != null) {
tdoc = maptype.get(uses);
if (tdoc == null) {
- LOG.warn("Undefined \"" + uses + "\" document type.");
+ LOG.warn("Undefined \"" + uses
+ + "\" document type.");
} else {
tprop.setUses(tdoc);
}
if (step != null) {
tprop.setResult(step);
}
-
+
tprop.disableCheck();
tdoc = getDocumentTypeService().createType(tprop); // Creation of Document Types
getDocumentTypeService().approve(tdoc);