private void loadCompartments() throws FileNotFoundException, Exception { XLSXmlParser xml = new XLSXmlParser(new CSFileInputStream(srcDir + "compartments.xml"), "compartments.xml"); Sheet sheet = xml.getSheets().get("compartments"); for (int row = 0; row < sheet.rows.size(); row++) { Compartment c = new Compartment(); c.setName(sheet.getColumn(row, "Name")); if (!c.getName().startsWith("!")) { c.setTitle(sheet.getColumn(row, "Title")); c.setDescription(sheet.getColumn(row, "Description")); c.setIdentity(sheet.getColumn(row, "Identification")); c.setMembership(sheet.getColumn(row, "Inclusion")); definitions.getCompartments().add(c); } } sheet = xml.getSheets().get("resources"); for (int row = 0; row < sheet.rows.size(); row++) { String mn = sheet.getColumn(row, "Resource"); if (!mn.startsWith("!")) { ResourceDefn r = definitions.getResourceByName(mn); for (Compartment c : definitions.getCompartments()) { c.getResources().put(r, sheet.getColumn(row, c.getName())); } } } }
private void loadPrimitives() throws Exception { XLSXmlParser xls = new XLSXmlParser(new CSFileInputStream(dtDir + "primitives.xml"), "primitives"); Sheet sheet = xls.getSheets().get("Imports"); for (int row = 0; row < sheet.rows.size(); row++) { processImport(sheet, row); } sheet = xls.getSheets().get("String Patterns"); for (int row = 0; row < sheet.rows.size(); row++) { processStringPattern(sheet, row); } }
private void loadStatusCodes() throws FileNotFoundException, Exception { XLSXmlParser xml = new XLSXmlParser(new CSFileInputStream(srcDir + "status-codes.xml"), "compartments.xml"); Sheet sheet = xml.getSheets().get("Status Codes"); for (int row = 0; row < sheet.rows.size(); row++) { String path = sheet.getColumn(row, "Path"); ArrayList<String> codes = new ArrayList<String>(); for (int i = 1; i <= 80; i++) { String s = sheet.getColumn(row, "c" + Integer.toString(i)); if (!Utilities.noString(s)) codes.add(s); } definitions.getStatusCodes().put(path, codes); } }
private String loadCompositeType(String n, Map<String, ElementDefn> map) throws Exception { TypeParser tp = new TypeParser(); List<TypeRef> ts = tp.parse(n); definitions.getKnownTypes().addAll(ts); try { TypeRef t = ts.get(0); File csv = new CSFile(dtDir + t.getName().toLowerCase() + ".xml"); if (csv.exists()) { SpreadsheetParser p = new SpreadsheetParser( new CSFileInputStream(csv), csv.getName(), definitions, srcDir, logger, registry); ElementDefn el = p.parseCompositeType(); map.put(t.getName(), el); el.getAcceptableGenericTypes().addAll(ts.get(0).getParams()); return el.getName(); } else { String p = ini.getStringProperty("types", n); csv = new CSFile(dtDir + p.toLowerCase() + ".xml"); if (!csv.exists()) throw new Exception("unable to find a definition for " + n + " in " + p); XLSXmlParser xls = new XLSXmlParser(new CSFileInputStream(csv), csv.getAbsolutePath()); Sheet sheet = xls.getSheets().get("Restrictions"); boolean found = false; for (int i = 0; i < sheet.rows.size(); i++) { if (sheet.getColumn(i, "Name").equals(n)) { found = true; Invariant inv = new Invariant(); inv.setId(n); inv.setEnglish(sheet.getColumn(i, "Rules")); inv.setOcl(sheet.getColumn(i, "OCL")); inv.setXpath(sheet.getColumn(i, "XPath")); definitions.getConstraints().put(n, new DefinedCode(n, sheet.getColumn(i, "Rules"), p)); definitions.getConstraintInvariants().put(n, inv); } } if (!found) throw new Exception("Unable to find definition for " + n); return n; } } catch (Exception e) { throw new Exception("Unable to load " + n + ": " + e.getMessage(), e); } }
public List<BindingSpecification> parse() throws Exception { List<BindingSpecification> results = new ArrayList<BindingSpecification>(); // BindingSpecification n = new BindingSpecification(); // n.setName("*unbound*"); // n.setBinding(BindingSpecification.Binding.Unbound); // results.add(n); xls = new XLSXmlParser(file, filename); Sheet sheet = xls.getSheets().get("Bindings"); for (int row = 0; row < sheet.rows.size(); row++) { processLine(results, sheet, row); } return results; }
public boolean loadCodes(BindingSpecification cd) throws Exception { // TODO Auto-generated method stub Sheet sheet = xls.getSheets().get(cd.getReference().substring(1)); if (sheet == null) return false; for (int row = 0; row < sheet.rows.size(); row++) { DefinedCode c = new DefinedCode(); c.setId(sheet.getColumn(row, "Id")); c.setCode(sheet.getColumn(row, "Code")); c.setDisplay(sheet.getColumn(row, "Display")); c.setSystem(sheet.getColumn(row, "System")); c.setDefinition(sheet.getColumn(row, "Definition")); c.setComment(sheet.getColumn(row, "Comment")); c.setV2Map(sheet.getColumn(row, "v2")); c.setV3Map(sheet.getColumn(row, "v3")); cd.getCodes().add(c); } return true; }