fix bugs in xml generator.

add report configuration.
Merge branch 'master' of https://github.com/justinliucs/haflow.git
Conflicts:
	src/main/webapp/script/haflow.main.js
	src/main/webapp/script/haflow.report_list.js
This commit is contained in:
zhaowei8188127 2013-12-06 13:32:32 +08:00
commit 2318e3cc77
11 changed files with 820 additions and 12895 deletions

View File

@ -1,12 +1,16 @@
package haflow.dto.entity;
import java.util.Set;
import java.util.UUID;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@ -19,6 +23,7 @@
private int position;
private Report report;
private Set<PortletConfiguration> configurations;
@Id
@Column(name="id", length = 16)
@ -67,4 +72,13 @@
this.report = report;
}
@OneToMany(mappedBy = "portlet", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
public Set<PortletConfiguration> getConfigurations() {
return configurations;
}
public void setConfigurations(Set<PortletConfiguration> configurations) {
this.configurations = configurations;
}
}

View File

@ -0,0 +1,54 @@
package haflow.dto.entity;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table( name = "portletconfiguration")
public class PortletConfiguration {
private UUID id;
private String key;
private String value;
private Portlet portlet;
@Id
@Column( name="id", length=16)
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
@Column( name="configurationKey")
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
@Column( name="configurationValue")
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@ManyToOne
@JoinColumn( name="portletid", referencedColumnName="id")
public Portlet getPortlet() {
return portlet;
}
public void setPortlet(Portlet portlet) {
this.portlet = portlet;
}
}

View File

@ -74,13 +74,15 @@ public class GraphTransformer {
nodeConfiguration.put(v.getPath().getSourceEndpoint(), v.getValue());//source end point
inputConfiguration.put(v.getPath().getTargetEndpoint(), v.getValue());//target end point
if( moduleType != ModuleType.SOURCE && moduleType != ModuleType.DEST ){
newGraphNodes.add(node);
if( targetModuleType != ModuleType.SOURCE && targetModuleType != ModuleType.DEST ){
newGraphEdges.add(v.getPath());
}
}
}
}
if( moduleType != ModuleType.SOURCE && moduleType != ModuleType.DEST ){
newGraphNodes.add(node);
}
}
return new DirectedGraph(newGraphNodes, newGraphEdges);

View File

@ -1,12 +1,14 @@
package haflow.ui.helper;
import haflow.dto.entity.Portlet;
import haflow.dto.entity.PortletConfiguration;
import haflow.dto.entity.Report;
import haflow.service.ReportService;
import haflow.ui.model.PortletConfigurationItemModel;
import haflow.ui.model.PortletModel;
import haflow.ui.model.ReportListModel;
import haflow.ui.model.SaveReportModel;
import haflow.ui.model.ReportResultModel;
import haflow.ui.model.SaveReportModel;
import java.util.ArrayList;
import java.util.HashSet;
@ -54,6 +56,15 @@ public class ReportHelper {
portletModel.setReportId(portlet.getReport().getId());
portletModel.setTitle(portlet.getTitle());
portletModel.setType(portlet.getType());
Set<PortletConfigurationItemModel> configurations = new HashSet<PortletConfigurationItemModel>();
for( PortletConfiguration pc : portlet.getConfigurations() ){
PortletConfigurationItemModel pcim = new PortletConfigurationItemModel();
pcim.setId(pc.getId());
pcim.setKey(pc.getKey());
pcim.setValue(pc.getValue());
configurations.add(pcim);
}
portletModel.setConfigurations(configurations);
portletModels.add(portletModel);
}
reportModel.setPortlets(portletModels);
@ -89,6 +100,16 @@ public class ReportHelper {
portlet.setTitle(portletModel.getTitle());
portlet.setType(portletModel.getType());
Set<PortletConfiguration> portletConfigurations = new HashSet<PortletConfiguration>();
for( PortletConfigurationItemModel cim : portletModel.getConfigurations()){
PortletConfiguration pc = new PortletConfiguration();
pc.setId(cim.getId());
pc.setKey(cim.getKey());
pc.setValue(cim.getValue());
pc.setPortlet(portlet);
portletConfigurations.add(pc);
}
portlet.setConfigurations(portletConfigurations);
portlets.add(portlet);
}
}

View File

@ -0,0 +1,41 @@
package haflow.ui.model;
import java.util.UUID;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "portletConfiguration")
public class PortletConfigurationItemModel {
private UUID id;
private String key;
private String value;
@XmlElement
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
@XmlElement
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
@XmlElement
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -1,8 +1,10 @@
package haflow.ui.model;
import java.util.Set;
import java.util.UUID;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="portlet")
@ -13,6 +15,7 @@ public class PortletModel {
private int position;
private UUID reportId;
private Set<PortletConfigurationItemModel> configurations;
@XmlElement
public UUID getId() {
@ -53,4 +56,13 @@ public class PortletModel {
public void setReportId(UUID reportId) {
this.reportId = reportId;
}
@XmlElementWrapper(name="configurations")
@XmlElement(name="configuration")
public Set<PortletConfigurationItemModel> getConfigurations() {
return configurations;
}
public void setConfigurations(Set<PortletConfigurationItemModel> configurations) {
this.configurations = configurations;
}
}

View File

@ -23,6 +23,7 @@
<mapping class="haflow.dto.entity.Report" />
<mapping class="haflow.dto.entity.Portlet" />
<mapping class="haflow.dto.entity.PortletConfiguration" />
<mapping class="haflow.dto.profile.NodeAppearance" />
<mapping class="haflow.dto.profile.NodeConfiguration" />

View File

@ -131,6 +131,7 @@ HAFlow.Main.prototype.initFlowContainer = function() {
_currentInstance.afterReportSelected();
var reportId = targetContainerPaneId.replace(reportContainerPaneString, "");
_currentInstance.currentReportId = reportId;
_currentInstance.setupReportDroppable(reportId);
// _currentInstance.paintReport(reportId);
}else if(targetContainerPaneId.substring(0, flowContainerPaneString.length)

View File

@ -2,12 +2,16 @@ dojo.require("dojox.widget.Portlet");
dojo.require("dojox.charting.Chart");
dojo.require("dojox.charting.plot2d.StackedAreas");
dojo.require("dojox.charting.themes.Wetland");
dojo.require("dojox/charting/themes/Claro");
dojo.require("dojox.charting.axis2d.Default");
dojo.require("dojox.charting.plot2d.Columns");
dojo.require("dojo.fx.easing");
dojo.require("dojox.fx.scroll");
dojo.require("dijit.registry");
dojo.require("dojo.window");
dojo.require("dojox.charting.plot2d.Pie");
dojo.require("dojox.charting.axis2d.Default");
dojo.require("dojox/charting/action2d/Tooltip");
HAFlow.Main.prototype.newReport = function(parentId) {
var newReportId = HAFlow.generateUUID();
@ -199,31 +203,36 @@ HAFlow.Main.prototype.paintReportList = function() {
HAFlow.Main.prototype.addReport = function(reportId, currentPortlet){
var reportContainer = dijit.byId("reportContainer_" + reportId);
var portlet = new dojox.widget.Portlet({
title : currentPortlet.type
title : currentPortlet.type,
id : "portlet_" + currentPortlet.id,
});
if (currentPortlet.type == "text") {
portlet.set("content", currentPortlet.text_content);
// portlet.set("content", currentPortlet.text_content);
portlet.startup();
reportContainer.addChild(portlet);//, currentPortlet.index
} else if (currentPortlet.type == "curve") {
var chartId = currentPortlet.id;
var chartDivId = "chart_" + chartId;
var chartDivId = "chart_" + chartId + "_div_id";
portlet.set("content", "<div id=\"" + chartDivId
+ "\" style=\"height:180px; width:480px;\"></div>");
portlet.startup();
reportContainer.addChild(portlet);//, currentPortlet.index
var c = new dojox.charting.Chart(chartDivId, {
var chart = new dojox.charting.Chart(chartDivId, {
// id : "chart_" + chartId,
title : currentPortlet.title,// "Production(Quantity)",
titlePos : "bottom",
titleGap : 25,
titleFont : "normal normal normal 15pt Arial",
titleFontColor : "orange"
});
var chart_series = [ 1, 2, 0.5, 1.5, 1, 2.8, 0.4 ];
c.addPlot("default", {
type : dojox.charting.plot2d.StackedAreas,
tension : 3
// var chart_series2 = [ 2, 4, 1, 3, 2, 5.6, 0.8 ];
chart.addPlot("default", {
type : dojox.charting.plot2d.StackedAreas,//dojox.charting.plot2d.PiePlot,//StackedAreas,
// tension : 3,
markers: true,
}).addAxis("x", {
fixLower : "major",
fixUpper : "major"
@ -234,11 +243,111 @@ HAFlow.Main.prototype.addReport = function(reportId, currentPortlet){
min : 0
}).setTheme(dojox.charting.themes.Wetland).addSeries("Series A",
chart_series).render();
chart.render();
// chart.title = "newTitle";
// chart.fullRender();
// chart.addSeries("Series B", chart_series2).render();
// chart.render();
} else {
alert("unknown report");
}
dojo.connect(portlet, "onClick", function(event){
var portletId = event.currentTarget.id;
portletId = portletId.replace("portlet_", "");
_currentInstance.onReportPortletClicked(portletId, chart);
});
};
HAFlow.Main.prototype.onReportPortletClicked = function(portletId, chart) {
var instance = this;
var reportInfo = instance.reports[this.currentReportId];
var text = "";
text += "<table border=\"0\">";
text += "<tr style=\"tr\"><th align=\"left\">Portlet Info</th>" + "<td>" + portletId + "</td></tr>";
var portlets = reportInfo.portlets;
var portlet;
for( var i = 0; i < portlets.length; i++ ){
if( portlets[i].id == portletId){
portlet = portlets[i];
break;
}
}
var configurations = portlet.configurations;
for( var i = 0; i < configurations.length; i++ ){
var configuration = configurations[i];
var configurationTextBoxSpanId = "portlet_configuration_" + configuration.id + "_text_box_pane";
text += "<tr style=\"tr\"><th align=\"left\">" + configuration.key + "</th>"
+ "<td><span id=" + configurationTextBoxSpanId + ">" + "</span></td></tr>";
}
text += "<tr style=\"tr\"><td align=\"left\">" +
"<div id=\"save_portlet_configurations_button_pane\" class=\"configuration-content\"></div>" +
"</td></tr>";
text += "</table>";
$("#" + instance.informationContainerId).html(text);
for( var i = 0; i < configurations.length; i++ ){
var configuration = configurations[i];
var configurationTextBoxId = "portlet_configuration_" + configuration.id + "_text_box";
var configurationTextBoxSpanId = "portlet_configuration_" + configuration.id + "_text_box_pane";
if (dijit.byId(configurationTextBoxId) != null) {
dijit.registry.remove(configurationTextBoxId);
}
var configurationTextBox = new dijit.form.TextBox({
id : configurationTextBoxId,
value : configuration.value,
style : "width:300px;"
});
configurationTextBox.placeAt(dojo.byId(configurationTextBoxSpanId));
configurationTextBox.startup();
}
var button = new dijit.form.Button({
label : "Save",
onClick : function() {
instance.savePortletConfiguration(portletId, chart);
}
});
button.placeAt(dojo.byId("save_portlet_configurations_button_pane"));
button.startup();
var informationPane = dijit.byId(instance.informationContainerId);
_currentInstance.ui.bottomContainer.selectChild(informationPane);
};
HAFlow.Main.prototype.savePortletConfiguration = function(portletId, chart){
this.addToConsole("something", false);
var reportInfo = this.reports[this.currentReportId];
var portlets = reportInfo.portlets;
var portlet;
for( var i = 0; i < portlets.length; i++ ){
if( portlets[i].id == portletId){
portlet = portlets[i];
break;
}
}
var configurations = portlet.configurations;
for( var i = 0; i < configurations.length; i++ ){
var configuration = configurations[i];
var configurationTextBoxId = "portlet_configuration_" + configuration.id + "_text_box";
var newValue = dijit.byId(configurationTextBoxId).value;
if( portlet.type == "text"){
var portletWidget = dijit.byId("portlet_" + portletId);
portletWidget.set(configuration.key, newValue);
}else{
//var chartDivId = "chart_" + portletId;
var chartWidget = chart;//dijit.byId(chartDivId);
// var chartWidget2 = dijit.byId(chartDivId);
var plot = chart.getPlot("default");
chartWidget.set(configuration.key, newValue);
chart.render();
}
// alert(newValue);
}
};
//private
HAFlow.Main.prototype.paintReport = function(reportId) {
var currentReport = this.reports[reportId];
@ -263,6 +372,7 @@ HAFlow.Main.prototype.onReportModuleAdded = function(currentInstance, reportId,
position: 1,
reportId: reportId,
configurations : [{id: HAFlow.generateUUID(), key:"content", value:"hello world!"}]
};
this.reports[reportId].portlets.push(currentPortlet);
this.addReport(reportId, currentPortlet);
@ -274,6 +384,8 @@ HAFlow.Main.prototype.onReportModuleAdded = function(currentInstance, reportId,
position: 1,
reportId: reportId,
configurations : [{id: HAFlow.generateUUID(), key: 'type', value : "Pie"},
{id: HAFlow.generateUUID(), key: 'markers', value: 'true'}]
};
this.reports[reportId].portlets.push(currentPortlet);
this.addReport(reportId, currentPortlet);

View File

@ -67,7 +67,13 @@ HAFlow.Main.prototype.fillReportsData = function(data) {
position: portlets[j].position,
reportId: portlets[j].reportId,
configurations:[]
};
var configurations = portlets[j].configurations;
for( var x = 0; x < configurations.length; x++){
var configuration = configurations[x];
currentPortlet.configurations.push(configuration);
}
this.reports[reportItemId].portlets.push(currentPortlet);
}
}

File diff suppressed because it is too large Load Diff