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

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

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

Model.getAllSubs介绍

[英]Get the ClassDescriptors for the all subclasses of a class
[中]获取类的所有子类的类描述符

代码示例

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

/**
 * Get the ClassDescriptors for the all subclasses of a class
 * @param cld the parent ClassDescriptor
 * @return the ClassDescriptors of all descedents
 */
public Set<ClassDescriptor> getAllSubs(ClassDescriptor cld) {
  Set<ClassDescriptor> returnSubs = new TreeSet<ClassDescriptor>();
  Set<ClassDescriptor> directSubs = getDirectSubs(cld);
  returnSubs.addAll(directSubs);
  for (ClassDescriptor sub : directSubs) {
    returnSubs.addAll(getAllSubs(sub));
  }
  return returnSubs;
}

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

/**
 * Get the ClassDescriptors for the all subclasses of a class
 * @param cld the parent ClassDescriptor
 * @return the ClassDescriptors of all descedents
 */
public Set<ClassDescriptor> getAllSubs(ClassDescriptor cld) {
  Set<ClassDescriptor> returnSubs = new TreeSet<ClassDescriptor>();
  Set<ClassDescriptor> directSubs = getDirectSubs(cld);
  returnSubs.addAll(directSubs);
  for (ClassDescriptor sub : directSubs) {
    returnSubs.addAll(getAllSubs(sub));
  }
  return returnSubs;
}

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

List<ClassDescriptor> clds = new ArrayList<ClassDescriptor>(model.getAllSubs(cld));
clds.add(cld);
for (ClassDescriptor nextCld : clds) {

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

private void countAndStore(ObjectStore os, Model model, ClassDescriptor cld)
  throws ObjectStoreException {
  if (!classCountsMap.containsKey(cld.getName())) {
    int classCount = countClass(os, cld.getType());
    LOG.info("Adding class count: " + cld.getUnqualifiedName() + " = " + classCount);
    classCountsMap.put(cld.getName(), new Integer(classCount));
    // if this class is empty all subclasses MUST be empty as well
    if (classCount == 0) {
      for (ClassDescriptor subCld : model.getAllSubs(cld)) {
        if (!classCountsMap.containsKey(subCld.getName())) {
          classCountsMap.put(subCld.getName(), new Integer(classCount));
        }
      }
    }
  }
}

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

List<ClassDescriptor> clds = new ArrayList<ClassDescriptor>(model.getAllSubs(cld));
clds.add(cld);
for (ClassDescriptor nextCld : clds) {

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

private Map<String, InterMineBag> filterBagsByType(Map<String, InterMineBag> bags,
    String type, boolean onlyCurrent, boolean includeSupers) {
  Set<String> acceptableTypes = new HashSet<String>();
  acceptableTypes.add(type);
  ClassDescriptor bagTypeCld = model.getClassDescriptorByName(type);
  if (bagTypeCld == null) {
    throw new NullPointerException("Could not find ClassDescriptor for name " + type);
  }
  for (ClassDescriptor cld : model.getAllSubs(bagTypeCld)) {
    acceptableTypes.add(cld.getUnqualifiedName());
  }
  if (includeSupers) {
    for (ClassDescriptor cld : bagTypeCld.getAllSuperDescriptors()) {
      acceptableTypes.add(cld.getUnqualifiedName());
    }
  }
  Map<String, InterMineBag> bagsOfType = new HashMap<String, InterMineBag>();
  for (Map.Entry<String, InterMineBag> entry : bags.entrySet()) {
    InterMineBag bag = entry.getValue();
    if (acceptableTypes.contains(bag.getType())) {
      if ((onlyCurrent && bag.isCurrent()) || !onlyCurrent) {
        bagsOfType.put(entry.getKey(), bag);
      }
    }
  }
  return bagsOfType;
}

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

private void countAndStore(ObjectStore os, Model model, ClassDescriptor cld)
  throws ObjectStoreException {
  if (!classCountsMap.containsKey(cld.getName())) {
    int classCount = countClass(os, cld.getType());
    LOG.info("Adding class count: " + cld.getUnqualifiedName() + " = " + classCount);
    classCountsMap.put(cld.getName(), new Integer(classCount));
    // if this class is empty all subclasses MUST be empty as well
    if (classCount == 0) {
      for (ClassDescriptor subCld : model.getAllSubs(cld)) {
        if (!classCountsMap.containsKey(subCld.getName())) {
          classCountsMap.put(subCld.getName(), new Integer(classCount));
        }
      }
    }
  }
}

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

private Map<String, InterMineBag> filterBagsByType(Map<String, InterMineBag> bags,
    String type, boolean onlyCurrent, boolean includeSupers) {
  Set<String> acceptableTypes = new HashSet<String>();
  acceptableTypes.add(type);
  ClassDescriptor bagTypeCld = model.getClassDescriptorByName(type);
  if (bagTypeCld == null) {
    throw new NullPointerException("Could not find ClassDescriptor for name " + type);
  }
  for (ClassDescriptor cld : model.getAllSubs(bagTypeCld)) {
    acceptableTypes.add(cld.getUnqualifiedName());
  }
  if (includeSupers) {
    for (ClassDescriptor cld : bagTypeCld.getAllSuperDescriptors()) {
      acceptableTypes.add(cld.getUnqualifiedName());
    }
  }
  Map<String, InterMineBag> bagsOfType = new HashMap<String, InterMineBag>();
  for (Map.Entry<String, InterMineBag> entry : bags.entrySet()) {
    InterMineBag bag = entry.getValue();
    if (acceptableTypes.contains(bag.getType())) {
      if ((onlyCurrent && bag.isCurrent()) || !onlyCurrent) {
        bagsOfType.put(entry.getKey(), bag);
      }
    }
  }
  return bagsOfType;
}

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

tracks.add(makeFeatureTrack(fcd, null));
for (ClassDescriptor cd: m.getAllSubs(fcd)) {
  tracks.add(makeFeatureTrack(cd, null));

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

private void processAdditionalConverters(Attributes attrs) {
  String fullyQualifiedName = attrs.getValue("class-name");
  String constraintPath = attrs.getValue("constraint-path");
  String targetType = attrs.getValue("target-type");
  String title = attrs.getValue("title");
  String urlField = attrs.getValue("urlField");
  ClassDescriptor typeCld = model.getClassDescriptorByName(targetType);
  if (typeCld == null) {
    LOG.warn("Invalid target type for additional converter: " + targetType);
    return;
  }
  try {
    new Path(model, constraintPath);
  } catch (PathException e) {
    LOG.warn("Can't add converter to bag-queries.xml, constraint-path '" + constraintPath
        + "' isn't in " + model.getName() + " model.");
    return;
  }
  Set<String> clds = new HashSet<String>();
  clds.add(typeCld.getName());
  for (ClassDescriptor cld : model.getAllSubs(typeCld)) {
    clds.add(cld.getName());
  }
  AdditionalConverter additionalConverter = new AdditionalConverter(constraintPath,
      targetType, fullyQualifiedName, title, urlField);
  for (String nextCld : clds) {
    Util.addToSetMap(additionalConverters, TypeUtil.unqualifiedName(nextCld),
        additionalConverter);
  }
}

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

private void processAdditionalConverters(Attributes attrs) {
  String fullyQualifiedName = attrs.getValue("class-name");
  String constraintPath = attrs.getValue("constraint-path");
  String targetType = attrs.getValue("target-type");
  String title = attrs.getValue("title");
  String urlField = attrs.getValue("urlField");
  ClassDescriptor typeCld = model.getClassDescriptorByName(targetType);
  if (typeCld == null) {
    LOG.warn("Invalid target type for additional converter: " + targetType);
    return;
  }
  try {
    new Path(model, constraintPath);
  } catch (PathException e) {
    LOG.warn("Can't add converter to bag-queries.xml, constraint-path '" + constraintPath
        + "' isn't in " + model.getName() + " model.");
    return;
  }
  Set<String> clds = new HashSet<String>();
  clds.add(typeCld.getName());
  for (ClassDescriptor cld : model.getAllSubs(typeCld)) {
    clds.add(cld.getName());
  }
  AdditionalConverter additionalConverter = new AdditionalConverter(constraintPath,
      targetType, fullyQualifiedName, title, urlField);
  for (String nextCld : clds) {
    Util.addToSetMap(additionalConverters, TypeUtil.unqualifiedName(nextCld),
        additionalConverter);
  }
}

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

tracks.add(makeFeatureTrack(fcd, null));
for (ClassDescriptor cd: m.getAllSubs(fcd)) {
  tracks.add(makeFeatureTrack(cd, null));

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

if (fld != null) {
  ClassKeyHelper.addKey(theseKeys, clsName, fld);
  for (ClassDescriptor subCld : model.getAllSubs(cld)) {
    ClassKeyHelper.addKey(theseKeys, subCld.getUnqualifiedName(), fld);

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

if (fld != null) {
  ClassKeyHelper.addKey(theseKeys, clsName, fld);
  for (ClassDescriptor subCld : model.getAllSubs(cld)) {
    ClassKeyHelper.addKey(theseKeys, subCld.getUnqualifiedName(), fld);

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

for (ClassDescriptor nextCld : os.getModel().getAllSubs(cld)) {
  clsNames.add(TypeUtil.unqualifiedName(nextCld.getName()));

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

for (ClassDescriptor nextCld : os.getModel().getAllSubs(cld)) {
  clsNames.add(TypeUtil.unqualifiedName(nextCld.getName()));

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

public void testGetAllSubs() throws Exception {
  Model model = Model.getInstanceByName("basicmodel");
  Set<ClassDescriptor> hasAddressCds =
    model.getClassDescriptorsForClass(org.intermine.model.basicmodel.Thing.class);
  assertEquals(1, hasAddressCds.size());
  ClassDescriptor addressCld = (ClassDescriptor) hasAddressCds.iterator().next();
  if (addressCld.getName() == "org.intermine.model.InterMineObject") {
    // we want org.intermine.model.basicmodel.HasAddress
    addressCld = (ClassDescriptor) hasAddressCds.iterator().next();
  }
  Set<ClassDescriptor> resultCds = model.getAllSubs(addressCld);
  Set<String> expectedCdNames = new HashSet<String>();
  expectedCdNames.add("org.intermine.model.basicmodel.Employable");
  expectedCdNames.add("org.intermine.model.basicmodel.Address");
  expectedCdNames.add("org.intermine.model.basicmodel.Employee");
  expectedCdNames.add("org.intermine.model.basicmodel.Manager");
  expectedCdNames.add("org.intermine.model.basicmodel.Department");
  expectedCdNames.add("org.intermine.model.basicmodel.Contractor");
  Set<String> resultCdNames = new HashSet<String>();
  for (ClassDescriptor cld : resultCds) {
    resultCdNames.add(cld.getName());
  }
  assertEquals(expectedCdNames, resultCdNames);
}

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

clds.addAll(cld.getModel().getAllSubs(cld));
for (ClassDescriptor nextCld : clds) {
  ClassDescriptor tableMaster = schema.getTableMaster(nextCld);

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

clds.addAll(cld.getModel().getAllSubs(cld));
for (ClassDescriptor nextCld : clds) {
  ClassDescriptor tableMaster = schema.getTableMaster(nextCld);

相关文章