Search in sources :

Example 51 with Binary

use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.

the class KMLMap method getKmlData.

/**
 * TODO: Make thread safe
 * @return
 */
public Binary getKmlData() {
    try {
        if (!isPointFile()) {
            File kmz = createKmlFile(inMessage);
            myKmzData = new Binary(kmz, false);
            kmz.delete();
            FormatDescription fd = new FormatDescription();
            fd.addFileExtension("kmz");
            fd.addMimeType("application/vnd.google-earth.kmz");
            myKmzData.setMimeType("application/vnd.google-earth.kmz");
            myKmzData.setFormatDescriptor(fd);
            return myKmzData;
        } else {
            File kml = createPointKmlFile(inMessage, messagePath);
            myKmzData = new Binary(kml, false);
            kml.delete();
            FormatDescription fd = new FormatDescription();
            fd.addFileExtension("kml");
            fd.addMimeType("application/vnd.google-earth.kml");
            myKmzData.setMimeType("application/vnd.google-earth.kml");
            myKmzData.setFormatDescriptor(fd);
            return myKmzData;
        }
    } catch (XMLParseException e) {
        logger.error("Error: ", e);
    } catch (IOException e) {
        logger.error("Error: ", e);
    }
    return null;
}
Also used : Binary(com.dexels.navajo.document.types.Binary) IOException(java.io.IOException) FormatDescription(com.dexels.navajo.document.metadata.FormatDescription) XMLParseException(com.dexels.navajo.document.nanoimpl.XMLParseException) File(java.io.File)

Example 52 with Binary

use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.

the class BirtUtils method createEmptyReport.

public Binary createEmptyReport(Navajo n, Binary template) throws IOException {
    InputStream templateStream = null;
    if (template == null) {
        templateStream = getClass().getResourceAsStream("blank.rptdesign");
    } else {
        templateStream = template.getDataAsStream();
    }
    File reportFile = File.createTempFile("temp", ".rptdesign");
    createEmptyReport(n, reportFile, templateStream);
    Binary result = new Binary(reportFile, false);
    Files.delete(reportFile.toPath());
    return result;
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Binary(com.dexels.navajo.document.types.Binary) File(java.io.File)

Example 53 with Binary

use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.

the class BirtUtils method main.

public static void main(String[] args) throws Exception {
    System.out.println("***IS IT A BIRT?***");
    // Change the path to the file to match your filesystem
    FileInputStream fis = new java.io.FileInputStream("C:/Users/Robin/Documents/Test.xml");
    Navajo navajo = NavajoFactory.getInstance().createNavajo(fis);
    Binary template = null;
    BirtUtils report = new BirtUtils();
    Binary result = report.createEmptyReport(navajo, template);
    BinaryOpener bo = BinaryOpenerFactory.getInstance();
    bo.open(result);
}
Also used : Navajo(com.dexels.navajo.document.Navajo) Binary(com.dexels.navajo.document.types.Binary) FileInputStream(java.io.FileInputStream) BinaryOpener(com.dexels.navajo.document.BinaryOpener)

Example 54 with Binary

use of com.dexels.navajo.document.types.Binary 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 55 with Binary

use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.

the class ElasticSearchAdapter method setPropertyValue.

private void setPropertyValue(ObjectNode an, Property property, ObjectMapper objectMapper) {
    if (Property.DATE_PROPERTY.equals(property.getType())) {
        Date d = (Date) property.getTypedValue();
        an.put(property.getName(), df.format(d));
    } else if (Property.INTEGER_PROPERTY.equals(property.getType())) {
        Integer d = (Integer) property.getTypedValue();
        an.put(property.getName(), d);
    } else if (Property.BOOLEAN_PROPERTY.equals(property.getType())) {
        Boolean d = (Boolean) property.getTypedValue();
        an.put(property.getName(), d);
    } else if (Property.BINARY_PROPERTY.equals(property.getType())) {
        Binary b = (Binary) property.getTypedValue();
        an.put(property.getName(), b.getData());
    } else {
        an.put(property.getName(), property.getValue());
    }
}
Also used : Binary(com.dexels.navajo.document.types.Binary) Date(java.util.Date)

Aggregations

Binary (com.dexels.navajo.document.types.Binary)139 Test (org.junit.Test)38 IOException (java.io.IOException)32 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)26 File (java.io.File)25 Ignore (org.junit.Ignore)17 Property (com.dexels.navajo.document.Property)16 URL (java.net.URL)16 UserException (com.dexels.navajo.script.api.UserException)14 OutputStream (java.io.OutputStream)13 FileOutputStream (java.io.FileOutputStream)12 Navajo (com.dexels.navajo.document.Navajo)11 MappableException (com.dexels.navajo.script.api.MappableException)11 FileInputStream (java.io.FileInputStream)9 InputStream (java.io.InputStream)9 Message (com.dexels.navajo.document.Message)8 StringWriter (java.io.StringWriter)8 OutputStreamWriter (java.io.OutputStreamWriter)7 NavajoException (com.dexels.navajo.document.NavajoException)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6