Search in sources :

Example 56 with Property

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();
}
Also used : Property(com.dexels.navajo.document.Property)

Example 57 with Property

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;
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Binary(com.dexels.navajo.document.types.Binary) Property(com.dexels.navajo.document.Property) URL(java.net.URL)

Example 58 with Property

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);
}
Also used : StringTokenizer(java.util.StringTokenizer) BirtUtils(com.dexels.navajo.birt.BirtUtils) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) File(java.io.File) Property(com.dexels.navajo.document.Property) FileInputStream(java.io.FileInputStream)

Example 59 with Property

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);
}
Also used : Configuration(org.osgi.service.cm.Configuration) Hashtable(java.util.Hashtable) Property(com.dexels.navajo.document.Property) Vector(java.util.Vector)

Example 60 with Property

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);
        }
    }
}
Also used : Message(com.dexels.navajo.document.Message) Property(com.dexels.navajo.document.Property)

Aggregations

Property (com.dexels.navajo.document.Property)253 Message (com.dexels.navajo.document.Message)148 Test (org.junit.Test)88 Navajo (com.dexels.navajo.document.Navajo)84 Selection (com.dexels.navajo.document.Selection)36 NavajoException (com.dexels.navajo.document.NavajoException)30 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)17 ArrayList (java.util.ArrayList)17 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)16 Binary (com.dexels.navajo.document.types.Binary)16 UserException (com.dexels.navajo.script.api.UserException)16 Access (com.dexels.navajo.script.api.Access)15 StringWriter (java.io.StringWriter)13 List (java.util.List)11 Operand (com.dexels.navajo.document.Operand)10 MappableException (com.dexels.navajo.script.api.MappableException)9 IOException (java.io.IOException)9 Writer (java.io.Writer)9 StringTokenizer (java.util.StringTokenizer)9 JSONTML (com.dexels.navajo.document.json.JSONTML)8