org.intermine.metadata.Model.getClassDescriptors()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(19.5k)|赞(0)|评价(0)|浏览(164)

本文整理了Java中org.intermine.metadata.Model.getClassDescriptors()方法的一些代码示例,展示了Model.getClassDescriptors()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.getClassDescriptors()方法的具体详情如下:
包路径:org.intermine.metadata.Model
类名称:Model
方法名:getClassDescriptors

Model.getClassDescriptors介绍

[英]Get all ClassDescriptors in this model.
[中]获取此模型中的所有类描述符。

代码示例

代码示例来源:origin: intermine/intermine

/**
 * Return ClassDescriptors for simple objects only - simple objects are light weight objects
 * without an id and with no inheritance.  They can't be interfaces and inherit directly from
 * java.lang.Object.
 * @return a set of ClassDescriptors for all simple objects in the model
 */
protected Set<ClassDescriptor> getSimpleObjectClassDescriptors() {
  Set<ClassDescriptor> simpleObjectClds = new HashSet<ClassDescriptor>();
  for (ClassDescriptor cld : getClassDescriptors()) {
    Set<String> superNames = cld.getSuperclassNames();
    if (superNames.size() == 1 && superNames.contains("java.lang.Object")) {
      simpleObjectClds.add(cld);
    }
  }
  return simpleObjectClds;
}

代码示例来源:origin: org.intermine/intermine-model

/**
 * Return ClassDescriptors for simple objects only - simple objects are light weight objects
 * without an id and with no inheritance.  They can't be interfaces and inherit directly from
 * java.lang.Object.
 * @return a set of ClassDescriptors for all simple objects in the model
 */
protected Set<ClassDescriptor> getSimpleObjectClassDescriptors() {
  Set<ClassDescriptor> simpleObjectClds = new HashSet<ClassDescriptor>();
  for (ClassDescriptor cld : getClassDescriptors()) {
    Set<String> superNames = cld.getSuperclassNames();
    if (superNames.size() == 1 && superNames.contains("java.lang.Object")) {
      simpleObjectClds.add(cld);
    }
  }
  return simpleObjectClds;
}

代码示例来源:origin: org.intermine/intermine-model

/**
 * Used to generate the SO additions file
 * @return the model as an additions file
 */
public String toAdditionsXML() {
  StringBuffer sb = new StringBuffer();
  sb.append("<?xml version=\"1.0\"?>"  + ENDL + "<classes>" + ENDL);
  for (ClassDescriptor cld : getClassDescriptors()) {
    if (!"org.intermine.model.InterMineObject".equals(cld.getName())) {
      sb.append(cld.toString());
    }
  }
  sb.append("</classes>");
  return sb.toString();
}

代码示例来源:origin: intermine/intermine

/**
 * Used to generate the SO additions file
 * @return the model as an additions file
 */
public String toAdditionsXML() {
  StringBuffer sb = new StringBuffer();
  sb.append("<?xml version=\"1.0\"?>"  + ENDL + "<classes>" + ENDL);
  for (ClassDescriptor cld : getClassDescriptors()) {
    if (!"org.intermine.model.InterMineObject".equals(cld.getName())) {
      sb.append(cld.toString());
    }
  }
  sb.append("</classes>");
  return sb.toString();
}

代码示例来源:origin: org.intermine/intermine-model

/**
 * {@inheritDoc}
 */
@Override
public String toString() {
  StringBuffer sb = new StringBuffer();
  sb.append("<model"
      + " name=\"" + modelName + "\""
      + " package=\"" + packageName + "\""
      + ((version == 0) ? "" : " version=\"" + version + "\"")
      + ">" + ENDL);
  for (ClassDescriptor cld : getClassDescriptors()) {
    if (!"org.intermine.model.InterMineObject".equals(cld.getName())) {
      sb.append(cld.toString());
    }
  }
  sb.append("</model>");
  return sb.toString();
}

代码示例来源:origin: intermine/intermine

/**
 * {@inheritDoc}
 */
@Override
public String toString() {
  StringBuffer sb = new StringBuffer();
  sb.append("<model"
      + " name=\"" + modelName + "\""
      + " package=\"" + packageName + "\""
      + ((version == 0) ? "" : " version=\"" + version + "\"")
      + ">" + ENDL);
  for (ClassDescriptor cld : getClassDescriptors()) {
    if (!"org.intermine.model.InterMineObject".equals(cld.getName())) {
      sb.append(cld.toString());
    }
  }
  sb.append("</model>");
  return sb.toString();
}

代码示例来源:origin: intermine/intermine

for (ClassDescriptor cld : model.getClassDescriptors()) {
  String cldName = cld.getName();
  if (!"org.intermine.model.InterMineObject".equals(cldName)) {

代码示例来源:origin: org.intermine/intermine-model

for (ClassDescriptor cld : model.getClassDescriptors()) {
  String cldName = cld.getName();
  if (!"org.intermine.model.InterMineObject".equals(cldName)) {

代码示例来源:origin: intermine/intermine

location.put("objectName", resolveValue(o, identPath));
for (ClassDescriptor cd: im.getModel().getClassDescriptors()) {
  if ("InterMineObject".equals(cd.getUnqualifiedName())) {
    continue;

代码示例来源:origin: org.intermine/intermine-jbrowse-endpoint

location.put("objectName", resolveValue(o, identPath));
for (ClassDescriptor cd: im.getModel().getClassDescriptors()) {
  if ("InterMineObject".equals(cd.getUnqualifiedName())) {
    continue;

代码示例来源:origin: intermine/intermine

public void testAddAttribute() throws Exception {
  String modelStr = "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\"><class name=\"org.intermine.model.testmodel.Secretary\" is-interface=\"false\"><attribute name=\"name\" type=\"java.lang.String\"/></class></model>";
  Model model = parser.process(new StringReader(modelStr));
  String addition = "<class name=\"org.intermine.model.testmodel.Secretary\" is-interface=\"false\"><attribute name=\"age\" type=\"java.lang.Integer\"/></class>";
  Set additionClds = parser.generateClassDescriptors(new StringReader(addition), model.getPackageName());
  String expected = "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\"><class name=\"org.intermine.model.testmodel.Secretary\" is-interface=\"false\"><attribute name=\"name\" type=\"java.lang.String\"/><attribute name=\"age\" type=\"java.lang.Integer\"/></class></model>";
  //assertXMLEqual(expected, xml);
  assertEquals(parser.process(new StringReader(expected)).getClassDescriptors(), ModelMerger.mergeModel(model, additionClds).getClassDescriptors());
}

代码示例来源:origin: intermine/intermine

public void testInheritanceChain() throws Exception {
  String modelStr = "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">"
            + "<class name=\"A\" extends=\"C\" is-interface=\"false\"></class>"
            + "<class name=\"C\" is-interface=\"false\"></class>"
           + "</model>";
  Model model = parser.process(new StringReader(modelStr));
  String addition = "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">"
            + "<class name=\"A\" extends=\"B\" is-interface=\"false\"></class>"
            + "<class name=\"B\" extends=\"C\" is-interface=\"false\"></class>"
           + "</model>";
  Set additionClds = parser.generateClassDescriptors(new StringReader(addition), model.getPackageName());
  String expected = "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">"
            + "<class name=\"A\" extends=\"B\" is-interface=\"false\"></class>"
            + "<class name=\"B\" extends=\"C\" is-interface=\"false\"></class>"
            + "<class name=\"C\" is-interface=\"false\"></class>"
           + "</model>";
  assertEquals(parser.process(new StringReader(expected)).getClassDescriptors(), ModelMerger.mergeModel(model, additionClds).getClassDescriptors());
}

代码示例来源:origin: intermine/intermine

public void testAddClass() throws Exception {
  String modelStr = "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">" +
            "<class name=\"org.intermine.model.testmodel.Secretary\" is-interface=\"false\">" +
              "<attribute name=\"name\" type=\"java.lang.String\"/>" +
            "</class>" +
           "</model>";
  Model model = parser.process(new StringReader(modelStr));
  String addition =   "<class name=\"org.intermine.model.testmodel.Department\" is-interface=\"false\">" +
              "<attribute name=\"name\" type=\"java.lang.String\"/>" +
            "</class>";
  Set additionClds = parser.generateClassDescriptors(new StringReader(addition), model.getPackageName());
  String expected = "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">" +
            "<class name=\"org.intermine.model.testmodel.Secretary\" is-interface=\"false\">" +
              "<attribute name=\"name\" type=\"java.lang.String\"/>" +
            "</class>" +
            "<class name=\"org.intermine.model.testmodel.Department\" is-interface=\"false\">" +
              "<attribute name=\"name\" type=\"java.lang.String\"/>" +
            "</class>" +
           "</model>";
  assertEquals(parser.process(new StringReader(expected)).getClassDescriptors(), ModelMerger.mergeModel(model, additionClds).getClassDescriptors());
}

代码示例来源:origin: intermine/intermine

public void testAddCollection() throws Exception {
  String modelStr = "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">" +
      "<class name=\"org.intermine.model.testmodel.Company\" is-interface=\"false\">" +
      "</class>" +
      "<class name=\"org.intermine.model.testmodel.Department\" is-interface=\"false\">" +
      "</class>" +
      "</model>";
  Model model = parser.process(new StringReader(modelStr));
  // add Company.departments
  String addition = "<class name=\"org.intermine.model.testmodel.Company\" is-interface=\"false\">" +
           "<collection name=\"departments\" referenced-type=\"org.intermine.model.testmodel.Department\" ordered=\"true\"/>" +
           "</class>";
  Set additionClds = parser.generateClassDescriptors(new StringReader(addition), model.getPackageName());
  String expected = "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">" +
      "<class name=\"org.intermine.model.testmodel.Company\" is-interface=\"false\">" +
      "<collection name=\"departments\" referenced-type=\"org.intermine.model.testmodel.Department\" ordered=\"true\"/>" +
      "</class>" +
      "<class name=\"org.intermine.model.testmodel.Department\" is-interface=\"false\">" +
      "</class>" +
      "</model>";
      //assertXMLEqual(expected, ModelMerger.mergeModel(model, additionClds).toString());
  assertEquals(parser.process(new StringReader(expected)).getClassDescriptors(), ModelMerger.mergeModel(model, additionClds).getClassDescriptors());
}

代码示例来源:origin: intermine/intermine

public void testGenerateClassDescriptors() throws Exception {
  Model model = parser.process(new StringReader(getModelXml()));
  assertEquals(getExpectedClds(), model.getClassDescriptors());
}

代码示例来源:origin: intermine/intermine

public void testSubclassExisting() throws Exception {
  String modelStr =   "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">" +
              "<class name=\"org.intermine.model.testmodel.Secretary\" is-interface=\"false\">" +
                "<attribute name=\"name\" type=\"java.lang.String\"/>" +
              "</class>" +
            "</model>";
  Model model = parser.process(new StringReader(modelStr));
  String addition =   "<class name=\"org.intermine.model.testmodel.DepartmentSecretary\" extends=\"org.intermine.model.testmodel.Secretary\" is-interface=\"false\">" +
              "<attribute name=\"department\" type=\"java.lang.String\"/>" +
            "</class>";
  Set additionClds = parser.generateClassDescriptors(new StringReader(addition), model.getPackageName());
  String expected =   "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">" +
              "<class name=\"org.intermine.model.testmodel.DepartmentSecretary\" extends=\"org.intermine.model.testmodel.Secretary\" is-interface=\"false\">" +
                "<attribute name=\"department\" type=\"java.lang.String\"/>" +
              "</class>" +
              "<class name=\"org.intermine.model.testmodel.Secretary\" is-interface=\"false\">" +
                "<attribute name=\"name\" type=\"java.lang.String\"/>" +
              "</class>" +
            "</model>";
  //assertXMLEqual(expected, ModelMerger.mergeModel(model, additionClds).toString());
  assertEquals(parser.process(new StringReader(expected)).getClassDescriptors(), ModelMerger.mergeModel(model, additionClds).getClassDescriptors());
}

代码示例来源:origin: intermine/intermine

public void testAddReference() throws Exception {
  String modelStr =   "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">" +
              "<class name=\"org.intermine.model.testmodel.Company\" is-interface=\"true\">" +
              "</class>" +
              "<class name=\"org.intermine.model.testmodel.Department\" is-interface=\"false\">" +
              "</class>" +
            "</model>";
  Model model = parser.process(new StringReader(modelStr));
  // add Department.company
  String addition = "<class name=\"org.intermine.model.testmodel.Department\" is-interface=\"false\">" +
            "<reference name=\"company\" referenced-type=\"org.intermine.model.testmodel.Company\"/>" +
           "</class>";
  Set additionClds = parser.generateClassDescriptors(new StringReader(addition), model.getPackageName());
  String expected = "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">" +
            "<class name=\"org.intermine.model.testmodel.Company\" is-interface=\"true\">" +
            "</class>" +
            "<class name=\"org.intermine.model.testmodel.Department\" is-interface=\"false\">" +
              "<reference name=\"company\" referenced-type=\"org.intermine.model.testmodel.Company\"/>" +
            "</class>" +
           "</model>";
  //assertXMLEqual(expected, ModelMerger.mergeModel(model, additionClds).toString());
  assertEquals(parser.process(new StringReader(expected)).getClassDescriptors(), ModelMerger.mergeModel(model, additionClds).getClassDescriptors());
}

代码示例来源:origin: intermine/intermine

public void testSuperclassExisting() throws Exception {
  String modelStr =   "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">" +
              "<class name=\"org.intermine.model.testmodel.DepartmentSecretary\" is-interface=\"false\">" +
                "<attribute name=\"department\" type=\"java.lang.String\"/>" +
              "</class>" +
            "</model>";
  Model model = parser.process(new StringReader(modelStr));
  String addition = "<model name=\"additions\" package=\"org.intermine.model.testmodel\">" +
            "<class name=\"org.intermine.model.testmodel.DepartmentSecretary\" extends=\"org.intermine.model.testmodel.Secretary\" is-interface=\"false\">" +
            "</class>" +
            "<class name=\"org.intermine.model.testmodel.Secretary\" is-interface=\"false\">" +
              "<attribute name=\"name\" type=\"java.lang.String\"/>" +
            "</class>" +
           "</model>";
  Set additionClds = parser.generateClassDescriptors(new StringReader(addition), model.getPackageName());
  String expected =   "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">" +
              "<class name=\"org.intermine.model.testmodel.DepartmentSecretary\" extends=\"org.intermine.model.testmodel.Secretary\" is-interface=\"false\">" +
                "<attribute name=\"department\" type=\"java.lang.String\"/>" +
              "</class>" +
              "<class name=\"org.intermine.model.testmodel.Secretary\" is-interface=\"false\">" +
                "<attribute name=\"name\" type=\"java.lang.String\"/>" +
              "</class>" +
            "</model>";
  //assertXMLEqual(expected, ModelMerger.mergeModel(model, additionClds).toString());
  assertEquals(parser.process(new StringReader(expected)).getClassDescriptors(), ModelMerger.mergeModel(model, additionClds).getClassDescriptors());
}

代码示例来源:origin: intermine/intermine

public void testRedundancy() throws Exception {
  String modelStr = "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">"
            + "<class name=\"A\" extends=\"C\" is-interface=\"false\">"
             + "<attribute name=\"name\" type=\"java.lang.String\"/>"
             + "<collection name=\"col\" referenced-type=\"C\"/>"
             + "<reference name=\"ref\" referenced-type=\"C\"/>"
            + "</class>"
            + "<class name=\"C\" is-interface=\"false\"></class>"
           + "</model>";
  Model model = parser.process(new StringReader(modelStr));
  String addition = "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">"
            + "<class name=\"A\" extends=\"B\" is-interface=\"false\"></class>"
            + "<class name=\"B\" extends=\"C\" is-interface=\"false\">"
             + "<attribute name=\"name\" type=\"java.lang.String\"/>"
             + "<collection name=\"col\" referenced-type=\"C\"/>"
             + "<reference name=\"ref\" referenced-type=\"C\"/>"
            + "</class>"
           + "</model>";
  Set additionClds = parser.generateClassDescriptors(new StringReader(addition), model.getPackageName());
  String expected = "<model name=\"testmodel\" package=\"org.intermine.model.testmodel\">"
            + "<class name=\"A\" extends=\"B\" is-interface=\"false\"></class>"
            + "<class name=\"B\" extends=\"C\" is-interface=\"false\">"
             + "<attribute name=\"name\" type=\"java.lang.String\"/>"
             + "<collection name=\"col\" referenced-type=\"C\"/>"
             + "<reference name=\"ref\" referenced-type=\"C\"/>"
            + "</class>"
            + "<class name=\"C\" is-interface=\"false\"></class>"
           + "</model>";
  assertEquals(parser.process(new StringReader(expected)).getClassDescriptors(), ModelMerger.mergeModel(model, additionClds).getClassDescriptors());
}

代码示例来源:origin: org.intermine/intermine-objectstore

for (ClassDescriptor oldClass : original.getClassDescriptors()) {
  if (!newClasses.containsKey(oldClass.getName())) {

相关文章