* @param child The to be referenced item.
* @param fieldIdx The field holding the reference.
*/
@SuppressWarnings("unchecked")
public static void addMapping(DcObject parent, DcObject child, int fieldIdx) {
DcMapping mapping = (DcMapping) DcModules.get(DcModules.getMappingModIdx(parent.getModule().getIndex(), child.getModule().getIndex(), fieldIdx)).getItem();
mapping.setValue(DcMapping._A_PARENT_ID, parent.getID());
mapping.setValue(DcMapping._B_REFERENCED_ID, child.getID());
mapping.setReference(child);
Collection<DcMapping> mappings = (Collection<DcMapping>) parent.getValue(fieldIdx);
mappings = mappings == null ? new ArrayList<DcMapping>() : mappings;
// check if a mapping exists already