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

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

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

NakedObjectSpecification.getAssociation介绍

暂无

代码示例

代码示例来源:origin: org.nakedobjects.plugins/dndviewer

private NakedObjectAssociation fieldFromActualSpec(final NakedObjectSpecification spec, final NakedObjectAssociation field) {
  final String fieldName = field.getId();
  return spec.getAssociation(fieldName);
}

代码示例来源:origin: org.nakedobjects.core/runtime

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

代码示例来源:origin: org.nakedobjects/remoting

private NakedObjectMember getAssociationElseThrowException(final Identifier id, final NakedObjectSpecification specification) {
  NakedObjectMember member = specification.getAssociation(id.getMemberName());
  if (member == null) {
    throw new NakedObjectException("No property or collection found for id " + id);
  }
  return member;
}

代码示例来源:origin: org.nakedobjects.core/remoting

private NakedObjectMember getAssociationElseThrowException(final Identifier id, final NakedObjectSpecification specification) {
  NakedObjectMember member = specification.getAssociation(id.getMemberName());
  if (member == null) {
    throw new NakedObjectException("No property or collection found for id " + id);
  }
  return member;
}

代码示例来源:origin: org.nakedobjects.core/remoting

/**
 * Applies only for {@link OneToOneAssociation}s.
 */
public ClearValueResponse clearValue(
    final ClearValueRequest request) {
  
  AuthenticationSession session = request.getSession();
  String fieldIdentifier = request.getFieldIdentifier();
  IdentityData targetIdentityData = request.getTarget();
  if (LOG.isDebugEnabled()) {
    LOG.debug("request clearValue " + fieldIdentifier + " on " + targetIdentityData + " for " + session);
  }
  
  final NakedObject targetAdapter = getPersistentNakedObject(session, targetIdentityData);
  final OneToOneAssociation association = (OneToOneAssociation) targetAdapter.getSpecification().getAssociation(fieldIdentifier);
  ensureAssociationModifiableElseThrowException(session, targetAdapter, association);
  association.clearAssociation(targetAdapter);
  return new ClearValueResponse(getUpdates());
}

代码示例来源:origin: org.nakedobjects/remoting

/**
 * Applies only for {@link OneToOneAssociation}s.
 */
public ClearValueResponse clearValue(
    final ClearValueRequest request) {
  
  AuthenticationSession session = request.getSession();
  String fieldIdentifier = request.getFieldIdentifier();
  IdentityData targetIdentityData = request.getTarget();
  if (LOG.isDebugEnabled()) {
    LOG.debug("request clearValue " + fieldIdentifier + " on " + targetIdentityData + " for " + session);
  }
  
  final NakedObject targetAdapter = getPersistentNakedObject(session, targetIdentityData);
  final OneToOneAssociation association = (OneToOneAssociation) targetAdapter.getSpecification().getAssociation(fieldIdentifier);
  ensureAssociationModifiableElseThrowException(session, targetAdapter, association);
  association.clearAssociation(targetAdapter);
  return new ClearValueResponse(getUpdates());
}

代码示例来源:origin: org.nakedobjects.core/remoting

public ResolveFieldResponse resolveField(
    ResolveFieldRequest request) {
  
  AuthenticationSession session = request.getSession();
  IdentityData targetData = request.getTarget();
  String fieldIdentifier = request.getFieldIdentifier();
  if (LOG.isDebugEnabled()) {
    LOG.debug("request resolveField " + targetData + "/" + fieldIdentifier + " for " + session);
  }
  final NakedObjectSpecification spec = getSpecification(targetData.getType());
  final NakedObjectAssociation field = spec.getAssociation(fieldIdentifier);
  final NakedObject targetAdapter = getPersistenceSession().recreateAdapter(targetData.getOid(), spec);
  
  getPersistenceSession().resolveField(targetAdapter, field);
  Data data = encoderDecoder.encodeForResolveField(targetAdapter, fieldIdentifier);
  return new ResolveFieldResponse(data);
}

代码示例来源:origin: org.nakedobjects/remoting

public ResolveFieldResponse resolveField(
    ResolveFieldRequest request) {
  
  AuthenticationSession session = request.getSession();
  IdentityData targetData = request.getTarget();
  String fieldIdentifier = request.getFieldIdentifier();
  if (LOG.isDebugEnabled()) {
    LOG.debug("request resolveField " + targetData + "/" + fieldIdentifier + " for " + session);
  }
  final NakedObjectSpecification spec = getSpecification(targetData.getType());
  final NakedObjectAssociation field = spec.getAssociation(fieldIdentifier);
  final NakedObject targetAdapter = getPersistenceSession().recreateAdapter(targetData.getOid(), spec);
  
  getPersistenceSession().resolveField(targetAdapter, field);
  Data data = encoderDecoder.encodeForResolveField(targetAdapter, fieldIdentifier);
  return new ResolveFieldResponse(data);
}

代码示例来源:origin: org.nakedobjects.plugins/htmlviewer-viewer

public void execute(final Request request, final Context context, final Page page) {
  final String objectId = request.getObjectId();
  final String elementId = request.getElementId();
  final String collectionField = request.getProperty();
  final NakedObject target = context.getMappedObject(objectId);
  final NakedObject element = context.getMappedObject(elementId);
  final NakedObjectSpecification specification = target.getSpecification();
  final OneToManyAssociation field = (OneToManyAssociation) specification.getAssociation(collectionField);
  field.removeElement(target, element);
  request.forward(ForwardRequest.viewObject(objectId, collectionField));
}

代码示例来源:origin: org.nakedobjects.plugins/html-viewer

public void execute(final Request request, final Context context, final Page page) {
  final String objectId = request.getObjectId();
  final String elementId = request.getElementId();
  final String collectionField = request.getProperty();
  final NakedObject target = context.getMappedObject(objectId);
  final NakedObject element = context.getMappedObject(elementId);
  final NakedObjectSpecification specification = target.getSpecification();
  final OneToManyAssociation field = (OneToManyAssociation) specification.getAssociation(collectionField);
  field.removeElement(target, element);
  request.forward(ForwardRequest.viewObject(objectId, collectionField));
}

代码示例来源:origin: org.nakedobjects/remoting

/**
 * Applies to both {@link OneToOneAssociation}s and {@link OneToManyAssociation}s.
 */
public SetAssociationResponse setAssociation(
    final SetAssociationRequest request) {
  
  AuthenticationSession session = request.getSession();
  String fieldIdentifier = request.getFieldIdentifier();
  IdentityData targetData = request.getTarget();
  IdentityData associateData = request.getAssociate();
  
  if (LOG.isDebugEnabled()) {
    LOG.debug("request setAssociation " + fieldIdentifier + " on " + targetData + " with " + associateData + " for " + session);
  }
  
  final NakedObject targetAdapter = getPersistentNakedObject(session, targetData);
  final NakedObject associate = getPersistentNakedObject(session, associateData);
  final NakedObjectAssociation association = targetAdapter.getSpecification().getAssociation(fieldIdentifier);
  
  ensureAssociationModifiableElseThrowException(session, targetAdapter, association);
  
  if (association instanceof OneToOneAssociation) {
    ((OneToOneAssociation) association).setAssociation(targetAdapter, associate);
  } else {
    ((OneToManyAssociation) association).addElement(targetAdapter, associate);
  }
  
  return new SetAssociationResponse(getUpdates());
}

代码示例来源:origin: org.nakedobjects.core/remoting

/**
 * Applies to both {@link OneToOneAssociation}s and {@link OneToManyAssociation}s.
 */
public SetAssociationResponse setAssociation(
    final SetAssociationRequest request) {
  
  AuthenticationSession session = request.getSession();
  String fieldIdentifier = request.getFieldIdentifier();
  IdentityData targetData = request.getTarget();
  IdentityData associateData = request.getAssociate();
  
  if (LOG.isDebugEnabled()) {
    LOG.debug("request setAssociation " + fieldIdentifier + " on " + targetData + " with " + associateData + " for " + session);
  }
  
  final NakedObject targetAdapter = getPersistentNakedObject(session, targetData);
  final NakedObject associate = getPersistentNakedObject(session, associateData);
  final NakedObjectAssociation association = targetAdapter.getSpecification().getAssociation(fieldIdentifier);
  
  ensureAssociationModifiableElseThrowException(session, targetAdapter, association);
  
  if (association instanceof OneToOneAssociation) {
    ((OneToOneAssociation) association).setAssociation(targetAdapter, associate);
  } else {
    ((OneToManyAssociation) association).addElement(targetAdapter, associate);
  }
  
  return new SetAssociationResponse(getUpdates());
}

代码示例来源:origin: org.nakedobjects.plugins/html-viewer

public void execute(final Request request, final Context context, final Page page) {
  final String collectionField = request.getProperty();
  final String idString = request.getObjectId();
  if (idString == null) {
    throw new ActionException("Task no longer in progress");
  }
  final NakedObject object = context.getMappedObject(idString);
  final NakedObjectSpecification specification = object.getSpecification();
  final OneToManyAssociation field = (OneToManyAssociation) specification.getAssociation(collectionField);
  final AddItemToCollectionTask addTask = new AddItemToCollectionTask(context, object, field);
  context.addTaskCrumb(addTask);
  request.forward(ForwardRequest.task(addTask));
}

代码示例来源:origin: org.nakedobjects.plugins/htmlviewer-viewer

public void execute(final Request request, final Context context, final Page page) {
  final String collectionField = request.getProperty();
  final String idString = request.getObjectId();
  if (idString == null) {
    throw new ActionException("Task no longer in progress");
  }
  final NakedObject object = context.getMappedObject(idString);
  final NakedObjectSpecification specification = object.getSpecification();
  final OneToManyAssociation field = (OneToManyAssociation) specification.getAssociation(collectionField);
  final AddItemToCollectionTask addTask = new AddItemToCollectionTask(context, object, field);
  context.addTaskCrumb(addTask);
  request.forward(ForwardRequest.task(addTask));
}

代码示例来源:origin: org.nakedobjects/remoting

/**
 * Applies only for {@link OneToOneAssociation}s.
 */
public SetValueResponse setValue(
    SetValueRequest request) {
  
  AuthenticationSession session = request.getSession();
  String fieldIdentifier = request.getFieldIdentifier();
  IdentityData targetIdentityData = request.getTarget();
  EncodableObjectData encodeableObjectData = request.getValue();
  Assert.assertNotNull(encodeableObjectData);
  if (LOG.isDebugEnabled()) {
    LOG.debug("request setValue " + fieldIdentifier + " on " + targetIdentityData + " with " + encodeableObjectData + " for " + session);
  }
  
  final NakedObject targetAdapter = getPersistentNakedObject(session, targetIdentityData);
  final OneToOneAssociation association = (OneToOneAssociation) targetAdapter.getSpecification().getAssociation(fieldIdentifier);
  
  ensureAssociationModifiableElseThrowException(session, targetAdapter, association);
  final String encodedObject = encodeableObjectData.getEncodedObjectData();
  final NakedObjectSpecification specification = association.getSpecification();
  final NakedObject adapter = restoreLeafObject(encodedObject, specification);
  association.setAssociation(targetAdapter, adapter);
  
  return new SetValueResponse(getUpdates());
}

代码示例来源:origin: org.nakedobjects.core/remoting

/**
 * Applies only for {@link OneToOneAssociation}s.
 */
public SetValueResponse setValue(
    SetValueRequest request) {
  
  AuthenticationSession session = request.getSession();
  String fieldIdentifier = request.getFieldIdentifier();
  IdentityData targetIdentityData = request.getTarget();
  EncodableObjectData encodeableObjectData = request.getValue();
  Assert.assertNotNull(encodeableObjectData);
  if (LOG.isDebugEnabled()) {
    LOG.debug("request setValue " + fieldIdentifier + " on " + targetIdentityData + " with " + encodeableObjectData + " for " + session);
  }
  
  final NakedObject targetAdapter = getPersistentNakedObject(session, targetIdentityData);
  final OneToOneAssociation association = (OneToOneAssociation) targetAdapter.getSpecification().getAssociation(fieldIdentifier);
  
  ensureAssociationModifiableElseThrowException(session, targetAdapter, association);
  final String encodedObject = encodeableObjectData.getEncodedObjectData();
  final NakedObjectSpecification specification = association.getSpecification();
  final NakedObject adapter = restoreLeafObject(encodedObject, specification);
  association.setAssociation(targetAdapter, adapter);
  
  return new SetValueResponse(getUpdates());
}

代码示例来源:origin: org.nakedobjects.core/remoting

final NakedObject associateAdapter = getPersistentNakedObject(session, associateData);
final NakedObjectSpecification specification = targetAdapter.getSpecification();
final NakedObjectAssociation association = specification.getAssociation(fieldIdentifier);

代码示例来源:origin: org.nakedobjects/remoting

final NakedObject associateAdapter = getPersistentNakedObject(session, associateData);
final NakedObjectSpecification specification = targetAdapter.getSpecification();
final NakedObjectAssociation association = specification.getAssociation(fieldIdentifier);

代码示例来源:origin: org.nakedobjects.plugins/htmlviewer-viewer

@Override
protected void doExecute(final Context context, final ViewPane content, final NakedObject object, final String field) {
  final String id = context.mapObject(object);
  final NakedObjectSpecification specification = object.getSpecification();
  final OneToManyAssociation collection = (OneToManyAssociation) specification.getAssociation(field);
  NakedObjectsContext.getPersistenceSession().resolveField(object, collection);
  context.addCollectionFieldCrumb(collection.getName());
  content.add(context.getComponentFactory().createHeading(collection.getName()));
  final Table table = TableBuilder.createTable(context, id, object, collection);
  content.add(table);
  if (collection.isUsable(NakedObjectsContext.getAuthenticationSession(), object).isAllowed()) {
    content.add(context.getComponentFactory().createAddOption(id, collection.getId()));
  }
}

代码示例来源:origin: org.nakedobjects.plugins/html-viewer

@Override
protected void doExecute(final Context context, final ViewPane content, final NakedObject object, final String field) {
  final String id = context.mapObject(object);
  final NakedObjectSpecification specification = object.getSpecification();
  final OneToManyAssociation collection = (OneToManyAssociation) specification.getAssociation(field);
  
  NakedObjectsContext.getPersistenceSession().resolveField(object, collection);
  
  context.addCollectionFieldCrumb(collection.getName());
  content.add(context.getComponentFactory().createHeading(collection.getName()));
  final Table table = TableUtil.createTable(context, id, object, collection);
  content.add(table);
  if (collection.isUsable(NakedObjectsContext.getAuthenticationSession(), object).isAllowed()) {
    content.add(context.getComponentFactory().createAddOption(id, collection.getId()));
  }
}

相关文章

微信公众号

最新文章

更多