use of com.haulmont.cuba.gui.data.NestedDatasource 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.gui.data.NestedDatasource in project cuba by cuba-platform.
the class DesktopTokenList method getInverseProperty.
@Nullable
protected MetaProperty getInverseProperty(CollectionDatasource datasource) {
if (datasource instanceof NestedDatasource) {
MetaProperty metaProperty = ((NestedDatasource) datasource).getProperty();
com.google.common.base.Preconditions.checkState(metaProperty != null);
return metaProperty.getInverse();
}
return null;
}
use of com.haulmont.cuba.gui.data.NestedDatasource in project cuba by cuba-platform.
the class WebTokenList method getInverseProperty.
@Nullable
protected MetaProperty getInverseProperty(CollectionDatasource datasource) {
if (datasource instanceof NestedDatasource) {
MetaProperty metaProperty = ((NestedDatasource) datasource).getProperty();
com.google.common.base.Preconditions.checkState(metaProperty != null);
return metaProperty.getInverse();
}
return null;
}
use of com.haulmont.cuba.gui.data.NestedDatasource in project cuba by cuba-platform.
the class DesktopTokenList method getMasterEntity.
@Nullable
protected Entity getMasterEntity(CollectionDatasource datasource) {
if (datasource instanceof NestedDatasource) {
Datasource masterDs = ((NestedDatasource) datasource).getMaster();
com.google.common.base.Preconditions.checkState(masterDs != null);
return masterDs.getItem();
}
return null;
}
use of com.haulmont.cuba.gui.data.NestedDatasource in project cuba by cuba-platform.
the class WebTokenList method getMasterEntity.
@Nullable
protected Entity getMasterEntity(CollectionDatasource datasource) {
if (datasource instanceof NestedDatasource) {
Datasource masterDs = ((NestedDatasource) datasource).getMaster();
com.google.common.base.Preconditions.checkState(masterDs != null);
return masterDs.getItem();
}
return null;
}
Aggregations