Пример #1
0
  /** @inheritDoc */
  public void refresh(Object theObj) {
    assertStateOk(theObj);

    assertContains(theObj);

    Object aDbObj = find(theObj.getClass(), EmpireUtil.asSupportsRdfId(theObj).getRdfId());

    Collection<AccessibleObject> aAccessors = new HashSet<AccessibleObject>();

    aAccessors.addAll(getAnnotatedFields(aDbObj.getClass()));
    aAccessors.addAll(getAnnotatedGetters(aDbObj.getClass(), true));

    if (theObj instanceof EmpireGenerated) {
      ((EmpireGenerated) theObj).setAllTriples(((EmpireGenerated) aDbObj).getAllTriples());
      ((EmpireGenerated) theObj)
          .setInstanceTriples(((EmpireGenerated) aDbObj).getInstanceTriples());
    }

    try {
      for (AccessibleObject aAccess : aAccessors) {
        Object aValue = safeGet(aAccess, aDbObj);

        AccessibleObject aSetter = asSetter(aDbObj.getClass(), aAccess);

        safeSet(aSetter, theObj, aValue);
      }
    } catch (InvocationTargetException e) {
      throw new PersistenceException(e);
    }
  }