Ejemplo n.º 1
0
  protected void setObject(final ObjectAdapterMemento parentObjectAdapterMemento) {
    final OneToOneAssociation property = propertyMemento.getProperty();
    final ObjectAdapter associatedAdapter =
        property.get(parentObjectAdapterMemento.getObjectAdapter(ConcurrencyChecking.CHECK));

    setObject(associatedAdapter);
  }
Ejemplo n.º 2
0
  /**
   * Not Wicket API, but used by <tt>EntityPage</tt> to do eager loading when rendering after
   * post-and-redirect.
   *
   * @return
   */
  public ObjectAdapter load(ConcurrencyChecking concurrencyChecking) {
    if (adapterMemento == null) {
      return null;
    }

    final ObjectAdapter objectAdapter = adapterMemento.getObjectAdapter(concurrencyChecking);
    return objectAdapter;
  }
  @Override
  protected String getDisplayText(final ObjectAdapterMemento choice) {
    if (choice == null) {
      return NULL_DISPLAY_TEXT;
    }

    final ObjectAdapter objectAdapter = choice.getObjectAdapter(ConcurrencyChecking.NO_CHECK);
    final IConverter<Object> converter = findConverter(objectAdapter);
    return converter != null
        ? converter.convertToString(objectAdapter.getObject(), getLocale())
        : objectAdapter.titleString(null);
  }
Ejemplo n.º 4
0
 /**
  * Analogous to {@link List#contains(Object)}, but does not perform {@link ConcurrencyChecking
  * concurrency checking} of the OID.
  */
 public boolean containedIn(List<ObjectAdapterMemento> list) {
   // REVIEW: heavy handed, ought to be possible to just compare the OIDs
   // ignoring the concurrency checking
   final ObjectAdapter currAdapter = getObjectAdapter(ConcurrencyChecking.NO_CHECK);
   for (ObjectAdapterMemento each : list) {
     if (each == null) {
       continue;
     }
     final ObjectAdapter otherAdapter = each.getObjectAdapter(ConcurrencyChecking.NO_CHECK);
     if (currAdapter == otherAdapter) {
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 5
0
  /**
   * Creates a model representing an action parameter of an action of a parent object, with the
   * {@link #getObject() value of this model} to be default value (if any) of that action parameter.
   */
  public ScalarModel(
      final ObjectAdapterMemento parentObjectAdapterMemento, final ActionParameterMemento apm) {
    this.kind = Kind.PARAMETER;
    this.parentObjectAdapterMemento = parentObjectAdapterMemento;
    this.parameterMemento = apm;

    final ObjectActionParameter actionParameter = parameterMemento.getActionParameter();
    // REVIEW: is no checking ok here?
    final ObjectAdapter defaultAdapter =
        actionParameter.getDefault(
            parentObjectAdapterMemento.getObjectAdapter(ConcurrencyChecking.NO_CHECK));
    setObject(defaultAdapter);

    setMode(Mode.EDIT);
  }
  /**
   * Filters all choices against a term by using their {@link
   * org.apache.isis.core.metamodel.adapter.ObjectAdapter#titleString(org.apache.isis.core.metamodel.adapter.ObjectAdapter)
   * title string}
   *
   * @param term The term entered by the user
   * @param choicesMementos The collections of choices to filter
   * @return A list of all matching choices
   */
  protected List<ObjectAdapterMemento> obtainMementos(
      String term, Collection<ObjectAdapterMemento> choicesMementos) {
    List<ObjectAdapterMemento> matches = Lists.newArrayList();
    if (Strings.isEmpty(term)) {
      matches.addAll(choicesMementos);
    } else {
      for (ObjectAdapterMemento candidate : choicesMementos) {
        ObjectAdapter objectAdapter = candidate.getObjectAdapter(ConcurrencyChecking.NO_CHECK);
        String title = objectAdapter.titleString(objectAdapter);
        if (title.toLowerCase().contains(term.toLowerCase())) {
          matches.add(candidate);
        }
      }
    }

    return matches;
  }
Ejemplo n.º 7
0
 private ObjectAdapter getPendingAdapter() {
   final ObjectAdapterMemento memento = getObject();
   return memento != null ? memento.getObjectAdapter(ConcurrencyChecking.NO_CHECK) : null;
 }