From 93c1e4fbda37186cd3a253ee6ccd66e4e328611d Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Thu, 23 May 2013 17:03:43 +0000 Subject: [PATCH] start of accounting integration git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@75307 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 1 + .../client/AppControllerExplorer.java | 68 +++++++ .../client/event/AccountingHistoryEvent.java | 38 ++++ .../event/AccountingHistoryEventHandler.java | 16 ++ .../client/event/AccountingReadersEvent.java | 38 ++++ .../event/AccountingReadersEventHandler.java | 16 ++ .../workspace/client/resources/Icons.java | 9 + .../workspace/client/resources/Resources.java | 15 ++ .../client/resources/icons/history.png | Bin 0 -> 799 bytes .../client/resources/icons/notread.png | Bin 0 -> 931 bytes .../workspace/client/resources/icons/read.png | Bin 0 -> 801 bytes .../client/rpc/GWTWorkspaceService.java | 16 ++ .../client/rpc/GWTWorkspaceServiceAsync.java | 7 + .../view/windows/AccoutingInfoContainer.java | 155 ++++++++++++++++ .../view/windows/WindowAccountingInfo.java | 42 +++++ .../workspace/server/GWTWorkspaceBuilder.java | 169 +++++++++++++++++- .../server/GWTWorkspaceServiceImpl.java | 62 ++++++- .../accounting/GxtAccountingEntryType.java | 52 ++++++ .../shared/accounting/GxtAccountingField.java | 85 +++++++++ 19 files changed, 784 insertions(+), 5 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingHistoryEvent.java create mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingHistoryEventHandler.java create mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingReadersEvent.java create mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/event/AccountingReadersEventHandler.java create mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/history.png create mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/notread.png create mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/read.png create mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/view/windows/AccoutingInfoContainer.java create mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/view/windows/WindowAccountingInfo.java create mode 100644 src/main/java/org/gcube/portlets/user/workspace/shared/accounting/GxtAccountingEntryType.java create mode 100644 src/main/java/org/gcube/portlets/user/workspace/shared/accounting/GxtAccountingField.java 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 0000000000000000000000000000000000000000..ebeb9f0d7371b7875e8b1e110892b297a340be6c GIT binary patch literal 799 zcmV+)1K|9LP)oX(l&Qhzk=c=VNNlGvlj5*nfUw3FdakFV#dHAn@7F%!G*C658wpv>h;3gsC!WfGQ z(B-Njs5EeNj(nq3QImDcBG)v)nY*7#hB@N(!L?fbfO7~*?kChLnV1W4aeRjchRSlh z=o)1T~J_>GMNyKM&b4{=w@fY$0`u{F<#bw zxbmwA*xUNPeokf4HSM??mK6plmCC7qvD@u1o6VxnaU5*#d|-2n!SwhJwH;aBCIWVy zf7_^ER&s_4`>@8439r|SNF)N9rqS2ehuYd&Fbo5p=iy>F3`uhEr6*wRI9_#D1nfB1 zc~G;ksLj9!uz$mRahf0qVzV?9!u*N~kSdiJf7azfZwUD2{#Aed#L9LNu=Uh)19ZB< zWqDETtT7@dJ0op3q8<-q`T2;DGQ8{>z)MdI;b6>o%eu}zr9xHx)BBt2^qUJ2gQbRs zQXzrQ=M!@jMIko9qI1BHV2r~>+vtP$9d(v88IQI)<~qj}uQyex3MFv~su$@|GCM~s zU`APV_YNUbmBfu_EVCp(xvKe?c_Pn4RWrPpU9NG3Iso*T@g7I?3;Hbti0!hwbhQX;`hQ$aGNf{aXAN)ICS4nCPo##0V2%hV)Dd3NG* d(|+Mk&u^8ZEFiXLZ0rC4002ovPDHLkV1hEmeQp2% literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..c5583def705b73a2303e8d109487a8b9da448de9 GIT binary patch literal 931 zcmV;U16=%xP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L00VXa00VXbebs`@00007bV*G`2i*l1 z3Ni?ZW*m|L00SdQL_t(I%cYZBOjCCp$A72)UQQ46l(nTeTM=5h*kxPXNDBx~K$?gb z5)*xpj3$I-%aXoqBiR-c%t(Cj`m)6M;DeIj$XH@D2Hiw7mZH|S&PzZGw8tJv+3A5^ zPJ2#IFUJ>snIoKKcHB`F;WZ=b-f#dU|>+9UUE<-|sJtj*s_!?r?nNXlvi( zxjpUwPXMdcdW&UQ@%+V6AxcO0e(!dRbyh1`K=OtMUaxOmfL^b67Yc=WjX`f1=0ocK zR%QY26aepunFcUa_^nNg?LpGbu#xM*605Cc+vBzRID;##a z6#(QILPjo?s(<$6sjlhMk6Y$Lq1_c~;zy}e{6kKX)a5Hz+mO@gTr?OA+DIgF(^B8C z^V`9}8~|Vdz|D9(Eee9bB1_>f9{GG1Xok%`4~HAQfk*W>Zv447&HQr|rBW%%WHKEi zN%D+tL)EtS=H@g_(}c(4aZ(i3D3hcY%0$ZFP%La;jYenYBH>?hqImyYZOxS*wzsxm z001VFX&fP>aUMAEn*qnG;_>*G2%!p>%XMUBWu<)K)aiYDl!}jJb#=4U>gw_NQ0Qf6 zYwOqL@%T5`+vk;)m0go7RMoXxETs=Lnxxz9J|>EytgEYwIn>rZFq}+ajdr_Buvi|- zjK&x~H@B1a`TmvzfCT^`lgaD@$Pk&F*^8vq?}0#o85tQ_-qzJU@cb2hahl^6iC_?I zRjUuH^LgUs!ot02iu(Dj13ds#d^a?-aq{NWB_^3(ByfC|7kD+tve)_K+T@+??#{|$ z@h2n4HJ2nw$ZNHnK$6F?_k^$VO-B*{AOHYNHZ|?9DK9@FOC~oj(e&7IHcNeGHusYT z!-wySGV^Z%i^Vi+7{50Dp*3N{(OP{dp;A=*SWLgB7u4w=O002ovPDHLk FV1h;svrYg2 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..9db8138fa3f924b1e5da81ff6e72d42c09391ddc GIT binary patch literal 801 zcmV++1K#|JP)&)wbJuG>P((B!gomCuv)Epk|e)1H8n}CZEffM)6+R2K^$wSyYm;fTSZy;k4D7 zXelY#wdn{f%Oa&xIS>@ZW1=8%E0V+ogFz`j=g6E)5m&GVFf%hlxcmC33BO+l2o13; zD=V$2n1Anf$Lo@lqgN8{YL*#|M#E}ztIK6QXxK;Z&B)jZ0Lqk$jQycHshX7z60AO@@ zI9I3F^GS&#R|k80>*$auv@E`|MWhurEC^eLMYcxX-``)EnVH#~ot<5OI6oifIBtny zn6TIDEuNj7O(O`xV=x%IBcWj4L{D!=V0y}>&~8yhm-u-A01P1nBuPHUaa>zyvpq{v zsgfCnxrpO<0!2{{nx-``UbpL=%}*Wzz;}dD%!M6vbE*H1$a5JJLwr`G?n3;;BH_8;(=OeVX-;V>bDb{sMn)Djv^EeP;R?xzd<@ 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; + } + +}