Пример #1
0
  /**
   * Refresh a property feature and/or value of iUserSession session.
   *
   * @param iUserSession The User Session
   * @param iUserObject The User Object of changed property
   * @param iFieldNames Optional field names to signal the change
   */
  public static void fieldChanged(
      SessionInfo iUserSession, Object iUserObject, String... iFieldNames) {
    if (iUserObject == null) return;

    if (iUserSession == null) iUserSession = component(SessionAspect.class).getActiveSessionInfo();

    List<FieldRefreshListener> listeners =
        Controller.getInstance().getListeners(FieldRefreshListener.class);

    synchronized (listeners) {
      SchemaObject sObj = Roma.session().getSchemaObject(iUserObject);
      if (sObj == null) return;

      if (iFieldNames == null || iFieldNames.length == 0) {
        // REFRESH ALL FIELDS
        for (Iterator<SchemaField> it = sObj.getFieldIterator(); it.hasNext(); )
          signalFieldChanged(iUserSession, iUserObject, listeners, sObj, it.next().getName());
      } else {
        // REFRESH PASSED FIELDS
        for (String fieldName : iFieldNames) {
          signalFieldChanged(iUserSession, iUserObject, listeners, sObj, fieldName);
        }
      }
    }
  }
Пример #2
0
  private static <T> SchemaFeatures getSchemaFeature(
      Object iUserObject, String elementName, Feature<T> feature) {
    SchemaObject schema = Roma.session().getSchemaObject(iUserObject);
    if (schema == null) return null;
    SchemaFeatures features = null;
    if (FeatureType.ACTION.equals(feature.getType())) {
      if (elementName == null) return null;
      features = schema.getAction(elementName);
      if (features == null) {
        if (schema.getSchemaClass().getAction(elementName) == null)
          throw new ConfigurationException(
              "Action '" + elementName + "' not found in class '" + schema + "'");
      }
    } else if (FeatureType.FIELD.equals(feature.getType())) {
      if (elementName == null) return null;
      features = schema.getField(elementName);
      if (features == null) {
        if (schema.getSchemaClass().getField(elementName) == null)
          throw new ConfigurationException(
              "Field '" + elementName + "' not found in class '" + schema + "'");
      }
    } else if (FeatureType.CLASS.equals(feature.getType())) features = schema;
    else if (FeatureType.EVENT.equals(feature.getType())) {
      if (elementName == null) return null;
      features = schema.getEvent(elementName);
    }

    return features;
  }
Пример #3
0
  /**
   * Refresh an object.
   *
   * @see ObjectContext#objectChanged(SessionInfo, Object)
   * @param iUserSession The User Session
   * @param iUserObject The User Object of changed property
   */
  public static void objectChanged(SessionInfo iUserSession, Object iUserObject) {
    if (iUserObject == null) return;

    if (iUserSession == null) iUserSession = Roma.session().getActiveSessionInfo();

    List<ObjectRefreshListener> listeners =
        Controller.getInstance().getListeners(ObjectRefreshListener.class);

    for (ObjectRefreshListener objectRefreshListener : listeners) {
      objectRefreshListener.onObjectRefresh(iUserSession, iUserObject);
    }
  }