diff --git a/.classpath b/.classpath
index d430d8b..256d116 100644
--- a/.classpath
+++ b/.classpath
@@ -12,6 +12,7 @@
+
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java
index 1f3b78f..b76895b 100644
--- a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java
+++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java
@@ -5,6 +5,10 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEvent;
+import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEventHandler;
+import org.gcube.portlets.user.workspace.client.event.AccountingReadersEvent;
+import org.gcube.portlets.user.workspace.client.event.AccountingReadersEventHandler;
import org.gcube.portlets.user.workspace.client.event.AddFolderEvent;
import org.gcube.portlets.user.workspace.client.event.AddFolderEventHandler;
import org.gcube.portlets.user.workspace.client.event.AddSmartFolderEvent;
@@ -104,6 +108,7 @@ import org.gcube.portlets.user.workspace.client.view.windows.InfoDisplay;
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxConfirm;
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxInfo;
+import org.gcube.portlets.user.workspace.client.view.windows.WindowAccountingInfo;
import org.gcube.portlets.user.workspace.client.view.windows.WindowImagePreview;
import org.gcube.portlets.user.workspace.client.view.windows.WindowOpenUrl;
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
@@ -111,6 +116,7 @@ import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExterna
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExternalUrl;
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTImageDocument;
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTUrlDocument;
+import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.BaseEvent;
@@ -643,6 +649,68 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
}
});
+
+ eventBus.addHandler(AccountingHistoryEvent.TYPE, new AccountingHistoryEventHandler() {
+
+ @Override
+ public void onAccountingHistoryShow(AccountingHistoryEvent accountingHistoryEvent) {
+
+ String itemIdentifier = accountingHistoryEvent.getItemIdentifier();
+
+ if(itemIdentifier!=null){
+
+ rpcWorkspaceService.getAccountingHistory(itemIdentifier, new AsyncCallback>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ new MessageBoxAlert("Error", caught.getMessage(), null);
+
+ }
+
+ @Override
+ public void onSuccess(List result) {
+
+ WindowAccountingInfo info = new WindowAccountingInfo(result);
+ info.setWindowTitle("Test");
+ info.show();
+ }
+ });
+
+
+ }
+
+ }
+ });
+
+ eventBus.addHandler(AccountingReadersEvent.TYPE, new AccountingReadersEventHandler() {
+
+ @Override
+ public void onAccountingReadersShow(AccountingReadersEvent accountingReadersEvent) {
+
+ String itemIdentifier = accountingReadersEvent.getItemIdentifier();
+
+ if(itemIdentifier!=null){
+
+ rpcWorkspaceService.getAccountingReaders(itemIdentifier, new AsyncCallback>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ new MessageBoxAlert("Error", caught.getMessage(), null);
+
+ }
+
+ @Override
+ public void onSuccess(List result) {
+
+ WindowAccountingInfo info = new WindowAccountingInfo(result);
+ info.setWindowTitle("Test");
+ info.show();
+ }
+ });
+
+ }
+ }
+ });
eventBus.addHandler(FileDownloadEvent.TYPE, new FileDownloadEventHandler() {
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingHistoryEvent.java b/src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingHistoryEvent.java
new file mode 100644
index 0000000..8049b5d
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingHistoryEvent.java
@@ -0,0 +1,38 @@
+package org.gcube.portlets.user.workspace.client.event;
+
+import com.google.gwt.event.shared.GwtEvent;
+
+/**
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @May 23, 2013
+ *
+ */
+public class AccountingHistoryEvent extends
+ GwtEvent {
+ public static Type TYPE = new Type();
+ private String itemIdentifier;
+
+ public AccountingHistoryEvent(String itemIdentifier) {
+ this.itemIdentifier = itemIdentifier;
+ }
+
+ @Override
+ public Type getAssociatedType() {
+ return TYPE;
+ }
+
+ @Override
+ protected void dispatch(AccountingHistoryEventHandler handler) {
+ handler.onAccountingHistoryShow(this);
+ }
+
+ public String getItemIdentifier() {
+ return itemIdentifier;
+ }
+
+ public void setItemIdentifier(String itemIdentifier) {
+ this.itemIdentifier = itemIdentifier;
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingHistoryEventHandler.java b/src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingHistoryEventHandler.java
new file mode 100644
index 0000000..91dfdde
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingHistoryEventHandler.java
@@ -0,0 +1,16 @@
+package org.gcube.portlets.user.workspace.client.event;
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @May 23, 2013
+ *
+ */
+public interface AccountingHistoryEventHandler extends EventHandler {
+ /**
+ * @param accountingHistoryEvent
+ */
+ void onAccountingHistoryShow(AccountingHistoryEvent accountingHistoryEvent);
+}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingReadersEvent.java b/src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingReadersEvent.java
new file mode 100644
index 0000000..88ee4d1
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingReadersEvent.java
@@ -0,0 +1,38 @@
+package org.gcube.portlets.user.workspace.client.event;
+
+import com.google.gwt.event.shared.GwtEvent;
+
+/**
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @May 23, 2013
+ *
+ */
+public class AccountingReadersEvent extends
+ GwtEvent {
+ public static Type TYPE = new Type();
+ private String itemIdentifier;
+
+ public AccountingReadersEvent(String itemIdentifier) {
+ this.itemIdentifier = itemIdentifier;
+ }
+
+ @Override
+ public Type getAssociatedType() {
+ return TYPE;
+ }
+
+ @Override
+ protected void dispatch(AccountingReadersEventHandler handler) {
+ handler.onAccountingReadersShow(this);
+ }
+
+ public String getItemIdentifier() {
+ return itemIdentifier;
+ }
+
+ public void setItemIdentifier(String itemIdentifier) {
+ this.itemIdentifier = itemIdentifier;
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingReadersEventHandler.java b/src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingReadersEventHandler.java
new file mode 100644
index 0000000..d5bd956
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingReadersEventHandler.java
@@ -0,0 +1,16 @@
+package org.gcube.portlets.user.workspace.client.event;
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @May 23, 2013
+ *
+ */
+public interface AccountingReadersEventHandler extends EventHandler {
+ /**
+ * @param accountingReadersEvent
+ */
+ void onAccountingReadersShow(AccountingReadersEvent accountingReadersEvent);
+}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java
index c8859e2..15e5470 100644
--- a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java
+++ b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java
@@ -262,5 +262,14 @@ public interface Icons extends ClientBundle {
@Source("icons/ppt.gif")
ImageResource ppt();
+
+ @Source("icons/read.png")
+ ImageResource read();
+
+ @Source("icons/notread.png")
+ ImageResource notread();
+
+ @Source("icons/history.png")
+ ImageResource history();
}
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java
index f3e612e..c7091bb 100644
--- a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java
+++ b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java
@@ -73,6 +73,16 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.csv());
}
+
+ public static AbstractImagePrototype getIconRead(){
+
+ return AbstractImagePrototype.create(ICONS.read());
+ }
+
+ public static AbstractImagePrototype getIconNotRead(){
+
+ return AbstractImagePrototype.create(ICONS.notread());
+ }
public static AbstractImagePrototype getCloseIcon(){
@@ -215,6 +225,11 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.documents());
}
+ public static AbstractImagePrototype getIconHistory(){
+
+ return AbstractImagePrototype.create(ICONS.history());
+ }
+
public static AbstractImagePrototype getIconSearch() {
return AbstractImagePrototype.create(ICONS.search());
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/history.png b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/history.png
new file mode 100644
index 0000000..ebeb9f0
Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/history.png differ
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/notread.png b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/notread.png
new file mode 100644
index 0000000..c5583de
Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/notread.png differ
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/read.png b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/read.png
new file mode 100644
index 0000000..9db8138
Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/read.png differ
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java
index b6f5ad0..4036ff9 100644
--- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java
+++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java
@@ -15,6 +15,7 @@ import org.gcube.portlets.user.workspace.client.model.ScopeModel;
import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
import org.gcube.portlets.user.workspace.client.model.SubTree;
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
+import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@@ -130,4 +131,19 @@ public interface GWTWorkspaceService extends RemoteService{
FileModel getParentByItemId(String identifier) throws Exception;
+ /**
+ * @param identifier
+ * @return
+ * @throws Exception
+ */
+ List getAccountingReaders(String identifier)
+ throws Exception;
+
+ /**
+ * @param identifier
+ * @return
+ * @throws Exception
+ */
+ List getAccountingHistory(String identifier) throws Exception;
+
}
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java
index 6f3d313..d7d6dcf 100644
--- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java
+++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java
@@ -15,6 +15,7 @@ import org.gcube.portlets.user.workspace.client.model.ScopeModel;
import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
import org.gcube.portlets.user.workspace.client.model.SubTree;
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
+import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -140,5 +141,11 @@ public interface GWTWorkspaceServiceAsync {
void getParentByItemId(String identifier,
AsyncCallback asyncCallback);
+ void getAccountingReaders(String identifier,
+ AsyncCallback> callback);
+
+ void getAccountingHistory(String identifier,
+ AsyncCallback> callback);
+
}
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/AccoutingInfoContainer.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/AccoutingInfoContainer.java
new file mode 100644
index 0000000..cbb5a0d
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/AccoutingInfoContainer.java
@@ -0,0 +1,155 @@
+package org.gcube.portlets.user.workspace.client.view.windows;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
+
+import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
+import com.extjs.gxt.ui.client.data.BaseModelData;
+import com.extjs.gxt.ui.client.data.ModelData;
+import com.extjs.gxt.ui.client.store.GroupingStore;
+import com.extjs.gxt.ui.client.store.ListStore;
+import com.extjs.gxt.ui.client.widget.ContentPanel;
+import com.extjs.gxt.ui.client.widget.LayoutContainer;
+import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
+import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
+import com.extjs.gxt.ui.client.widget.grid.Grid;
+import com.extjs.gxt.ui.client.widget.grid.GridGroupRenderer;
+import com.extjs.gxt.ui.client.widget.grid.GroupColumnData;
+import com.extjs.gxt.ui.client.widget.grid.GroupingView;
+import com.extjs.gxt.ui.client.widget.layout.FitLayout;
+
+public class AccoutingInfoContainer extends LayoutContainer {
+
+
+ protected static final String DATE = "Date";
+ protected static final String AUTHOR = "Author";
+ protected static final String OPERATION = "Operation";
+ protected static final String DESCRIPTION = "Description";
+ private ColumnModel cm;
+ private Grid grid;
+ private ContentPanel cp;
+ private GroupingStore store = new GroupingStore();
+
+ public AccoutingInfoContainer(){
+ initContentPanel();
+ initGrid();
+ }
+
+ public void initGrid() {
+
+ store.groupBy(OPERATION);
+
+ List columns = new ArrayList();
+
+ ColumnConfig descr = createSortableColumnConfig(DESCRIPTION, DESCRIPTION, 230);
+ columns.add(descr);
+
+ ColumnConfig oper = createSortableColumnConfig(OPERATION, OPERATION, 70);
+ columns.add(oper);
+
+ ColumnConfig auth = createSortableColumnConfig(OPERATION, AUTHOR, 70);
+ columns.add(auth);
+
+ ColumnConfig date = createSortableColumnConfig(DATE, DATE, 70);
+ columns.add(date);
+
+ cm = new ColumnModel(columns);
+
+ final ColumnModel columnModel = cm;
+
+ grid = new Grid(this.store, cm);
+
+ GroupingView view = new GroupingView();
+ view.setShowGroupedColumn(true);
+ this.grid.setView(view);
+
+ view.setGroupRenderer(new GridGroupRenderer() {
+ public String render(GroupColumnData data) {
+ String f = columnModel.getColumnById(data.field).getHeader();
+ String l = data.models.size() == 1 ? "Item" : "Items";
+ return f + ": " + data.group + " (" + data.models.size() + " " + l + ")";
+ }
+ });
+
+ grid.setBorders(true);
+ grid.setStripeRows(true);
+ grid.getView().setAutoFill(true);
+ grid.setColumnLines(true);
+ grid.setColumnReordering(true);
+ grid.setStyleAttribute("borderTop", "none");
+
+ cp.add(grid);
+
+ }
+
+ public AccoutingInfoContainer(List accountings) {
+
+ initContentPanel();
+ initGrid();
+ updateListAccounting(accountings);
+ }
+
+
+ private void updateListAccounting(List accountings){
+
+ List listModelData = new ArrayList();
+
+ store.removeAll();
+
+ for (GxtAccountingField gxtAccountingField : accountings) {
+ BaseModelData baseModel = new BaseModelData();
+
+ baseModel.set(DESCRIPTION, gxtAccountingField.getDescription());
+ baseModel.set(OPERATION, gxtAccountingField.getOperation());
+ baseModel.set(AUTHOR, gxtAccountingField.getUser());
+ baseModel.set(DATE, gxtAccountingField.getDate());
+
+ listModelData.add(baseModel);
+ }
+
+ store.add(listModelData);
+ }
+
+ private void initContentPanel() {
+ setLayout(new FitLayout());
+ getAriaSupport().setPresentation(true);
+ cp = new ContentPanel();
+ cp.setHeaderVisible(false);
+ cp.setBodyBorder(true);
+ cp.setLayout(new FitLayout());
+ cp.setButtonAlign(HorizontalAlignment.CENTER);
+ cp.setLayout(new FitLayout());
+// cp.getHeader().setIconAltText("Grid Icon");
+ cp.setSize(500, 250);
+
+ add(cp);
+ }
+
+ public void updateStore(ListStore store){
+
+ this.grid.getStore().removeAll();
+// for (ModelData modelData : store.getModels()){
+// this.grid.getStore().add(modelData);
+// }
+
+ this.grid.getStore().add(store.getModels());
+
+// cp.layout();
+ }
+
+ public ColumnConfig createSortableColumnConfig(String id, String name, int width)
+ {
+ ColumnConfig columnConfig = new ColumnConfig(id, name, width);
+ columnConfig.setSortable(true);
+
+ return columnConfig;
+ }
+
+ public void setHeaderTitle(String title) {
+ cp.setHeading(title);
+// cp.layout();
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/WindowAccountingInfo.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/WindowAccountingInfo.java
new file mode 100644
index 0000000..fd92ba5
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/WindowAccountingInfo.java
@@ -0,0 +1,42 @@
+package org.gcube.portlets.user.workspace.client.view.windows;
+
+
+import java.util.List;
+
+import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
+
+import com.extjs.gxt.ui.client.widget.Window;
+
+/**
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @May 23, 2013
+ *
+ */
+public class WindowAccountingInfo extends Window{
+
+
+ private List accountingsFields;
+ private AccoutingInfoContainer accountingsContainers;
+
+ public WindowAccountingInfo(List accountingsFields) {
+ setModal(true);
+ setSize(550, 300);
+ this.accountingsFields = accountingsFields;
+ this.accountingsContainers = new AccoutingInfoContainer(accountingsFields);
+
+ add(accountingsContainers);
+ }
+
+
+ public void setWindowTitle(String title) {
+ this.setHeading(title);
+
+ }
+
+
+ public List getAccountingsFields() {
+ return accountingsFields;
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java
index ac2e4c9..38aab41 100644
--- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java
+++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java
@@ -20,6 +20,12 @@ import org.gcube.portlets.user.homelibrary.home.workspace.Properties;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceSmartFolder;
+import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntry;
+import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryCut;
+import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryPaste;
+import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryRead;
+import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryRemoval;
+import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryRenaming;
import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderBulkCreator;
import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.AquaMapsItem;
@@ -79,6 +85,8 @@ import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTP
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTUrlDocument;
import org.gcube.portlets.user.workspace.server.util.UserUtil;
import org.gcube.portlets.user.workspace.server.util.Util;
+import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
+import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryType;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
@@ -859,15 +867,36 @@ public class GWTWorkspaceBuilder {
}
- protected List buildGxtInfoContactFromPortalLogin(List listPortalLogin){
+ /**
+ *
+ * @param listPortalLogin
+ * @return
+ */
+ protected List buildGxtInfoContactsFromPortalLogins(List listPortalLogin){
List listContact = new ArrayList();
for (String portalLogin : listPortalLogin)
- listContact.add(new InfoContactModel(portalLogin, portalLogin, UserUtil.getUserFullName(portalLogin)));
+ listContact.add(buildGxtInfoContactFromPortalLogin(portalLogin));
return listContact;
}
+ /**
+ *
+ * @param portalLogin
+ * @return
+ */
+ protected InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin){
+
+ if(portalLogin==null){
+ logger.warn("portal login is null, return empty");
+ portalLogin = "";
+ }
+
+ return new InfoContactModel(portalLogin, portalLogin, UserUtil.getUserFullName(portalLogin));
+
+ }
+
/**
* Used in test mode
* @param listPortalLogin
@@ -925,6 +954,9 @@ public class GWTWorkspaceBuilder {
}
+ //ACCOUNTING
+ fileModel.setMarkAsRead(item.isMarkedAsRead());
+
if(parentFolderModel.isShared()){
fileModel.setShared(true);
fileModel.setShareable(false);
@@ -989,6 +1021,9 @@ public class GWTWorkspaceBuilder {
}
+ //ACCOUNTING
+// fileGridModel.setMarkAsRead(item.isMarkedAsRead());
+
return fileGridModel;
}
@@ -1048,6 +1083,9 @@ public class GWTWorkspaceBuilder {
}
+ //ACCOUNTING
+ fileGridModel.setMarkAsRead(item.isMarkedAsRead());
+
if(parentFileModel.isShared()){
fileGridModel.setShared(true);
fileGridModel.setShareable(false);
@@ -1594,4 +1632,131 @@ public class GWTWorkspaceBuilder {
return listBulkCreatorModel;
}
+
+
+ /**
+ * @param accouting
+ */
+ public List buildGXTAccountingItem(List accoutings, GxtAccountingEntryType gxtEntryType) {
+
+ List listAccFields = new ArrayList();
+
+ if(accoutings!=null){
+ logger.trace("accoutings size "+accoutings.size()+ "converting");
+
+ for (AccountingEntry accountingEntry : accoutings) {
+
+ GxtAccountingField af = new GxtAccountingField();
+
+ InfoContactModel user = buildGxtInfoContactFromPortalLogin(accountingEntry.getUser());
+
+ af.setUser(user);
+ af.setDate(toDate(accountingEntry.getDate()));
+
+ switch (accountingEntry.getEntryType()) {
+
+ case READ:
+
+ if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.READ)){
+
+ af.setOperation(GxtAccountingEntryType.READ);
+ af.setDescription("read by "+user.getName());
+ }
+
+ break;
+
+ case CUT:
+
+ if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.CUT)){
+
+ af.setOperation(GxtAccountingEntryType.CUT);
+
+ AccountingEntryCut cut = (AccountingEntryCut) accountingEntry;
+
+ af.setDescription("cut by "+user.getName() +" from "+cut.getItemName());
+ }
+
+ break;
+
+ case PASTE:
+
+ if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.PASTE)){
+
+ af.setOperation(GxtAccountingEntryType.PASTE);
+
+ AccountingEntryPaste paste = (AccountingEntryPaste) accountingEntry;
+
+ af.setDescription("paste by "+user.getName() +" from path: "+paste.getFromPath());
+ }
+
+ break;
+
+ case REMOVAL:
+
+ if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.REMOVED)){
+
+ af.setOperation(GxtAccountingEntryType.REMOVED);
+
+ AccountingEntryRemoval rem = (AccountingEntryRemoval) accountingEntry;
+
+ af.setDescription("remove by "+user.getName() +", name: "+rem.getItemName());
+ }
+ break;
+
+ case RENAMING:
+
+ if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.RENAMING)){
+
+ af.setOperation(GxtAccountingEntryType.RENAMING);
+
+ AccountingEntryRenaming ren = (AccountingEntryRenaming) accountingEntry;
+
+ af.setDescription("rename by "+user.getName() +", last name: "+ren.getOldItemName());
+ }
+ break;
+ }
+
+
+ listAccFields.add(af);
+
+ }
+
+ }
+
+ logger.trace("get accounting readers converting completed - returning size "+listAccFields.size());
+
+ return listAccFields;
+
+ }
+
+
+ /**
+ * @param readers
+ * @return
+ */
+ public List buildGXTAccountingItemFromReaders(List readers) {
+
+ List listAccFields = new ArrayList();
+
+ if(readers!=null){
+
+ for (AccountingEntryRead accReader : readers) {
+
+ GxtAccountingField af = new GxtAccountingField();
+
+ InfoContactModel user = buildGxtInfoContactFromPortalLogin(accReader.getUser());
+
+ af.setUser(user);
+ af.setDate(toDate(accReader.getDate()));
+
+ af.setOperation(GxtAccountingEntryType.READ);
+ af.setDescription("read by "+user.getName());
+
+ listAccFields.add(af);
+ }
+
+ }
+
+ return listAccFields;
+ }
}
diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java
index 512fa8a..204f869 100644
--- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java
@@ -21,6 +21,8 @@ import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItemType;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceSharedFolder;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceSmartFolder;
+import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntry;
+import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntryRead;
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemNotFoundException;
@@ -51,6 +53,8 @@ import org.gcube.portlets.user.workspace.server.notifications.NotificationsProdu
import org.gcube.portlets.user.workspace.server.util.UserUtil;
import org.gcube.portlets.user.workspace.server.util.Util;
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
+import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryType;
+import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
import org.gcube.portlets.user.workspaceapplicationhandler.ApplicationReaderFromGenericResource;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@@ -227,7 +231,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
logger.info("get children");
WorkspaceItem wsItem = workspace.getItem(folder.getIdentifier());
-
+
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
listFileModels = builder.buildGXTListFileModelItem(wsItem, folder);
@@ -1664,7 +1668,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
if(isTestMode())
return builder.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
- return builder.buildGxtInfoContactFromPortalLogin(listPortalLogin);
+ return builder.buildGxtInfoContactsFromPortalLogins(listPortalLogin);
}
else{
@@ -1708,7 +1712,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
return builder.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
- return builder.buildGxtInfoContactFromPortalLogin(listPortalLogin);
+ return builder.buildGxtInfoContactsFromPortalLogins(listPortalLogin);
}
}
@@ -1984,4 +1988,56 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
throw new Exception(e.getMessage());
}
}
+
+ @Override
+ public List getAccountingReaders(String identifier) throws Exception {
+
+ workspaceLogger.trace("get accounting readers "+ identifier);
+ try {
+
+ Workspace workspace = getWorkspace();
+
+ WorkspaceItem wsItem = workspace.getItem(identifier);
+
+ List accoutings = wsItem.getAccounting();
+
+ GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
+
+ List listReaders = builder.buildGXTAccountingItemFromReaders(wsItem.getReaders());
+
+ workspaceLogger.trace("get accounting readers - returning size "+listReaders.size());
+ return listReaders;
+
+ } catch (Exception e) {
+ workspaceLogger.error("Error get accounting readers ", e);
+ String error = ConstantsExplorer.SERVER_ERROR+" getting account. "+ConstantsExplorer.TRY_AGAIN;
+ throw new Exception(error);
+ }
+ }
+
+ @Override
+ public List getAccountingHistory(String identifier) throws Exception {
+
+ workspaceLogger.trace("get accounting history "+ identifier);
+ try {
+
+ Workspace workspace = getWorkspace();
+
+ WorkspaceItem wsItem = workspace.getItem(identifier);
+
+ List accoutings = wsItem.getAccounting();
+
+ GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
+
+ List listReaders = builder.buildGXTAccountingItem(accoutings, GxtAccountingEntryType.ALLWITHOUTREAD);
+
+ workspaceLogger.trace("get accounting readers - returning size "+listReaders.size());
+ return listReaders;
+
+ } catch (Exception e) {
+ workspaceLogger.error("Error get accounting readers ", e);
+ String error = ConstantsExplorer.SERVER_ERROR+" getting account. "+ConstantsExplorer.TRY_AGAIN;
+ throw new Exception(error);
+ }
+ }
}
diff --git a/src/main/java/org/gcube/portlets/user/workspace/shared/accounting/GxtAccountingEntryType.java b/src/main/java/org/gcube/portlets/user/workspace/shared/accounting/GxtAccountingEntryType.java
new file mode 100644
index 0000000..498b172
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/workspace/shared/accounting/GxtAccountingEntryType.java
@@ -0,0 +1,52 @@
+/**
+ *
+ */
+package org.gcube.portlets.user.workspace.shared.accounting;
+
+/**
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @May 23, 2013
+ *
+ */
+public enum GxtAccountingEntryType {
+
+ REMOVED("removed", "removed"),
+
+ RENAMING("renamed", "renamed"),
+
+ CREATED("created", "created"),
+
+ PASTE("pasted", "pasted"),
+
+ CUT("cutted", "cutted"),
+
+ READ("read", "read"),
+
+ ALLWITHOUTREAD("all", "all");
+
+ private String id;
+ private String name;
+
+ GxtAccountingEntryType(String id, String name) {
+ this.id = id;
+ this.name = name;
+
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/workspace/shared/accounting/GxtAccountingField.java b/src/main/java/org/gcube/portlets/user/workspace/shared/accounting/GxtAccountingField.java
new file mode 100644
index 0000000..918b2dc
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/workspace/shared/accounting/GxtAccountingField.java
@@ -0,0 +1,85 @@
+package org.gcube.portlets.user.workspace.shared.accounting;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
+
+import com.extjs.gxt.ui.client.data.BaseModelData;
+
+/**
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @May 23, 2013
+ *
+ */
+public class GxtAccountingField implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -2114527164447302004L;
+
+ private InfoContactModel user;
+ private Date date;
+ private GxtAccountingEntryType operation;
+ private String description;
+
+ public GxtAccountingField() {
+
+ }
+
+ /**
+ * @param description
+ * @param user
+ * @param date
+ * @param operation
+ */
+ public GxtAccountingField(String description, InfoContactModel user,
+ Date date, GxtAccountingEntryType operation) {
+ setUser(user);
+ setDate(date);
+ setOperation(operation);
+ setDescription(description);
+ }
+
+ public InfoContactModel getUser() {
+ return user;
+ }
+
+ public void setUser(InfoContactModel user) {
+ this.user = user;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ /**
+ * @return the operation
+ */
+ public GxtAccountingEntryType getOperation() {
+ return operation;
+ }
+
+ /**
+ * @param operation
+ * the operation to set
+ */
+ public void setOperation(GxtAccountingEntryType operation) {
+ this.operation = operation;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+}