use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class BirtUtils method createArrayMessageQueryText.
private String createArrayMessageQueryText(List<Property> props, String serviceName, Message arrayMessage) {
boolean isArray = arrayMessage.getType().equals(Message.MSG_TYPE_ARRAY);
String fixed = serviceName.replaceAll("/", "_");
StringBuilder sb = new StringBuilder();
sb.append("table0#-TNAME-#table0#");
sb.append(":");
if (isArray) {
sb.append("#[/" + fixed + "/tml/" + getLaszloMessagePath(arrayMessage) + "/row]#");
} else {
sb.append("#[/" + fixed + "/tml/" + getLaszloMessagePath(arrayMessage) + "]#");
}
sb.append(":");
sb.append("#");
// for each prop:
for (int i = 0; i < props.size(); i++) {
Property current = props.get(i);
if (isArray) {
sb.append("{" + current.getName() + ";" + getPropertyType(current, true) + ";/@" + current.getName() + "}");
} else {
sb.append("{" + current.getName() + ";" + getPropertyType(current, true) + ";/p_" + current.getName() + "/@value}");
}
if (i < props.size() - 1) {
sb.append(",");
}
}
return sb.toString();
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class BIRTXmlMap method processReport.
private Binary processReport(File fixedFile, Navajo n) throws IOException {
Property outputFormatProperty = n.getProperty("/__ReportDefinition/OutputFormat");
if (outputFormatProperty != null) {
outputFormat = outputFormatProperty.getValue();
}
if (outputFormat == null || "".equals(outputFormat)) {
outputFormat = DEFAULT_OUTPUT_FORMAT;
}
Binary result;
StringBuilder urlBuffer = new StringBuilder();
urlBuffer.append(getViewerUrl());
urlBuffer.append("/run?__report=" + fixedFile.getName());
for (Iterator<String> iter = parameters.keySet().iterator(); iter.hasNext(); ) {
String element = iter.next();
String value = (String) parameters.get(element);
urlBuffer.append("&" + element + "=" + value);
}
urlBuffer.append("&__format=" + outputFormat);
logger.debug("Result = {}", urlBuffer);
URL u = new URL(urlBuffer.toString());
InputStream is = u.openStream();
result = new Binary(is);
return result;
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class BIRTXmlMap method executeReport.
private Binary executeReport(Navajo input) throws IOException {
int top = 15;
int right = 15;
int bottom = 15;
int left = 15;
BirtUtils b = new BirtUtils();
File rep = File.createTempFile("generic", ".rptdesign", new File(getViewerReportDir()));
Property marginProperty = inNavajo.getProperty("/__ReportDefinition/Margin");
String margin = null;
if (marginProperty != null) {
margin = marginProperty.getValue();
}
if (margin != null) {
logger.debug("Margin: {}", margin);
StringTokenizer st = new StringTokenizer(margin, ",");
top = Integer.parseInt(st.nextToken());
right = Integer.parseInt(st.nextToken());
bottom = Integer.parseInt(st.nextToken());
left = Integer.parseInt(st.nextToken());
}
Property landscapeProperty = inNavajo.getProperty("/__ReportDefinition/Orientation");
boolean landscape = extractLandscape(landscapeProperty);
File templateDir = new File(getReportDir() + "template/");
if (!templateDir.exists()) {
templateDir.mkdirs();
}
File reportTemplateFile = new File(templateDir, "template.rptdesign");
InputStream reportTemplateStream = new FileInputStream(reportTemplateFile);
b.createTableReport(reportTemplateStream, rep, input, left, top, right, bottom, landscape);
return processReport(rep, input);
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class NavajoContextInstanceFactory method addDatasource.
private void addDatasource(String instance, Message dataSource, Map<String, Set<String>> aliases) throws IOException {
String name = dataSource.getName();
List<Property> props = dataSource.getAllProperties();
Dictionary<String, Object> settings = new Hashtable<String, Object>();
for (Property property : props) {
// skip type, it is not a 'real' connection setter
if (property.getName().equals("type") || property.getName().equals("alias")) {
continue;
}
// Conversion
if (property.getName().equals("username")) {
settings.put("user", property.getTypedValue());
} else {
settings.put(property.getName(), property.getTypedValue());
}
}
Set<String> aliaseSet = aliases.get(name);
if (aliaseSet != null) {
for (String alias : aliaseSet) {
settings.put(alias, "alias");
}
Vector<String> aliasVector = new Vector<String>(aliaseSet);
aliasVector.add(name);
settings.put("aliases", aliasVector);
}
settings.put("name", name);
if (instance != null) {
settings.put("instance", instance);
settings.put(instance, "instance");
}
settings.put("deployment", repositoryInstance.getDeployment());
Property typeProperty = dataSource.getProperty("type");
if (typeProperty == null) {
throw new NullPointerException("No type property missing for instance: " + instance + " and name: " + name);
}
// String type = (String) typeProperty.getTypedValue();
String[] types = ((String) typeProperty.getTypedValue()).split(",");
if (configAdmin == null) {
logger.warn("No configuration admin, assuming testing");
return;
}
String uniqueId = getUniqueId(settings);
if (uniqueId != null) {
settings.put("navajo.uniqueid", uniqueId);
}
for (String type : types) {
final String filter = createFilter(instance, name, settings, type, uniqueId);
Configuration cc = createOrReuse("navajo.resource." + type, filter);
appendIfChanged(cc, settings);
logger.debug("Data source settings for source: {} : {}", name, settings);
}
// addResourceGroup(name, instance, type, settings);
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class NavajoContextInstanceFactory method appendResources.
private void appendResources(Map<String, Set<String>> aliases, Map<String, Message> result, Message resources, Message aliasMessage, Message aliasConditionalMessage) {
if (aliasMessage != null) {
List<Property> aliasProps = aliasMessage.getAllProperties();
for (Property property : aliasProps) {
String aliasValue = (String) property.getTypedValue();
String name = property.getName();
Set<String> found = aliases.get(aliasValue);
if (found == null) {
found = new HashSet<String>();
aliases.put(aliasValue, found);
}
found.add(name);
}
}
if (aliasConditionalMessage != null) {
appendConditionalAlias(aliasConditionalMessage, aliases);
}
if (resources != null) {
List<Message> sources = resources.getAllMessages();
for (Message rsrc : sources) {
result.put(rsrc.getName(), rsrc);
}
}
}
Aggregations