use of com.haulmont.cuba.core.global.ExtendedEntities in project cuba by cuba-platform.
the class ExcludeAction method doRemove.
@SuppressWarnings("unchecked")
@Override
protected void doRemove(Set<Entity> selected, boolean autocommit) {
@SuppressWarnings({ "unchecked" }) CollectionDatasource ds = target.getDatasource();
if (ds instanceof NestedDatasource) {
// Clear reference to master entity
Datasource masterDs = ((NestedDatasource) ds).getMaster();
MetaProperty metaProperty = ((NestedDatasource) ds).getProperty();
if (masterDs != null && metaProperty != null) {
MetaProperty inverseProp = metaProperty.getInverse();
if (inverseProp != null) {
ExtendedEntities extendedEntities = metadata.getExtendedEntities();
Class inversePropClass = extendedEntities.getEffectiveClass(inverseProp.getDomain());
Class dsClass = extendedEntities.getEffectiveClass(ds.getMetaClass());
if (inversePropClass.isAssignableFrom(dsClass)) {
for (Entity item : selected) {
item.setValue(inverseProp.getName(), null);
}
}
}
}
}
for (Entity item : selected) {
ds.modifyItem(item);
ds.excludeItem(item);
}
if (autocommit && (ds.getCommitMode() != Datasource.CommitMode.PARENT)) {
try {
ds.commit();
} catch (RuntimeException e) {
ds.refresh();
throw e;
}
}
}
use of com.haulmont.cuba.core.global.ExtendedEntities in project cuba by cuba-platform.
the class SetupAttributeAccessEvent method getResolvableType.
@Override
public ResolvableType getResolvableType() {
ExtendedEntities extendedEntities = AppBeans.get(ExtendedEntities.NAME);
MetaClass metaClass = extendedEntities.getOriginalOrThisMetaClass(getEntity().getMetaClass());
return ResolvableType.forClassWithGenerics(getClass(), ResolvableType.forClass(metaClass.getJavaClass()));
}
use of com.haulmont.cuba.core.global.ExtendedEntities in project cuba by cuba-platform.
the class WebTokenList method isInversePropertyAssignableFromDsClass.
protected boolean isInversePropertyAssignableFromDsClass(MetaProperty inverseProp) {
Metadata metadata = AppBeans.get(Metadata.NAME);
ExtendedEntities extendedEntities = metadata.getExtendedEntities();
Class inversePropClass = extendedEntities.getEffectiveClass(inverseProp.getDomain());
Class dsClass = extendedEntities.getEffectiveClass(datasource.getMetaClass());
// noinspection unchecked
return inversePropClass.isAssignableFrom(dsClass);
}
use of com.haulmont.cuba.core.global.ExtendedEntities in project cuba by cuba-platform.
the class DesktopTokenList method isInversePropertyAssignableFromDsClass.
protected boolean isInversePropertyAssignableFromDsClass(MetaProperty inverseProp) {
Metadata metadata = AppBeans.get(Metadata.NAME);
ExtendedEntities extendedEntities = metadata.getExtendedEntities();
Class inversePropClass = extendedEntities.getEffectiveClass(inverseProp.getDomain());
Class dsClass = extendedEntities.getEffectiveClass(datasource.getMetaClass());
// noinspection unchecked
return inversePropClass.isAssignableFrom(dsClass);
}
Aggregations