Search in sources :

Example 1 with EscapeHtmlReference

use of org.apache.velocity.app.event.implement.EscapeHtmlReference in project webofneeds by researchstudio-sat.

the class WonOwnerMailSender method createContext.

private VelocityContext createContext(String toEmail, String localNeed, String remoteNeed, String localConnection, String textMsg) {
    String ownerAppLink = uriService.getOwnerProtocolOwnerURI().toString();
    VelocityContext velocityContext = new VelocityContext();
    EventCartridge ec = new EventCartridge();
    ec.addEventHandler(new EscapeHtmlReference());
    ec.attachToContext(velocityContext);
    if (remoteNeed != null) {
        Dataset needDataset = linkedDataSource.getDataForResource(URI.create(remoteNeed));
        DefaultNeedModelWrapper remoteNeedWrapper = new DefaultNeedModelWrapper(needDataset);
        String remoteNeedTitle = remoteNeedWrapper.getSomeTitleFromIsOrAll("en", "de");
        velocityContext.put("remoteNeedTitle", remoteNeedTitle);
        String linkRemoteNeed = uriService.getOwnerProtocolOwnerURI() + OWNER_REMOTE_NEED_LINK + remoteNeed;
        velocityContext.put("linkRemoteNeed", linkRemoteNeed);
    }
    if (localNeed != null) {
        Dataset localNeedDataset = linkedDataSource.getDataForResource(URI.create(localNeed));
        DefaultNeedModelWrapper localNeedWrapper = new DefaultNeedModelWrapper(localNeedDataset);
        String localNeedTitle = localNeedWrapper.getSomeTitleFromIsOrAll("en", "de");
        String linkLocalNeed = ownerAppLink + OWNER_LOCAL_NEED_LINK + localNeed;
        velocityContext.put("linkLocalNeed", linkLocalNeed);
        velocityContext.put("localNeedTitle", localNeedTitle);
    }
    if (localConnection != null) {
        String linkConnection = ownerAppLink + String.format(OWNER_CONNECTION_LINK, localNeed, localConnection, ConnectionState.CONNECTED.getURI().toString());
        velocityContext.put("linkConnection", linkConnection);
    }
    if (textMsg != null) {
        velocityContext.put("textMsg", textMsg);
    }
    return velocityContext;
}
Also used : DefaultNeedModelWrapper(won.protocol.util.DefaultNeedModelWrapper) EscapeHtmlReference(org.apache.velocity.app.event.implement.EscapeHtmlReference) VelocityContext(org.apache.velocity.VelocityContext) Dataset(org.apache.jena.query.Dataset) EventCartridge(org.apache.velocity.app.event.EventCartridge)

Aggregations

Dataset (org.apache.jena.query.Dataset)1 VelocityContext (org.apache.velocity.VelocityContext)1 EventCartridge (org.apache.velocity.app.event.EventCartridge)1 EscapeHtmlReference (org.apache.velocity.app.event.implement.EscapeHtmlReference)1 DefaultNeedModelWrapper (won.protocol.util.DefaultNeedModelWrapper)1