import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
* Named search filters.
*/
private transient Map<String, Map<String, Object>> _filter = null;
- /**
- * Default document types structured by step.formats.
- */
- private transient Map<String, DocumentType> _defdoctype = null;
/**
* Available template files.
*/
gprop.put("title", "");
gprop.put("context", new ArrayList<SimulationContext>());
- _defdoctype = new LinkedHashMap<String, DocumentType>();
- _tempfile = new HashMap<String, String>();
- _viewermap = new String[0];
- _convertmap = new HashMap<String, Converter>();
_filter = new HashMap<String, Map<String, Object>>();
_filter.put("study", fprop);
_filter.put("knowledge", gprop);
+ _tempfile = new HashMap<String, String>();
+ _viewermap = new String[0];
+ _convertmap = new HashMap<String, Converter>();
+
// Customization (must be done after above default settings)
File config = new File(filename);
if (config.exists()) {
+ config.getAbsolutePath() + "\", using default settings");
}
// Settings based on the customization
- _bars = new HashMap<Integer, ToolBar>(); // May be empty if no module installed
-
configureToolbars();
}
* Configure toolbars for steps.
*/
private void configureToolbars() {
+ _bars = new HashMap<Integer, ToolBar>(); // May be empty if no module installed
+
List<ProjectSettingsService.Step> steps = getProjectSettings()
.getAllSteps();
for (Iterator<ProjectSettingsService.Step> i = steps.iterator(); i
.hasNext();) {
ProjectSettingsService.Step step = i.next();
- List<String> formats = getDefaultFormats(step);
+ List<String> formats = getProjectSettings().getDefaultFormats(step);
if (formats.isEmpty()) {
continue;
}
module.add(command);
String[] parsed = command.split("/");
String[] name = parsed[parsed.length - 1].split("\\x2E");
- DocumentType dtype = MY_APP._defdoctype.get(step.getNumber()
- + "." + format);
+ DocumentType dtype = getProjectSettings()
+ .getDefaultDocumentType(step, format);
String docname = "";
if (dtype != null) {
docname = dtype.getName();
return MY_APP._convertmap.get(format + type.getName()); // May be null;
}
- public static DocumentType getDefaultDocumentType(final Step step,
+ public DocumentType getDefaultDocumentType(final Step step,
final String format) {
- String[] table = format.split("\\x2E");
- return MY_APP._defdoctype.get(step.getNumber() + "."
- + table[table.length - 1]); // May be null
+ return getProjectSettings().getDefaultDocumentType(step.getStep(),
+ format); // May be null
}
public static String getDownloadURL(final User user) {
// Private services
// ==============================================================================================================================
- private List<String> getDefaultFormats(
- final ProjectSettingsService.Step step) {
- Set<String> keys = _defdoctype.keySet();
- int number = step.getNumber();
- List<String> result = new ArrayList<String>();
-
- for (Iterator<String> i = keys.iterator(); i.hasNext();) {
- String[] key = i.next().split("\\x2E");
- if (Integer.valueOf(key[0]) != number) {
- continue;
- }
- if (key[1].equals("pdf")) {
- continue; // PDF is not an authoring format
- }
- result.add(key[1]); // Formats are unique
- }
- return result;
- }
-
/**
* Load customization of workflow from the given XML file.
- * @param config the XML configuration file
+ *
+ * @param config
+ * the XML configuration file
*/
private void loadCustomization(final File config) {
try {
HashMap<String, Node> children = XDOM.getNamedChildNodes(conf
.getDocumentElement());
- // Load default document types.
- loadDocTypes(children);
-
// Modules tag
loadModules(children);
}
}
- /**
- * Load default document types from XML configuration.
- *
- * @param children
- * XML nodes
- */
- private void loadDocTypes(final Map<String, Node> children) {
- Node child = children.get("default-doctypes");
- NodeList nlist = child.getChildNodes();
-
- List<DocumentType> listype = getDocumentTypeService().selectAllTypes();
- Map<String, DocumentType> maptype = new HashMap<String, DocumentType>();
- for (Iterator<DocumentType> i = listype.iterator(); i.hasNext();) {
- DocumentType type = i.next();
- maptype.put(type.getName(), type);
- }
- for (int i = 0; i < nlist.getLength(); i++) {
- child = nlist.item(i);
- if (!child.getNodeName().equals("step")) {
- continue;
- }
-
- String nstep = child.getAttributes().getNamedItem("number")
- .getNodeValue();
- NodeList map = child.getChildNodes();
- for (int j = 0; j < map.getLength(); j++) {
- child = map.item(j);
- if (!child.getNodeName().equals("mapping")) {
- continue;
- }
- NamedNodeMap natr = child.getAttributes();
- String dext = natr.getNamedItem("extension").getNodeValue();
- String type = natr.getNamedItem("type").getNodeValue();
- _defdoctype.put(nstep + "." + dext, maptype.get(type));
- }
- }
- }
-
/**
* Get the documentTypeService.
*