@Override public boolean apply(final ObjectAction input) { return input.getType() == type; } };
public boolean matchesTypeOf(final ObjectAction action) { return action != null && action.getType().equals(this); }
public static List<ObjectAction> flattened(final List<ObjectAction> objectActions) { final List<ObjectAction> actions = Lists.newArrayList(); for (final ObjectAction action : objectActions) { if (action.getType() == ActionType.SET) { final ObjectActionSet actionSet = (ObjectActionSet) action; final List<ObjectAction> subActions = actionSet.getActions(); for (final ObjectAction subAction : subActions) { actions.add(subAction); } } else { actions.add(action); } } return actions; }
private List<ObjectAction> getFlattenedActions(final List<ObjectAction> objectActions, final ActionType type) { final List<ObjectAction> actions = Lists.newArrayList(); for (final ObjectAction action : objectActions) { if (action.getType().isSet()) { final ObjectActionSet actionSet = (ObjectActionSet) action; final List<ObjectAction> subActions = actionSet.getActions(); for (final ObjectAction subAction : subActions) { if (type.matchesTypeOf(subAction)) { actions.add(subAction); } } } else { if (type.matchesTypeOf(action)) { actions.add(action); } } } return actions; }
private ObjectAction getAction(final List<ObjectAction> availableActions, final ActionType type, final String actionName, final List<ObjectSpecification> parameters) { outer: for (int i = 0; i < availableActions.size(); i++) { final ObjectAction action = availableActions.get(i); if (action.getActions().size() > 0) { // deal with action set final ObjectAction a = getAction(action.getActions(), type, actionName, parameters); if (a != null) { return a; } } else { // regular action if (!action.getType().equals(type)) { continue outer; } if (actionName != null && !actionName.equals(action.getId())) { continue outer; } if (action.getParameters().size() != parameters.size()) { continue outer; } for (int j = 0; j < parameters.size(); j++) { if (!parameters.get(j).isOfType(action.getParameters().get(j).getSpecification())) { continue outer; } } return action; } } return null; }
public ActionMemento(final ObjectAction action) { this(new SpecMemento(action.getOnType()), action.getType(), action.getIdentifier().toNameParmsIdentityString()); this.action = action; }
@Override protected void putExtensionsIsisProprietary() { getExtensions().mapPut("actionType", objectMember.getType().name().toLowerCase()); final ActionSemantics.Of semantics = objectMember.getSemantics(); getExtensions().mapPut("actionSemantics", semantics.getCamelCaseName()); }
@Override protected void putExtensionsIsisProprietary() { getExtensions().mapPut("actionType", objectMember.getType().name().toLowerCase()); final ActionSemantics.Of semantics = objectMember.getSemantics(); getExtensions().mapPut("actionSemantics", semantics.getCamelCaseName()); }
@Override protected void putExtensionsIsisProprietary() { getExtensions().mapPut("actionType", objectMember.getType().name().toLowerCase()); final ActionSemantics.Of semantics = objectMember.getSemantics(); getExtensions().mapPut("actionSemantics", semantics.getCamelCaseName()); }
public ActionMemento( final ObjectSpecId owningType, final ActionType actionType, final String nameParmsId, final SpecificationLoader specificationLoader) { this(owningType, actionType, nameParmsId, actionFor(owningType, actionType, nameParmsId, specificationLoader)); }
public ActionMemento( final ObjectSpecId owningType, final ActionType actionType, final String nameParmsId, final SpecificationLoader specificationLoader) { this(owningType, actionType, nameParmsId, actionFor(owningType, actionType, nameParmsId, specificationLoader)); }
public void getType(final ObjectAction mockAction, final ActionType returns) { context.checking(new Expectations() { { allowing(mockAction).getType(); will(returnValue(returns)); } }); }
/** * Factory method for creating {@link PageParameters}. * * see {@link #ActionModel(PageParameters, SpecificationLoader)} */ public static PageParameters createPageParameters( final ObjectAdapter adapter, final ObjectAction objectAction, final ConcurrencyChecking concurrencyChecking) { final PageParameters pageParameters = PageParametersUtils.newPageParameters(); final String oidStr = concurrencyChecking == ConcurrencyChecking.CHECK? adapter.getOid().enString(): adapter.getOid().enStringNoVersion(); PageParameterNames.OBJECT_OID.addStringTo(pageParameters, oidStr); final ActionType actionType = objectAction.getType(); PageParameterNames.ACTION_TYPE.addEnumTo(pageParameters, actionType); final ObjectSpecification actionOnTypeSpec = objectAction.getOnType(); if (actionOnTypeSpec != null) { PageParameterNames.ACTION_OWNING_SPEC.addStringTo(pageParameters, actionOnTypeSpec.getFullIdentifier()); } final String actionId = determineActionId(objectAction); PageParameterNames.ACTION_ID.addStringTo(pageParameters, actionId); return pageParameters; }
/** * Factory method for creating {@link PageParameters}. * * see {@link #ActionModel(PageParameters, SpecificationLoader)} */ public static PageParameters createPageParameters( final ObjectAdapter adapter, final ObjectAction objectAction, final ConcurrencyChecking concurrencyChecking) { final PageParameters pageParameters = PageParametersUtils.newPageParameters(); final String oidStr = concurrencyChecking == ConcurrencyChecking.CHECK? adapter.getOid().enString(): adapter.getOid().enStringNoVersion(); PageParameterNames.OBJECT_OID.addStringTo(pageParameters, oidStr); final ActionType actionType = objectAction.getType(); PageParameterNames.ACTION_TYPE.addEnumTo(pageParameters, actionType); final ObjectSpecification actionOnTypeSpec = objectAction.getOnType(); if (actionOnTypeSpec != null) { PageParameterNames.ACTION_OWNING_SPEC.addStringTo(pageParameters, actionOnTypeSpec.getFullIdentifier()); } final String actionId = determineActionId(objectAction); PageParameterNames.ACTION_ID.addStringTo(pageParameters, actionId); return pageParameters; }
/** * Factory method for creating {@link PageParameters}. * * see {@link #ActionModel(PageParameters)} */ public static PageParameters createPageParameters(final ObjectAdapter adapter, final ObjectAction noAction, final OidStringifier oidStringifier, final ObjectAdapter contextAdapter, final SingleResultsMode singleResultsMode) { final PageParameters pageParameters = EntityModel.createPageParameters(adapter, oidStringifier); final String actionType = noAction.getType().name(); final String actionNameParmsId = determineActionId(noAction); final Mode actionMode = determineActionMode(noAction, contextAdapter); PageParameterNames.ACTION_TYPE.addTo(pageParameters, actionType); final ObjectSpecification actionOnTypeSpec = noAction.getOnType(); if (actionOnTypeSpec != null) { PageParameterNames.ACTION_OWNING_SPEC.addTo(pageParameters, actionOnTypeSpec.getFullIdentifier()); } PageParameterNames.ACTION_NAME_PARMS.addTo(pageParameters, actionNameParmsId); PageParameterNames.ACTION_MODE.addTo(pageParameters, actionMode.name()); PageParameterNames.ACTION_SINGLE_RESULTS_MODE.addTo(pageParameters, singleResultsMode.name()); addActionParamContextIfPossible(noAction, oidStringifier, contextAdapter, pageParameters); return pageParameters; }
private void addActions(final ObjectAdapter objectAdapter, final List<ObjectAction> actions, final JsonRepresentation members) { final LinkFollower linkFollower = getLinkFollower().follow("members"); for (final ObjectAction action : actions) { final Consent visibility = action.isVisible(getSession(), objectAdapter, resourceContext.getWhere()); if (!visibility.isAllowed()) { continue; } if (action.getType().isSet()) { final ObjectActionSet objectActionSet = (ObjectActionSet) action; final List<ObjectAction> subactions = objectActionSet.getActions(); addActions(objectAdapter, subactions, members); } else { final RendererFactory factory = getRendererFactoryRegistry().find(RepresentationType.OBJECT_ACTION); final ObjectActionReprRenderer renderer = (ObjectActionReprRenderer) factory.newRenderer(getResourceContext(), linkFollower, JsonRepresentation.newMap()); renderer.with(new ObjectAndAction(objectAdapter, action)).usingLinkTo(linkToBuilder); members.arrayAdd(renderer.render()); } } }