update open item event

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@69469 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2013-02-20 13:28:25 +00:00
parent a3cc98082b
commit 8d51f05602
11 changed files with 14 additions and 322 deletions

View File

@ -11,6 +11,7 @@
<!-- Moduel GXT --> <!-- Moduel GXT -->
<inherits name='com.extjs.gxt.ui.GXT'/> <inherits name='com.extjs.gxt.ui.GXT'/>
<servlet path="/WorkspaceService" class="org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl" /> <servlet path="/WorkspaceService" class="org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl" />
<!-- <!--
<servlet path="/ImageService" class="org.gcube.portlets.user.workspace.server.ImageServlet" /> <servlet path="/ImageService" class="org.gcube.portlets.user.workspace.server.ImageServlet" />

View File

@ -1191,13 +1191,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
public void doClickOpenReport(OpenReportsEvent openReportsEvent) { public void doClickOpenReport(OpenReportsEvent openReportsEvent) {
// System.out.println("IDREPORT " + ConstantsExplorer.IDREPORT); rpcWorkspaceService.getURLFromApplicationProfile(openReportsEvent.getSourceFileModel().getIdentifier(), new AsyncCallback<String>() {
// System.out.println("id " +openReportsEvent.getSourceFileModel().getIdentifier());
// System.out.println("name " +openReportsEvent.getSourceFileModel().getName());
rpcWorkspaceService.getURLFromApplicationProfile(ConstantsExplorer.IDREPORT, openReportsEvent.getSourceFileModel().getIdentifier(), new AsyncCallback<String>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -1219,27 +1213,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
}); });
// rpcWorkspaceService.setValueInSession(ConstantsExplorer.IDREPORT, openReportsEvent.getSourceFileModel().getIdentifier(), new AsyncCallback<Void>() {
//
// @Override
// public void onFailure(Throwable caught) {
// new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " setting session attribute idreport", null);
//
// }
//
// @Override
// public void onSuccess(Void result) {
// String currentUrl = portalURL();
// int last = currentUrl.lastIndexOf("/");
// String reportUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.REPORTGENERATION;
//// Log.trace("Url: "+reportUrl);
// System.out.println("currentUrl " +currentUrl);
// System.out.println("reportUrl " +reportUrl);
// new WindowOpenUrl(reportUrl, "_self", "");
//
// }
//
// });
} }
private void doClickOpenReportTemplate(OpenReportsEvent openReportTemplateEvent) { private void doClickOpenReportTemplate(OpenReportsEvent openReportTemplateEvent) {
@ -1248,7 +1221,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
// System.out.println("id " +openReportTemplateEvent.getSourceFileModel().getIdentifier()); // System.out.println("id " +openReportTemplateEvent.getSourceFileModel().getIdentifier());
// System.out.println("name " +openReportTemplateEvent.getSourceFileModel().getName()); // System.out.println("name " +openReportTemplateEvent.getSourceFileModel().getName());
rpcWorkspaceService.getURLFromApplicationProfile(ConstantsExplorer.IDTEMPLATE, openReportTemplateEvent.getSourceFileModel().getIdentifier(), new AsyncCallback<String>() { rpcWorkspaceService.getURLFromApplicationProfile(openReportTemplateEvent.getSourceFileModel().getIdentifier(), new AsyncCallback<String>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -1269,29 +1242,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
}); });
// rpcWorkspaceService.setValueInSession(ConstantsExplorer.IDTEMPLATE, openReportTemplateEvent.getSourceFileModel().getIdentifier(), new AsyncCallback<Void>() {
//
// @Override
// public void onFailure(Throwable caught) {
//// Log.error("Error setting session attribute idtemplate",caught);
// new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" setting session attribute idtemplate", null);
//
// }
//
// @Override
// public void onSuccess(Void result) {
// String currentUrl = portalURL();
// int last = currentUrl.lastIndexOf("/");
// String templateUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.TEMPLATECREATION;
//// Log.trace("Url: "+templateUrl);
// System.out.println("currentUrl " +currentUrl);
// System.out.println("reportUrl " +templateUrl);
// new WindowOpenUrl(templateUrl, "_self", "");
//
// }
//
// });
} }
}); });

View File

@ -112,7 +112,7 @@ public interface GWTWorkspaceService extends RemoteService{
public List<FileModel> getListParentsByItemIdentifier(String itemIdentifier) throws Exception; public List<FileModel> getListParentsByItemIdentifier(String itemIdentifier) throws Exception;
public String getURLFromApplicationProfile(String name, String value) throws Exception; public String getURLFromApplicationProfile(String oid) throws Exception;
// public ArrayList<List<FileModel>> getChildrenListsByParentsIdentifier(String itemIdentifier) throws Exception; // public ArrayList<List<FileModel>> getChildrenListsByParentsIdentifier(String itemIdentifier) throws Exception;

View File

@ -117,8 +117,7 @@ public interface GWTWorkspaceServiceAsync {
void getListParentsByItemIdentifier(String itemIdentifier, void getListParentsByItemIdentifier(String itemIdentifier,
AsyncCallback<List<FileModel>> callback); AsyncCallback<List<FileModel>> callback);
void getURLFromApplicationProfile(String name, String value, void getURLFromApplicationProfile(String oid, AsyncCallback<String> callback);
AsyncCallback<String> callback);
// void getListParentsByItemIdentifier(String itemIdentifier,AsyncCallback<ArrayList<String>> callback); // void getListParentsByItemIdentifier(String itemIdentifier,AsyncCallback<ArrayList<String>> callback);

View File

@ -232,13 +232,12 @@ public class MultiValuePanel extends Composite {
itemBox.setText(fullName); itemBox.setText(fullName);
itemBox.setValue(fullName); itemBox.setValue(fullName);
final ListItem displayItem = new ListItem(); final ListItem displayItem = new ListItem();
displayItem.setStyleName("multivalue-panel-token-ws");
Paragraph p = new Paragraph(fullName); Paragraph p = new Paragraph(fullName);
displayItem.add(p); displayItem.add(p);
if(displayRemoveItem){ if(displayRemoveItem){
displayItem.setStyleName("multivalue-panel-token-ws-notselectable"); displayItem.setStyleName("multivalue-panel-token-ws");
Span span = new Span("x"); Span span = new Span("x");
span.addClickHandler(new ClickHandler() { span.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) { public void onClick(ClickEvent clickEvent) {
@ -249,7 +248,7 @@ public class MultiValuePanel extends Composite {
displayItem.add(span); displayItem.add(span);
} }
else else
displayItem.setStyleName("multivalue-panel-token-ws"); displayItem.setStyleName("multivalue-panel-token-ws-notselectable");
GWT.log("Adding selected wp item '" + itemBox.getValue()); GWT.log("Adding selected wp item '" + itemBox.getValue());
itemsSelected.add(itemBox.getValue()); itemsSelected.add(itemBox.getValue());

View File

@ -55,7 +55,7 @@ li.multivalue-panel-token-ws-notselectable {
padding: 1px 3px; padding: 1px 3px;
background-color: white; background-color: white;
border: 1px solid #9DACCC; border: 1px solid #9DACCC;
color: white; color: #1C2A47;
cursor: default; cursor: default;
font-size: 11px; font-size: 11px;
border-radius: 5px; border-radius: 5px;

View File

@ -19,7 +19,6 @@ 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.WorkspaceFolder;
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; 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.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.WorkspaceSmartFolder;
import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderBulkCreator; 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.FolderItem;
@ -79,7 +78,6 @@ import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTM
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTPDFDocument; 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.client.workspace.folder.item.gcube.GWTUrlDocument;
import org.gcube.portlets.user.workspace.server.util.AllScope; 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 * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it

View File

@ -1,14 +1,11 @@
package org.gcube.portlets.user.workspace.server; package org.gcube.portlets.user.workspace.server;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.applicationsupportlayer.social.SocialPortalBridge;
import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBEClientLog; import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.common.core.utils.logging.GCUBELog; import org.gcube.common.core.utils.logging.GCUBELog;
@ -28,6 +25,7 @@ import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalU
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ts.TimeSeries; import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ts.TimeSeries;
import org.gcube.portlets.user.homelibrary.home.workspace.search.SearchItem; 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.homelibrary.home.workspace.sharing.WorkspaceMessage;
import org.gcube.portlets.user.opengcubeapplication.ApplicationReaderFromGenericResource;
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface; import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface;
import org.gcube.portlets.user.workspace.client.model.BulkCreatorModel; 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.FileDetailsModel;
@ -751,37 +749,15 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
} }
@Override @Override
public String getURLFromApplicationProfile(String property, String value) throws Exception { public String getURLFromApplicationProfile(String oid) throws Exception {
String urlPortlet = ""; String urlPortlet = "";
String appId = "";
ApplicationReaderFromGenericResource app = new ApplicationReaderFromGenericResource();
try{ try{
ASLSession session = Util.getAslSession(this.getThreadLocalRequest().getSession());
Properties prop = new Properties(); urlPortlet = app.getURLFromApplicationProfile(oid, Util.getAslSession(this.getThreadLocalRequest().getSession()));
InputStream in = (InputStream) GWTWorkspaceServiceImpl.class.getResourceAsStream("portletClassName.properties");
// load a properties file
prop.load(in);
// get the property value - the application Id
appId = prop.getProperty(property);
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
logger.trace("get URL From property file return AppId: "+appId);
//print it out
System.out.println("get URL From property file return AppId: "+appId);
//set property in ASL session
setValueInSession(property,value);
SocialPortalBridge spb = new SocialPortalBridge(session,appId);
urlPortlet = spb.getApplicationProfile().getUrl();
} catch (Exception e) { } catch (Exception e) {

View File

@ -1,28 +0,0 @@
# Property files
#
# author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
# created 02/2013
#
# Property = key value
#
# property - is the type of Folder Item set in HL
# value - (see property (2))
#
REPORT_TEMPLATE = idtemplate
REPORT = idreport
# Property = gCube App URL
#
# property (2) - is the key that must be set in ASL Session with value OID (OID is the "object id" of the object that must be open)
# value - is the AppId the must be read from Application Profile to retrieve the url application (gCube Apps) that must open the object wih OID
# Ex. idtemplate = "12345" - "12345" is the value (OID set in ASL session at run-time) , that must be read from Report Application to
# open directly the object
#
idtemplate=org.gcube.portlets.user.templates.server.TemplateServiceImpl
idreport=org.gcube.portlets.user.reportgenerator.server.servlet.ReportServiceImpl

View File

@ -1,126 +0,0 @@
package org.gcube.portlets.user.workspace.server.util;
import java.util.List;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.applicationsupportlayer.social.ex.ApplicationProfileNotFoundException;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.XMLResult;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.portlets.user.workspace.shared.ApplicationProfile;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
public class GcubeApplicationProfileReader {
protected static final String RESOURCE_PROFILE_BODY_ENDPOINT_URL_TEXT = "/Resource/Profile/Body/EndPoint/URL/text()";
protected static final String RESOURCE_PROFILE_BODY_ENDPOINT_SCOPE_TEXT = "/Resource/Profile/Body/EndPoint/Scope/text()";
protected static final String RESOURCE_PROFILE_BODY_THUMBNAIL_URL_TEXT = "/Resource/Profile/Body/ThumbnailURL/text()";
protected static final String RESOURCE_PROFILE_BODY_APP_ID_TEXT = "/Resource/Profile/Body/AppId/text()";
protected static final String RESOURCE_PROFILE_DESCRIPTION_TEXT = "/Resource/Profile/Description/text()";
protected static final String RESOURCE_PROFILE_NAME_TEXT = "/Resource/Profile/Name/text()";
private ASLSession aslSession;
private ApplicationProfile applicationProfile;
private GCUBEClientLog logger = new GCUBEClientLog(GcubeApplicationProfileReader.class);
public ApplicationProfile getApplicationProfile() {
return applicationProfile;
}
/**
*
* @param session
*/
public GcubeApplicationProfileReader(ASLSession session, String portletClassName) {
this.aslSession = session;
this.applicationProfile = readProfileFromInfrastrucure(portletClassName);
}
public GcubeApplicationProfileReader(ASLSession session) {
this.aslSession = session;
this.applicationProfile = null;
}
/**
* this method looks up the applicationProfile profile among the ones available in the infrastructure
* @param portletClassName your servlet class name will be used ad unique identifier for your applicationProfile
* @return the applicationProfile profile
*/
private ApplicationProfile readProfileFromInfrastrucure(String portletClassName) {
try {
ApplicationProfile toReturn = new ApplicationProfile();
ISClient client = GHNContext.getImplementation(ISClient.class);
GCUBEGenericQuery query = client.getQuery(GCUBEGenericQuery.class);
query.setExpression("for $profile in collection('/db/Profiles/GenericResource')//Resource " +
"where $profile/Profile/SecondaryType/string() eq 'ApplicationProfile' and $profile/Profile/Body/AppId/string() " +
" eq '" + portletClassName + "'" +
"return $profile");
GCUBEScope scope = aslSession.getScope();
List<XMLResult> appProfile = client.execute(query, scope.getInfrastructure());
if (appProfile == null || appProfile.size() == 0)
throw new ApplicationProfileNotFoundException("Your applicationProfile is not registered in the infrastructure");
else {
XMLResult node = appProfile.get(0);
List<String> currValue = null;
currValue = node.evaluate(RESOURCE_PROFILE_NAME_TEXT);
if (currValue != null && currValue.size() > 0) {
toReturn.setName(currValue.get(0));
}
else throw new ApplicationProfileNotFoundException("Your applicationProfile NAME was not found in the profile");
currValue = node.evaluate(RESOURCE_PROFILE_DESCRIPTION_TEXT);
if (currValue != null && currValue.size() > 0) {
toReturn.setDescription(currValue.get(0));
}
else logger.warn("No Description exists for " + toReturn.getName());
currValue = node.evaluate(RESOURCE_PROFILE_BODY_APP_ID_TEXT);
if (currValue != null && currValue.size() > 0) {
toReturn.setKey(currValue.get(0));
}
else throw new ApplicationProfileNotFoundException("Your applicationProfile ID n was not found in the profile, consider adding <AppId> element in <Body>");
currValue = node.evaluate(RESOURCE_PROFILE_BODY_THUMBNAIL_URL_TEXT);
if (currValue != null && currValue.size() > 0) {
toReturn.setImageUrl(currValue.get(0));
}
else throw new ApplicationProfileNotFoundException("Your applicationProfile Image Url was not found in the profile, consider adding <ThumbnailURL> element in <Body>");
currValue = node.evaluate(RESOURCE_PROFILE_BODY_ENDPOINT_SCOPE_TEXT);
if (currValue != null && currValue.size() > 0) {
List<String> scopes = currValue;
boolean foundUrl = false;
for (int i = 0; i < scopes.size(); i++) {
if (currValue.get(i).trim().compareTo(scope.toString()) == 0) {
toReturn.setUrl(node.evaluate(RESOURCE_PROFILE_BODY_ENDPOINT_URL_TEXT).get(i));
toReturn.setScope(scope.toString());
foundUrl = true;
break;
}
}
if (! foundUrl)
throw new ApplicationProfileNotFoundException("Your applicationProfile URL was not found in the profile for Scope: " + scope.toString());
}
else throw new ApplicationProfileNotFoundException("Your applicationProfile EndPoint was not found in the profile, consider adding <EndPoint><Scope> element in <Body>");
return toReturn;
}
} catch (Exception e) {
logger.error("Error while trying to fetch applicationProfile profile from the infrastructure");
e.printStackTrace();
return null;
}
}
}

View File

@ -1,77 +0,0 @@
package org.gcube.portlets.user.workspace.shared;
import java.io.Serializable;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
@SuppressWarnings("serial")
public class ApplicationProfile implements Serializable {
private String key;
private String name;
private String description;
private String imageUrl;
private String scope;
private String url;
public ApplicationProfile() {
super();
}
public ApplicationProfile(String key, String name, String description, String imageUrl, String scope, String url) {
super();
this.key = key;
this.name = name;
this.description = description;
this.imageUrl = imageUrl;
this.scope = scope;
this.url = url;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override
public String toString() {
return "ApplicationProfile [key=" + key + ", name=" + name + ", description="
+ description + ", imageUrl=" + imageUrl + ", scope=" + scope
+ ", url=" + url + "]";
}
}