本文整理了Java中com.haulmont.chile.core.model.MetaClass.getDescendants()
方法的一些代码示例,展示了MetaClass.getDescendants()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MetaClass.getDescendants()
方法的具体详情如下:
包路径:com.haulmont.chile.core.model.MetaClass
类名称:MetaClass
方法名:getDescendants
[英]All descendants of the metaclass, recursively. Order is undefined.
[中]元类的所有后代,递归地。秩序是不确定的。
代码示例来源:origin: com.haulmont.cuba/cuba-global
protected void findMissingDescendants(MetaClass ancestor, Collection<MetaClass> missingDescendants) {
Collection<MetaClass> descendants = ancestor.getDescendants();
for (Object descendant : descendants) {
missingDescendants.add((MetaClass) descendant);
findMissingDescendants((MetaClass) descendant, missingDescendants);
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-core
protected Set<String> getDescendants(Set<String> relatedTypes) {
if (relatedTypes == null) return null;
Set<String> newRelatedTypes = new HashSet<>();
relatedTypes.forEach(type -> {
newRelatedTypes.add(type);
MetaClass metaClass = metadata.getClassNN(type);
if (metaClass.getDescendants() != null) {
Set<String> descendants = metaClass.getDescendants().stream()
.filter(it -> it.getJavaClass() != null && !it.getJavaClass().isAnnotationPresent(MappedSuperclass.class))
.map(MetadataObject::getName).collect(Collectors.toSet());
newRelatedTypes.addAll(descendants);
}
});
return newRelatedTypes;
}
代码示例来源:origin: com.haulmont.cuba/cuba-global
public static String printClassHierarchy(MetaClass metaClass) {
StringBuilder builder = new StringBuilder();
builder.append(metaClass.getName()).append("\n");
for (MetaClass descendantClass : metaClass.getDescendants()) {
builder.append(shift(printClassHierarchy(descendantClass)));
}
return builder.toString();
}
代码示例来源:origin: com.haulmont.cuba/cuba-global
/**
* @return true if the first MetaClass is equal or an ancestor of the second.
*/
public boolean isAssignableFrom(MetaClass metaClass, MetaClass other) {
checkNotNullArgument(metaClass);
checkNotNullArgument(other);
return metaClass.equals(other) || metaClass.getDescendants().contains(other);
}
代码示例来源:origin: com.haulmont.fts/fts-core
@Override
public List<String> collectEntityHierarchyNames(String entityName) {
MetaClass metaClass = metadata.getClassNN(entityName);
List<String> result = new ArrayList<>();
result.add(entityName);
result.addAll(metaClass.getDescendants().stream().map(MetadataObject::getName).collect(Collectors.toList()));
MetaClass originalMetaClass = metadata.getExtendedEntities().getOriginalMetaClass(metaClass);
if (originalMetaClass != null) {
result.add(originalMetaClass.getName());
}
return result;
}
代码示例来源:origin: com.haulmont.cuba/cuba-global
protected void initMetaAnnotations(MetaClass metaClass) {
for (Annotation annotation : metaClass.getJavaClass().getAnnotations()) {
MetaAnnotation metaAnnotation = AnnotationUtils.findAnnotation(annotation.getClass(), MetaAnnotation.class);
if (metaAnnotation != null) {
String name = annotation.annotationType().getName();
Map<String, Object> attributes = new LinkedHashMap<>(AnnotationUtils.getAnnotationAttributes(metaClass.getJavaClass(), annotation));
metaClass.getAnnotations().put(name, attributes);
Object propagateToSubclasses = attributes.get("propagateToSubclasses");
if (propagateToSubclasses == null || Boolean.TRUE.equals(propagateToSubclasses)) {
for (MetaClass descMetaClass : metaClass.getDescendants()) {
Annotation descAnnotation = descMetaClass.getJavaClass().getAnnotation(annotation.annotationType());
if (descAnnotation == null) {
descMetaClass.getAnnotations().put(name, attributes);
}
}
}
}
}
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-gui
@Override
public void setItem(T item) {
backgroundWorker.checkUIAccess();
if (State.VALID.equals(state)) {
T prevItem = this.item;
if (prevItem != item) {
if (item != null) {
final MetaClass aClass = item.getMetaClass();
if (!aClass.equals(this.metaClass) && !this.metaClass.getDescendants().contains(aClass)) {
throw new DevelopmentException(String.format("Invalid item metaClass '%s'", aClass));
}
}
this.item = item;
fireItemChanged(prevItem);
}
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-gui
@Override
public void setItem(@Nullable E item) {
E prevItem = this.item;
if (this.item != null) {
detachListener(this.item);
}
if (item != null) {
final MetaClass aClass = item.getMetaClass();
if (!aClass.equals(entityMetaClass) && !entityMetaClass.getDescendants().contains(aClass)) {
throw new DevelopmentException(String.format("Invalid item's metaClass '%s'", aClass),
ParamsMap.of("container", toString(), "metaClass", aClass));
}
attachListener(item);
}
this.item = item;
fireItemChanged(prevItem);
}
代码示例来源:origin: com.haulmont.cuba/cuba-global
protected void postProcessClass(MetaClass metaClass) {
for (MetaProperty property : metaClass.getOwnProperties()) {
postProcessProperty(metaClass, property);
}
Collection<MetaClass> missingDescendants = new HashSet<>(1);
findMissingDescendants(metaClass, missingDescendants);
if (!missingDescendants.isEmpty()) {
CollectionUtils.addAll(metaClass.getDescendants(), missingDescendants.iterator());
MetaClass ancestorMetaClass = metaClass.getAncestor();
while (ancestorMetaClass != null) {
CollectionUtils.addAll(ancestorMetaClass.getDescendants(), missingDescendants.iterator());
ancestorMetaClass = ancestorMetaClass.getAncestor();
}
}
MetaClass ancestorMetaClass = metaClass.getAncestor();
while (ancestorMetaClass != null) {
((MetaClassImpl) metaClass).addAncestor(ancestorMetaClass);
ancestorMetaClass = ancestorMetaClass.getAncestor();
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-gui
protected void __setItem(T item) {
if (this.item != null) {
detachListener(this.item);
}
if (item != null) {
final MetaClass aClass = item.getMetaClass();
if (!aClass.equals(metaClass) && !metaClass.getDescendants().contains(aClass)) {
throw new DevelopmentException(String.format("Invalid item metaClass '%s'", aClass),
ParamsMap.of("datasource", getId(), "metaClass", aClass));
}
attachListener(item);
}
this.item = item;
this.modified = false;
clearCommitLists();
if (item != null && PersistenceHelper.isNew(item)) {
itemsToCreate.add(item);
this.modified = true;
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-gui
@Override
public void setItem(T item) {
backgroundWorker.checkUIAccess();
if (getState() == State.VALID) {
Object prevItem = this.item;
if (prevItem != item) {
if (item != null) {
final MetaClass aClass = item.getMetaClass();
MetaClass metaClass = getMetaClass();
if (!aClass.equals(metaClass) && !metaClass.getDescendants().contains(aClass)) {
throw new DevelopmentException(String.format("Invalid item metaClass '%s'", aClass),
ParamsMap.of("datasource", getId(), "metaClass", aClass));
}
}
this.item = item;
//noinspection unchecked
fireItemChanged((T) prevItem);
}
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-core
protected void processOnDeleteInverse(List<MetaProperty> properties) {
for (MetaProperty property : properties) {
MetaClass metaClass = property.getDomain();
List<MetaClass> persistentEntities = new ArrayList<>();
if (isPersistent(metaClass))
persistentEntities.add(metaClass);
for (MetaClass descendant : metaClass.getDescendants()) {
if (isPersistent(descendant))
persistentEntities.add(descendant);
}
for (MetaClass persistentEntity : persistentEntities) {
OnDeleteInverse annotation = property.getAnnotatedElement().getAnnotation(OnDeleteInverse.class);
DeletePolicy deletePolicy = annotation.value();
switch (deletePolicy) {
case DENY:
if (referenceExists(persistentEntity.getName(), property))
throw new DeletePolicyException(this.metaClass.getName(), persistentEntity.getName());
break;
case CASCADE:
cascade(persistentEntity.getName(), property);
break;
case UNLINK:
unlink(persistentEntity.getName(), property);
break;
}
}
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-core
metClassesToRestore.addAll(detailMetaClass.getDescendants());
for (MetaClass metaClassToRestore : metClassesToRestore) {
if (!metadata.getTools().isPersistent(metaClassToRestore))
内容来源于网络,如有侵权,请联系作者删除!