Пример #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;
  }