org.nakedobjects.noa.spec.NakedObjectSpecification.getField()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(79)

本文整理了Java中org.nakedobjects.noa.spec.NakedObjectSpecification.getField()方法的一些代码示例,展示了NakedObjectSpecification.getField()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NakedObjectSpecification.getField()方法的具体详情如下:
包路径:org.nakedobjects.noa.spec.NakedObjectSpecification
类名称:NakedObjectSpecification
方法名:getField

NakedObjectSpecification.getField介绍

[英]Get the extension object of the specified type for the field with the specified name.

TODO: think this should live on NakedObjectMember - or even NakedObjectFeature - instead.
[中]为具有指定名称的字段获取指定类型的扩展对象。
TODO:我认为这应该在NakedObjectMember上实现,甚至NakedObjectFeature上实现。

代码示例

代码示例来源:origin: org.nakedobjects/nos-viewer-dnd

private NakedObjectField fieldFromActualSpec(NakedObjectSpecification spec, NakedObjectField field) {
  String fieldName = field.getId();
  return spec.getField(fieldName);
}

代码示例来源:origin: org.nakedobjects/nos-objectstore-hibernate

private void addIdType(
    final NakedObjectSpecification spec,
    final Element id,
    final String attributeName,
    final boolean nakedPropertyAccessor,
    final boolean valueFieldAccess) {
  try {
    NakedObjectField idField = spec.getField("id");
    if (idField != null && idField.getId().equals("id")) {
      setType(idField, id, attributeName, nakedPropertyAccessor, valueFieldAccess);
      return;
    }
  } catch (NakedObjectSpecificationException ignore) {}
  // field does not exist, but id property might not be exposed to Naked Objects
  // (e.g. private methods) so check class
  Method getIdMethod = extractGetMethod(spec, "id");
  if (getIdMethod != null) {
    id.addAttribute(attributeName, getIdMethod.getReturnType().getName());
  } else {
    id.addAttribute(attributeName, ID_TYPE);
    if (nakedPropertyAccessor) {
      id.addAttribute("access", OidAccessor.class.getName());
    }
  }
}

代码示例来源:origin: org.nakedobjects/nos-viewer-dnd

public void removeObject(final NakedObject object) {
  final NakedObject perspective = (NakedObject) getContent().getNaked();
  OneToManyAssociation fld = (OneToManyAssociation) perspective.getSpecification().getField("objects");
  fld.removeElement(perspective, object);
}

代码示例来源:origin: org.nakedobjects/nos-objectstore-hibernate

private void addTitleType(
    final NakedObjectSpecification spec,
    final Element element,
    final String attributeName,
    final boolean nakedPropertyAccessor,
    final boolean valueFieldAccess) {
  try {
    NakedObjectField titleField = spec.getField("title");
    if (titleField != null && titleField.getId().equals("Title")) {
      setType(titleField, element, attributeName, nakedPropertyAccessor, valueFieldAccess);
      return;
    }
  } catch (NakedObjectSpecificationException ignore) {}
  // field does not exist, but title property might not be exposed to Naked Objects
  // (e.g. private methods) so check class
  Method getTitleMethod = extractGetMethod(spec, "Title");
  if (getTitleMethod != null) {
    element.addAttribute(attributeName, getTitleMethod.getReturnType().getName());
  } else {
    element.addAttribute(attributeName, "string");
    if (nakedPropertyAccessor) {
      element.addAttribute("access", TitleAccessor.class.getName());
    }
  }
}

代码示例来源:origin: org.nakedobjects/nof-reflector-core

public Data resolveField(final Session session, final IdentityData target, final String fieldName) {
  LOG.debug("request resolveEagerly " + target + "/" + fieldName + " for " + session);
  NakedObjectSpecification spec = getSpecification(target.getType());
  NakedObjectField field = spec.getField(fieldName);
  // NakedObject object = NakedObjects.getObjectManager().getObject(target.getOid(), spec);
  NakedObject object = NakedObjectsContext.getObjectLoader().recreateAdapterForPersistent(target.getOid(), spec);
  NakedObjectsContext.getObjectPersistor().resolveField(object, field);
  return encoder.createForResolveField(object, fieldName);
}

代码示例来源:origin: org.nakedobjects/nof-reflector-core

public ObjectData[] clearValue(final Session session, final String fieldIdentifier, final IdentityData target) {
  LOG.debug("request clearValue " + fieldIdentifier + " on " + target + " for " + session);
  NakedObject inObject = getPersistentNakedObject(session, target);
  ValueAssociation association = (ValueAssociation) inObject.getSpecification().getField(fieldIdentifier);
  if (!association.isVisible() || association.isUsable(inObject).isVetoed()) {
    throw new IllegalRequestException("can't modify field as not visible or editable");
  }
  association.clearValue(inObject);
  return getUpdates();
}

代码示例来源:origin: org.nakedobjects/nof-utilities

field = nos.getField(fieldName);
} catch (NakedObjectSpecificationException ex) {
  LOG.info("includeField(Pl, Vec, Str): could not locate field, skipping");

代码示例来源:origin: org.nakedobjects/nos-objectstore-hibernate

private void checkInverseAssociations() {
  for (Iterator<PersistentNakedClass> iter = classes.values().iterator(); iter.hasNext();) {
    PersistentNakedClass persistentClass = iter.next();
    NakedObjectField[] fields = persistentClass.getUniqueFields();
    for (int i = 0; i < fields.length; i++) {
      if (fields[i].isValue() || !fields[i].isPersisted()) {
        continue;
      }
      PersistentNakedClass associatedClass = getPersistentClass(fields[i].getSpecification().getFullName());
      if (associatedClass == null) {
        continue;
      }
      String inverse = getInverse(persistentClass, fields[i].getId());
      if (inverse != null) {
        NakedObjectField associatedField = associatedClass.getSpecification().getField(inverse);
        Association association = new Association(associatedClass, associatedField, false);
        persistentClass.addAssociation(fields[i].getId(), association);
        Association reverseAssociation = new Association(persistentClass, fields[i], true);
        associatedClass.addAssociation(inverse, reverseAssociation);
      }
    }
  }
}

代码示例来源:origin: org.nakedobjects/nos-viewer-dnd

public void execute(Workspace workspace, View view, Location at) {
    
    ObjectContent parent = (ObjectContent) view.getParent().getContent();
    NakedObject perspective = parent.getObject();
    OneToManyAssociation fld = (OneToManyAssociation) perspective.getSpecification().getField("services");
    ServiceObject service = (ServiceObject) view.getContent();
    NakedObject element = service.getObject();
    fld.removeElement(perspective, element);
    super.execute(workspace, view, at);
  }
});

代码示例来源:origin: org.nakedobjects/nof-reflector-core

public ObjectData[] setAssociation(
    final Session session,
    final String fieldIdentifier,
    final IdentityData target,
    final IdentityData associated) {
  LOG.debug("request setAssociation " + fieldIdentifier + " on " + target + " with " + associated + " for " + session);
  NakedObject inObject = getPersistentNakedObject(session, target);
  NakedObject associate = getPersistentNakedObject(session, associated);
  NakedObjectField association = (NakedObjectField) inObject.getSpecification().getField(fieldIdentifier);
  if (!association.isVisible() || association.isUsable(inObject).isVetoed()) {
    throw new IllegalRequestException("can't modify field as not visible or editable");
  }
  if (association instanceof OneToOneAssociation) {
    ((OneToOneAssociation) association).setAssociation(inObject, associate);
  } else {
    ((OneToManyAssociation) association).addElement(inObject, associate);
  }
  return getUpdates();
}

代码示例来源:origin: org.nakedobjects/nof-reflector-core

public ObjectData[] clearAssociation(
    final Session session,
    final String fieldIdentifier,
    final IdentityData target,
    final IdentityData associated) {
  LOG.debug("request clearAssociation " + fieldIdentifier + " on " + target + " of " + associated + " for " + session);
  NakedObject inObject = getPersistentNakedObject(session, target);
  NakedObject associate = getPersistentNakedObject(session, associated);
  NakedObjectSpecification specification = inObject.getSpecification();
  NakedObjectField association = (NakedObjectField) specification.getField(fieldIdentifier);
  if (!association.isVisible() || association.isUsable(inObject).isVetoed()) {
    throw new IllegalRequestException("can't modify field as not visible or editable");
  }
  if (association instanceof OneToOneAssociation) {
    ((OneToOneAssociation) association).clearAssociation(inObject, associate);
  } else {
    ((OneToManyAssociation) association).removeElement(inObject, associate);
  }
  return getUpdates();
}

代码示例来源:origin: org.nakedobjects/nof-reflector-core

private NakedObjectMember getMember(final String memberName) {
  final MemberIdentifier id = MemberIdentifierImpl.fromIdentityString(memberName);
  final NakedObjectSpecification specification = NakedObjectsContext.getReflector().loadSpecification(id.getClassName());
  NakedObjectMember member;
  if (id.isField()) {
    member = (NakedObjectMember) specification.getField(id.getName());
    if (member == null) {
      throw new IllegalRequestException("No field found for id " + id);
    }
  } else {
    member = (NakedObjectMember) specification.getObjectAction(NakedObjectAction.USER, id.getName(), id
        .getParameterSpecifications());
    if (member == null) {
      throw new IllegalRequestException("No user action found for id " + id);
    }
  }
  return member;
}

代码示例来源:origin: org.nakedobjects/nof-reflector-core

public ObjectData[] setValue(
    final Session session,
    final String fieldIdentifier,
    final IdentityData target,
    final ValueData value) {
  Assert.assertNotNull(value);
  LOG.debug("request setValue " + fieldIdentifier + " on " + target + " with " + value + " for " + session);
  NakedObject inObject = getPersistentNakedObject(session, target);
  ValueAssociation association = (ValueAssociation) inObject.getSpecification().getField(fieldIdentifier);
  if (!association.isVisible() || association.isUsable(inObject).isVetoed()) {
    throw new IllegalRequestException("can't modify field as not visible or editable");
  }
  NakedValue fieldValue = (NakedValue) association.get(inObject);
  if (fieldValue != null) {
    // /byte[] encodedString =
    // NakedObjectsContext.getObjectLoader().createAdapterForValue(value).asEncodedString();
    fieldValue.restoreFromEncodedString(value.getEncodedValue());
  }
  NakedValue valueAdapter = NakedObjectsContext.getObjectLoader().createValueInstance(association.getSpecification());
  valueAdapter.restoreFromEncodedString(value.getEncodedValue());
  association.setValue(inObject, valueAdapter);
  return getUpdates();
}

代码示例来源:origin: org.nakedobjects/nos-viewer-dnd

OneToManyAssociation fld = (OneToManyAssociation) perspective.getSpecification().getField("services");
  fld.addElement(perspective, source);
  invalidateContent();
} else {
  if (!drag.isShift()) {
    OneToManyAssociation fld = (OneToManyAssociation) perspective.getSpecification().getField("objects");
    fld.addElement(perspective, source);

相关文章