2521: Explore the possibility to port the StatMan interface onto Dataminer
https://support.d4science.org/issues/2521 Added Data Miner Test git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@126841 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9e85d968db
commit
0c668ecc1a
|
@ -34,6 +34,7 @@ import com.sencha.gxt.widget.core.client.container.HorizontalLayoutContainer.Hor
|
|||
import com.sencha.gxt.widget.core.client.container.MarginData;
|
||||
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.container.Viewport;
|
||||
|
||||
/**
|
||||
|
@ -298,7 +299,7 @@ public class DataMinerManager implements EntryPoint {
|
|||
|
||||
}
|
||||
});
|
||||
lc.add(itemExperiment);
|
||||
lc.add(itemExperiment,new VerticalLayoutData(300, 300, new Margins(0)));
|
||||
/*
|
||||
* LayoutContainer itemJobs = createMenuItem( "Check the Computations",
|
||||
* "This section allows to check the status of the computation. A list of processes launched by the user is shown along with meta-information. By clicking on the completed jobs it is possible to visualize the data set contents."
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.user.dataminermanager.shared;
|
|||
|
||||
public class Constants {
|
||||
public static final boolean DEBUG_MODE = false;
|
||||
public static final boolean TEST_ENABLE = false;
|
||||
|
||||
public static final String APPLICATION_ID = "org.gcube.portlets.user.dataminermanager.portlet.DataMinerManager";
|
||||
public static final String DATA_MINER_MANAGER_ID = "DataMinerManagerId";
|
||||
|
@ -43,4 +44,6 @@ public class Constants {
|
|||
public static final String WPSUser = "gianpaolo.coro";
|
||||
public static final String SESSION_TOKEN = "SESSION_TOKEN";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -47,19 +47,19 @@
|
|||
<entry-point
|
||||
class='org.gcube.portlets.user.dataminermanager.client.DataMinerManager' />
|
||||
|
||||
<!--
|
||||
|
||||
<set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
|
||||
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
|
||||
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
|
||||
/> -->
|
||||
/>
|
||||
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
|
||||
/> -->
|
||||
|
||||
|
||||
<!--
|
||||
<set-property name="log_ConsoleLogger" value="DISABLED" />
|
||||
<set-property name="log_DivLogger" value="DISABLED" />
|
||||
<set-property name="log_GWTLogger" value="DISABLED" />
|
||||
<set-property name="log_SystemLogger" value="DISABLED" />
|
||||
<set-property name="log_SystemLogger" value="DISABLED" /> -->
|
||||
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="DISABLED"
|
||||
/> -->
|
||||
|
||||
|
|
|
@ -4,11 +4,12 @@
|
|||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="ExtGWT/css/gxt-all.css">
|
||||
<link type="text/css" rel="stylesheet" href="gxt/css/gxt-all.css">
|
||||
<link type="text/css" rel="stylesheet" href="DataMinerManager.css">
|
||||
|
||||
<title>Data Miner Manager</title>
|
||||
|
||||
<script type="text/javascript" language="javascript"
|
||||
src="dataminermanager/js/jquery-1.10.1.min.js"></script>
|
||||
<script type="text/javascript" language="javascript"
|
||||
src="dataminermanager/dataminermanager.nocache.js"></script>
|
||||
</head>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<!-- between html and your Web Toolkit module -->
|
||||
<link rel="stylesheet" href="<%= request.getContextPath()%>/dataminermanager/reset.css" type="text/css"/>
|
||||
<link rel="stylesheet" href="<%= request.getContextPath()%>/DataMinerManager.css" type="text/css">
|
||||
<link rel="stylesheet" href="<%= request.getContextPath()%>/ExtGWT/css/gxt-all.css" type="text/css">
|
||||
<link rel="stylesheet" href="<%= request.getContextPath()%>/gxt/css/gxt-all.css" type="text/css">
|
||||
<script src='<%=request.getContextPath()%>/dataminermanager/js/jquery-1.10.1.min.js'></script>
|
||||
<script src='<%=request.getContextPath()%>/dataminermanager/dataminermanager.nocache.js'></script>
|
||||
|
||||
|
|
|
@ -1,134 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.dataminermanager;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.Util;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||
|
||||
|
||||
/**
|
||||
* @author Federico De Faveri defaveri@isti.cnr.it Modified by Francesco
|
||||
* Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
*/
|
||||
public class ItemBuilder {
|
||||
|
||||
public static Item purgeEmptyFolders(Item item) {
|
||||
for (Item child : item.getChildren())
|
||||
purgeEmptyFolders(child);
|
||||
|
||||
List<Item> toRemoveList = new LinkedList<Item>();
|
||||
for (Item child : item.getChildren()) {
|
||||
boolean toRemove = isAnEmptyFolder(child);
|
||||
if (toRemove)
|
||||
toRemoveList.add(child);
|
||||
}
|
||||
for (Item child : toRemoveList)
|
||||
item.removeChild(child);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
protected static boolean isAnEmptyFolder(Item item) {
|
||||
return Util.isFolder(item.getType()) && item.getChildren().size() == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parent
|
||||
* @param workspaceItem
|
||||
* @param showableTypes
|
||||
* @param depth
|
||||
* @return
|
||||
* @throws InternalErrorException
|
||||
*/
|
||||
public static Item getItem(Item parent, WorkspaceItem workspaceItem,
|
||||
List<ItemType> showableTypes, FilterCriteria filterCriteria,
|
||||
int depth) throws InternalErrorException {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static ItemType getItemType(WorkspaceItem item)
|
||||
throws InternalErrorException {
|
||||
switch (item.getType()) {
|
||||
case SHARED_FOLDER:
|
||||
case FOLDER:
|
||||
return ItemType.FOLDER;
|
||||
case FOLDER_ITEM:
|
||||
return getFolderItemType((FolderItem) item);
|
||||
case SMART_FOLDER:
|
||||
break;
|
||||
case TRASH_FOLDER:
|
||||
break;
|
||||
case TRASH_ITEM:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static ItemType getFolderItemType(FolderItem item) {
|
||||
// System.out.println("getFolderItemType "+item.getFolderItemType().toString());
|
||||
return ItemType.valueOf(item.getFolderItemType().toString());
|
||||
}
|
||||
|
||||
protected static boolean filterItem(ItemType type, WorkspaceItem item,
|
||||
FilterCriteria filterCriteria) throws InternalErrorException {
|
||||
boolean mimeTypeCheck = checkAllowedMimeTypes(type, item,
|
||||
filterCriteria.getAllowedMimeTypes());
|
||||
if (!mimeTypeCheck)
|
||||
return false;
|
||||
|
||||
boolean propertiesCheck = checkProperties(item,
|
||||
filterCriteria.getRequiredProperties());
|
||||
return propertiesCheck;
|
||||
}
|
||||
|
||||
protected static boolean checkAllowedMimeTypes(ItemType type,
|
||||
WorkspaceItem item, List<String> allowedMimeTypes) {
|
||||
if (allowedMimeTypes.size() == 0)
|
||||
return true;
|
||||
|
||||
if (type == ItemType.EXTERNAL_FILE || type == ItemType.EXTERNAL_IMAGE
|
||||
|| type == ItemType.EXTERNAL_PDF_FILE) {
|
||||
ExternalFile externalFile = (ExternalFile) item;
|
||||
String mimeType = externalFile.getMimeType();
|
||||
return allowedMimeTypes.contains(mimeType);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected static boolean checkProperties(WorkspaceItem item,
|
||||
Map<String, String> requestedProperties)
|
||||
throws InternalErrorException {
|
||||
if (requestedProperties.size() == 0
|
||||
|| item.getType() != WorkspaceItemType.FOLDER_ITEM)
|
||||
return true;
|
||||
|
||||
Map<String, String> itemProperties = item.getProperties()
|
||||
.getProperties();
|
||||
for (Entry<String, String> requestProperty : requestedProperties
|
||||
.entrySet()) {
|
||||
String propertyValue = itemProperties.get(requestProperty.getKey());
|
||||
if (propertyValue == null)
|
||||
return false;
|
||||
if (!propertyValue.equals(requestProperty.getValue()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.dataminermanager;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.Util;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
|
||||
|
||||
/**
|
||||
* A comparator that sorts the items first by type, folder up others down, the each group alphabetically on the item name.
|
||||
* @author "Federico De Faveri defaveri@isti.cnr.it"
|
||||
*/
|
||||
public class ItemComparator implements Comparator<Item> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int compare(Item item1, Item item2) {
|
||||
|
||||
//if one of the item is folder and the other one not, we move up the folder
|
||||
boolean isItem1Folder = Util.isFolder(item1.getType());
|
||||
boolean isItem2Folder = Util.isFolder(item2.getType());
|
||||
|
||||
if (isItem1Folder ^ isItem2Folder) return isItem1Folder?0:1;
|
||||
|
||||
//otherwise we compare the names
|
||||
return String.CASE_INSENSITIVE_ORDER.compare(item1.getName(), item2.getName());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.dataminermanager;
|
||||
|
||||
import org.gcube.application.framework.core.cache.CachesManager;
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
|
||||
/**
|
||||
* @author "Federico De Faveri defaveri@isti.cnr.it"
|
||||
*
|
||||
*/
|
||||
public class TestASLSession {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
CachesManager.getInstance();
|
||||
ASLSession session = SessionManager.getInstance().getASLSession("1", "federico.defaveri");
|
||||
session.setScope("/gcube/devsec");
|
||||
System.out.println(session.getUsername());
|
||||
}
|
||||
|
||||
}
|
|
@ -16,7 +16,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
@ -77,6 +76,15 @@ public class TestDataMinerService extends TestCase {
|
|||
}
|
||||
|
||||
public void testExecuteProcess() {
|
||||
if(Constants.TEST_ENABLE){
|
||||
executeProcess();
|
||||
} else {
|
||||
assertTrue(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void executeProcess(){
|
||||
|
||||
try {
|
||||
|
||||
|
|
|
@ -1,149 +0,0 @@
|
|||
package org.gcube.portlets.user.dataminermanager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.w3c.dom.CharacterData;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author ceras
|
||||
*
|
||||
*/
|
||||
public class TestIsResources {
|
||||
|
||||
//private static final String GR_SECONDARY_TYPE = "Manager";
|
||||
//private static final String GR_NAME = "Operators";
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
// public static void main(String[] args) {
|
||||
// try {
|
||||
// GCUBEScope scope = GCUBEScope.getScope("/gcube");
|
||||
//
|
||||
// ISClient client = GHNContext.getImplementation(ISClient.class);
|
||||
//
|
||||
// GCUBEGenericResourceQuery rtrQuery = client.getQuery(GCUBEGenericResourceQuery.class);
|
||||
// rtrQuery.addAtomicConditions(new AtomicCondition("/Profile/SecondaryType", GR_SECONDARY_TYPE));
|
||||
// rtrQuery.addAtomicConditions(new AtomicCondition("/Profile/Name", GR_NAME));
|
||||
//
|
||||
// List<GCUBEGenericResource> rtrs = client.execute(rtrQuery, scope);
|
||||
// if (rtrs.size()==0) throw new Exception("Generic resource not found");
|
||||
//
|
||||
// GCUBEGenericResource resource = rtrs.get(0);
|
||||
// String xml = resource.getBody();
|
||||
//
|
||||
// System.out.println("xml = "+xml);
|
||||
//
|
||||
// List<String> operators = new ArrayList<String>();
|
||||
// operators.add("pinco");
|
||||
// operators.add("pallino");
|
||||
// operators.add("ciccio");
|
||||
// operators.add("ceras");
|
||||
// operators.add("gianpaolo");
|
||||
// operators.add("coro");
|
||||
//
|
||||
// //////////////
|
||||
// System.out.println("Operators found:");
|
||||
// for (String op: operators)
|
||||
// System.out.println(op);
|
||||
// System.out.println();
|
||||
// //////////////
|
||||
//
|
||||
//
|
||||
// List<String> prevoiusOperators = getOperatorsFromXml(xml);
|
||||
//
|
||||
// //////////////
|
||||
// System.out.println("Operators in generic resource:");
|
||||
// for (String op: prevoiusOperators)
|
||||
// System.out.println(op);
|
||||
// System.out.println();
|
||||
// //////////////
|
||||
//
|
||||
// List<String> newOperators = new ArrayList<String>();
|
||||
//
|
||||
// StringBuilder newXml = new StringBuilder();
|
||||
// newXml.append("<operators>");
|
||||
// for (String op: operators) {
|
||||
// newXml.append("<operator>"+op+"</operator>");
|
||||
// if (!prevoiusOperators.contains(op))
|
||||
// newOperators.add(op);
|
||||
// }
|
||||
// newXml.append("</operators>");
|
||||
//
|
||||
// //////////////
|
||||
// System.out.println(newXml.toString());
|
||||
// System.out.println();
|
||||
//
|
||||
// if (newOperators.size()==0)
|
||||
// System.out.println("No news");
|
||||
// else {
|
||||
// System.out.println("News:");
|
||||
// for (String op: newOperators)
|
||||
// System.out.println(op);
|
||||
// }
|
||||
// //////////////
|
||||
//
|
||||
// resource.setBody(newXml.toString());
|
||||
// ISPublisher publisher = GHNContext.getImplementation(ISPublisher.class);
|
||||
// publisher.updateGCUBEResource(resource, scope, null);
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* @param xml
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws SAXException
|
||||
* @throws ParserConfigurationException
|
||||
*/
|
||||
private static List<String> getOperatorsFromXml(String xml) throws SAXException, IOException, ParserConfigurationException {
|
||||
List<String> operators = new ArrayList<String>();
|
||||
|
||||
DocumentBuilderFactory dbf =
|
||||
DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
InputSource is = new InputSource();
|
||||
is.setCharacterStream(new StringReader(xml));
|
||||
|
||||
Document doc = db.parse(is);
|
||||
NodeList nodes = doc.getElementsByTagName("operator");
|
||||
|
||||
// iterate the employees
|
||||
for (int i = 0; i < nodes.getLength(); i++) {
|
||||
Element operator = (Element) nodes.item(i);
|
||||
String operatorId = getCharacterDataFromElement(operator);
|
||||
operators.add(operatorId);
|
||||
}
|
||||
|
||||
return operators;
|
||||
}
|
||||
|
||||
public static String getCharacterDataFromElement(Element e) {
|
||||
Node child = e.getFirstChild();
|
||||
if (child instanceof CharacterData) {
|
||||
CharacterData cd = (CharacterData) child;
|
||||
return cd.getData();
|
||||
}
|
||||
return "?";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
package org.gcube.portlets.user.dataminermanager;
|
||||
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
public class testws {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
ScopeProvider.instance.set("/gcube/devsec/devVRE");
|
||||
//
|
||||
Workspace workspace = HomeLibrary.getUserWorkspace("fabio.fiorellato");
|
||||
|
||||
|
||||
WorkspaceItem root = workspace.getRoot();
|
||||
// System.out.println("before sort");
|
||||
// List<String> allowedMimeTypes = new ArrayList<String>();
|
||||
// Map<String, String> requiredProperties = new HashMap<String, String>();
|
||||
// FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes, requiredProperties);
|
||||
// List<ItemType> showableTypesParam = new ArrayList<ItemType>();
|
||||
//
|
||||
// showableTypesParam.add(ItemType.ROOT);
|
||||
// showableTypesParam.add(ItemType.FOLDER);
|
||||
// showableTypesParam.add(ItemType.EXTERNAL_IMAGE);
|
||||
// showableTypesParam.add(ItemType.EXTERNAL_FILE);
|
||||
// showableTypesParam.add(ItemType.EXTERNAL_PDF_FILE);
|
||||
// showableTypesParam.add(ItemType.EXTERNAL_URL);
|
||||
// showableTypesParam.add(ItemType.QUERY);
|
||||
// showableTypesParam.add(ItemType.REPORT_TEMPLATE);
|
||||
// showableTypesParam.add(ItemType.REPORT);
|
||||
// showableTypesParam.add(ItemType.DOCUMENT);
|
||||
// showableTypesParam.add(ItemType.METADATA);
|
||||
// showableTypesParam.add(ItemType.PDF_DOCUMENT);
|
||||
// showableTypesParam.add(ItemType.IMAGE_DOCUMENT);
|
||||
// showableTypesParam.add(ItemType.URL_DOCUMENT);
|
||||
// showableTypesParam.add(ItemType.TIME_SERIES);
|
||||
// showableTypesParam.add(ItemType.AQUAMAPS_ITEM);
|
||||
// showableTypesParam.add(ItemType.WORKFLOW_REPORT);
|
||||
// showableTypesParam.add(ItemType.WORKFLOW_TEMPLATE);
|
||||
// showableTypesParam.add(ItemType.EXTERNAL_RESOURCE_LINK);
|
||||
// showableTypesParam.add(ItemType.UNKNOWN_TYPE);
|
||||
// Item rootItem = ItemBuilder.getItem(null, root, showableTypesParam, filterCriteria, 2);
|
||||
//
|
||||
// System.out.println("############ rootItem null");
|
||||
//
|
||||
// boolean purgeEmpyFolders=false;
|
||||
//
|
||||
// if (purgeEmpyFolders) rootItem = ItemBuilder.purgeEmptyFolders(rootItem);
|
||||
//
|
||||
// System.out.println("Returning:");
|
||||
//
|
||||
//
|
||||
// Collections.sort(rootItem.getChildren(), new ItemComparator());
|
||||
//// Collections.sort(root.getChildren(), new ItemComparator());
|
||||
//
|
||||
// System.out.println("after sort");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.print("end");
|
||||
} catch (WorkspaceFolderNotFoundException | InternalErrorException
|
||||
| HomeNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue