Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
BZ-1104237 - When the KPI is exported, the associated data source sho…
…uld too
  • Loading branch information
dgutierr committed Dec 9, 2014
1 parent 0e5239c commit b6a1c34
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
Expand Up @@ -221,6 +221,7 @@ protected String inferDatabaseName() throws Exception {
}

public String inferDatabaseName(DataSource ds) throws Exception {
if (ds == null) return null;
Connection connection = null;
try {
connection = ds.getConnection();
Expand Down
Expand Up @@ -35,6 +35,7 @@
import org.jboss.dashboard.commons.message.Message;
import org.jboss.dashboard.commons.message.MessageList;
import org.apache.commons.lang.StringEscapeUtils;
import org.slf4j.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
Expand All @@ -43,6 +44,9 @@
@ApplicationScoped
public class ImportManagerImpl implements ImportManager {

@Inject
private transient Logger log;

@Inject
protected DataDisplayerManager dataDisplayerManager;

Expand Down Expand Up @@ -246,6 +250,7 @@ protected void parseKPIs(NodeList xmlNodes, ImportResults results) throws Except
}
results.addKPI(kpi);
} catch (Exception e) {
log.error("Error parsing KPI", e);
// Continue with the next KPI...
}
}
Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.jboss.dashboard.dataset.profiler.DataSetSortConstraints;
import org.jboss.dashboard.profiler.ProfilerHelper;
import org.jboss.dashboard.profiler.memory.SizeEstimations;
import org.jboss.dashboard.provider.DefaultDataProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.jboss.dashboard.DataProviderServices;
Expand Down Expand Up @@ -541,13 +542,30 @@ public void formatXMLProperties(PrintWriter out, int indent) throws Exception {
}

public void parseXMLProperties(NodeList nodes) throws Exception {
boolean update = getProperties().length > 0;
List<DataProperty> result = _parseXMLProperties(nodes, update);
if (!update) {
setPropertySize(result.size());
for (int i = 0; i < result.size(); i++) {
DataProperty p = result.get(i);
addProperty(p, i);
}
}
}

public List<DataProperty> _parseXMLProperties(NodeList nodes, boolean update) throws Exception {
List<DataProperty> result = new ArrayList<DataProperty>();
for (int x = 0; x < nodes.getLength(); x++) {
Node node = nodes.item(x);
if (node.getNodeName().equals("dataproperty")) {
String idDataProperty = StringEscapeUtils.unescapeXml(node.getAttributes().getNamedItem("id").getNodeValue());
DataProperty property = getPropertyById(idDataProperty);
if (property == null) continue; // Be aware of deleted properties.
if (property == null) {
if (update) continue; // Be aware of deleted properties.
else property = new DefaultDataProperty(idDataProperty);
}

result.add(property);
NodeList dataProperties = node.getChildNodes();
for (int y = 0; y < dataProperties.getLength(); y++) {
Node dataProperty = dataProperties.item(y);
Expand All @@ -564,6 +582,7 @@ public void parseXMLProperties(NodeList nodes) throws Exception {
}
}
}
return result;
}

protected void printIndent(PrintWriter out, int indent) {
Expand Down
Expand Up @@ -20,4 +20,9 @@ public class DefaultDataProperty extends AbstractDataProperty {
public DefaultDataProperty() {
super();
}

public DefaultDataProperty(String id) {
super();
super.setPropertyId(id);
}
}

0 comments on commit b6a1c34

Please sign in to comment.