use of won.protocol.util.DefaultAtomModelWrapper in project webofneeds by researchstudio-sat.
the class WonOwnerMailSender method sendCloseNotificationMessage.
public void sendCloseNotificationMessage(String toEmail, String localAtom, String targetAtom, String localConnection, String localSocket, String targetSocket, String textMsg) {
StringWriter writer = new StringWriter();
VelocityContext context = createContext(toEmail, localAtom, targetAtom, localConnection, localSocket, targetSocket, textMsg);
closeNotificationTemplate.merge(context, writer);
Dataset atomDataset = linkedDataSource.getDataForPublicResource(URI.create(localAtom));
DefaultAtomModelWrapper wrapper = new DefaultAtomModelWrapper(atomDataset);
String subject = SUBJECT_CLOSE;
if (isChatSocket(wrapper, localSocket)) {
subject = SUBJECT_CLOSE_CHAT;
}
logger.debug("sending {} to {}", subject, toEmail);
this.wonMailSender.sendTextMessage(toEmail, subject, writer.toString());
}
use of won.protocol.util.DefaultAtomModelWrapper in project webofneeds by researchstudio-sat.
the class WonOwnerMailSender method createContext.
private VelocityContext createContext(String toEmail, String localAtom, String targetAtom, String localConnection, String localSocket, String targetSocket, String textMsg) {
String ownerAppLink = uriService.getOwnerProtocolOwnerURI().toString();
VelocityContext velocityContext = new VelocityContext();
if (targetAtom != null) {
Dataset atomDataset = linkedDataSource.getDataForPublicResource(URI.create(targetAtom));
DefaultAtomModelWrapper targetAtomWrapper = new DefaultAtomModelWrapper(atomDataset);
velocityContext.put("targetAtomTitle", getLabelForAtomInMail(targetAtomWrapper));
velocityContext.put("targetAtomIsPersona", isPersonaAtom(targetAtomWrapper));
velocityContext.put("targetSocketIsGroupSocket", isGroupChatSocket(targetAtomWrapper, targetSocket));
velocityContext.put("targetSocketIsChatSocket", isChatSocket(targetAtomWrapper, targetSocket));
String linkTargetAtom = uriService.getOwnerProtocolOwnerURI() + OWNER_TARGET_ATOM_LINK + targetAtom;
velocityContext.put("linkTargetAtom", linkTargetAtom);
}
if (localAtom != null) {
Dataset localAtomDataset = linkedDataSource.getDataForPublicResource(URI.create(localAtom));
DefaultAtomModelWrapper localAtomWrapper = new DefaultAtomModelWrapper(localAtomDataset);
String linkLocalAtom = ownerAppLink + OWNER_LOCAL_ATOM_LINK + localAtom;
velocityContext.put("linkLocalAtom", linkLocalAtom);
velocityContext.put("localAtomTitle", getLabelForAtomInMail(localAtomWrapper));
velocityContext.put("localAtomIsPersona", isPersonaAtom(localAtomWrapper));
velocityContext.put("localSocketIsGroupSocket", isGroupChatSocket(localAtomWrapper, localSocket));
velocityContext.put("localSocketIsChatSocket", isChatSocket(localAtomWrapper, localSocket));
}
if (localConnection != null && localAtom != null) {
String linkConnection = ownerAppLink + String.format(OWNER_CONNECTION_LINK, localAtom, localConnection);
velocityContext.put("linkConnection", linkConnection);
}
if (textMsg != null) {
velocityContext.put("textMsg", textMsg);
}
if (this.ownerWebappUri != null) {
velocityContext.put("serviceName", this.ownerWebappUri);
}
return velocityContext;
}
use of won.protocol.util.DefaultAtomModelWrapper in project webofneeds by researchstudio-sat.
the class WonOwnerMailSender method sendConnectNotificationMessage.
public void sendConnectNotificationMessage(String toEmail, String localAtom, String targetAtom, String localConnection, String localSocket, String targetSocket, String textMsg) {
StringWriter writer = new StringWriter();
VelocityContext context = createContext(toEmail, localAtom, targetAtom, localConnection, localSocket, targetSocket, textMsg);
connectNotificationTemplate.merge(context, writer);
Dataset atomDataset = linkedDataSource.getDataForPublicResource(URI.create(localAtom));
DefaultAtomModelWrapper wrapper = new DefaultAtomModelWrapper(atomDataset);
String subject = SUBJECT_CONNECT;
if (isChatSocket(wrapper, localSocket)) {
subject = SUBJECT_CONNECT_CHAT;
}
logger.debug("sending {} to {}", subject, toEmail);
this.wonMailSender.sendTextMessage(toEmail, subject, writer.toString());
}
use of won.protocol.util.DefaultAtomModelWrapper in project webofneeds by researchstudio-sat.
the class WonOwnerMailSender method createMultipleHintsContext.
private VelocityContext createMultipleHintsContext(Map<String, Long> hintCountPerAtom) {
String ownerAppLink = uriService.getOwnerProtocolOwnerURI().toString();
VelocityContext velocityContext = new VelocityContext();
velocityContext.put("hintCount", hintCountPerAtom);
velocityContext.put("serviceName", this.ownerWebappUri);
velocityContext.put("atoms", hintCountPerAtom.keySet());
Map<String, String> atomLinks = new HashMap<>();
Map<String, String> atomTitles = new HashMap<>();
Map<String, Boolean> atomIsPersonas = new HashMap<>();
hintCountPerAtom.keySet().stream().forEach(localAtom -> {
Dataset localAtomDataset = linkedDataSource.getDataForPublicResource(URI.create(localAtom));
DefaultAtomModelWrapper localAtomWrapper = new DefaultAtomModelWrapper(localAtomDataset);
String linkLocalAtom = ownerAppLink + OWNER_LOCAL_ATOM_LINK + localAtom;
atomLinks.put(localAtom, linkLocalAtom);
atomTitles.put(localAtom, getLabelForAtomInMail(localAtomWrapper));
atomIsPersonas.put(localAtom, isPersonaAtom(localAtomWrapper));
});
velocityContext.put("atomTitle", atomTitles);
velocityContext.put("atomLink", atomLinks);
velocityContext.put("atomIsPersona", atomIsPersonas);
return velocityContext;
}
use of won.protocol.util.DefaultAtomModelWrapper in project webofneeds by researchstudio-sat.
the class SolrMatcherEvaluation method createAtomId.
public static String createAtomId(Dataset atom) {
String title = "";
String description = "";
try {
DefaultAtomModelWrapper atomModelWrapper = new DefaultAtomModelWrapper(atom);
title = atomModelWrapper.getAllTitles().iterator().next();
title = title.replaceAll("[^A-Za-z0-9 ]", "_");
title = title.replaceAll("NOT", "_");
title = title.replaceAll("AND", "_");
title = title.replaceAll("OR", "_");
description = atomModelWrapper.getSomeDescription();
} catch (IncorrectPropertyCountException e) {
// do nothing
}
if (title.isEmpty()) {
throw new IllegalArgumentException("atom has no title!!");
}
return title + "_" + (title + description).hashCode();
}
Aggregations