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
This commit is contained in:
parent
d8e502b3e6
commit
93c1e4fbda
|
@ -12,6 +12,7 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
|
|
@ -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;
|
||||
|
@ -644,6 +650,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<List<GxtAccountingField>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<GxtAccountingField> 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<List<GxtAccountingField>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<GxtAccountingField> result) {
|
||||
|
||||
WindowAccountingInfo info = new WindowAccountingInfo(result);
|
||||
info.setWindowTitle("Test");
|
||||
info.show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventBus.addHandler(FileDownloadEvent.TYPE, new FileDownloadEventHandler() {
|
||||
|
||||
|
|
|
@ -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<AccountingHistoryEventHandler> {
|
||||
public static Type<AccountingHistoryEventHandler> TYPE = new Type<AccountingHistoryEventHandler>();
|
||||
private String itemIdentifier;
|
||||
|
||||
public AccountingHistoryEvent(String itemIdentifier) {
|
||||
this.itemIdentifier = itemIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<AccountingHistoryEventHandler> 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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<AccountingReadersEventHandler> {
|
||||
public static Type<AccountingReadersEventHandler> TYPE = new Type<AccountingReadersEventHandler>();
|
||||
private String itemIdentifier;
|
||||
|
||||
public AccountingReadersEvent(String itemIdentifier) {
|
||||
this.itemIdentifier = itemIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<AccountingReadersEventHandler> 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,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());
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 799 B |
Binary file not shown.
After Width: | Height: | Size: 931 B |
Binary file not shown.
After Width: | Height: | Size: 801 B |
|
@ -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<GxtAccountingField> getAccountingReaders(String identifier)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
* @param identifier
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
List<GxtAccountingField> getAccountingHistory(String identifier) throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -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<FileModel> asyncCallback);
|
||||
|
||||
void getAccountingReaders(String identifier,
|
||||
AsyncCallback<List<GxtAccountingField>> callback);
|
||||
|
||||
void getAccountingHistory(String identifier,
|
||||
AsyncCallback<List<GxtAccountingField>> callback);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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<ModelData> grid;
|
||||
private ContentPanel cp;
|
||||
private GroupingStore<ModelData> store = new GroupingStore<ModelData>();
|
||||
|
||||
public AccoutingInfoContainer(){
|
||||
initContentPanel();
|
||||
initGrid();
|
||||
}
|
||||
|
||||
public void initGrid() {
|
||||
|
||||
store.groupBy(OPERATION);
|
||||
|
||||
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
|
||||
|
||||
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<ModelData>(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<GxtAccountingField> accountings) {
|
||||
|
||||
initContentPanel();
|
||||
initGrid();
|
||||
updateListAccounting(accountings);
|
||||
}
|
||||
|
||||
|
||||
private void updateListAccounting(List<GxtAccountingField> accountings){
|
||||
|
||||
List<BaseModelData> listModelData = new ArrayList<BaseModelData>();
|
||||
|
||||
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<ModelData> 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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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<GxtAccountingField> accountingsFields;
|
||||
private AccoutingInfoContainer accountingsContainers;
|
||||
|
||||
public WindowAccountingInfo(List<GxtAccountingField> 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<GxtAccountingField> getAccountingsFields() {
|
||||
return accountingsFields;
|
||||
}
|
||||
|
||||
}
|
|
@ -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<InfoContactModel> buildGxtInfoContactFromPortalLogin(List<String> listPortalLogin){
|
||||
/**
|
||||
*
|
||||
* @param listPortalLogin
|
||||
* @return
|
||||
*/
|
||||
protected List<InfoContactModel> buildGxtInfoContactsFromPortalLogins(List<String> listPortalLogin){
|
||||
|
||||
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
|
||||
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<GxtAccountingField> buildGXTAccountingItem(List<AccountingEntry> accoutings, GxtAccountingEntryType gxtEntryType) {
|
||||
|
||||
List<GxtAccountingField> listAccFields = new ArrayList<GxtAccountingField>();
|
||||
|
||||
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<GxtAccountingField> buildGXTAccountingItemFromReaders(List<AccountingEntryRead> readers) {
|
||||
|
||||
List<GxtAccountingField> listAccFields = new ArrayList<GxtAccountingField>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -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<GxtAccountingField> getAccountingReaders(String identifier) throws Exception {
|
||||
|
||||
workspaceLogger.trace("get accounting readers "+ identifier);
|
||||
try {
|
||||
|
||||
Workspace workspace = getWorkspace();
|
||||
|
||||
WorkspaceItem wsItem = workspace.getItem(identifier);
|
||||
|
||||
List<AccountingEntry> accoutings = wsItem.getAccounting();
|
||||
|
||||
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
||||
|
||||
List<GxtAccountingField> 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<GxtAccountingField> getAccountingHistory(String identifier) throws Exception {
|
||||
|
||||
workspaceLogger.trace("get accounting history "+ identifier);
|
||||
try {
|
||||
|
||||
Workspace workspace = getWorkspace();
|
||||
|
||||
WorkspaceItem wsItem = workspace.getItem(identifier);
|
||||
|
||||
List<AccountingEntry> accoutings = wsItem.getAccounting();
|
||||
|
||||
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
||||
|
||||
List<GxtAccountingField> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue