metadata setting RSG for writing complete 50 percent
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@90386 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
783499aa6a
commit
4830e2830f
|
@ -4,6 +4,9 @@
|
|||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||
<dependent-module archiveName="gcube-reporting-modeler-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-reporting-modeler/gcube-reporting-modeler">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||
<property name="context-root" value="reports"/>
|
||||
</wb-module>
|
||||
|
|
|
@ -365,8 +365,8 @@ public class TemplateComponent {
|
|||
case REPEAT_SEQUENCE:
|
||||
//Log.debug("FOUND SEQUENCE trying getGroup");
|
||||
RepeatableSequence repeatableSequence = (RepeatableSequence) sc.getPossibleContent();
|
||||
|
||||
ClientRepeatableSequence rps = new ClientRepeatableSequence(presenter, repeatableSequence);
|
||||
rps.setMetadata(sc.getMetadata());
|
||||
this.content = rps;
|
||||
break;
|
||||
case BODY_TABLE_IMAGE:
|
||||
|
@ -511,6 +511,7 @@ public class TemplateComponent {
|
|||
break;
|
||||
case REPEAT_SEQUENCE:
|
||||
ClientRepeatableSequence repSeq = (ClientRepeatableSequence) this.content;
|
||||
metas = repSeq.getMetadata();
|
||||
RepeatableSequence toStore = new RepeatableSequence(getSerializableSequence(repSeq), repSeq.getIdentifier(), height);
|
||||
content = toStore;
|
||||
break;
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package org.gcube.portlets.user.reportgenerator.client.targets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.d4sreporting.common.shared.BasicComponent;
|
||||
import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
|
||||
import org.gcube.portlets.d4sreporting.common.shared.Metadata;
|
||||
import org.gcube.portlets.d4sreporting.common.shared.RepeatableSequence;
|
||||
import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
|
||||
import org.gcube.portlets.user.reportgenerator.client.model.TemplateComponent;
|
||||
|
@ -14,6 +16,7 @@ import com.google.gwt.user.client.ui.VerticalPanel;
|
|||
public class ClientRepeatableSequence extends Composite implements ClientSequence {
|
||||
protected ArrayList<TemplateComponent> groupedComponents = new ArrayList<TemplateComponent>();
|
||||
|
||||
private List<Metadata> metas;
|
||||
private VerticalPanel myPanel = new VerticalPanel();
|
||||
private Presenter p;
|
||||
private String identifier;
|
||||
|
@ -122,11 +125,41 @@ public class ClientRepeatableSequence extends Composite implements ClientSequenc
|
|||
groupedComponents.remove(tc);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: change the -1 in the current max
|
||||
@Override
|
||||
public ArrayList<TemplateComponent> getGroupedComponents() {
|
||||
return groupedComponents;
|
||||
}
|
||||
/**
|
||||
* @return specific cor RSG Case search for binding="geoRefList[3]"
|
||||
*/
|
||||
private int getMaxIndex() {
|
||||
int max = 0;
|
||||
for (TemplateComponent co : groupedComponents) {
|
||||
for (Metadata prop : co.getAllMetadata()) {
|
||||
if (prop.getAttribute().equals(SequenceWidget.RSG_BINDING_PROPERTY)) {
|
||||
int currValue = extractIndexFromBindingContext(prop.getValue());
|
||||
if (currValue > max)
|
||||
max = currValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
private int extractIndexFromBindingContext(String binding) {
|
||||
int openSquareBracket = binding.lastIndexOf("[")+1;
|
||||
int closeSquareBracket = binding.lastIndexOf("]");
|
||||
return Integer.parseInt(binding.substring(openSquareBracket, closeSquareBracket));
|
||||
|
||||
}
|
||||
|
||||
private String replaceIndexFromBindingContext(String binding, int newIndex) {
|
||||
int openSquareBracket = binding.lastIndexOf("[")+1;
|
||||
int closeSquareBracket = binding.lastIndexOf("]");
|
||||
String toReturn = binding.substring(0, openSquareBracket) + newIndex + binding.substring(closeSquareBracket);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public void setGroupedComponents(ArrayList<TemplateComponent> groupedComponents) {
|
||||
this.groupedComponents = groupedComponents;
|
||||
|
@ -155,6 +188,14 @@ public class ClientRepeatableSequence extends Composite implements ClientSequenc
|
|||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public List<Metadata> getMetadata() {
|
||||
return metas;
|
||||
}
|
||||
|
||||
public void setMetadata(List<Metadata> metas) {
|
||||
this.metas = metas;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.reportgenerator.client.targets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.d4sreporting.common.shared.BasicComponent;
|
||||
import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
|
||||
|
@ -20,6 +21,11 @@ import com.google.gwt.user.client.ui.HorizontalPanel;
|
|||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
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
|
||||
*/
|
||||
protected static final String RSG_BINDING_PROPERTY = "bindingContext";
|
||||
private static final int RSG_BINDING_PROPERTY_VALUE = -1;
|
||||
|
||||
private VerticalPanel myPanel;
|
||||
|
||||
|
@ -33,7 +39,7 @@ public class SequenceWidget extends Composite {
|
|||
private ClientSequence owner;
|
||||
private RepeatableSequence repSequence;
|
||||
private ArrayList<TemplateComponent> seqGroupedComponents = new ArrayList<TemplateComponent>();
|
||||
|
||||
|
||||
//in case of references tells if the ref is empty
|
||||
private boolean isEmptyRef = false;
|
||||
|
||||
|
@ -64,7 +70,7 @@ public class SequenceWidget extends Composite {
|
|||
sComp.getType() == ComponentType.BODY_NOT_FORMATTED ||
|
||||
sComp.getType() == ComponentType.DYNA_IMAGE) ) {
|
||||
sComp.setPossibleContent("");
|
||||
sComp.setMetadata(new ArrayList<Metadata>());
|
||||
sComp.setMetadata(setPropertiesForRSG(sComp.getMetadata()));
|
||||
}
|
||||
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
|
||||
|
@ -72,8 +78,8 @@ public class SequenceWidget extends Composite {
|
|||
cRef.clear();
|
||||
}
|
||||
add(toAdd);
|
||||
|
||||
|
||||
|
||||
|
||||
} //end for
|
||||
initWidget(myPanel);
|
||||
|
||||
|
@ -107,15 +113,43 @@ public class SequenceWidget extends Composite {
|
|||
addAnother();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* this is specific for the RSG case
|
||||
*
|
||||
* whenever a new Sequence is added it sets the metadata named bindingContext to ...[-1] to identify it is new
|
||||
* @param properties the properties of the compoenent
|
||||
* @return the list of metadata with bindingContext set to -1
|
||||
*/
|
||||
private List<Metadata> setPropertiesForRSG(List<Metadata> properties) {
|
||||
List<Metadata> toReturn = new ArrayList<Metadata>();
|
||||
|
||||
for (Metadata metadata : properties) {
|
||||
Metadata toAdd = new Metadata(metadata.getAttribute(), metadata.getValue());
|
||||
toReturn.add(toAdd);
|
||||
}
|
||||
|
||||
for (Metadata prop : toReturn) {
|
||||
if (prop.getAttribute().equals(RSG_BINDING_PROPERTY)) {
|
||||
prop.setValue(replaceIndexFromBindingContext(prop.getValue(), RSG_BINDING_PROPERTY_VALUE));
|
||||
}
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private String replaceIndexFromBindingContext(String binding, int newIndex) {
|
||||
int openSquareBracket = binding.lastIndexOf("[")+1;
|
||||
int closeSquareBracket = binding.lastIndexOf("]");
|
||||
String toReturn = binding.substring(0, openSquareBracket) + newIndex + binding.substring(closeSquareBracket);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
protected boolean hideClearAssociationButton() {
|
||||
return buttonsWrapperPanel.remove(clearB);
|
||||
}
|
||||
|
||||
|
||||
protected boolean hideAddEntryButton() {
|
||||
return buttonsWrapperPanel.remove(addAnotherB);
|
||||
}
|
||||
|
@ -155,14 +189,14 @@ public class SequenceWidget extends Composite {
|
|||
}
|
||||
}
|
||||
repSequence.setGroupedComponents(cleanedRef);
|
||||
|
||||
|
||||
//in the VIEW
|
||||
for (TemplateComponent tc : seqGroupedComponents) {
|
||||
if (tc.getType() == ComponentType.BODY_NOT_FORMATTED || tc.getType() == ComponentType.HEADING_2) {
|
||||
myPanel.remove(tc.getContent());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
buttonsWrapperPanel.clear();
|
||||
selectNewB.getElement().getStyle().setWidth(130, Unit.PX);
|
||||
selectNewB.getElement().getStyle().setMargin(10, Unit.PX);
|
||||
|
@ -182,7 +216,7 @@ public class SequenceWidget extends Composite {
|
|||
protected boolean isAnEmptyRef() {
|
||||
return isEmptyRef;
|
||||
}
|
||||
|
||||
|
||||
public void add(TemplateComponent toAdd) {
|
||||
if (toAdd.getType() != ComponentType.REPEAT_SEQUENCE_INNER) {
|
||||
owner.getGroupedComponents().add(toAdd);
|
||||
|
@ -208,7 +242,7 @@ public class SequenceWidget extends Composite {
|
|||
public RepeatableSequence getSequence() {
|
||||
return repSequence;
|
||||
}
|
||||
|
||||
|
||||
public void alignButtonsLeft() {
|
||||
buttonPanel.setWidth("10%");
|
||||
}
|
||||
|
|
|
@ -33,6 +33,10 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.gcube.application.framework.accesslogger.library.impl.AccessLogger;
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
import org.gcube.application.reporting.ReportsModeler;
|
||||
import org.gcube.application.reporting.component.interfaces.ReportComponent;
|
||||
import org.gcube.application.reporting.reader.ModelReader;
|
||||
import org.gcube.application.reporting.reader.Section;
|
||||
import org.gcube.application.rsg.client.RsgClient;
|
||||
import org.gcube.application.rsg.service.RsgService;
|
||||
import org.gcube.application.rsg.service.dto.ReportEntry;
|
||||
|
@ -91,6 +95,7 @@ import org.gcube.portlets.widgets.exporter.shared.SaveReportFileExistException;
|
|||
import org.gcube.portlets.widgets.exporter.shared.TypeExporter;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.junit.After;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -807,6 +812,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
saveReport(toSave, folderid, itemName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param save a report in another folder .
|
||||
|
@ -815,6 +821,10 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
public void saveReport(Model toSave, String folderid, String newname) {
|
||||
|
||||
Model model = toSave;
|
||||
|
||||
ModelReader reader = new ModelReader(model);
|
||||
System.out.println(reader);
|
||||
|
||||
storeTemplateInSession(toSave);
|
||||
_log.info("Serializing Model in folder: " + folderid );
|
||||
_log.info("Trying to convert dynamic images ... ");
|
||||
|
@ -1548,6 +1558,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
|
|||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ModelReader reader = new ModelReader(model);
|
||||
System.out.println(reader);
|
||||
return model;
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue