本文整理了Java中com.haulmont.chile.core.model.MetaClass.getAncestors()
方法的一些代码示例,展示了MetaClass.getAncestors()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MetaClass.getAncestors()
方法的具体详情如下:
包路径:com.haulmont.chile.core.model.MetaClass
类名称:MetaClass
方法名:getAncestors
[英]All ancestors of the metaclass, in order going up from the immediate ancestor.
[中]元类的所有祖先,以从直接祖先向上的顺序。
代码示例来源:origin: com.haulmont.cuba/cuba-core
protected void fillProperties(List<MetaProperty> properties, String annotationName) {
properties.clear();
MetaProperty[] metaProperties = (MetaProperty[]) metaClass.getAnnotations().get(annotationName);
if (metaProperties != null)
properties.addAll(Arrays.asList(metaProperties));
for (MetaClass aClass : metaClass.getAncestors()) {
metaProperties = (MetaProperty[]) aClass.getAnnotations().get(annotationName);
if (metaProperties != null)
properties.addAll(Arrays.asList(metaProperties));
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-core
protected void fillProperties(MetaClass metaClass, List<MetaProperty> properties, String annotationName) {
properties.clear();
MetaProperty[] metaProperties = (MetaProperty[]) metaClass.getAnnotations().get(annotationName);
if (metaProperties != null)
properties.addAll(Arrays.asList(metaProperties));
for (MetaClass aClass : metaClass.getAncestors()) {
metaProperties = (MetaProperty[]) aClass.getAnnotations().get(annotationName);
if (metaProperties != null)
properties.addAll(Arrays.asList(metaProperties));
}
}
}
代码示例来源:origin: com.haulmont.reports/reports-gui
/**
* Check if the meta class is applicable for the input parameter
*/
public boolean parameterMatchesMetaClass(ReportInputParameter parameter, MetaClass metaClass) {
if (isNotBlank(parameter.getEntityMetaClass())) {
MetaClass parameterMetaClass = metadata.getClassNN(parameter.getEntityMetaClass());
return (metaClass.equals(parameterMetaClass) || metaClass.getAncestors().contains(parameterMetaClass));
} else {
return false;
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-global
protected String getEntityNameForIdGeneration(MetaClass metaClass) {
List<MetaClass> persistentAncestors = metaClass.getAncestors().stream()
.filter(mc -> tools.isPersistent(mc)) // filter out all mapped superclasses
.collect(Collectors.toList());
if (persistentAncestors.size() > 0) {
MetaClass root = persistentAncestors.get(persistentAncestors.size() - 1);
Class<?> javaClass = root.getJavaClass();
Inheritance inheritance = javaClass.getAnnotation(Inheritance.class);
if (inheritance == null || inheritance.strategy() != InheritanceType.TABLE_PER_CLASS) {
// use root of inheritance tree if the strategy is JOINED or SINGLE_TABLE because ID is stored in the root table
return root.getName();
}
}
return metaClass.getName();
}
代码示例来源:origin: com.haulmont.cuba/cuba-global
protected List<ConstraintData> getConstraints(MetaClass metaClass) {
UserSession userSession = userSessionSource.getUserSession();
MetaClass mainMetaClass = extendedEntities.getOriginalOrThisMetaClass(metaClass);
List<ConstraintData> constraints = new ArrayList<>();
constraints.addAll(userSession.getConstraints(mainMetaClass.getName()));
for (MetaClass parent : mainMetaClass.getAncestors()) {
constraints.addAll(userSession.getConstraints(parent.getName()));
}
return constraints;
}
代码示例来源:origin: com.haulmont.reports/reports-gui
/**
* Apply constraints for query to select reports which have input parameter with class matching inputValueMetaClass
*/
public void applyPoliciesByEntityParameters(LoadContext lc, @Nullable MetaClass inputValueMetaClass) {
if (inputValueMetaClass != null) {
QueryTransformer transformer = queryTransformerFactory.transformer(lc.getQuery().getQueryString());
StringBuilder parameterTypeCondition = new StringBuilder("r.inputEntityTypesIdx like :type escape '\\'");
lc.getQuery().setParameter("type", wrapIdxParameterForSearch(inputValueMetaClass.getName()));
List<MetaClass> ancestors = inputValueMetaClass.getAncestors();
for (int i = 0; i < ancestors.size(); i++) {
MetaClass metaClass = ancestors.get(i);
String paramName = "type" + (i + 1);
parameterTypeCondition.append(" or r.inputEntityTypesIdx like :").append(paramName).append(" escape '\\'");
lc.getQuery().setParameter(paramName, wrapIdxParameterForSearch(metaClass.getName()));
}
transformer.addWhereAsIs(String.format("(%s)", parameterTypeCondition.toString()));
lc.getQuery().setQueryString(transformer.getResult());
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-global
protected View getAncestorView(MetaClass metaClass, String ancestor, Set<ViewInfo> visited) {
View ancestorView = retrieveView(metaClass, ancestor, visited);
if (ancestorView == null) {
ExtendedEntities extendedEntities = metadata.getExtendedEntities();
MetaClass originalMetaClass = extendedEntities.getOriginalMetaClass(metaClass);
if (originalMetaClass != null) {
ancestorView = retrieveView(originalMetaClass, ancestor, visited);
}
if (ancestorView == null) {
// Last resort - search for all ancestors
for (MetaClass ancestorMetaClass : metaClass.getAncestors()) {
if (ancestorMetaClass.equals(metaClass)) {
ancestorView = retrieveView(ancestorMetaClass, ancestor, visited);
if (ancestorView != null)
break;
}
}
}
if (ancestorView == null) {
throw new DevelopmentException("No ancestor view found: " + ancestor + " for " + metaClass.getName());
}
}
return ancestorView;
}
内容来源于网络,如有侵权,请联系作者删除!