本文整理了Java中org.nakedobjects.metamodel.spec.NakedObjectSpecification
类的一些代码示例,展示了NakedObjectSpecification
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NakedObjectSpecification
类的具体详情如下:
包路径:org.nakedobjects.metamodel.spec.NakedObjectSpecification
类名称:NakedObjectSpecification
暂无
代码示例来源:origin: org.nakedobjects/metamodel
public NakedObjectAction[] getServiceActionsFor(final NakedObjectActionType type) {
final List<NakedObject> services = getRuntimeContext().getServices();
final List<NakedObjectAction> relatedActions = new ArrayList<NakedObjectAction>();
for (NakedObject serviceAdapter : services) {
final NakedObjectAction[] serviceActions = serviceAdapter.getSpecification().getObjectActions(type);
final List<NakedObjectAction> matchingActions = new ArrayList<NakedObjectAction>();
for (int j = 0; j < serviceActions.length; j++) {
final NakedObjectSpecification returnType = serviceActions[j].getReturnType();
if (returnType != null && returnType.isCollection()) {
final TypeOfFacet facet = returnType.getFacet(TypeOfFacet.class);
final NakedObjectSpecification elementType = facet.valueSpec();
if (elementType.isOfType(this)) {
matchingActions.add(serviceActions[j]);
}
} else if (returnType != null && returnType.isOfType(this)) {
matchingActions.add(serviceActions[j]);
}
}
if (matchingActions.size() > 0) {
final NakedObjectActionSet set = new NakedObjectActionSet("id", serviceAdapter.titleString(), matchingActions, runtimeContext);
relatedActions.add(set);
}
}
return (NakedObjectAction[]) relatedActions.toArray(new NakedObjectAction[relatedActions.size()]);
}
代码示例来源:origin: org.nakedobjects.core/runtime
private static String[] specificationNames(final NakedObjectSpecification[] specifications) {
final String[] names = new String[specifications.length];
for (int i = 0; i < names.length; i++) {
names[i] = specifications[i].getFullName();
}
return names;
}
代码示例来源:origin: org.nakedobjects.plugins/dndviewer
private boolean containEnoughFields(Content content) {
NakedObjectSpecification specification = content.getSpecification();
NakedObjectAssociation[] associations = specification.getAssociations(new AbstractFilter<NakedObjectAssociation>() {
public boolean accept(NakedObjectAssociation t) {
return t.isOneToManyAssociation() || (t.isOneToOneAssociation() && !((OneToOneAssociation)t).getSpecification().isParseable());
}
});
// int threshold = NakedObjectsContext.getConfiguration().getInteger(Properties.PROPERTY_BASE + "tree-count-threshold", 2);
return associations.length >= 1;
}
代码示例来源:origin: org.nakedobjects.core/metamodel
protected static void checkChoicesType(RuntimeContext runtimeContext, Object[] objects, NakedObjectSpecification paramSpec) {
for (Object object : objects) {
NakedObjectSpecification componentSpec = runtimeContext.getSpecificationLoader().loadSpecification(object.getClass());
if (!componentSpec.isOfType(paramSpec)) {
throw new ModelException("Choice type incompatible with parameter type; expected " + paramSpec.getFullName() + ", but was " + componentSpec.getFullName());
}
}
}
代码示例来源:origin: org.nakedobjects/remoting
private NakedObject restoreLeafObject(final String encodedObject, final NakedObjectSpecification specification) {
final EncodableFacet encoder = specification.getFacet(EncodableFacet.class);
if (encoder == null) {
throw new NakedObjectException("No encoder for " + specification.getFullName());
}
final NakedObject object = encoder.fromEncodedString(encodedObject);
return object;
}
代码示例来源:origin: org.nakedobjects.plugins/htmlviewer-viewer
public final String image(final NakedObjectSpecification specification) {
if (specification == null) {
return image((String)null);
}
final String specShortName = specification.getShortName();
final String imageName = image(specShortName);
if (imageName != null) {
return imageName;
}
// search up the hierarchy
return image(specification.superclass());
}
代码示例来源:origin: org.nakedobjects/metamodel
public static boolean isImmutableOncePersisted(final NakedObjectSpecification specification) {
// this is a workaround for a dubious test
if (specification == null) {
return false;
}
final ImmutableFacet immutableFacet = specification.getFacet(ImmutableFacet.class);
if (immutableFacet == null) {
return false;
}
return immutableFacet.value() == When.ONCE_PERSISTED;
}
代码示例来源:origin: org.nakedobjects.plugins/dndviewer
public void execute() {
final ActionHelper helper = ActionHelper.createInstance(target, action);
Content content;
if (target == null && action.getOnType().isService() || target != null && target.getSpecification().isObject()) {
content = new ObjectActionContent(helper);
} else if (target.getSpecification().isCollection()) {
content = new CollectionActionContent(helper);
} else {
throw new UnknownTypeException(target);
}
final View dialog = Toolkit.getViewFactory().createDialog(content);
final Location loc = view.getAbsoluteLocation();
dialog.setLocation(loc);
workspace.addDialog(dialog);
}
代码示例来源:origin: org.nakedobjects.core/metamodel
public NakedObjectAction[] getServiceActionsFor(final NakedObjectActionType... types) {
final List<NakedObject> services = getRuntimeContext().getServices();
final List<NakedObjectAction> relatedActions = new ArrayList<NakedObjectAction>();
for (NakedObject serviceAdapter : services) {
final List<NakedObjectAction> matchingActions = new ArrayList<NakedObjectAction>();
for (NakedObjectActionType type : types) {
final NakedObjectAction[] serviceActions = serviceAdapter.getSpecification().getObjectActions(type);
for (int j = 0; j < serviceActions.length; j++) {
final NakedObjectSpecification returnType = serviceActions[j].getReturnType();
if (returnType != null && returnType.isCollection()) {
final TypeOfFacet facet = serviceActions[j].getFacet(TypeOfFacet.class);
final NakedObjectSpecification elementType = facet.valueSpec();
if (elementType.isOfType(this)) {
matchingActions.add(serviceActions[j]);
}
} else if (returnType != null && returnType.isOfType(this)) {
matchingActions.add(serviceActions[j]);
}
}
}
if (matchingActions.size() > 0) {
final NakedObjectActionSet set = new NakedObjectActionSet("id", serviceAdapter.titleString(), matchingActions,
runtimeContext);
relatedActions.add(set);
}
}
return (NakedObjectAction[]) relatedActions.toArray(new NakedObjectAction[relatedActions.size()]);
}
代码示例来源:origin: org.nakedobjects.core/runtime
private ObjectData createObjectData(final NakedObject adapter) {
final NakedObjectSpecification cls = adapter.getSpecification();
final NakedObjectAssociation[] fields = cls.getAssociations();
final ObjectData data = new ObjectData(adapter.getOid(), adapter.getResolveState().name(), cls.getFullName());
for (int i = 0; i < fields.length; i++) {
if (fields[i].isDerived()) {
continue;
}
createFieldData(adapter, data, fields[i]);
}
return data;
}
代码示例来源:origin: org.nakedobjects/metamodel
@Override
public boolean accept(final NakedObjectActionParameter parameter) {
return parameter.getSpecification().isObject();
}
};
代码示例来源:origin: org.nakedobjects.plugins/dndviewer
public Content createRootContent(final NakedObject object) {
Assert.assertNotNull(object);
final NakedObjectSpecification objectSpec = object.getSpecification();
if (objectSpec.isCollection()) {
return new RootCollection(object);
}
if (objectSpec.isObject()) {
return new RootObject(object);
}
throw new IllegalArgumentException("Must be an object or collection: " + object);
}
代码示例来源:origin: org.nakedobjects.core/runtime
/**
* Returns the title from the underlying business object.
*
* <p>
* If the object has not yet been resolved the specification will be asked for a unresolved title,
* which could of been persisted by the persistence mechanism. If either of the above provides null
* as the title then this method will return a title relating to the name of the object type,
* e.g. "A Customer", "A Product".
*/
public String titleString() {
if (getSpecification().isCollection()) {
final CollectionFacet facet = getSpecification().getFacet(CollectionFacet.class);
return collectionTitleString(facet);
} else {
return objectTitleString();
}
}
代码示例来源:origin: org.nakedobjects/metamodel
public static String typeNameFor(final NakedObjectSpecification specification) {
return specification.isCollection() ? "Collection" : "Object";
}
代码示例来源:origin: org.nakedobjects.plugins/htmlviewer-viewer
static void forwardObjectResult(final Request request, final Context context, final NakedObject resultAdapter) {
final String objectId = context.mapObject(resultAdapter);
if (resultAdapter.isTransient() &&
resultAdapter.getSpecification().persistability() == Persistability.USER_PERSISTABLE) {
request.forward(ForwardRequest.editObject(objectId));
} else if (resultAdapter.getSpecification().isService()) {
request.forward(ForwardRequest.viewService(objectId));
} else {
request.forward(ForwardRequest.viewObject(objectId));
}
}
代码示例来源:origin: org.nakedobjects/remoting
private final Data createParameter(final String type, final NakedObject adapter, final KnownObjectsRequest knownObjects) {
if (adapter == null) {
return dataFactory.createNullData(type);
}
if (!adapter.getSpecification().isObject()) {
throw new UnknownTypeException(adapter.getSpecification());
}
if (adapter.getSpecification().isEncodeable()) {
return serializer.serializeEncodeable(adapter);
} else {
return encode(adapter, clientSideActionParameterGraphDepth, knownObjects);
}
}
代码示例来源:origin: org.nakedobjects.core/runtime
public void reset() {
LOG.debug("reset");
for (Iterator<Map.Entry<Object, NakedObject>> iterator = adapterByPojoMap.entrySet().iterator(); iterator.hasNext();) {
Map.Entry<Object, NakedObject> entry = iterator.next();
NakedObject adapter = entry.getValue();
if (!adapter.getSpecification().isService()) {
iterator.remove();
}
}
}
代码示例来源: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/metamodel
public boolean promptForParameters(final NakedObject target) {
NakedObjectActionParameter[] parameters = getParameters();
if (isContributed() && !target.getSpecification().isService()) {
return getParameterCount() > 1 || !target.getSpecification().isOfType(parameters[0].getSpecification());
} else {
return getParameterCount() > 0;
}
}
代码示例来源:origin: org.nakedobjects.core/runtime
/**
* Checks whether there are any instances of the specified type. The object
* store should look for instances of the type represented by <variable>type
* </variable> and return <code>true</code> if there are, or
* <code>false</code> if there are not.
*/
public boolean hasInstances(final NakedObjectSpecification specification) {
if (LOG.isInfoEnabled()) {
LOG.info("hasInstances of " + specification.getShortName());
}
return hasInstancesFromPersistenceLayer(specification);
}
内容来源于网络,如有侵权,请联系作者删除!