use of com.emc.storageos.db.client.util.DbClientCallbackEvent in project coprhd-controller by CoprHD.
the class LazyLoader method refreshMappedByStringSet.
/**
* @param obj
* @param lazyLoadedFieldReadMethod
* @param mappedByFieldReadMethod
* @param mappedByFieldWriteMethod
* @param mappedByObjType
* @throws IllegalAccessException
* @throws InvocationTargetException
* @throws InstantiationException
*/
private void refreshMappedByStringSet(DataObject obj, Method lazyLoadedFieldReadMethod, Method mappedByFieldReadMethod, Method mappedByFieldWriteMethod, Class mappedByObjType) {
try {
Collection<DataObject> lazyLoadedFieldValue = (Collection) lazyLoadedFieldReadMethod.invoke(obj);
StringSet mappedByFieldValue = (StringSet) mappedByFieldReadMethod.invoke(obj);
// otherwise, set the mapped by stringset to the list of id's in the lazy loaded collection
if (lazyLoadedFieldValue == null || lazyLoadedFieldValue.isEmpty()) {
if (mappedByFieldValue != null) {
mappedByFieldValue.clear();
mappedByFieldWriteMethod.invoke(obj, mappedByFieldValue);
}
} else {
if (mappedByFieldValue == null) {
mappedByFieldValue = (StringSet) mappedByObjType.newInstance();
}
DbClientCallbackEvent cb = mappedByFieldValue.getCallback();
mappedByFieldValue.setCallback(null);
copyCollectionToStringSet(lazyLoadedFieldValue, mappedByFieldValue);
mappedByFieldValue.setCallback(cb);
mappedByFieldWriteMethod.invoke(obj, mappedByFieldValue);
}
} catch (IllegalAccessException | IllegalArgumentException | InstantiationException | InvocationTargetException e) {
// we've done all the checking we can; if we end up here, it's a programming error
log.error(e.getMessage(), e);
}
}
use of com.emc.storageos.db.client.util.DbClientCallbackEvent in project coprhd-controller by CoprHD.
the class LazyLoadedCollection method removeAll.
/*
* (non-Javadoc)
*
* @see java.util.Collection#removeAll(java.util.Collection)
*/
@Override
public synchronized boolean removeAll(Collection<?> c) {
if (mappedByUriSet != null) {
DbClientCallbackEvent cb = mappedByUriSet.getCallback();
mappedByUriSet.setCallback(null);
mappedByUriSet.remove(toIds(c));
mappedByUriSet.setCallback(cb);
}
return getCollection().removeAll(c);
}
use of com.emc.storageos.db.client.util.DbClientCallbackEvent in project coprhd-controller by CoprHD.
the class LazyLoadedCollection method addAll.
/*
* (non-Javadoc)
*
* @see java.util.Collection#addAll(java.util.Collection)
*/
@Override
public synchronized boolean addAll(Collection<? extends E> c) {
if (mappedByUriSet != null) {
DbClientCallbackEvent cb = mappedByUriSet.getCallback();
mappedByUriSet.setCallback(null);
mappedByUriSet.addAll(toIds(c));
mappedByUriSet.setCallback(cb);
}
return getCollection().addAll(c);
}
use of com.emc.storageos.db.client.util.DbClientCallbackEvent in project coprhd-controller by CoprHD.
the class LazyLoadedCollection method clear.
/*
* (non-Javadoc)
*
* @see java.util.Collection#clear()
*/
@Override
public synchronized void clear() {
if (mappedByUriSet != null) {
DbClientCallbackEvent cb = mappedByUriSet.getCallback();
mappedByUriSet.setCallback(null);
mappedByUriSet.clear();
mappedByUriSet.setCallback(cb);
}
getCollection().clear();
}
use of com.emc.storageos.db.client.util.DbClientCallbackEvent in project coprhd-controller by CoprHD.
the class LazyLoadedCollection method add.
/*
* (non-Javadoc)
*
* @see java.util.Collection#add(java.lang.Object)
*/
@Override
public synchronized boolean add(E e) {
if (mappedByUriSet != null) {
DbClientCallbackEvent cb = mappedByUriSet.getCallback();
mappedByUriSet.setCallback(null);
mappedByUriSet.add(e.getId().toString());
mappedByUriSet.setCallback(cb);
}
return getCollection().add(e);
}
Aggregations