/** * * @param fpo fastpath object * @param path path * @return object */ public static Object resolveValue(FastPathObject fpo, String path) { FastPathObject o = fpo; String[] parts = path.split("\\."); Object res = null; for (int i = 0; i < parts.length; i++) { if (o == null) { return res; } try { res = o.getFieldValue(parts[i]); } catch (IllegalAccessException e) { throw new ServiceException("Could not read object value.", e); } if (i + 1 < parts.length && res instanceof FastPathObject) { o = (FastPathObject) res; } } return res; } }
/** * * @param fpo fastpath object * @param path path * @return object */ public static Object resolveValue(FastPathObject fpo, String path) { FastPathObject o = fpo; String[] parts = path.split("\\."); Object res = null; for (int i = 0; i < parts.length; i++) { if (o == null) { return res; } try { res = o.getFieldValue(parts[i]); } catch (IllegalAccessException e) { throw new ServiceException("Could not read object value.", e); } if (i + 1 < parts.length && res instanceof FastPathObject) { o = (FastPathObject) res; } } return res; } }
/** * Get a list of key field values for the given object. This will return null if there are no * key fields for the object's class or if there are no non-null values for the key fields. * The key fields are kept in a consistent order with inherited fields appearing before those * defined in a subclass. * @param obj an object from the model * @param classKeys the key field definition for this model * @return the first available key field value or null */ public static List<Object> getKeyFieldValues(FastPathObject obj, Map<String, List<FieldDescriptor>> classKeys) { String clsName = DynamicUtil.getSimpleClass(obj).getSimpleName(); List<Object> fieldValueList = new ArrayList<Object>(); try { for (String keyField : getKeyFieldNames(classKeys, clsName)) { Object valueFromObject = obj.getFieldValue(keyField); if (valueFromObject != null) { fieldValueList.add(valueFromObject); } } return fieldValueList; } catch (IllegalAccessException e) { // this shouldn't happen because objects conform to the model LOG.error("Error fetching a key field value from object: " + obj); } return null; } }
/** * Constructs a new ResultCell object * @param imObj the InterMineObject or SimpleObject to wrap * @param path the Path * @param isKeyField should be true if this is an identifying field */ public ResultElement(FastPathObject imObj, Path path, boolean isKeyField) { this.imObj = imObj; this.keyField = isKeyField; this.path = path; if (imObj != null) { try { field = imObj.getFieldValue(path.getEndFieldDescriptor().getName()); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } else { field = null; } }
/** * Get a key field value for the given object. This will return null if there are no key fields * for the object's class or if there are no non-null values for the key fields. The key fields * are kept in a consistent order with inherited fields appearing before those defined in a * subclass. * @param obj an object from the model * @param classKeys the key field definition for this model * @return the first available key field value or null */ public static Object getKeyFieldValue(FastPathObject obj, Map<String, List<FieldDescriptor>> classKeys) { String clsName = DynamicUtil.getSimpleClass(obj).getSimpleName(); try { for (String keyField : getKeyFieldNames(classKeys, clsName)) { Object valueFromObject = obj.getFieldValue(keyField); if (valueFromObject != null) { return valueFromObject; } } } catch (IllegalAccessException e) { // this shouldn't happen because objects conform to the model LOG.error("Error fetching a key field value from object: " + obj); } return null; }
/** * Get a list of key field values for the given object. This will return null if there are no * key fields for the object's class or if there are no non-null values for the key fields. * The key fields are kept in a consistent order with inherited fields appearing before those * defined in a subclass. * @param obj an object from the model * @param classKeys the key field definition for this model * @return the first available key field value or null */ public static List<Object> getKeyFieldValues(FastPathObject obj, Map<String, List<FieldDescriptor>> classKeys) { String clsName = DynamicUtil.getSimpleClass(obj).getSimpleName(); List<Object> fieldValueList = new ArrayList<Object>(); try { for (String keyField : getKeyFieldNames(classKeys, clsName)) { Object valueFromObject = obj.getFieldValue(keyField); if (valueFromObject != null) { fieldValueList.add(valueFromObject); } } return fieldValueList; } catch (IllegalAccessException e) { // this shouldn't happen because objects conform to the model LOG.error("Error fetching a key field value from object: " + obj); } return null; } }
/** * Constructs a new ResultCell object * @param imObj the InterMineObject or SimpleObject to wrap * @param path the Path * @param isKeyField should be true if this is an identifying field */ public ResultElement(FastPathObject imObj, Path path, boolean isKeyField) { this.imObj = imObj; this.keyField = isKeyField; this.path = path; if (imObj != null) { try { field = imObj.getFieldValue(path.getEndFieldDescriptor().getName()); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } else { field = null; } }
/** * Get a key field value for the given object. This will return null if there are no key fields * for the object's class or if there are no non-null values for the key fields. The key fields * are kept in a consistent order with inherited fields appearing before those defined in a * subclass. * @param obj an object from the model * @param classKeys the key field definition for this model * @return the first available key field value or null */ public static Object getKeyFieldValue(FastPathObject obj, Map<String, List<FieldDescriptor>> classKeys) { String clsName = DynamicUtil.getSimpleClass(obj).getSimpleName(); try { for (String keyField : getKeyFieldNames(classKeys, clsName)) { Object valueFromObject = obj.getFieldValue(keyField); if (valueFromObject != null) { return valueFromObject; } } } catch (IllegalAccessException e) { // this shouldn't happen because objects conform to the model LOG.error("Error fetching a key field value from object: " + obj); } return null; }
Object value = obj.getFieldValue(att.getName());
Object value = obj.getFieldValue(att.getName());
Object value = obj.getFieldValue(fieldname);
Object value = obj.getFieldValue(fieldname);
FieldDescriptor field = fieldEntry.getValue(); if (field.relationType() == FieldDescriptor.M_N_RELATION) { Object sr = o.getFieldValue(fieldName); if (sr instanceof SingletonResults) { Query existingQ = ((SingletonResults) sr).getQuery();
FieldDescriptor field = fieldEntry.getValue(); if (field.relationType() == FieldDescriptor.M_N_RELATION) { Object sr = o.getFieldValue(fieldName); if (sr instanceof SingletonResults) { Query existingQ = ((SingletonResults) sr).getQuery();
= (Collection<Object>) obj.getFieldValue(refList.getName()); for (String refId : refList.getRefIds()) { col.add(objMap.get(refId));
= (Collection<Object>) obj.getFieldValue(refList.getName()); for (String refId : refList.getRefIds()) { col.add(objMap.get(refId));
switch (field.relationType()) { case FieldDescriptor.NOT_RELATION: Object value = srcObj.getFieldValue(fieldName); if (value instanceof ClobAccess) { case FieldDescriptor.ONE_ONE_RELATION: if ((type == FROM_DB) || (type == SOURCE)) { InterMineObject loser = (InterMineObject) dest.getFieldValue(fieldName); ReferenceDescriptor reverseRef = ((ReferenceDescriptor) field) .getReverseReferenceDescriptor(); timeSpentRecursing += time2 - time1; } else { target = (InterMineObject) srcObj.getFieldValue(fieldName); if (!seenBrokenOneToMany.contains(brokenOneToMany)) { @SuppressWarnings("unchecked") Collection<InterMineObject> col = (Collection) srcObj.getFieldValue(fieldName); if (!col.isEmpty()) { LOG.error("Data source should not contain data in the one to many " .equals(((InterMineObject) srcObj).getId()))))) { @SuppressWarnings("unchecked") Collection<InterMineObject> destCol = (Collection) dest.getFieldValue(fieldName); @SuppressWarnings("unchecked") Collection<InterMineObject> col = (Collection) srcObj.getFieldValue(fieldName); for (InterMineObject colObj : col) { if (type == FROM_DB) {
switch (field.relationType()) { case FieldDescriptor.NOT_RELATION: Object value = srcObj.getFieldValue(fieldName); if (value instanceof ClobAccess) { case FieldDescriptor.ONE_ONE_RELATION: if ((type == FROM_DB) || (type == SOURCE)) { InterMineObject loser = (InterMineObject) dest.getFieldValue(fieldName); ReferenceDescriptor reverseRef = ((ReferenceDescriptor) field) .getReverseReferenceDescriptor(); timeSpentRecursing += time2 - time1; } else { target = (InterMineObject) srcObj.getFieldValue(fieldName); if (!seenBrokenOneToMany.contains(brokenOneToMany)) { @SuppressWarnings("unchecked") Collection<InterMineObject> col = (Collection) srcObj.getFieldValue(fieldName); if (!col.isEmpty()) { LOG.error("Data source should not contain data in the one to many " .equals(((InterMineObject) srcObj).getId()))))) { @SuppressWarnings("unchecked") Collection<InterMineObject> destCol = (Collection) dest.getFieldValue(fieldName); @SuppressWarnings("unchecked") Collection<InterMineObject> col = (Collection) srcObj.getFieldValue(fieldName); for (InterMineObject colObj : col) { if (type == FROM_DB) {