private void processImport(Sheet sheet, int row) throws Exception {
   PrimitiveType prim = new PrimitiveType();
   prim.setCode(sheet.getColumn(row, "Data Type"));
   prim.setDefinition(sheet.getColumn(row, "Definition"));
   prim.setComment(sheet.getColumn(row, "Comments"));
   prim.setSchemaType(sheet.getColumn(row, "Schema"));
   prim.setRegEx(sheet.getColumn(row, "RegEx"));
   TypeRef td = new TypeRef();
   td.setName(prim.getCode());
   definitions.getKnownTypes().add(td);
   definitions.getPrimitives().put(prim.getCode(), prim);
 }
  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 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);
   }
 }
  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;
  }
  private void processLine(List<BindingSpecification> results, Sheet sheet, int row)
      throws Exception {
    BindingSpecification cd = new BindingSpecification();
    cd.setName(sheet.getColumn(row, "Binding Name"));
    if (!cd.getName().startsWith("!")) {
      cd.setDefinition(sheet.getColumn(row, "Definition"));
      cd.setBinding(readBinding(sheet.getColumn(row, "Binding")));
      cd.setReference(sheet.getColumn(row, "Reference"));
      if (!cd.getBinding().equals(Binding.Unbound) && Utilities.noString(cd.getReference()))
        throw new Exception("binding " + cd.getName() + " is missing a reference");
      cd.setDescription(sheet.getColumn(row, "Description"));
      cd.setId(registry.idForName(cd.getName()));
      cd.setSource(filename);
      cd.setUri(sheet.getColumn(row, "Uri"));
      cd.setOid(sheet.getColumn(row, "Oid"));
      cd.setWebSite(sheet.getColumn(row, "Website"));
      cd.setEmail(sheet.getColumn(row, "Email"));
      cd.setV2Map(sheet.getColumn(row, "v2"));
      cd.setV3Map(sheet.getColumn(row, "v3"));

      results.add(cd);
    }
  }
 private void processStringPattern(Sheet sheet, int row) throws Exception {
   DefinedStringPattern prim = new DefinedStringPattern();
   prim.setCode(sheet.getColumn(row, "Data Type"));
   prim.setDefinition(sheet.getColumn(row, "Definition"));
   prim.setComment(sheet.getColumn(row, "Comments"));
   prim.setRegex(sheet.getColumn(row, "RegEx"));
   prim.setSchema(sheet.getColumn(row, "Schema"));
   prim.setBase(sheet.getColumn(row, "Base"));
   TypeRef td = new TypeRef();
   td.setName(prim.getCode());
   definitions.getKnownTypes().add(td);
   definitions.getPrimitives().put(prim.getCode(), prim);
 }
  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);
    }
  }