You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/09/26 20:00:10 UTC
[isis] branch v2 updated: ISIS-1976: cleanup after removal of bulk
action support
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/v2 by this push:
new 4e7ea31 ISIS-1976: cleanup after removal of bulk action support
4e7ea31 is described below
commit 4e7ea3142403412fd495856d68fe291bc368c687
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Sep 26 21:53:19 2018 +0200
ISIS-1976: cleanup after removal of bulk action support
Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
---
.../apache/isis/applib/annotation/InvokedOn.java | 32 ---
.../collection/bulk/BulkActionsLinkFactory.java | 243 ---------------------
.../StandaloneCollectionPanel.java | 8 -
3 files changed, 283 deletions(-)
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/InvokedOn.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/InvokedOn.java
deleted file mode 100644
index d079dac..0000000
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/InvokedOn.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.applib.annotation;
-
-/**
- * How an action was invoked.
- */
-public enum InvokedOn {
- OBJECT,
- COLLECTION;
-
- public boolean isObject() { return this == OBJECT; }
- public boolean isCollection() { return this == COLLECTION; }
-
-
-}
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/bulk/BulkActionsLinkFactory.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/bulk/BulkActionsLinkFactory.java
deleted file mode 100644
index 799051f..0000000
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/collection/bulk/BulkActionsLinkFactory.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.viewer.wicket.ui.components.collection.bulk;
-
-import java.util.List;
-import java.util.stream.Collectors;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
-import org.apache.wicket.markup.html.link.AbstractLink;
-import org.apache.wicket.markup.html.link.Link;
-
-import org.apache.isis.applib.RecoverableException;
-import org.apache.isis.applib.services.command.Command;
-import org.apache.isis.applib.services.command.Command.Executor;
-import org.apache.isis.applib.services.command.CommandContext;
-import org.apache.isis.applib.services.xactn.TransactionService;
-import org.apache.isis.commons.internal.base._NullSafe;
-import org.apache.isis.commons.internal.collections._Lists;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.authentication.MessageBroker;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.concurrency.ConcurrencyChecking;
-import org.apache.isis.core.metamodel.adapter.version.ConcurrencyException;
-import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
-import org.apache.isis.core.metamodel.services.ServicesInjector;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.specloader.SpecificationLoader;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.runtime.system.session.IsisSessionFactory;
-import org.apache.isis.viewer.wicket.model.links.LinkAndLabel;
-import org.apache.isis.viewer.wicket.model.mementos.ActionMemento;
-import org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento;
-import org.apache.isis.viewer.wicket.model.models.ActionModel;
-import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
-import org.apache.isis.viewer.wicket.model.models.ToggledMementosProvider;
-import org.apache.isis.viewer.wicket.ui.actionresponse.ActionResultResponse;
-import org.apache.isis.viewer.wicket.ui.actionresponse.ActionResultResponseType;
-import org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.columns.ObjectAdapterToggleboxColumn;
-import org.apache.isis.viewer.wicket.ui.components.widgets.linkandlabel.ActionLinkFactory;
-import org.apache.isis.viewer.wicket.ui.errors.JGrowlBehaviour;
-
-public final class BulkActionsLinkFactory implements ActionLinkFactory {
-
- private static final long serialVersionUID = 1L;
- private final EntityCollectionModel model;
-
- private final ObjectAdapterToggleboxColumn toggleboxColumn;
-
- public BulkActionsLinkFactory(
- final EntityCollectionModel model,
- final ObjectAdapterToggleboxColumn toggleboxColumn) {
- this.model = model;
- this.toggleboxColumn = toggleboxColumn;
- }
-
- /**
- * @param objectAction
- * @param linkId
- */
- @Override
- public LinkAndLabel newLink(
- final ObjectAction objectAction,
- final String linkId,
- final ToggledMementosProvider toggledMementosProviderIfAny) {
-
- final ActionMemento actionMemento = new ActionMemento(objectAction);
- final AbstractLink link = new Link<Object>(linkId) {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick() {
- final ObjectAction objectAction = actionMemento.getAction(getSpecificationLoader());
- final ConcurrencyChecking concurrencyChecking =
- ConcurrencyChecking.concurrencyCheckingFor(objectAction.getSemantics());
-
- try {
- final List<ObjectAdapter> toggledAdapters = _NullSafe.stream(model.getToggleMementosList())
- .map(ObjectAdapterMemento.Functions.fromMemento(
- concurrencyChecking, getPersistenceSession(), getSpecificationLoader()))
- .collect(Collectors.toList());
-
- ObjectAdapter lastReturnedAdapter = null;
-
- for(final ObjectAdapter adapter : toggledAdapters) {
-
- final CommandContext commandContext = getServicesInjector().lookupService(CommandContext.class);
- final Command command;
- if (commandContext != null) {
- command = commandContext.getCommand();
- command.internal().setExecutor(Executor.USER);
- }
-
- int numParameters = objectAction.getParameterCount();
- if(numParameters != 0) {
- return;
- }
-
- final ObjectAdapter mixedInAdapter = null;
- final ObjectAdapter[] arguments = {};
-
- lastReturnedAdapter = objectAction.executeWithRuleChecking(
- adapter, mixedInAdapter, arguments,
- InteractionInitiatedBy.USER, ActionModel.WHERE_FOR_ACTION_INVOCATION
- );
- TransactionService transactionService =
- getServicesInjector().lookupService(TransactionService.class);
- transactionService.nextTransaction();
- }
-
-
- model.clearToggleMementosList();
- toggleboxColumn.clearToggles();
-
- final ActionModel actionModel = model.getActionModelHint();
- if(actionModel != null && actionModel.getActionMemento().getAction(getSpecificationLoader()).getSemantics().isIdempotentInNature()) {
- actionModel.detach(); // force reload
- ObjectAdapter resultAdapter = actionModel.getObject();
- model.setObjectList(resultAdapter);
- } else {
- model.setObject(persistentAdaptersWithin(model.getObject()));
- }
-
- if(lastReturnedAdapter != null) {
- final ActionResultResponse resultResponse =
- ActionResultResponseType.determineAndInterpretResult(actionModel, null, lastReturnedAdapter);
- resultResponse.getHandlingStrategy().handleResults(resultResponse, model.getIsisSessionFactory());
- }
-
- } catch(final ConcurrencyException ex) {
-
- recover();
- // display a warning to the user so that they know that the action wasn't performed
- getMessageBroker().addWarning(ex.getMessage());
- return;
-
- } catch(final RuntimeException ex) {
-
- final RecoverableException appEx = RecoverableException.Util.getRecoverableExceptionIfAny(ex);
- if (appEx != null) {
-
- recover();
-
- getMessageBroker().setApplicationError(appEx.getMessage());
-
- // there's no need to abort the transaction, it will have already been done
- // (in IsisTransactionManager#executeWithinTransaction(...)).
- return;
- }
- throw ex;
- }
- }
-
- private void recover() {
- // resync with the objectstore
- final List<ObjectAdapterMemento> toggleMementosList = _Lists.newArrayList(model.getToggleMementosList());
- for (ObjectAdapterMemento oam : toggleMementosList) {
- // just requesting the adapter will sync the OAM's version with the objectstore
- oam.getObjectAdapter(ConcurrencyChecking.NO_CHECK, getPersistenceSession(), getSpecificationLoader());
- }
-
- // discard any adapters that might have been deleted
- model.setObject(persistentAdaptersWithin(model.getObject()));
-
- // attempt to preserve the toggled adapters
- final List<ObjectAdapter> adapters = model.getObject();
- model.clearToggleMementosList();
- for (ObjectAdapterMemento oam : toggleMementosList) {
- final ObjectAdapter objectAdapter = oam.getObjectAdapter(ConcurrencyChecking.NO_CHECK,
- getPersistenceSession(), getSpecificationLoader());
- if(adapters.contains(objectAdapter)) {
- // in case it has been deleted...
- model.toggleSelectionOn(objectAdapter);
- }
- }
- }
-
- private List<ObjectAdapter> persistentAdaptersWithin(List<ObjectAdapter> adapters) {
- return _Lists.newArrayList(Iterables.filter(adapters, new Predicate<ObjectAdapter>() {
- @Override
- public boolean apply(ObjectAdapter input) {
- return !input.isTransient() && !input.isDestroyed();
- }
- }));
- }
-
- };
- link.add(new JGrowlBehaviour());
-
- final String disabledReasonIfAny = null;
- final boolean blobOrClob = false;
- final ObjectAdapter objectAdapter = null;
-
- return LinkAndLabel.newLinkAndLabel(objectAdapter, objectAction, link, disabledReasonIfAny, blobOrClob);
- }
-
- ///////////////////////////////////////////////////////
- // Dependencies (from context)
- ///////////////////////////////////////////////////////
-
- SpecificationLoader getSpecificationLoader() {
- return getIsisSessionFactory().getSpecificationLoader();
- }
-
- PersistenceSession getPersistenceSession() {
- return getIsisSessionFactory().getCurrentSession().getPersistenceSession();
- }
-
- public AuthenticationSession getAuthenticationSession() {
- return getIsisSessionFactory().getCurrentSession().getAuthenticationSession();
- }
-
- protected MessageBroker getMessageBroker() {
- return getAuthenticationSession().getMessageBroker();
- }
-
- protected ServicesInjector getServicesInjector() {
- return getIsisSessionFactory().getServicesInjector();
- }
-
- private IsisSessionFactory getIsisSessionFactory() {
- return model.getIsisSessionFactory();
- }
-
-}
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.java
index 8584c00..dbe2202 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/standalonecollection/StandaloneCollectionPanel.java
@@ -28,20 +28,16 @@ import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.Model;
-import org.apache.isis.commons.internal.collections._Lists;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
import org.apache.isis.viewer.wicket.model.common.OnSelectionHandler;
-import org.apache.isis.viewer.wicket.model.links.LinkAndLabel;
import org.apache.isis.viewer.wicket.model.models.ActionModel;
import org.apache.isis.viewer.wicket.model.models.ActionPromptProvider;
import org.apache.isis.viewer.wicket.model.models.EntityCollectionModel;
import org.apache.isis.viewer.wicket.ui.ComponentFactory;
import org.apache.isis.viewer.wicket.ui.ComponentType;
import org.apache.isis.viewer.wicket.ui.app.registry.ComponentFactoryRegistry;
-import org.apache.isis.viewer.wicket.ui.components.actionmenu.entityactions.AdditionalLinksPanel;
import org.apache.isis.viewer.wicket.ui.components.actionprompt.ActionPromptModalWindow;
-import org.apache.isis.viewer.wicket.ui.components.collection.bulk.BulkActionsLinkFactory;
import org.apache.isis.viewer.wicket.ui.components.collection.bulk.BulkActionsProvider;
import org.apache.isis.viewer.wicket.ui.components.collection.count.CollectionCountProvider;
import org.apache.isis.viewer.wicket.ui.components.collection.selector.CollectionSelectorHelper;
@@ -61,15 +57,11 @@ implements CollectionCountProvider, CollectionSelectorProvider, BulkActionsProvi
private static final String ID_ACTION_NAME = "actionName";
private static final String ID_ACTION_PROMPT_MODAL_WINDOW = "actionPromptModalWindow";
- private static final String ID_ADDITIONAL_LINKS = "additionalLinks";
- private static final String ID_ADDITIONAL_LINK = "additionalLink";
-
private static final String ID_SELECTOR_DROPDOWN = "selectorDropdown";
private final ActionPromptModalWindow actionPromptModalWindow;
private final CollectionSelectorPanel selectorDropdownPanel;
- private boolean additionalLinksAdded;
private MarkupContainer outerDiv = this;