1659 lines
59 KiB
Java
1659 lines
59 KiB
Java
|
package org.gcube.portlets.user.workspace.server;
|
||
|
|
||
|
import java.text.ParseException;
|
||
|
import java.text.SimpleDateFormat;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Calendar;
|
||
|
import java.util.Date;
|
||
|
import java.util.LinkedHashMap;
|
||
|
import java.util.LinkedList;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
import java.util.Map.Entry;
|
||
|
import java.util.concurrent.TimeUnit;
|
||
|
|
||
|
import org.gcube.common.core.utils.logging.GCUBELog;
|
||
|
import org.gcube.portlets.user.homelibrary.home.User;
|
||
|
import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException;
|
||
|
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.WorkspaceItemAccounting;
|
||
|
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.folder.FolderBulkCreator;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItem;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.AquaMapsItem;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalFile;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalImage;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalPDFFile;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalUrl;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.Query;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.Report;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ReportTemplate;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.WorkflowReport;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.WorkflowTemplate;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.Document;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.DocumentMetadata;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.ImageDocument;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.Metadata;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.PDFDocument;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.gcube.UrlDocument;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ts.TimeSeries;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ts.TimeSeriesInfo;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.search.SearchFolderItem;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.search.SearchItem;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.sharing.WorkspaceMessage;
|
||
|
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface;
|
||
|
import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum;
|
||
|
import org.gcube.portlets.user.workspace.client.model.BulkCreatorModel;
|
||
|
import org.gcube.portlets.user.workspace.client.model.FileDetailsModel;
|
||
|
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
||
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||
|
import org.gcube.portlets.user.workspace.client.model.FolderGridModel;
|
||
|
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||
|
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||
|
import org.gcube.portlets.user.workspace.client.model.MessageModel;
|
||
|
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.util.ImageRequestType;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.GWTProperties;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceFolder;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItemAction;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTAquaMapsItem;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExternalFile;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExternalImage;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExternalPDFFile;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExternalUrl;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTQuery;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTReport;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTReportTemplate;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTTimeSeries;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTWorkflowReport;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTWorkflowTemplate;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTDocument;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTDocumentMetadata;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTImageDocument;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTMetadata;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTPDFDocument;
|
||
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTUrlDocument;
|
||
|
import org.gcube.portlets.user.workspace.server.util.AllScope;
|
||
|
import org.gcube.portlets.user.workspace.server.util.Util;
|
||
|
|
||
|
/**
|
||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||
|
*
|
||
|
*/
|
||
|
public class GWTWorkspaceBuilder {
|
||
|
|
||
|
protected static final String IMAGE_SERVICE_URL = "ImageService";
|
||
|
protected GCUBELog logger;
|
||
|
// private final String UNKNOWN = "unknown";
|
||
|
// private final String FOLDER = "Folder";
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @param logger
|
||
|
*/
|
||
|
public GWTWorkspaceBuilder(GCUBELog logger) {
|
||
|
this.logger = logger;
|
||
|
}
|
||
|
|
||
|
// protected GWTWorkspaceFolder buildWorkspaceTree(WorkspaceFolder workspace) throws InternalErrorException
|
||
|
// {
|
||
|
// logger.trace("buildWorkspaceTree workspace: "+workspace);
|
||
|
// return buildGWTWorkspace(workspace, null);
|
||
|
// }
|
||
|
//
|
||
|
// protected GWTWorkspaceFolder buildGWTWorkspace(WorkspaceFolder workspace, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
// {
|
||
|
// GWTProperties gwtProperties = buildGWTProperties(workspace.getProperties());
|
||
|
//
|
||
|
// List<GWTWorkspaceItem> children = new LinkedList<GWTWorkspaceItem>();
|
||
|
//
|
||
|
// GWTWorkspaceFolder gwtWorkspace = new GWTWorkspaceFolder(
|
||
|
// workspace.getId(),
|
||
|
// workspace.getName(),
|
||
|
// workspace.getDescription(),
|
||
|
// workspace.getOwner().getPortalLogin(),
|
||
|
// toDate(workspace.getCreationTime()),
|
||
|
// gwtProperties,
|
||
|
// toDate(workspace.getLastModificationTime()),
|
||
|
// GWTWorkspaceItemAction.valueOf(workspace.getLastAction().toString()),
|
||
|
// parent,
|
||
|
// children);
|
||
|
//
|
||
|
// gwtWorkspace.setShared(workspace.getCapabilities().isShared());
|
||
|
//
|
||
|
// for (WorkspaceItem folder : workspace.getChildren()){
|
||
|
// GWTWorkspaceItem gwtFolder = buildGWTWorkspaceItem(folder, gwtWorkspace);
|
||
|
// if (gwtFolder!=null) children.add(gwtFolder);
|
||
|
// else{
|
||
|
// logger.error("gwt conversion return null for folder "+folder);
|
||
|
// }
|
||
|
// }
|
||
|
//
|
||
|
// return gwtWorkspace;
|
||
|
// }
|
||
|
|
||
|
protected Date toDate(Calendar calendar)
|
||
|
{
|
||
|
if (calendar == null) return new Date(0);
|
||
|
return calendar.getTime();
|
||
|
|
||
|
}
|
||
|
|
||
|
protected String toDateFormatToString(Calendar calendar){
|
||
|
|
||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM, yyyy HH:mm:ss z");
|
||
|
|
||
|
Date resultdate = getDate(calendar);
|
||
|
|
||
|
return dateFormat.format(resultdate);
|
||
|
}
|
||
|
|
||
|
|
||
|
protected Date toDateFormat(Calendar calendar){
|
||
|
|
||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM, yyyy HH:mm:ss z");
|
||
|
|
||
|
Date resultdate = getDate(calendar);
|
||
|
|
||
|
try {
|
||
|
|
||
|
resultdate = dateFormat.parse(dateFormat.format(resultdate));
|
||
|
|
||
|
} catch (ParseException e) {
|
||
|
e.printStackTrace();
|
||
|
resultdate = new Date(0);
|
||
|
}
|
||
|
|
||
|
return resultdate;
|
||
|
}
|
||
|
|
||
|
|
||
|
private Date getDate(Calendar calendar) {
|
||
|
|
||
|
Date resultdate = null;
|
||
|
|
||
|
if (calendar == null)
|
||
|
resultdate = new Date(0);
|
||
|
else
|
||
|
resultdate = new Date(calendar.getTimeInMillis());
|
||
|
|
||
|
return resultdate;
|
||
|
|
||
|
}
|
||
|
|
||
|
// protected GWTWorkspaceItem buildGWTWorkspaceItem(WorkspaceItem item, GWTWorkspaceItem parent) throws InternalErrorException
|
||
|
// {
|
||
|
// logger.trace("buildGWTWorkspaceItem item: "+item);
|
||
|
// switch (item.getType())
|
||
|
// {
|
||
|
// case FOLDER: return buildGWTWorkspace((WorkspaceFolder) item, (GWTWorkspaceFolder) parent);
|
||
|
// case FOLDER_ITEM: return buildGWTFolderItem((FolderItem) item, (GWTWorkspaceFolder) parent);
|
||
|
// }
|
||
|
//
|
||
|
// logger.error("Unknown item type: "+item.getType());
|
||
|
//
|
||
|
// return null;
|
||
|
// }
|
||
|
|
||
|
protected GWTProperties buildGWTProperties(Properties metadata) throws InternalErrorException
|
||
|
{
|
||
|
//FIXME temp solution
|
||
|
//GWTProperties gwtProperties = new GWTProperties(metadata.getId(), metadata.getProperties());
|
||
|
return new GWTProperties();
|
||
|
}
|
||
|
|
||
|
|
||
|
// protected GWTFolderItem buildGWTFolderItem(FolderItem item, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
// {
|
||
|
// switch(item.getFolderItemType())
|
||
|
// {
|
||
|
// case EXTERNAL_IMAGE: return buildGWTExternalImage((ExternalImage) item, parent);
|
||
|
// case EXTERNAL_FILE: return buildGWTExternalFile((ExternalFile) item, parent);
|
||
|
// case EXTERNAL_PDF_FILE: return buildGWTExternalPDFFile((ExternalPDFFile) item, parent);
|
||
|
// case EXTERNAL_URL: return buildGWTExternalUrl((ExternalUrl)item, parent);
|
||
|
// case REPORT_TEMPLATE: return buildGWTReportTemplate((ReportTemplate)item, parent);
|
||
|
// case REPORT: return buildGWTReport((Report)item, parent);
|
||
|
// case QUERY: return buildGWTQuery((Query) item, parent);
|
||
|
// case TIME_SERIES: return buildGWTTimeSeries((TimeSeries)item, parent);
|
||
|
// case AQUAMAPS_ITEM: return buildGWTAquaMapsItem((AquaMapsItem)item, parent);
|
||
|
// case PDF_DOCUMENT: return buildGWTPDFDocument((PDFDocument) item, parent);
|
||
|
// case IMAGE_DOCUMENT: return buildGWTImageDocument((ImageDocument) item, parent);
|
||
|
// case DOCUMENT: return buildGWTDocument((Document) item, parent);
|
||
|
// case URL_DOCUMENT: return buildGWTUrlDocument((UrlDocument) item, parent);
|
||
|
// case METADATA: return buildGWTMetadata((Metadata) item, parent);
|
||
|
// case WORKFLOW_REPORT: return buildGWTWorkflowReport((WorkflowReport) item, parent);
|
||
|
// case WORKFLOW_TEMPLATE: return buildGWTWorkflowTemplate((WorkflowTemplate) item, parent);
|
||
|
// }
|
||
|
//
|
||
|
// logger.error("Unknown folder item type: "+item.getFolderItemType());
|
||
|
//
|
||
|
// return null;
|
||
|
// }
|
||
|
|
||
|
protected String buildImageUrl(String id)
|
||
|
{
|
||
|
return buildImageServiceUrl(id, ImageRequestType.IMAGE);
|
||
|
}
|
||
|
|
||
|
protected String buildThumbnailUrl(String id)
|
||
|
{
|
||
|
return buildImageServiceUrl(id, ImageRequestType.THUMBNAIL);
|
||
|
}
|
||
|
|
||
|
protected String buildImageServiceUrl(String id, ImageRequestType requestType){
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
sb.append(IMAGE_SERVICE_URL);
|
||
|
sb.append("?id=");
|
||
|
sb.append(id);
|
||
|
sb.append("&type=");
|
||
|
sb.append(requestType.toString());
|
||
|
return sb.toString();
|
||
|
}
|
||
|
|
||
|
|
||
|
protected GWTExternalFile buildGWTExternalFile(ExternalFile file, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
{
|
||
|
GWTProperties gwtProperties = buildGWTProperties(file.getProperties());
|
||
|
GWTExternalFile gwtFile = new GWTExternalFile(
|
||
|
toDate(file.getCreationTime()),
|
||
|
file.getId(),
|
||
|
gwtProperties,
|
||
|
file.getName(),
|
||
|
file.getOwner().getPortalLogin(),
|
||
|
file.getDescription(),
|
||
|
toDate(file.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(file.getLastAction().toString()),
|
||
|
parent,
|
||
|
file.getLength(),
|
||
|
file.getMimeType());
|
||
|
|
||
|
return gwtFile;
|
||
|
}
|
||
|
|
||
|
protected GWTExternalPDFFile buildGWTExternalPDFFile(ExternalPDFFile pdfFile, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
{
|
||
|
GWTProperties gwtProperties = buildGWTProperties(pdfFile.getProperties());
|
||
|
GWTExternalPDFFile gwtPDFFile = new GWTExternalPDFFile(
|
||
|
toDate(pdfFile.getCreationTime()),
|
||
|
pdfFile.getId(),
|
||
|
gwtProperties,
|
||
|
pdfFile.getName(),
|
||
|
pdfFile.getOwner().getPortalLogin(),
|
||
|
pdfFile.getDescription(),
|
||
|
toDate(pdfFile.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(pdfFile.getLastAction().toString()),
|
||
|
parent,
|
||
|
pdfFile.getLength(),
|
||
|
pdfFile.getMimeType(),
|
||
|
pdfFile.getAuthor(),
|
||
|
pdfFile.getNumberOfPages(),
|
||
|
pdfFile.getProducer(),
|
||
|
pdfFile.getTitle(),
|
||
|
pdfFile.getVersion());
|
||
|
|
||
|
return gwtPDFFile;
|
||
|
}
|
||
|
|
||
|
protected GWTExternalImage buildGWTExternalImage(ExternalImage image, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
{
|
||
|
GWTProperties gwtProperties = buildGWTProperties(image.getProperties());
|
||
|
GWTExternalImage gwtImage = new GWTExternalImage(
|
||
|
toDate(image.getCreationTime()),
|
||
|
image.getId(),
|
||
|
gwtProperties,
|
||
|
image.getName(),
|
||
|
image.getOwner().getPortalLogin(),
|
||
|
image.getDescription(),
|
||
|
toDate(image.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(image.getLastAction().toString()),
|
||
|
parent,
|
||
|
buildImageUrl(image.getId()),
|
||
|
buildThumbnailUrl(image.getId()),
|
||
|
image.getWidth(),
|
||
|
image.getHeight(),
|
||
|
image.getLength(),
|
||
|
image.getThumbnailWidth(),
|
||
|
image.getThumbnailHeight(),
|
||
|
image.getThumbnailLength(),
|
||
|
image.getMimeType());
|
||
|
|
||
|
return gwtImage;
|
||
|
}
|
||
|
|
||
|
protected GWTQuery buildGWTQuery(Query query, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
{
|
||
|
GWTProperties gwtProperties = buildGWTProperties(query.getProperties());
|
||
|
GWTQuery gwtQuery = new GWTQuery(
|
||
|
query.getId(),
|
||
|
query.getName(),
|
||
|
query.getDescription(),
|
||
|
query.getOwner().getPortalLogin(),
|
||
|
toDate(query.getCreationTime()),
|
||
|
gwtProperties,
|
||
|
toDate(query.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(query.getLastAction().toString()),
|
||
|
parent,
|
||
|
query.getLength());
|
||
|
|
||
|
return gwtQuery;
|
||
|
}
|
||
|
|
||
|
protected GWTAquaMapsItem buildGWTAquaMapsItem(AquaMapsItem aquamapsItem, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
{
|
||
|
GWTProperties gwtProperties = buildGWTProperties(aquamapsItem.getProperties());
|
||
|
|
||
|
GWTAquaMapsItem gwtAquaMapsItem = new GWTAquaMapsItem(
|
||
|
aquamapsItem.getId(),
|
||
|
aquamapsItem.getName(),
|
||
|
aquamapsItem.getDescription(),
|
||
|
aquamapsItem.getOwner().getPortalLogin(),
|
||
|
toDate(aquamapsItem.getCreationTime()),
|
||
|
gwtProperties,
|
||
|
toDate(aquamapsItem.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(aquamapsItem.getLastAction().toString()),
|
||
|
parent,
|
||
|
aquamapsItem.getLength(),
|
||
|
aquamapsItem.getMapName(),
|
||
|
aquamapsItem.getMapType(),
|
||
|
aquamapsItem.getAuthor(),
|
||
|
aquamapsItem.getNumberOfSpecies(),
|
||
|
aquamapsItem.getBoundingBox(),
|
||
|
aquamapsItem.getPsoThreshold(),
|
||
|
aquamapsItem.getNumberOfGeneratedImages()
|
||
|
);
|
||
|
|
||
|
return gwtAquaMapsItem;
|
||
|
}
|
||
|
|
||
|
|
||
|
protected GWTTimeSeries buildGWTTimeSeries(TimeSeries timeseries, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
{
|
||
|
GWTProperties gwtProperties = buildGWTProperties(timeseries.getProperties());
|
||
|
|
||
|
TimeSeriesInfo timeSeriesInfo = timeseries.getTimeSeriesInfo();
|
||
|
|
||
|
GWTTimeSeries gwtTimeSeries = new GWTTimeSeries(
|
||
|
timeseries.getId(),
|
||
|
timeseries.getName(),
|
||
|
timeseries.getDescription(),
|
||
|
timeseries.getOwner().getPortalLogin(),
|
||
|
toDate(timeseries.getCreationTime()),
|
||
|
gwtProperties,
|
||
|
toDate(timeseries.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(timeseries.getLastAction().toString()),
|
||
|
parent,
|
||
|
timeseries.getLength(),
|
||
|
timeSeriesInfo.getId(),
|
||
|
timeSeriesInfo.getTitle(),
|
||
|
timeSeriesInfo.getCreator(),
|
||
|
timeSeriesInfo.getDescription(),
|
||
|
timeSeriesInfo.getCreationDate(),
|
||
|
timeSeriesInfo.getPublisher(),
|
||
|
timeSeriesInfo.getSourceId(),
|
||
|
timeSeriesInfo.getSourceName(),
|
||
|
timeSeriesInfo.getRights(),
|
||
|
timeSeriesInfo.getDimension(),
|
||
|
new LinkedList<String>(timeseries.getHeaderLabels())
|
||
|
);
|
||
|
|
||
|
return gwtTimeSeries;
|
||
|
}
|
||
|
|
||
|
protected GWTReportTemplate buildGWTReportTemplate(ReportTemplate template, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
{
|
||
|
GWTProperties gwtProperties = buildGWTProperties(template.getProperties());
|
||
|
GWTReportTemplate gwtTemplate = new GWTReportTemplate(
|
||
|
template.getId(),
|
||
|
template.getName(),
|
||
|
template.getDescription(),
|
||
|
template.getOwner().getPortalLogin(),
|
||
|
toDate(template.getCreationTime()),
|
||
|
gwtProperties,
|
||
|
toDate(template.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(template.getLastAction().toString()),
|
||
|
parent,
|
||
|
template.getLength(),
|
||
|
toDate(template.getCreated()),
|
||
|
toDate(template.getLastEdit()),
|
||
|
template.getAuthor(),
|
||
|
template.getLastEditBy(),
|
||
|
template.getNumberOfSections(),
|
||
|
template.getStatus());
|
||
|
|
||
|
return gwtTemplate;
|
||
|
}
|
||
|
|
||
|
protected GWTReport buildGWTReport(Report template, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
{
|
||
|
GWTProperties gwtProperties = buildGWTProperties(template.getProperties());
|
||
|
GWTReport gwtReport = new GWTReport(
|
||
|
template.getId(),
|
||
|
template.getName(),
|
||
|
template.getDescription(),
|
||
|
template.getOwner().getPortalLogin(),
|
||
|
toDate(template.getCreationTime()),
|
||
|
gwtProperties,
|
||
|
toDate(template.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(template.getLastAction().toString()),
|
||
|
parent,
|
||
|
template.getLength(),
|
||
|
toDate(template.getCreated()),
|
||
|
toDate(template.getLastEdit()),
|
||
|
template.getAuthor(),
|
||
|
template.getLastEditBy(),
|
||
|
template.getTemplateName(),
|
||
|
template.getNumberOfSections(),
|
||
|
template.getStatus()
|
||
|
);
|
||
|
return gwtReport;
|
||
|
}
|
||
|
|
||
|
protected GWTWorkflowReport buildGWTWorkflowReport(WorkflowReport workflowReport, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
{
|
||
|
GWTProperties gwtProperties = buildGWTProperties(workflowReport.getProperties());
|
||
|
GWTWorkflowReport gwtWorkflowReport = new GWTWorkflowReport(
|
||
|
workflowReport.getId(),
|
||
|
workflowReport.getName(),
|
||
|
workflowReport.getDescription(),
|
||
|
workflowReport.getOwner().getPortalLogin(),
|
||
|
toDate(workflowReport.getCreationTime()),
|
||
|
gwtProperties,
|
||
|
toDate(workflowReport.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(workflowReport.getLastAction().toString()),
|
||
|
parent,
|
||
|
workflowReport.getLength()
|
||
|
);
|
||
|
gwtWorkflowReport.setWorkflowStatus(workflowReport.getWorkflowStatus());
|
||
|
return gwtWorkflowReport;
|
||
|
}
|
||
|
|
||
|
protected GWTWorkflowTemplate buildGWTWorkflowTemplate(WorkflowTemplate workflowTemplate, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
{
|
||
|
GWTProperties gwtProperties = buildGWTProperties(workflowTemplate.getProperties());
|
||
|
GWTWorkflowTemplate gwtWorkflowReport = new GWTWorkflowTemplate(
|
||
|
workflowTemplate.getId(),
|
||
|
workflowTemplate.getName(),
|
||
|
workflowTemplate.getDescription(),
|
||
|
workflowTemplate.getOwner().getPortalLogin(),
|
||
|
toDate(workflowTemplate.getCreationTime()),
|
||
|
gwtProperties,
|
||
|
toDate(workflowTemplate.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(workflowTemplate.getLastAction().toString()),
|
||
|
parent,
|
||
|
workflowTemplate.getLength()
|
||
|
);
|
||
|
gwtWorkflowReport.setWorkflowStatus(workflowTemplate.getWorkflowStatus());
|
||
|
return gwtWorkflowReport;
|
||
|
}
|
||
|
|
||
|
protected GWTImageDocument buildGWTImageDocument(ImageDocument image, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
{
|
||
|
GWTProperties gwtProperties = buildGWTProperties(image.getProperties());
|
||
|
|
||
|
Map<String, GWTDocumentMetadata> gwtmetadatas = getMetadatas(image.getMetadata(), image.getId());
|
||
|
|
||
|
GWTImageDocument gwtImage = new GWTImageDocument(
|
||
|
toDate(image.getCreationTime()),
|
||
|
image.getId(),
|
||
|
gwtProperties,
|
||
|
image.getName(),
|
||
|
image.getOwner().getPortalLogin(),
|
||
|
image.getDescription(),
|
||
|
toDate(image.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(image.getLastAction().toString()),
|
||
|
parent,
|
||
|
buildImageUrl(image.getId()),
|
||
|
buildThumbnailUrl(image.getId()),
|
||
|
image.getWidth(),
|
||
|
image.getHeight(),
|
||
|
image.getThumbnailWidth(),
|
||
|
image.getThumbnailHeight(),
|
||
|
image.getThumbnailLength(),
|
||
|
image.getLength(),
|
||
|
image.getMimeType(),
|
||
|
image.getURI(),
|
||
|
gwtmetadatas,
|
||
|
new LinkedHashMap<String, String>(),
|
||
|
image.getCollectionName(),
|
||
|
image.getAlternatives().size(),
|
||
|
image.getParts().size()
|
||
|
|
||
|
);
|
||
|
|
||
|
return gwtImage;
|
||
|
|
||
|
}
|
||
|
|
||
|
protected GWTPDFDocument buildGWTPDFDocument(PDFDocument pdfDocument, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
{
|
||
|
GWTProperties gwtProperties = buildGWTProperties(pdfDocument.getProperties());
|
||
|
|
||
|
Map<String, GWTDocumentMetadata> gwtmetadatas = getMetadatas(pdfDocument.getMetadata(), pdfDocument.getId());
|
||
|
|
||
|
GWTPDFDocument gwtPDF = new GWTPDFDocument(
|
||
|
toDate(pdfDocument.getCreationTime()),
|
||
|
pdfDocument.getId(),
|
||
|
gwtProperties,
|
||
|
pdfDocument.getName(),
|
||
|
pdfDocument.getOwner().getPortalLogin(),
|
||
|
pdfDocument.getDescription(),
|
||
|
toDate(pdfDocument.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(pdfDocument.getLastAction().toString()),
|
||
|
parent,
|
||
|
pdfDocument.getLength(),
|
||
|
pdfDocument.getURI(),
|
||
|
pdfDocument.getMimeType(),
|
||
|
gwtmetadatas,
|
||
|
new LinkedHashMap<String, String>(),
|
||
|
pdfDocument.getCollectionName(),
|
||
|
pdfDocument.getAlternatives().size(),
|
||
|
pdfDocument.getParts().size(),
|
||
|
pdfDocument.getAuthor(),
|
||
|
pdfDocument.getNumberOfPages(),
|
||
|
pdfDocument.getProducer(),
|
||
|
pdfDocument.getTitle(),
|
||
|
pdfDocument.getVersion(),
|
||
|
"DocumentService?id="+pdfDocument.getId()
|
||
|
);
|
||
|
|
||
|
return gwtPDF;
|
||
|
|
||
|
}
|
||
|
|
||
|
protected GWTDocument buildGWTDocument(Document document, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
{
|
||
|
GWTProperties gwtProperties = buildGWTProperties(document.getProperties());
|
||
|
|
||
|
Map<String, GWTDocumentMetadata> gwtmetadatas = getMetadatas(document.getMetadata(), document.getId());
|
||
|
|
||
|
GWTDocument gwtPDF = new GWTDocument(
|
||
|
toDate(document.getCreationTime()),
|
||
|
document.getId(),
|
||
|
gwtProperties,
|
||
|
document.getName(),
|
||
|
document.getOwner().getPortalLogin(),
|
||
|
document.getDescription(),
|
||
|
toDate(document.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(document.getLastAction().toString()),
|
||
|
parent,
|
||
|
document.getLength(),
|
||
|
document.getURI(),
|
||
|
document.getMimeType(),
|
||
|
gwtmetadatas,
|
||
|
new LinkedHashMap<String, String>(),
|
||
|
document.getCollectionName(),
|
||
|
document.getAlternatives().size(),
|
||
|
document.getParts().size()
|
||
|
);
|
||
|
|
||
|
return gwtPDF;
|
||
|
|
||
|
}
|
||
|
|
||
|
protected GWTMetadata buildGWTMetadata(Metadata metadata, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
{
|
||
|
GWTProperties gwtProperties = buildGWTProperties(metadata.getProperties());
|
||
|
|
||
|
GWTMetadata gwtMetadata = new GWTMetadata(
|
||
|
metadata.getId(),
|
||
|
metadata.getName(),
|
||
|
metadata.getDescription(),
|
||
|
metadata.getOwner().getPortalLogin(),
|
||
|
toDate(metadata.getCreationTime()),
|
||
|
gwtProperties,
|
||
|
toDate(metadata.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(metadata.getLastAction().toString()),
|
||
|
parent,
|
||
|
metadata.getLength(),
|
||
|
metadata.getURI(),
|
||
|
metadata.getSchema(),
|
||
|
metadata.getLanguage(),
|
||
|
metadata.getCollectionName(),
|
||
|
"MetadataService?id="+metadata.getId()+"&type="+MetadataFormat.HTML,
|
||
|
"MetadataService?id="+metadata.getId()+"&type="+MetadataFormat.RAW_XML_AS_HTML
|
||
|
);
|
||
|
|
||
|
return gwtMetadata;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
///////////////////////*********************USED
|
||
|
|
||
|
//ADD FRANCESCO
|
||
|
protected GWTWorkspaceItem buildGWTWorkspaceImage(WorkspaceItem item, boolean isInteralImage, boolean fullDetails) throws InternalErrorException
|
||
|
{
|
||
|
|
||
|
GWTWorkspaceItem gwtImage;
|
||
|
|
||
|
GWTProperties gwtProperties = buildGWTProperties(item.getProperties());
|
||
|
//
|
||
|
if(isInteralImage){
|
||
|
|
||
|
ImageDocument image = (ImageDocument) item; //Cast Image Document
|
||
|
|
||
|
Map<String, GWTDocumentMetadata> gwtmetadatas = getMetadatas(image.getMetadata(), image.getId());
|
||
|
|
||
|
gwtImage = (GWTImageDocument) new GWTImageDocument(
|
||
|
toDate(image.getCreationTime()),
|
||
|
image.getId(),
|
||
|
gwtProperties,
|
||
|
image.getName(),
|
||
|
image.getOwner().getPortalLogin(),
|
||
|
image.getDescription(),
|
||
|
toDate(image.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(image.getLastAction().toString()),
|
||
|
null,
|
||
|
buildImageUrl(image.getId()),
|
||
|
buildThumbnailUrl(image.getId()),
|
||
|
image.getWidth(),
|
||
|
image.getHeight(),
|
||
|
image.getThumbnailWidth(),
|
||
|
image.getThumbnailHeight(),
|
||
|
image.getThumbnailLength(),
|
||
|
image.getLength(),
|
||
|
image.getMimeType(),
|
||
|
image.getURI(),
|
||
|
gwtmetadatas,
|
||
|
new LinkedHashMap<String, String>(),
|
||
|
image.getCollectionName(),
|
||
|
image.getAlternatives().size(),
|
||
|
image.getParts().size());
|
||
|
}
|
||
|
|
||
|
else{
|
||
|
|
||
|
ExternalImage image = (ExternalImage) item; //Cast External Document
|
||
|
|
||
|
if(fullDetails){
|
||
|
|
||
|
gwtImage = new GWTExternalImage(
|
||
|
toDate(image.getCreationTime()),
|
||
|
image.getId(),
|
||
|
gwtProperties,
|
||
|
image.getName(),
|
||
|
image.getOwner().getPortalLogin(),
|
||
|
image.getDescription(),
|
||
|
toDate(image.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(image.getLastAction().toString()),
|
||
|
null, //parent
|
||
|
buildImageUrl(image.getId()),
|
||
|
buildThumbnailUrl(image.getId()),
|
||
|
image.getWidth(),
|
||
|
image.getHeight(),
|
||
|
image.getLength(),
|
||
|
image.getThumbnailWidth(),
|
||
|
image.getThumbnailHeight(),
|
||
|
image.getThumbnailLength(),
|
||
|
image.getMimeType());
|
||
|
}
|
||
|
else{
|
||
|
|
||
|
gwtImage = new GWTExternalImage(
|
||
|
buildImageUrl(image.getId()),
|
||
|
buildThumbnailUrl(image.getId()),
|
||
|
image.getWidth(),
|
||
|
image.getHeight(),
|
||
|
image.getLength(),
|
||
|
image.getThumbnailWidth(),
|
||
|
image.getThumbnailHeight(),
|
||
|
image.getThumbnailLength(),
|
||
|
image.getMimeType());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
return gwtImage;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
protected GWTExternalUrl buildGWTExternalUrl(ExternalUrl url, GWTWorkspaceFolder parent) throws InternalErrorException
|
||
|
{
|
||
|
GWTProperties gwtProperties = buildGWTProperties(url.getProperties());
|
||
|
GWTExternalUrl gwtUrl = new GWTExternalUrl(
|
||
|
toDate(url.getCreationTime()),
|
||
|
url.getId(),
|
||
|
gwtProperties,
|
||
|
url.getName(),
|
||
|
url.getOwner().getPortalLogin(),
|
||
|
url.getDescription(),
|
||
|
toDate(url.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(url.getLastAction().toString()),
|
||
|
parent,
|
||
|
url.getLength(),
|
||
|
url.getUrl());
|
||
|
|
||
|
return gwtUrl;
|
||
|
}
|
||
|
|
||
|
|
||
|
protected GWTWorkspaceItem buildGWTWorspaceUrl(WorkspaceItem item, boolean isInternalUrl, boolean fullDetails) throws InternalErrorException
|
||
|
{
|
||
|
|
||
|
GWTWorkspaceItem gwtUrl = null;
|
||
|
|
||
|
GWTProperties gwtProperties = buildGWTProperties(item.getProperties());
|
||
|
|
||
|
// GWTUrlDocument gwtUrlDocument = null;
|
||
|
|
||
|
if(isInternalUrl){
|
||
|
|
||
|
UrlDocument document = (UrlDocument) item; //Cast
|
||
|
|
||
|
Map<String, GWTDocumentMetadata> gwtmetadatas = getMetadatas(document.getMetadata(), document.getId());
|
||
|
|
||
|
gwtUrl = new GWTUrlDocument(
|
||
|
toDate(document.getCreationTime()),
|
||
|
document.getId(),
|
||
|
gwtProperties,
|
||
|
document.getName(),
|
||
|
document.getOwner().getPortalLogin(),
|
||
|
document.getDescription(),
|
||
|
toDate(document.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(document.getLastAction().toString()),
|
||
|
null,
|
||
|
document.getLength(),
|
||
|
document.getURI(),
|
||
|
document.getMimeType(),
|
||
|
gwtmetadatas,
|
||
|
new LinkedHashMap<String, String>(),
|
||
|
document.getCollectionName(),
|
||
|
document.getAlternatives().size(),
|
||
|
document.getParts().size(),
|
||
|
document.getUrl());
|
||
|
}
|
||
|
else{
|
||
|
|
||
|
ExternalUrl document = (ExternalUrl) item; //Cast
|
||
|
|
||
|
if(fullDetails){
|
||
|
|
||
|
gwtUrl = new GWTExternalUrl(
|
||
|
toDate(document.getCreationTime()),
|
||
|
document.getId(),
|
||
|
gwtProperties,
|
||
|
document.getName(),
|
||
|
document.getOwner().getPortalLogin(),
|
||
|
document.getDescription(),
|
||
|
toDate(document.getLastModificationTime()),
|
||
|
GWTWorkspaceItemAction.valueOf(document.getLastAction().toString()),
|
||
|
null,
|
||
|
document.getLength(),
|
||
|
document.getUrl());
|
||
|
|
||
|
}
|
||
|
else{
|
||
|
|
||
|
gwtUrl = new GWTExternalUrl(document.getUrl());
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
return gwtUrl;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
protected Map<String, GWTDocumentMetadata> getMetadatas(Map<String, DocumentMetadata> metadatas, String documentId)
|
||
|
{
|
||
|
Map<String, GWTDocumentMetadata> gwtmetadatas = new LinkedHashMap<String, GWTDocumentMetadata>();
|
||
|
|
||
|
for (Entry<String, DocumentMetadata> metadata : metadatas.entrySet()) gwtmetadatas.put(metadata.getKey(), getMetadata(metadata.getValue(), documentId));
|
||
|
|
||
|
return gwtmetadatas;
|
||
|
}
|
||
|
|
||
|
protected GWTDocumentMetadata getMetadata(DocumentMetadata metadata, String documentId)
|
||
|
{
|
||
|
return new GWTDocumentMetadata(metadata.getSchemaName(),
|
||
|
"MetadataService?id="+documentId+"&schema="+metadata.getSchemaName()+"&type="+MetadataFormat.HTML,
|
||
|
"MetadataService?id="+documentId+"&schema="+metadata.getSchemaName()+"&type="+MetadataFormat.RAW_XML_AS_HTML,
|
||
|
"MetadataService?id="+documentId+"&schema="+metadata.getSchemaName()+"&type="+MetadataFormat.FORMATTED_XML);
|
||
|
}
|
||
|
|
||
|
|
||
|
//*****************************************************NEW
|
||
|
|
||
|
|
||
|
public FolderModel buildWorkspaceFileModelRoot(WorkspaceFolder workspaceRoot) throws InternalErrorException {
|
||
|
|
||
|
logger.trace("workspace id: "+ workspaceRoot.getId());
|
||
|
logger.trace("workspace name: "+ workspaceRoot.getName());
|
||
|
logger.trace("workspace path "+ workspaceRoot.getPath());
|
||
|
|
||
|
FolderModel root = new FolderModel(workspaceRoot.getId(),workspaceRoot.getName(),null, true, workspaceRoot.isShared());
|
||
|
root.setIsRoot(true);
|
||
|
|
||
|
// root.setOwner(new InfoContactModel(workspaceRoot.getOwner().getId(), workspaceRoot.getOwner().getPortalLogin(), "name"));
|
||
|
// root.setShared(workspaceRoot.isShared());
|
||
|
// root.setMarkAsRead(workspaceRoot.isMarkedAsRead());
|
||
|
|
||
|
|
||
|
//TODO
|
||
|
WorkspaceItemAccounting a = workspaceRoot.getAccounting();
|
||
|
|
||
|
|
||
|
return root;
|
||
|
}
|
||
|
|
||
|
|
||
|
// public GWTWorkspaceItem buildWorkspaceFileModelItems(WorkspaceFolder workspace) throws InternalErrorException {
|
||
|
//
|
||
|
// List<GWTWorkspaceItem> children = new LinkedList<GWTWorkspaceItem>();
|
||
|
//
|
||
|
// for (WorkspaceItem folder : workspace.getChildren()){
|
||
|
// GWTWorkspaceItem gwtFolder = buildGWTWorkspaceItem(folder, gwtWorkspace);
|
||
|
// if (gwtFolder!=null) children.add(gwtFolder);
|
||
|
// else{
|
||
|
// logger.error("gwt conversion return null for folder "+folder);
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// return root;
|
||
|
// }
|
||
|
|
||
|
|
||
|
protected List<FileModel> buildGXTListFileModelItem(WorkspaceItem workspaceFolder, FileModel parentFolderModel) throws InternalErrorException
|
||
|
{
|
||
|
|
||
|
List<FileModel> listFileModel = new ArrayList<FileModel>();
|
||
|
|
||
|
List<WorkspaceItem> listItems = (List<WorkspaceItem>) workspaceFolder.getChildren();
|
||
|
|
||
|
//TEST TIME
|
||
|
// Long startTime = System.currentTimeMillis();
|
||
|
// Long endTime = System.currentTimeMillis() - startTime;
|
||
|
// String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
||
|
// logger.trace("tree getChildren() returning "+listItems.size()+" elements in " + time);
|
||
|
// startTime = System.currentTimeMillis();
|
||
|
|
||
|
for (WorkspaceItem item : listItems){
|
||
|
listFileModel.add(buildGXTFileModelItem(item,parentFolderModel));
|
||
|
}
|
||
|
|
||
|
//TEST TIME
|
||
|
// endTime = System.currentTimeMillis() - startTime;
|
||
|
// time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
||
|
// logger.trace("tree gxt objects getChildren() returning "+listItems.size()+" elements in " + time);
|
||
|
|
||
|
return listFileModel;
|
||
|
|
||
|
// return buildGXTListFileModelItem((WorkspaceItem) workspaceFolder.getChildren(), parentFolderModel);
|
||
|
}
|
||
|
|
||
|
|
||
|
protected List<FileModel> buildGXTListFileModelItemForAttachs(List<WorkspaceItem> listWorspaceItems) throws InternalErrorException
|
||
|
{
|
||
|
|
||
|
List<FileModel> listFileModel = new ArrayList<FileModel>();
|
||
|
|
||
|
for (WorkspaceItem item : listWorspaceItems){
|
||
|
|
||
|
FileModel fileModel = null;
|
||
|
|
||
|
switch (item.getType()) {
|
||
|
|
||
|
case FOLDER: fileModel = new FolderModel(item.getId(), item.getName(), true);
|
||
|
fileModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
|
||
|
break;
|
||
|
|
||
|
case FOLDER_ITEM:
|
||
|
fileModel = new FileModel(item.getId(), item.getName(), false);
|
||
|
FolderItem folderItem = (FolderItem) item;
|
||
|
fileModel = setFolderItemType(fileModel, folderItem);
|
||
|
break;
|
||
|
|
||
|
case SHARED_FOLDER:
|
||
|
|
||
|
fileModel = new FolderModel(item.getId(), item.getName(), true);
|
||
|
fileModel.setShared(true);
|
||
|
fileModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
|
||
|
|
||
|
// WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) item;
|
||
|
// fileModel.setListShareUser(buildGxtInfoContactFromPortalLogin(sharedFolder.getUsers()));
|
||
|
|
||
|
break;
|
||
|
default:
|
||
|
logger.error("gxt conversion return null for item "+item.getName());
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
listFileModel.add(fileModel);
|
||
|
}
|
||
|
return listFileModel;
|
||
|
}
|
||
|
|
||
|
|
||
|
//TODO
|
||
|
//TEMP??
|
||
|
protected List<InfoContactModel> buildGxtInfoContactFromPortalLogin(List<String> listPortalLogin){
|
||
|
|
||
|
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
|
||
|
for (String portalLogin : listPortalLogin)
|
||
|
listContact.add(new InfoContactModel(portalLogin, portalLogin, "name"));
|
||
|
return listContact;
|
||
|
}
|
||
|
|
||
|
|
||
|
protected FileModel buildGXTFileModelItem(WorkspaceItem item, FileModel parentFolderModel) throws InternalErrorException
|
||
|
{
|
||
|
|
||
|
FileModel fileModel = null;
|
||
|
|
||
|
switch (item.getType()) {
|
||
|
|
||
|
case FOLDER:
|
||
|
|
||
|
fileModel = new FolderModel(item.getId(), item.getName(), (FolderModel) parentFolderModel, true, false);
|
||
|
fileModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
|
||
|
break;
|
||
|
|
||
|
case FOLDER_ITEM:
|
||
|
// fileModel = new FileModel(item.getId(), item.getName(), item.getPath(), (FolderModel) parentFolderModel, false);
|
||
|
fileModel = new FileModel(item.getId(), item.getName(), (FolderModel) parentFolderModel, false, false);
|
||
|
FolderItem folderItem = (FolderItem) item;
|
||
|
fileModel = setFolderItemType(fileModel, folderItem);
|
||
|
break;
|
||
|
|
||
|
case SHARED_FOLDER:
|
||
|
|
||
|
fileModel = new FolderModel(item.getId(), item.getName(), (FolderModel) parentFolderModel, true, true);
|
||
|
fileModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
|
||
|
|
||
|
// WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) item;
|
||
|
// fileModel.setListShareUser(buildGxtInfoContactFromPortalLogin(sharedFolder.getUsers()));
|
||
|
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
logger.error("gxt conversion return null for item "+item.getName());
|
||
|
break;
|
||
|
|
||
|
}
|
||
|
|
||
|
if(parentFolderModel.isShared())
|
||
|
fileModel.setShared(true);
|
||
|
|
||
|
// fileModel.setOwner(new InfoContactModel(item.getOwner().getId(), item.getOwner().getPortalLogin(), "name"));
|
||
|
//// fileModel.setShared(item.isShared());
|
||
|
// fileModel.setMarkAsRead(item.isMarkedAsRead());
|
||
|
|
||
|
return fileModel;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
protected List<FileGridModel> buildGXTListFileGridModelItemForSearch(List<SearchItem> listSearchItems, FileModel parentFileModel) throws InternalErrorException
|
||
|
{
|
||
|
|
||
|
List<FileGridModel> listFileGridModel = new ArrayList<FileGridModel>();
|
||
|
|
||
|
for (SearchItem item : listSearchItems)
|
||
|
listFileGridModel.add(buildGXTFileGridModelItemForSearch(item,parentFileModel));
|
||
|
|
||
|
|
||
|
return listFileGridModel;
|
||
|
}
|
||
|
|
||
|
private FileGridModel buildGXTFileGridModelItemForSearch(SearchItem item, FileModel parentFileModel) throws InternalErrorException{
|
||
|
|
||
|
FileGridModel fileGridModel = null;
|
||
|
|
||
|
switch (item.getType()) {
|
||
|
|
||
|
case FOLDER:
|
||
|
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationDate()), parentFileModel, -1, true, false);
|
||
|
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
|
||
|
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
break;
|
||
|
|
||
|
case FOLDER_ITEM:
|
||
|
SearchFolderItem folderItem = (SearchFolderItem) item;
|
||
|
fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getCreationDate()), parentFileModel, folderItem.getSize(), false, false);
|
||
|
// FolderItem folderItem = (FolderItem) item;
|
||
|
fileGridModel = (FileGridModel) setFolderItemTypeForSearch(fileGridModel, folderItem);
|
||
|
break;
|
||
|
|
||
|
case SHARED_FOLDER:
|
||
|
|
||
|
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationDate()), parentFileModel, -1, true, false);
|
||
|
fileGridModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
|
||
|
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
|
||
|
// WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) item;
|
||
|
// fileGridModel.setListShareUser(buildGxtInfoContactFromPortalLogin(sharedFolder.getUsers()));
|
||
|
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
logger.error("gxt conversion return null for item "+item.getName());
|
||
|
break;
|
||
|
|
||
|
}
|
||
|
|
||
|
return fileGridModel;
|
||
|
|
||
|
}
|
||
|
|
||
|
public List<String> getListLoginByInfoContactModel(List<InfoContactModel> listContacts){
|
||
|
|
||
|
List<String> listUsers = new ArrayList<String>();
|
||
|
|
||
|
for (InfoContactModel infoContactModel : listContacts) {
|
||
|
listUsers.add(infoContactModel.getLogin());
|
||
|
}
|
||
|
|
||
|
return listUsers;
|
||
|
}
|
||
|
|
||
|
|
||
|
protected List<FileGridModel> buildGXTListFileGridModelItem(List<WorkspaceItem> listWorkspaceItems, FileModel parentFileModel) throws InternalErrorException
|
||
|
{
|
||
|
|
||
|
Long startTime = System.currentTimeMillis();
|
||
|
|
||
|
List<FileGridModel> listFileGridModel = new ArrayList<FileGridModel>();
|
||
|
|
||
|
for (WorkspaceItem item : listWorkspaceItems)
|
||
|
listFileGridModel.add(buildGXTFileGridModelItem(item,parentFileModel));
|
||
|
|
||
|
Long endTime = System.currentTimeMillis() - startTime;
|
||
|
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
||
|
logger.trace("gxt grid objects getChildren() returning "+listWorkspaceItems.size()+" elements in " + time);
|
||
|
|
||
|
|
||
|
return listFileGridModel;
|
||
|
}
|
||
|
|
||
|
private FileGridModel buildGXTFileGridModelItem(WorkspaceItem item, FileModel parentFileModel) throws InternalErrorException{
|
||
|
|
||
|
|
||
|
FileGridModel fileGridModel = null;
|
||
|
|
||
|
switch (item.getType()) {
|
||
|
|
||
|
case FOLDER:
|
||
|
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationTime()), parentFileModel, -1, true, false);
|
||
|
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
|
||
|
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
break;
|
||
|
|
||
|
case FOLDER_ITEM:
|
||
|
|
||
|
FolderItem folderItem = (FolderItem) item;
|
||
|
fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getCreationTime()), parentFileModel, folderItem.getLength(), false, false);
|
||
|
// FolderItem folderItem = (FolderItem) item;
|
||
|
fileGridModel = (FileGridModel) setFolderItemType(fileGridModel, folderItem);
|
||
|
break;
|
||
|
|
||
|
case SHARED_FOLDER:
|
||
|
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationTime()), parentFileModel, -1, true, true);
|
||
|
fileGridModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
|
||
|
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
logger.error("gxt conversion return null for item "+item.getName());
|
||
|
break;
|
||
|
|
||
|
}
|
||
|
|
||
|
if(parentFileModel.isShared())
|
||
|
fileGridModel.setShared(true);
|
||
|
|
||
|
// fileGridModel.setOwner(new InfoContactModel(item.getOwner().getId(), item.getOwner().getPortalLogin(), "name"));
|
||
|
//// fileGridModel.setShared(item.isShared());
|
||
|
// fileGridModel.setMarkAsRead(item.isMarkedAsRead());
|
||
|
|
||
|
return fileGridModel;
|
||
|
|
||
|
}
|
||
|
|
||
|
protected FileModel setFolderItemTypeForSearch(FileModel fileModel, SearchFolderItem searchFolderItem){
|
||
|
|
||
|
if(searchFolderItem.getFolderItemType()==null){
|
||
|
logger.trace("Search folder item type is null for "+searchFolderItem.getId() + " name: "+searchFolderItem.getName());
|
||
|
//FOR DEBUG
|
||
|
System.out.println("Search folder item type is null for "+searchFolderItem.getId() + " name: "+searchFolderItem.getName());
|
||
|
return fileModel;
|
||
|
}
|
||
|
|
||
|
switch(searchFolderItem.getFolderItemType())
|
||
|
{
|
||
|
case EXTERNAL_IMAGE:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_IMAGE);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_IMAGES);
|
||
|
fileModel.setType(searchFolderItem.getMimeType());
|
||
|
break;
|
||
|
case EXTERNAL_FILE:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_FILE);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
fileModel.setType(searchFolderItem.getMimeType());
|
||
|
break;
|
||
|
case EXTERNAL_PDF_FILE:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_PDF_FILE);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
fileModel.setType(searchFolderItem.getMimeType());
|
||
|
break;
|
||
|
case EXTERNAL_URL:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_URL);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_LINKS);
|
||
|
break;
|
||
|
case REPORT_TEMPLATE:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.REPORT_TEMPLATE);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_REPORTS);
|
||
|
break;
|
||
|
case REPORT:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.REPORT);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_REPORTS);
|
||
|
break;
|
||
|
case QUERY:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.QUERY);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
break;
|
||
|
case TIME_SERIES:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.TIME_SERIES);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_TIMESERIES);
|
||
|
break;
|
||
|
// case AQUAMAPS_ITEM:
|
||
|
// fileModel.setFolderItemType(GXTFolderItemTypeEnum.AQUAMAPS_ITEM);
|
||
|
// fileModel.setShortcutCategory(GXTCategoryItemInterface.BIODIVERSITY);
|
||
|
// break;
|
||
|
case PDF_DOCUMENT:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.PDF_DOCUMENT);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
break;
|
||
|
case IMAGE_DOCUMENT:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.IMAGE_DOCUMENT);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_IMAGES);
|
||
|
fileModel.setType(searchFolderItem.getMimeType());
|
||
|
break;
|
||
|
case DOCUMENT:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.DOCUMENT);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
fileModel.setType(searchFolderItem.getMimeType());
|
||
|
break;
|
||
|
case URL_DOCUMENT:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.URL_DOCUMENT);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
break;
|
||
|
case METADATA:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.METADATA);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
break;
|
||
|
case WORKFLOW_REPORT:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.WORKFLOW_REPORT);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
break;
|
||
|
case WORKFLOW_TEMPLATE:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.WORKFLOW_TEMPLATE);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
// logger.trace("**************************************DOCUMENTS******* filemodel "+ fileModel.getName());
|
||
|
break;
|
||
|
case EXTERNAL_RESOURCE_LINK:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_RESOURCE_LINK);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_LINKS);
|
||
|
break;
|
||
|
default:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.UNKNOWN_TYPE);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_UNKNOWN);
|
||
|
fileModel.setType(GXTFolderItemTypeEnum.UNKNOWN_TYPE.toString());
|
||
|
// logger.trace("**************************************UNKNOWN******* filemodel "+ fileModel.getName());
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return fileModel;
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
protected FileModel setFolderItemType(FileModel fileModel, FolderItem worspaceFolderItem){
|
||
|
|
||
|
switch(worspaceFolderItem.getFolderItemType())
|
||
|
{
|
||
|
case EXTERNAL_IMAGE:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_IMAGE);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_IMAGES);
|
||
|
ExternalImage extImage = (ExternalImage) worspaceFolderItem;
|
||
|
fileModel.setType(extImage.getMimeType());
|
||
|
break;
|
||
|
case EXTERNAL_FILE:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_FILE);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
ExternalFile extFile = (ExternalFile) worspaceFolderItem;
|
||
|
fileModel.setType(extFile.getMimeType());
|
||
|
break;
|
||
|
case EXTERNAL_PDF_FILE:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_PDF_FILE);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
ExternalPDFFile pdfExt = (ExternalPDFFile) worspaceFolderItem;
|
||
|
fileModel.setType(pdfExt.getMimeType());
|
||
|
break;
|
||
|
case EXTERNAL_URL:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_URL);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_LINKS);
|
||
|
break;
|
||
|
case REPORT_TEMPLATE:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.REPORT_TEMPLATE);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_REPORTS);
|
||
|
break;
|
||
|
case REPORT:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.REPORT);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_REPORTS);
|
||
|
break;
|
||
|
case QUERY:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.QUERY);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
break;
|
||
|
case TIME_SERIES:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.TIME_SERIES);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_TIMESERIES);
|
||
|
break;
|
||
|
// case AQUAMAPS_ITEM:
|
||
|
// fileModel.setFolderItemType(GXTFolderItemTypeEnum.AQUAMAPS_ITEM);
|
||
|
// fileModel.setShortcutCategory(GXTCategoryItemInterface.BIODIVERSITY);
|
||
|
// break;
|
||
|
case PDF_DOCUMENT:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.PDF_DOCUMENT);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
break;
|
||
|
case IMAGE_DOCUMENT:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.IMAGE_DOCUMENT);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_IMAGES);
|
||
|
ImageDocument imgDoc = (ImageDocument) worspaceFolderItem;
|
||
|
fileModel.setType(imgDoc.getMimeType());
|
||
|
break;
|
||
|
case DOCUMENT:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.DOCUMENT);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
Document doc = (Document) worspaceFolderItem;
|
||
|
fileModel.setType(doc.getMimeType());
|
||
|
break;
|
||
|
case URL_DOCUMENT:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.URL_DOCUMENT);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
break;
|
||
|
case METADATA:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.METADATA);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
break;
|
||
|
case WORKFLOW_REPORT:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.WORKFLOW_REPORT);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
break;
|
||
|
case WORKFLOW_TEMPLATE:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.WORKFLOW_TEMPLATE);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||
|
// logger.trace("**************************************DOCUMENTS******* filemodel "+ fileModel.getName());
|
||
|
break;
|
||
|
case EXTERNAL_RESOURCE_LINK:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_RESOURCE_LINK);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_LINKS);
|
||
|
break;
|
||
|
default:
|
||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.UNKNOWN_TYPE);
|
||
|
fileModel.setShortcutCategory(GXTCategoryItemInterface.SMF_UNKNOWN);
|
||
|
fileModel.setType(GXTFolderItemTypeEnum.UNKNOWN_TYPE.toString());
|
||
|
// logger.trace("**************************************UNKNOWN******* filemodel "+ fileModel.getName());
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return fileModel;
|
||
|
}
|
||
|
|
||
|
public FolderModel buildGXTFolderModelItem(WorkspaceFolder wsFolder, FileModel parent) throws InternalErrorException {
|
||
|
|
||
|
return new FolderModel(wsFolder.getId(),wsFolder.getName(), parent, true, wsFolder.isShared());
|
||
|
|
||
|
}
|
||
|
|
||
|
public FileDetailsModel buildGWTWorkspaceFileDetails(WorkspaceItem wsItem, FileModel item) throws InternalErrorException {
|
||
|
|
||
|
FileDetailsModel fileDetailsModel = new FileDetailsModel(
|
||
|
wsItem.getId(),
|
||
|
wsItem.getName(),
|
||
|
wsItem.getPath(),
|
||
|
toDate(wsItem.getCreationTime()),
|
||
|
item.getParentFileModel(),
|
||
|
0,//size
|
||
|
item.isDirectory(),
|
||
|
wsItem.getDescription(),
|
||
|
toDate(wsItem.getLastModificationTime()),
|
||
|
""+wsItem.getOwner(),wsItem.isShared());
|
||
|
|
||
|
return fileDetailsModel;
|
||
|
}
|
||
|
|
||
|
// public List<FileGridModel> filterListByCategory(List<FileGridModel> listFileGridModel, String category) {
|
||
|
//
|
||
|
// List<FileGridModel> filteredList = new ArrayList<FileGridModel>();
|
||
|
//
|
||
|
// logger.trace("Category :" + category);
|
||
|
//
|
||
|
// for(FileGridModel fileGridModel: listFileGridModel){
|
||
|
//
|
||
|
// if(fileGridModel.getShortcutCategory()!=null){
|
||
|
//
|
||
|
//// logger.trace("file GridModel category:" + fileGridModel.getShortcutCategory());
|
||
|
//
|
||
|
// if(fileGridModel.getShortcutCategory().compareTo(category)==0){
|
||
|
// filteredList.add(fileGridModel);
|
||
|
// }
|
||
|
//
|
||
|
// }else
|
||
|
// logger.trace("file GridModel category null");
|
||
|
// }
|
||
|
//
|
||
|
// return filteredList;
|
||
|
// }
|
||
|
|
||
|
|
||
|
|
||
|
protected String getFolderItemTypeCategory(SearchItem item) throws InternalErrorException{
|
||
|
|
||
|
switch (item.getType()) {
|
||
|
|
||
|
case FOLDER:
|
||
|
|
||
|
return GXTCategoryItemInterface.SMF_DOCUMENTS;
|
||
|
|
||
|
case FOLDER_ITEM:
|
||
|
|
||
|
SearchFolderItem folderItem = (SearchFolderItem) item;
|
||
|
switch(folderItem.getFolderItemType())
|
||
|
{
|
||
|
case EXTERNAL_IMAGE:
|
||
|
return GXTCategoryItemInterface.SMF_IMAGES;
|
||
|
case EXTERNAL_FILE:
|
||
|
return GXTCategoryItemInterface.SMF_DOCUMENTS;
|
||
|
case EXTERNAL_PDF_FILE:
|
||
|
return GXTCategoryItemInterface.SMF_DOCUMENTS;
|
||
|
case EXTERNAL_URL:
|
||
|
return GXTCategoryItemInterface.SMF_LINKS;
|
||
|
case REPORT_TEMPLATE:
|
||
|
return GXTCategoryItemInterface.SMF_REPORTS;
|
||
|
case REPORT:
|
||
|
return GXTCategoryItemInterface.SMF_REPORTS;
|
||
|
case QUERY:
|
||
|
return GXTCategoryItemInterface.SMF_DOCUMENTS;
|
||
|
case TIME_SERIES:
|
||
|
return GXTCategoryItemInterface.SMF_TIMESERIES;
|
||
|
case AQUAMAPS_ITEM:
|
||
|
return GXTCategoryItemInterface.SMF_BIODIVERSITY;
|
||
|
case PDF_DOCUMENT:
|
||
|
return GXTCategoryItemInterface.SMF_DOCUMENTS;
|
||
|
case IMAGE_DOCUMENT:
|
||
|
return GXTCategoryItemInterface.SMF_IMAGES;
|
||
|
case DOCUMENT:
|
||
|
return GXTCategoryItemInterface.SMF_DOCUMENTS;
|
||
|
case URL_DOCUMENT:
|
||
|
return GXTCategoryItemInterface.SMF_DOCUMENTS;
|
||
|
case METADATA:
|
||
|
return GXTCategoryItemInterface.SMF_DOCUMENTS;
|
||
|
case WORKFLOW_REPORT:
|
||
|
return GXTCategoryItemInterface.SMF_DOCUMENTS;
|
||
|
case WORKFLOW_TEMPLATE:
|
||
|
return GXTCategoryItemInterface.SMF_DOCUMENTS;
|
||
|
case EXTERNAL_RESOURCE_LINK:
|
||
|
return GXTCategoryItemInterface.SMF_LINKS;
|
||
|
default:
|
||
|
return GXTCategoryItemInterface.SMF_UNKNOWN;
|
||
|
}
|
||
|
|
||
|
default:
|
||
|
logger.error("gxt conversion return null for item "+item.getName());
|
||
|
return GXTCategoryItemInterface.SMF_UNKNOWN;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
public List<FileGridModel> filterListFileGridModelItemByCategory(List<SearchItem> listSearchItem, String category) throws InternalErrorException {
|
||
|
|
||
|
List<FileGridModel> filteredList = new ArrayList<FileGridModel>();
|
||
|
|
||
|
logger.trace("filterListFileGridModelItemByCategory - Category:" + category + "listSearchItem size " + listSearchItem.size());
|
||
|
//FOR DEBUG
|
||
|
// System.out.println("filterListFileGridModelItemByCategory - Category:" + category + "listSearchItem size " + listSearchItem.size());
|
||
|
|
||
|
for(SearchItem searchItem: listSearchItem){
|
||
|
|
||
|
logger.trace("wsItem: " + searchItem.getName());
|
||
|
// FOR DEBUG
|
||
|
// System.out.println("wsItem: " + searchItem.getName());
|
||
|
|
||
|
if(category.equals(getFolderItemTypeCategory(searchItem))){
|
||
|
|
||
|
filteredList.add(buildGXTFileGridModelItemForSearch(searchItem,null));
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
return filteredList;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
// public SmartFolderModel buildGXTSmartFolderModel(WorkspaceFolder wsFolder, String query) throws InternalErrorException {
|
||
|
//
|
||
|
// SmartFolderModel smartFolderModel = new SmartFolderModel(
|
||
|
// wsFolder.getId(),
|
||
|
// wsFolder.getName(),
|
||
|
// query);
|
||
|
//
|
||
|
// logger.trace("in return SmartFolder: " + smartFolderModel.getIdentifier() + " " + smartFolderModel.getName() + " " + smartFolderModel.getQuery());
|
||
|
// return smartFolderModel;
|
||
|
// }
|
||
|
|
||
|
// public List<SmartFolderModel> buildGXTListSmartFolderModel(List<WorkspaceFolder> listWorkspaceFolder) throws InternalErrorException {
|
||
|
//
|
||
|
// List<SmartFolderModel> listSmartFolder = new ArrayList<SmartFolderModel>();
|
||
|
//
|
||
|
// for(WorkspaceFolder workspaceFolder : listWorkspaceFolder)
|
||
|
// listSmartFolder.add(buildGXTSmartFolderModel(workspaceFolder, ""));
|
||
|
//
|
||
|
// return listSmartFolder;
|
||
|
// }
|
||
|
|
||
|
public List<SmartFolderModel> buildGXTListSmartFolderModel(List<WorkspaceSmartFolder> listWorkspaceSmartFolder) throws InternalErrorException {
|
||
|
List<SmartFolderModel> listSmartFolder = new ArrayList<SmartFolderModel>();
|
||
|
|
||
|
for(WorkspaceSmartFolder workspaceFolder : listWorkspaceSmartFolder)
|
||
|
listSmartFolder.add(buildGXTSmartFolderModel(workspaceFolder, ""));
|
||
|
|
||
|
return listSmartFolder;
|
||
|
}
|
||
|
|
||
|
|
||
|
public SmartFolderModel buildGXTSmartFolderModel(WorkspaceSmartFolder wsFolder, String query) throws InternalErrorException {
|
||
|
|
||
|
SmartFolderModel smartFolderModel = new SmartFolderModel(
|
||
|
wsFolder.getId(),
|
||
|
wsFolder.getName(),
|
||
|
query);
|
||
|
|
||
|
logger.trace("in return SmartFolder: " + smartFolderModel.getIdentifier() + " " + smartFolderModel.getName() + " " + smartFolderModel.getQuery());
|
||
|
return smartFolderModel;
|
||
|
}
|
||
|
|
||
|
public List<ScopeModel> buildGXTListScopeModel(List<String> listScopes) {
|
||
|
|
||
|
List<ScopeModel> listScopeModel = new ArrayList<ScopeModel>();
|
||
|
|
||
|
listScopeModel.add(AllScope.getScopeModel());
|
||
|
|
||
|
for(String scope: listScopes)
|
||
|
listScopeModel.add(new ScopeModel(scope, scope));
|
||
|
|
||
|
// listScopeModel.add(new ScopeModel("1", "Aquamaps"));
|
||
|
// listScopeModel.add(new ScopeModel("2", "VTI"));
|
||
|
// listScopeModel.add(new ScopeModel("3", "TimeSeries"));
|
||
|
|
||
|
return listScopeModel;
|
||
|
|
||
|
}
|
||
|
|
||
|
public List<InfoContactModel> buildGXTListContactsModel(List<User> listUsers) throws InternalErrorException {
|
||
|
|
||
|
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
|
||
|
|
||
|
for(User user: listUsers){
|
||
|
//TODO REMOVE COMMENT
|
||
|
// listContactsModel.add(new InfoContactModel(user.getId(), user.getPortalLogin()));
|
||
|
|
||
|
}
|
||
|
|
||
|
//THIS IS A TEST
|
||
|
listContactsModel.add(new InfoContactModel("1", "Federico.Test", "Federico de Faveri"));
|
||
|
listContactsModel.add(new InfoContactModel("2", "Antonio.Test", "Antonio Gioia"));
|
||
|
listContactsModel.add(new InfoContactModel("3", "Fabio.Test", "Fabio Sinibaldi"));
|
||
|
listContactsModel.add(new InfoContactModel("4", Util.TEST_USER, Util.TEST_USER));
|
||
|
|
||
|
return listContactsModel;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* @param listContactsModel
|
||
|
* @return list of portal logins
|
||
|
* @throws InternalErrorException
|
||
|
*/
|
||
|
public List<String> buildListLoginFromContanctModel(List<InfoContactModel> listContactsModel) throws InternalErrorException {
|
||
|
|
||
|
List<String> listPortalLogin = new ArrayList<String>();
|
||
|
|
||
|
for(InfoContactModel contact: listContactsModel){
|
||
|
listPortalLogin.add(contact.getLogin());
|
||
|
|
||
|
}
|
||
|
return listPortalLogin;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
public List<MessageModel> buildGXTListMessageModelForGrid(List<WorkspaceMessage> listMessages, String typeMessages) throws InternalErrorException {
|
||
|
|
||
|
List<MessageModel> listMessageModel = new ArrayList<MessageModel>();
|
||
|
|
||
|
|
||
|
for(WorkspaceMessage mess: listMessages){
|
||
|
List<WorkspaceItem> listAttachs = mess.getAttachments();
|
||
|
List<String> listAttachsNames = new ArrayList<String>();
|
||
|
|
||
|
logger.trace("IN SERVER MESSAGE TYPE: " +typeMessages);
|
||
|
logger.trace("subject " + mess.getSubject());
|
||
|
|
||
|
if(listAttachs!=null){
|
||
|
for(WorkspaceItem attach: listAttachs){
|
||
|
listAttachsNames.add(attach.getName());
|
||
|
logger.trace("Received attach: "+ attach.getName() + " " +attach.getId());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
listMessageModel.add(new MessageModel(mess.getId(), mess.getSubject(), buildGXTInfoContactModel(mess.getSender()), toDate(mess.getSendTime()), listAttachsNames, typeMessages, mess.isRead()));
|
||
|
|
||
|
}
|
||
|
// listMessageModel.add(new MessageModel("1", "subject", new InfoContactModel("1", "Federico"), "2001.07.04 at 12:08:56", 5));
|
||
|
// listMessageModel.add(new MessageModel("2", "subject 2", new InfoContactModel("1", "Federico"), "2005.07.04 at 12:08:56", 2));
|
||
|
// listMessageModel.add(new MessageModel("3", "subject 3", new InfoContactModel("3", "Francesco"), "2001.07.04 at 15:08:56", 3));
|
||
|
|
||
|
return listMessageModel;
|
||
|
}
|
||
|
|
||
|
public MessageModel buildGXTMessageModel(WorkspaceMessage mess, List<WorkspaceItem> listWorkspaceItems, String messageType) throws InternalErrorException {
|
||
|
|
||
|
|
||
|
List<FileModel> listAttachs = buildGXTListFileModelItemForAttachs(listWorkspaceItems);
|
||
|
|
||
|
// List<InfoContactModel> listContacts = new ArrayList<InfoContactModel>();
|
||
|
|
||
|
// mess.getAddresses();
|
||
|
// listContacts.add(new InfoContactModel("1", "Empty"));
|
||
|
|
||
|
return new MessageModel(mess.getId(), mess.getSubject(), buildGXTInfoContactModel(mess.getSender()), toDate(mess.getSendTime()), mess.getBody(), listAttachs, mess.getAddresses(), messageType, mess.isRead());
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
private InfoContactModel buildGXTInfoContactModel(User user) throws InternalErrorException{
|
||
|
|
||
|
return new InfoContactModel(user.getId(), user.getPortalLogin(), "name");
|
||
|
}
|
||
|
|
||
|
|
||
|
// private static float counter = 0;
|
||
|
|
||
|
public List<BulkCreatorModel> buildGXTListBulkCreatorModel(List<FolderBulkCreator> listFBC) throws InternalErrorException {
|
||
|
|
||
|
List<BulkCreatorModel> listBulkCreatorModel = new ArrayList<BulkCreatorModel>();
|
||
|
|
||
|
for (FolderBulkCreator item : listFBC){
|
||
|
|
||
|
BulkCreatorModel bulk;
|
||
|
|
||
|
if(item.getStatus()<1)
|
||
|
bulk = new BulkCreatorModel(item.getId(), item.getDestinationFolder().getName(), item.getStatus(), BulkCreatorModel.ONGOING, item.getNumberOfRequests(), item.getFailures());
|
||
|
else{//status = 1
|
||
|
|
||
|
int failures = item.getFailures();
|
||
|
|
||
|
if(failures==0)
|
||
|
bulk = new BulkCreatorModel(item.getId(), item.getDestinationFolder().getName(), item.getStatus(), BulkCreatorModel.COMPLETED, item.getNumberOfRequests(), item.getFailures());
|
||
|
else
|
||
|
if(failures<item.getNumberOfRequests())
|
||
|
bulk = new BulkCreatorModel(item.getId(), item.getDestinationFolder().getName(), item.getStatus(), BulkCreatorModel.FAILED, item.getNumberOfRequests(), item.getFailures());
|
||
|
else
|
||
|
bulk = new BulkCreatorModel(item.getId(), item.getDestinationFolder().getName(), item.getStatus(), BulkCreatorModel.FAILED, item.getNumberOfRequests(), item.getFailures());
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
listBulkCreatorModel.add(bulk);
|
||
|
}
|
||
|
|
||
|
// //TODO EXAMPLES
|
||
|
//
|
||
|
// if(counter < 0.4){
|
||
|
// listBulkCreatorModel.add(new BulkCreatorModel("1", "Test 1", counter, BulkCreatorModel.ONGOING, 5, 0));
|
||
|
// listBulkCreatorModel.add(new BulkCreatorModel("2", "Test 2", counter, BulkCreatorModel.ONGOING, 5, 0));
|
||
|
// listBulkCreatorModel.add(new BulkCreatorModel("3", "Test 3", counter, BulkCreatorModel.ONGOING, 5, 0));
|
||
|
// listBulkCreatorModel.add(new BulkCreatorModel("4", "Test 4", counter, BulkCreatorModel.ONGOING, 5, 0));
|
||
|
// listBulkCreatorModel.add(new BulkCreatorModel("5", "Test 5", counter, BulkCreatorModel.ONGOING, 5, 0));
|
||
|
// listBulkCreatorModel.add(new BulkCreatorModel("6", "Test 6", counter, BulkCreatorModel.ONGOING, 5, 0));
|
||
|
// }
|
||
|
//
|
||
|
// else{
|
||
|
//
|
||
|
//// float perc = (float) 0.8;
|
||
|
//
|
||
|
// listBulkCreatorModel.add(new BulkCreatorModel("1", "Test 1", (float) 1, BulkCreatorModel.FAILED, 5, 3));
|
||
|
// listBulkCreatorModel.add(new BulkCreatorModel("2", "Test 2", (float) 1, BulkCreatorModel.FAILED, 5, 4));
|
||
|
// listBulkCreatorModel.add(new BulkCreatorModel("3", "Test 3", counter, BulkCreatorModel.COMPLETED, 5, 0));
|
||
|
// listBulkCreatorModel.add(new BulkCreatorModel("4", "Test 4", counter, BulkCreatorModel.ONGOING, 5, 0));
|
||
|
// listBulkCreatorModel.add(new BulkCreatorModel("5", "Test 5", counter, BulkCreatorModel.ONGOING, 5, 0));
|
||
|
// listBulkCreatorModel.add(new BulkCreatorModel("6", "Test 6", counter, BulkCreatorModel.ONGOING, 5, 0));
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
// counter+=0.2;
|
||
|
//
|
||
|
// if(counter>1)
|
||
|
// counter=0;
|
||
|
|
||
|
return listBulkCreatorModel;
|
||
|
}
|
||
|
}
|