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

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

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

Model.getClassDescriptorsForClass介绍

[英]Takes a Class, and generates a Set of all ClassDescriptors that are the Class or any of its parents. The Class may be a dynamic class - ie not in the model, although at least one of its parents are in the model.
[中]获取一个类,并生成一组作为该类或其任何父类的所有类描述符。该类可能是一个动态类,即不在模型中,但至少有一个父类在模型中。

代码示例

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

/**
 * Takes a Class, and generates a Map of all FieldDescriptors that are the class fields
 * or any of its parents. The Class may be a dynamic class - ie not in the model, although
 * at least one of its parents are in the model.
 *
 * @param c a Class
 * @return a Map of FieldDescriptor objects
 */
public Map<String, FieldDescriptor> getFieldDescriptorsForClass(Class<?> c) {
  synchronized (classToFieldDescriptorMap) {
    Map<String, FieldDescriptor> retval = classToFieldDescriptorMap.get(c);
    if (retval == null) {
      retval = new LinkedHashMap<String, FieldDescriptor>();
      for (ClassDescriptor cld : getClassDescriptorsForClass(c)) {
        for (FieldDescriptor fd : cld.getFieldDescriptors()) {
          retval.put(fd.getName(), fd);
        }
      }
      classToFieldDescriptorMap.put(c, retval);
    }
    return retval;
  }
}

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

/**
 * Takes a Class, and generates a Map of all FieldDescriptors that are the class fields
 * or any of its parents. The Class may be a dynamic class - ie not in the model, although
 * at least one of its parents are in the model.
 *
 * @param c a Class
 * @return a Map of FieldDescriptor objects
 */
public Map<String, FieldDescriptor> getFieldDescriptorsForClass(Class<?> c) {
  synchronized (classToFieldDescriptorMap) {
    Map<String, FieldDescriptor> retval = classToFieldDescriptorMap.get(c);
    if (retval == null) {
      retval = new LinkedHashMap<String, FieldDescriptor>();
      for (ClassDescriptor cld : getClassDescriptorsForClass(c)) {
        for (FieldDescriptor fd : cld.getFieldDescriptors()) {
          retval.put(fd.getName(), fd);
        }
      }
      classToFieldDescriptorMap.put(c, retval);
    }
    return retval;
  }
}

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

/**
 * Returns true if the given field is a member of any primary key on the given class, for the
 * given source.
 *
 * @param model the Model in which to find ClassDescriptors
 * @param clazz the Class in which to look
 * @param fieldName the name of the field to check
 * @param source the Source that the keys belong to
 * @return true if the field is a primary key
 */
public static boolean fieldIsPrimaryKey(Model model, Class<?> clazz, String fieldName,
    Source source) {
  Map<PrimaryKeyCacheKey, Set<String>> cache = primaryKeyCache.get();
  PrimaryKeyCacheKey key = new PrimaryKeyCacheKey(model, clazz, source);
  Set<String> fields = cache.get(key);
  if (fields == null) {
    fields = new HashSet<String>();
    for (ClassDescriptor cld : model.getClassDescriptorsForClass(clazz)) {
      for (PrimaryKey pk : getPrimaryKeys(cld, source, null)) {
        fields.addAll(pk.getFieldNames());
      }
    }
    cache.put(key, fields);
  }
  return fields.contains(fieldName);
}

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

/**
 * Returns true if the given field is a member of any primary key on the given class, for the
 * given source.
 *
 * @param model the Model in which to find ClassDescriptors
 * @param clazz the Class in which to look
 * @param fieldName the name of the field to check
 * @param source the Source that the keys belong to
 * @return true if the field is a primary key
 */
public static boolean fieldIsPrimaryKey(Model model, Class<?> clazz, String fieldName,
    Source source) {
  Map<PrimaryKeyCacheKey, Set<String>> cache = primaryKeyCache.get();
  PrimaryKeyCacheKey key = new PrimaryKeyCacheKey(model, clazz, source);
  Set<String> fields = cache.get(key);
  if (fields == null) {
    fields = new HashSet<String>();
    for (ClassDescriptor cld : model.getClassDescriptorsForClass(clazz)) {
      for (PrimaryKey pk : getPrimaryKeys(cld, source, null)) {
        fields.addAll(pk.getFieldNames());
      }
    }
    cache.put(key, fields);
  }
  return fields.contains(fieldName);
}

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

Set<ClassDescriptor> classDescriptors = model.getClassDescriptorsForClass(summaryClass);
for (ClassDescriptor cld : classDescriptors) {
  if (source == null) {

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

private void setClassDescriptors() throws UnknownBagTypeException {
  try {
    Class<?> cls = Class.forName(getQualifiedType());
    classDescriptors = os.getModel().getClassDescriptorsForClass(cls);
  } catch (ClassNotFoundException e) {
    throw new UnknownBagTypeException("bag type " + getQualifiedType() + " not known", e);
  }
}

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

private void setClassDescriptors() throws UnknownBagTypeException {
  try {
    Class<?> cls = Class.forName(getQualifiedType());
    classDescriptors = os.getModel().getClassDescriptorsForClass(cls);
  } catch (ClassNotFoundException e) {
    throw new UnknownBagTypeException("bag type " + getQualifiedType() + " not known", e);
  }
}

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

allPkClassesEmpty = Boolean.TRUE;
Set<ClassDescriptor> classDescriptors = lookupOs.getModel()
  .getClassDescriptorsForClass(obj.getClass());
Iterator<ClassDescriptor> cldIter = classDescriptors.iterator();
while (cldIter.hasNext() && allPkClassesEmpty.booleanValue()) {

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

allPkClassesEmpty = Boolean.TRUE;
Set<ClassDescriptor> classDescriptors = lookupOs.getModel()
  .getClassDescriptorsForClass(obj.getClass());
Iterator<ClassDescriptor> cldIter = classDescriptors.iterator();
while (cldIter.hasNext() && allPkClassesEmpty.booleanValue()) {

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

public void testGetClassDescriptorsForClass() throws Exception {
  Model model = Model.getInstanceByName("basicmodel");
  Set<ClassDescriptor> cds = model.getClassDescriptorsForClass(org.intermine.model.basicmodel.Employee.class);
  Set<String> expectedCdNames = new HashSet<String>();
  expectedCdNames.add("org.intermine.model.basicmodel.Employee");
  Set<String> cdNames = new HashSet<String>();
  for (ClassDescriptor cd: cds) {
    cdNames.add(cd.getName());
  }
  assertEquals(expectedCdNames, cdNames);
}

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

/**
 * Test whether the given type can be added to this bag, type can be a
 * qualified or un-qualified string.
 * @param testType type to check
 * @return true if type can be added to the bag
 */
public boolean isOfType(String testType) {
  Model model = os.getModel();
  // this method works with qualified and unqualified class names
  ClassDescriptor testCld = model.getClassDescriptorByName(testType);
  if (testCld == null) {
    throw new IllegalArgumentException("Class not found in model: " + testType);
  }
  Set<ClassDescriptor> clds = model.getClassDescriptorsForClass(testCld
      .getType());
  for (ClassDescriptor cld : clds) {
    String className = cld.getName();
    if (TypeUtil.unqualifiedName(className).equals(getType())) {
      return true;
    }
  }
  return false;
}

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

/**
 * Test whether the given type can be added to this bag, type can be a
 * qualified or un-qualified string.
 * @param testType type to check
 * @return true if type can be added to the bag
 */
public boolean isOfType(String testType) {
  Model model = os.getModel();
  // this method works with qualified and unqualified class names
  ClassDescriptor testCld = model.getClassDescriptorByName(testType);
  if (testCld == null) {
    throw new IllegalArgumentException("Class not found in model: " + testType);
  }
  Set<ClassDescriptor> clds = model.getClassDescriptorsForClass(testCld
      .getType());
  for (ClassDescriptor cld : clds) {
    String className = cld.getName();
    if (TypeUtil.unqualifiedName(className).equals(getType())) {
      return true;
    }
  }
  return false;
}

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

Model model = path.getModel();
if (path.getStartClassDescriptor() != null) {
  Set<ClassDescriptor> clds = model.getClassDescriptorsForClass(o.getClass());
  if (!clds.contains(path.getStartClassDescriptor())) {
    throw new PathException("ClassDescriptor from the start of path: " + path

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

Model model = path.getModel();
if (path.getStartClassDescriptor() != null) {
  Set<ClassDescriptor> clds = model.getClassDescriptorsForClass(o.getClass());
  if (!clds.contains(path.getStartClassDescriptor())) {
    throw new PathException("ClassDescriptor from the start of path: " + path

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

public void testGetDirectSubs() 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.getDirectSubs(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.Department");
  Set<String> resultCdNames = new HashSet<String>();
  for (ClassDescriptor cld : resultCds) {
    resultCdNames.add(cld.getName());
  }
  assertEquals(expectedCdNames, resultCdNames);
}

代码示例来源: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

for (ClassDescriptor cld : model.getClassDescriptorsForClass(o.getClass())) {
  ClassDescriptor tableMaster = schema.getTableMaster(cld);
  String tableName = DatabaseUtil.getTableName(tableMaster);

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

for (ClassDescriptor cld : model.getClassDescriptorsForClass(o.getClass())) {
  ClassDescriptor tableMaster = schema.getTableMaster(cld);
  String tableName = DatabaseUtil.getTableName(tableMaster);

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

Query onlyQ = null;
Set<ClassDescriptor> classDescriptors = model.getClassDescriptorsForClass(obj.getClass());
boolean valid = classDescriptors.isEmpty();
boolean invalid = false;

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

Query onlyQ = null;
Set<ClassDescriptor> classDescriptors = model.getClassDescriptorsForClass(obj.getClass());
boolean valid = classDescriptors.isEmpty();
boolean invalid = false;

相关文章