it seems this version is quite complete

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@90702 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-01-29 16:34:57 +00:00
parent 03ee613822
commit afd8018685
10 changed files with 140 additions and 81 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/reports-4.7.6-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/reports-4.7.9-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
@ -31,5 +31,5 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/reports-4.7.6-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/reports-4.7.9-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -2,6 +2,6 @@
<<<<<<<=.mine <<<<<<<=.mine
>>>>>>>=.r71295 >>>>>>>=.r71295
eclipse.preferences.version=1 eclipse.preferences.version=1
lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.7.6-SNAPSHOT lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.7.9-SNAPSHOT
warSrcDir=src/main/webapp warSrcDir=src/main/webapp
warSrcDirIsOutput=false warSrcDirIsOutput=false

View File

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>reports</artifactId> <artifactId>reports</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>4.7.6-SNAPSHOT</version> <version>4.7.9-SNAPSHOT</version>
<name>gCube Reports Manager</name> <name>gCube Reports Manager</name>
<description> <description>
gCube Reports Portlet. gCube Reports Portlet.

View File

@ -537,42 +537,6 @@ public class Presenter {
}); });
} }
/**
* Save the current report in a given folder
*
*/
public void exportReportToRSG() {
if (Window.confirm("Are you sure you want to commit the " + model.getTemplateName() + " into the VME Database?")) {
dlg.center();
dlg.show();
Model toSave = model.getSerializableModel();
reportService.exportReportToRSG(currentVmeType, toSave, new AsyncCallback<VmeExportResponse>() {
public void onFailure(Throwable caught) {
dlg.hide();
MessageBox.alert("Warning","Report Not Exported: " + caught.getMessage(), null);
}
public void onSuccess(VmeExportResponse response) {
dlg.hide();
//write ok
if (response.isGloballySucceded())
MessageBox.info("Exporting to RSG Operation","Report Exported Successfully", null);
//runtime exception
else if (response.getResponseMessageList().size() == 1 && response.getResponseMessageList().get(0).getResponseEntryCode().equals("RUNTIME_EXCEPTION")) {
MessageBox.alert("Exporting to RSG Operation Failed","Report Exporting has failed for the following reason: <br/> " + response.getResponseMessageList().get(0).getResponseMessage(), null);
}
//user report compile exception
else {
String failReasons = "";
for (VmeResponseEntry entry : response.getResponseMessageList()) {
failReasons += entry.getResponseMessage() + "<br/>";
}
MessageBox.alert("Exporting to RSG Operation Failed","Report Exporting has failed for the following reasons: <br/> " + failReasons, null);
}
}
});
}
}
/** /**
* Save the current report in a given folder * Save the current report in a given folder
* *
@ -1299,6 +1263,7 @@ public class Presenter {
public void onSuccess(Model toLoad) { public void onSuccess(Model toLoad) {
if (toLoad != null) { if (toLoad != null) {
loadModel(toLoad, type == VMETypeIdentifier.Vme); loadModel(toLoad, type == VMETypeIdentifier.Vme);
currentVmeType = type;
} }
else else
Window.alert("Could not Load Template Model, error on server."); Window.alert("Could not Load Template Model, error on server.");
@ -1306,7 +1271,41 @@ public class Presenter {
}); });
} }
/**
* Export To the Reports Store Gateway
*
*/
public void exportReportToRSG() {
if (Window.confirm("Are you sure you want to commit the " + model.getTemplateName() + " into the VME Database?")) {
dlg.center();
dlg.show();
Model toSave = model.getSerializableModel();
reportService.exportReportToRSG(currentVmeType, toSave, new AsyncCallback<VmeExportResponse>() {
public void onFailure(Throwable caught) {
dlg.hide();
MessageBox.alert("Warning","Report Not Exported: " + caught.getMessage(), null);
}
public void onSuccess(VmeExportResponse response) {
dlg.hide();
//write ok
if (response.isGloballySucceded())
MessageBox.info("Exporting to RSG Operation","Report Exported Successfully", null);
//runtime exception
else if (response.getResponseMessageList().size() == 1 && response.getResponseMessageList().get(0).getResponseEntryCode().equals("RUNTIME_EXCEPTION")) {
MessageBox.alert("Exporting to RSG Operation Failed","Report Exporting has failed for the following reason: <br/> " + response.getResponseMessageList().get(0).getResponseMessage(), null);
}
//user report compile exception
else {
String failReasons = "";
for (VmeResponseEntry entry : response.getResponseMessageList()) {
failReasons += entry.getResponseMessage() + "<br/>";
}
MessageBox.alert("Exporting to RSG Operation Failed","Report Exporting has failed for the following reasons: <br/> " + failReasons, null);
}
}
});
}
}
private void deleteVMEReport(String reportId, String name, final VMETypeIdentifier type) { private void deleteVMEReport(String reportId, String name, final VMETypeIdentifier type) {
if (Window.confirm("Are you sure you want to delete " + name + " from the VME Database? (This action is Undoable)")) { if (Window.confirm("Are you sure you want to delete " + name + " from the VME Database? (This action is Undoable)")) {

View File

@ -154,22 +154,30 @@ public class ClientRepeatableSequence extends Composite implements ClientSequenc
GWT.log("Reference found"); GWT.log("Reference found");
ClientReportReference refGroup = (ClientReportReference) co.getContent(); ClientReportReference refGroup = (ClientReportReference) co.getContent();
if (refGroup != null) { if (refGroup != null) {
boolean keepLooking = true;
for (Metadata prop : refGroup.getMetadata()) {
if ( prop.getAttribute().equals(SequenceWidget.RSG_BINDING_PROPERTY) && (extractIndexFromBindingContext(prop.getValue()) == -1) ) {
prop.setValue(replaceIndexFromBindingContext(prop.getValue(), maxBindingContext));
keepLooking = false;
break;
}
}
if (keepLooking) {
for (Metadata prop : refGroup.getMetadata()) { for (Metadata prop : refGroup.getMetadata()) {
GWT.log("-" + prop.getAttribute()+":"+prop.getValue()); GWT.log("-" + prop.getAttribute()+":"+prop.getValue());
//if there's a new component //if there's a new component
if ( prop.getAttribute().equals(SequenceWidget.RSG_BINDING_PROPERTY) && (extractIndexFromBindingContext(prop.getValue()) == -1) ) { if ( prop.getAttribute().equals(SequenceWidget.RSG_BINDING_CONTEXT_PROPERTY) && (extractIndexFromBindingContext(prop.getValue()) == -1) ) {
prop.setValue(replaceIndexFromBindingContext(prop.getValue(), maxBindingContext)); prop.setValue(replaceIndexFromBindingContext(prop.getValue(), maxBindingContext));
break; break;
} }
} }
}
//GWT.log("-" + prop.getAttribute()+":"+prop.getValue());
} }
} }
//for any other component //for any other component
for (Metadata prop : co.getAllMetadata()) { for (Metadata prop : co.getAllMetadata()) {
//if there's a new component //if there's a new component
if ( prop.getAttribute().equals(SequenceWidget.RSG_BINDING_PROPERTY) && (extractIndexFromBindingContext(prop.getValue()) == -1) ) { if ( prop.getAttribute().equals(SequenceWidget.RSG_BINDING_CONTEXT_PROPERTY) && (extractIndexFromBindingContext(prop.getValue()) == -1) ) {
prop.setValue(replaceIndexFromBindingContext(prop.getValue(), maxBindingContext)); prop.setValue(replaceIndexFromBindingContext(prop.getValue(), maxBindingContext));
break; break;
} }
@ -185,10 +193,12 @@ public class ClientRepeatableSequence extends Composite implements ClientSequenc
* @return the integer into square brackets * @return the integer into square brackets
*/ */
private int extractIndexFromBindingContext(String binding) { private int extractIndexFromBindingContext(String binding) {
if (binding.contains("[") && binding.contains("]")) {
int openSquareBracket = binding.lastIndexOf("[")+1; int openSquareBracket = binding.lastIndexOf("[")+1;
int closeSquareBracket = binding.lastIndexOf("]"); int closeSquareBracket = binding.lastIndexOf("]");
return Integer.parseInt(binding.substring(openSquareBracket, closeSquareBracket)); return Integer.parseInt(binding.substring(openSquareBracket, closeSquareBracket));
}
return 0;
} }
/** /**
* *
@ -197,11 +207,14 @@ public class ClientRepeatableSequence extends Composite implements ClientSequenc
* @return return the newIndex into square brackets * @return return the newIndex into square brackets
*/ */
private String replaceIndexFromBindingContext(String binding, int newIndex) { private String replaceIndexFromBindingContext(String binding, int newIndex) {
if (binding.contains("[") && binding.contains("]")) {
int openSquareBracket = binding.lastIndexOf("[")+1; int openSquareBracket = binding.lastIndexOf("[")+1;
int closeSquareBracket = binding.lastIndexOf("]"); int closeSquareBracket = binding.lastIndexOf("]");
String toReturn = binding.substring(0, openSquareBracket) + newIndex + binding.substring(closeSquareBracket); String toReturn = binding.substring(0, openSquareBracket) + newIndex + binding.substring(closeSquareBracket);
return toReturn; return toReturn;
} }
return binding;
}
/** /**
* @return specific cor RSG Case search for binding="geoRefList[3]" and return the max number into the square brackets * @return specific cor RSG Case search for binding="geoRefList[3]" and return the max number into the square brackets
*/ */
@ -209,7 +222,7 @@ public class ClientRepeatableSequence extends Composite implements ClientSequenc
int max = 0; int max = 0;
for (TemplateComponent co : groupedComponents) { for (TemplateComponent co : groupedComponents) {
for (Metadata prop : co.getAllMetadata()) { for (Metadata prop : co.getAllMetadata()) {
if (prop.getAttribute().equals(SequenceWidget.RSG_BINDING_PROPERTY)) { if (prop.getAttribute().equals(SequenceWidget.RSG_BINDING_CONTEXT_PROPERTY) || prop.getAttribute().equals(SequenceWidget.RSG_BINDING_PROPERTY)) {
int currValue = extractIndexFromBindingContext(prop.getValue()); int currValue = extractIndexFromBindingContext(prop.getValue());
if (currValue > max) if (currValue > max)
max = currValue; max = currValue;
@ -266,7 +279,8 @@ public class ClientRepeatableSequence extends Composite implements ClientSequenc
this.id = id; this.id = id;
} }
@Override
public void cleanInModel() {
//not needed
}
} }

View File

@ -126,7 +126,10 @@ public class ClientReportReference extends Composite implements ClientSequence,
public ArrayList<TemplateComponent> getGroupedComponents() { public ArrayList<TemplateComponent> getGroupedComponents() {
return groupedComponents; return groupedComponents;
} }
@Override
public void cleanInModel() {
this.id = "-1";
}
@Override @Override
public boolean add(String id, RepeatableSequence sequence, boolean isSingleRelation) { public boolean add(String id, RepeatableSequence sequence, boolean isSingleRelation) {
//(beacuse the ref is indented //(beacuse the ref is indented

View File

@ -16,4 +16,6 @@ public interface ClientSequence {
SequenceWidget remove(SequenceWidget toRemove); SequenceWidget remove(SequenceWidget toRemove);
void AddButtonClicked(RepeatableSequence sequence); void AddButtonClicked(RepeatableSequence sequence);
void cleanInModel();
} }

View File

@ -25,7 +25,8 @@ public class SequenceWidget extends Composite {
/** /**
* for the RSG case, whenever a new Sequence is added it sets the metadata named "bindingContext" to ...[-1] to identify it is new * for the RSG case, whenever a new Sequence is added it sets the metadata named "bindingContext" to ...[-1] to identify it is new
*/ */
protected static final String RSG_BINDING_PROPERTY = "bindingContext"; protected static final String RSG_BINDING_PROPERTY = "binding";
protected static final String RSG_BINDING_CONTEXT_PROPERTY = "bindingContext";
private static final int RSG_BINDING_PROPERTY_VALUE = -1; private static final int RSG_BINDING_PROPERTY_VALUE = -1;
private VerticalPanel myPanel; private VerticalPanel myPanel;
@ -77,6 +78,7 @@ public class SequenceWidget extends Composite {
TemplateComponent toAdd = new TemplateComponent(p.getModel(), sComp, p, false, null); TemplateComponent toAdd = new TemplateComponent(p.getModel(), sComp, p, false, null);
if (isNew && sComp.getType() == ComponentType.REPORT_REFERENCE ) { //when adding a new Sequence blanks the Ref if (isNew && sComp.getType() == ComponentType.REPORT_REFERENCE ) { //when adding a new Sequence blanks the Ref
GWT.log("Ref j=" + j);
ClientReportReference cRef = (ClientReportReference) toAdd.getContent(); ClientReportReference cRef = (ClientReportReference) toAdd.getContent();
//need to clone the Tuple otherwise when blanking the ref it blanks the source too //need to clone the Tuple otherwise when blanking the ref it blanks the source too
ArrayList<Tuple> clonedTuples = new ArrayList<Tuple>(); ArrayList<Tuple> clonedTuples = new ArrayList<Tuple>();
@ -146,21 +148,42 @@ public class SequenceWidget extends Composite {
toReturn.add(toAdd); toReturn.add(toAdd);
} }
boolean keepLooking = true;
for (Metadata prop : toReturn) { for (Metadata prop : toReturn) {
if (prop.getAttribute().equals(RSG_BINDING_PROPERTY)) { if (prop.getAttribute().equals(RSG_BINDING_PROPERTY) && (prop.getValue().contains("[") && prop.getValue().contains("]")) ) {
prop.setValue(replaceIndexFromBinding(prop.getValue(), RSG_BINDING_PROPERTY_VALUE));
keepLooking = false;
}
}
if (keepLooking) {
for (Metadata prop : toReturn) {
if (prop.getAttribute().equals(RSG_BINDING_CONTEXT_PROPERTY) && (prop.getValue().contains("[") && prop.getValue().contains("]")) ) {
prop.setValue(replaceIndexFromBindingContext(prop.getValue(), RSG_BINDING_PROPERTY_VALUE)); prop.setValue(replaceIndexFromBindingContext(prop.getValue(), RSG_BINDING_PROPERTY_VALUE));
} }
} }
}
return toReturn; return toReturn;
} }
private String replaceIndexFromBindingContext(String binding, int newIndex) { private String replaceIndexFromBindingContext(String binding, int newIndex) {
String toReturn = "";
GWT.log("got bindingContext = " + binding + " newIndex = " + newIndex);
int openSquareBracket = binding.lastIndexOf("[")+1; int openSquareBracket = binding.lastIndexOf("[")+1;
int closeSquareBracket = binding.lastIndexOf("]"); int closeSquareBracket = binding.lastIndexOf("]");
String toReturn = binding.substring(0, openSquareBracket) + newIndex + binding.substring(closeSquareBracket); toReturn = binding.substring(0, openSquareBracket) + newIndex + binding.substring(closeSquareBracket);
return toReturn; return toReturn;
} }
private String replaceIndexFromBinding(String binding, int newIndex) {
String toReturn = "";
GWT.log("got binding = " + binding + " newIndex = " + newIndex);
int openSquareBracket = binding.lastIndexOf("[")+1;
int closeSquareBracket = binding.lastIndexOf("]");
toReturn = binding.substring(0, openSquareBracket) + newIndex + binding.substring(closeSquareBracket);
return toReturn;
}
protected boolean hideClearAssociationButton() { protected boolean hideClearAssociationButton() {
return buttonsWrapperPanel.remove(clearB); return buttonsWrapperPanel.remove(clearB);
} }
@ -192,12 +215,13 @@ public class SequenceWidget extends Composite {
buttonsWrapperPanel.insert(clearB, 0); buttonsWrapperPanel.insert(clearB, 0);
} }
//TODO:
public void clearAssociation() { public void clearAssociation() {
GWT.log("Clearing Association"); GWT.log("Clearing Association");
//in the MODEL leave only the delimiters //in the MODEL leave only the delimiters
ArrayList<BasicComponent> cleanedRef = new ArrayList<BasicComponent>(); ArrayList<BasicComponent> cleanedRef = new ArrayList<BasicComponent>();
owner.cleanInModel();
for (BasicComponent bc : repSequence.getGroupedComponents()) { for (BasicComponent bc : repSequence.getGroupedComponents()) {
if (bc.getType() == ComponentType.REPEAT_SEQUENCE_DELIMITER) { if (bc.getType() == ComponentType.REPEAT_SEQUENCE_DELIMITER) {
cleanedRef.add(bc); cleanedRef.add(bc);

View File

@ -1619,7 +1619,15 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
//Use the RSG client to get a template for the report whose type is the last token (i.e. the corresponding class' 'simple name') //Use the RSG client to get a template for the report whose type is the last token (i.e. the corresponding class' 'simple name')
//appearing in the VME model class name as stored in the 'type' metadata //appearing in the VME model class name as stored in the 'type' metadata
CompiledReport template = rsgClient.getTemplate(new ReportType(refType.getId())); CompiledReport template = null;
if (refType == VMETypeIdentifier.Vme) {
_log.info("getTemplate for VME Report");
template = rsgClient.getTemplate(new ReportType(refType.getId()));
}
else {
_log.info("getTemplate for Ref Report");
template = rsgClient.getRefTemplate(new ReportType(refType.getId()));
}
CompiledReport toSend = null; CompiledReport toSend = null;
try { try {
toSend = new ReportManagerReportBuilder().extract(template, model); toSend = new ReportManagerReportBuilder().extract(template, model);

View File

@ -68,6 +68,15 @@
<url-pattern>/reports/UploadService</url-pattern> <url-pattern>/reports/UploadService</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet>
<servlet-name>localUploadServlet</servlet-name>
<servlet-class>org.gcube.portlets.user.workspace.server.LocalUploadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>localUploadServlet</servlet-name>
<url-pattern>/reports/LocalUploadService</url-pattern>
</servlet-mapping>
<servlet> <servlet>
<servlet-name>DownloadService</servlet-name> <servlet-name>DownloadService</servlet-name>
<servlet-class>org.gcube.portlets.user.workspace.server.DownloadServlet</servlet-class> <servlet-class>org.gcube.portlets.user.workspace.server.DownloadServlet</servlet-class>