List of usage examples for com.google.gson GsonBuilder create
public Gson create()
From source file:com.ikanow.infinit.e.data_model.store.BaseDbPojo.java
License:Apache License
@SuppressWarnings("unchecked") public static <S extends BaseDbPojo> S fromDb(DBObject s, TypeToken<S> type, BasePojoDbMap<S> dynamicMap) { if (null == s) return null; GsonBuilder gb = null; try {/*from w w w. j a v a2 s. c om*/ Class<S> clazz = (Class<S>) type.getType(); gb = ((S) clazz.newInstance()).extendBuilder(BaseDbPojo.getDefaultBuilder()); } catch (Exception e) { return null; } if (null != dynamicMap) { gb = dynamicMap.extendBuilder(gb); } return (S) gb.create().fromJson(MongoDbUtil.encode(s), type.getType()); }
From source file:com.ikanow.infinit.e.data_model.store.BaseDbPojo.java
License:Apache License
public static <S extends BaseDbPojo> DBObject listToDb(Collection<S> list, TypeToken<? extends Collection<S>> listType, BasePojoDbMap<S> dynamicMap) { GsonBuilder gb = null; try {//from www . j ava 2s . c om if (!list.isEmpty()) { gb = list.iterator().next().extendBuilder(BaseDbPojo.getDefaultBuilder()); } } catch (Exception e) { return null; } return (DBObject) MongoDbUtil .encodeArray(gb.create().toJsonTree(list, listType.getType()).getAsJsonArray()); }
From source file:com.ikanow.infinit.e.data_model.store.BaseDbPojo.java
License:Apache License
@SuppressWarnings("unchecked") public static <S extends BaseDbPojo, L extends Collection<S>> L listFromDb(DBCursor bson, TypeToken<? extends L> listType, BasePojoDbMap<S> dynamicMap) { GsonBuilder gb = null; try {/*from w ww.ja v a2 s. c o m*/ Class<S> clazz = (Class<S>) ((ParameterizedType) listType.getType()).getActualTypeArguments()[0]; // (know this works because of construction of listType) gb = (clazz.newInstance()).extendBuilder(BaseDbPojo.getDefaultBuilder()); } catch (Exception e) { return null; } if (null != dynamicMap) { gb = dynamicMap.extendBuilder(gb); } return (L) gb.create().fromJson(MongoDbUtil.encode(bson), listType.getType()); }
From source file:com.ikanow.infinit.e.harvest.enrichment.custom.StructuredAnalysisHarvester.java
License:Open Source License
public void setContext(HarvestContext context) { _context = context;/*from w w w . ja v a 2 s. c o m*/ _securityManager = _context.getSecurityManager(); // Setup some globals if necessary if (null == _gson) { GsonBuilder gb = new GsonBuilder(); _gson = gb.create(); } }
From source file:com.ikanow.infinit.e.harvest.enrichment.custom.StructuredAnalysisHarvester.java
License:Open Source License
/** * executeHarvest(SourcePojo source, List<DocumentPojo> feeds) extracts document GEO, Entities, * and Associations based on the DocGeoSpec, EntitySpec, and AssociationSpec information contained * within the source document's StructuredAnalysis sections * @param source/*from w ww . ja v a 2 s .c o m*/ * @param docs * @return List<DocumentPojo> * @throws ScriptException */ public List<DocumentPojo> executeHarvest(HarvestController contextController, SourcePojo source, List<DocumentPojo> docs) { _context = contextController; _securityManager = _context.getSecurityManager(); if (null == _gson) { GsonBuilder gb = new GsonBuilder(); _gson = gb.create(); } Gson g = _gson; // Skip if the StructuredAnalysis object of the source is null if (source.getStructuredAnalysisConfig() != null) { StructuredAnalysisConfigPojo s = source.getStructuredAnalysisConfig(); // (some pre-processing to expand the specs) expandIterationLoops(s); // Instantiate a new ScriptEngineManager and create an engine to execute // the type of script specified in StructuredAnalysisPojo.scriptEngine this.intializeScriptEngine(); this.loadLookupCaches(s.getCaches(), source.getCommunityIds(), source.getOwnerId()); // Iterate over each doc in docs, create entity and association pojo objects // to add to the feed using the source entity and association spec pojos Iterator<DocumentPojo> it = docs.iterator(); int nDocs = 0; while (it.hasNext()) { DocumentPojo f = it.next(); nDocs++; try { resetEntityCache(); _document = null; _docPojo = null; // (don't create this until needed, since it might need to be (re)serialized after a call // to the UAH which would obviously be undesirable) // If the script engine has been instantiated pass the feed document and any scripts if (_scriptEngine != null) { List<String> scriptList = null; List<String> scriptFileList = null; try { // Script code embedded in source scriptList = Arrays.asList(s.getScript()); } catch (Exception e) { } try { // scriptFiles - can contain String[] of script files to import into the engine scriptFileList = Arrays.asList(s.getScriptFiles()); } catch (Exception e) { } this.loadGlobalFunctions(scriptFileList, scriptList, s.getScriptEngine()); } //TESTED // 1. Document level fields // Extract Title if applicable boolean bTryTitleLater = false; try { if (s.getTitle() != null) { intializeDocIfNeeded(f, g); if (JavaScriptUtils.containsScript(s.getTitle())) { f.setTitle((String) getValueFromScript(s.getTitle(), null, null)); } else { f.setTitle(getFormattedTextFromField(s.getTitle(), null)); } if (null == f.getTitle()) { bTryTitleLater = true; } } } catch (Exception e) { this._context.getHarvestStatus().logMessage("title: " + e.getMessage(), true); //DEBUG (don't output log messages per doc) //logger.error("title: " + e.getMessage(), e); } // Extract Display URL if applicable boolean bTryDisplayUrlLater = false; try { if (s.getDisplayUrl() != null) { intializeDocIfNeeded(f, g); if (JavaScriptUtils.containsScript(s.getDisplayUrl())) { f.setDisplayUrl((String) getValueFromScript(s.getDisplayUrl(), null, null)); } else { f.setDisplayUrl(getFormattedTextFromField(s.getDisplayUrl(), null)); } if (null == f.getDisplayUrl()) { bTryDisplayUrlLater = true; } } } catch (Exception e) { this._context.getHarvestStatus().logMessage("displayUrl: " + e.getMessage(), true); //DEBUG (don't output log messages per doc) //logger.error("displayUrl: " + e.getMessage(), e); } //TOTEST // Extract Description if applicable boolean bTryDescriptionLater = false; try { if (s.getDescription() != null) { intializeDocIfNeeded(f, g); if (JavaScriptUtils.containsScript(s.getDescription())) { f.setDescription((String) getValueFromScript(s.getDescription(), null, null)); } else { f.setDescription(getFormattedTextFromField(s.getDescription(), null)); } if (null == f.getDescription()) { bTryDescriptionLater = true; } } } catch (Exception e) { this._context.getHarvestStatus().logMessage("description: " + e.getMessage(), true); //DEBUG (don't output log messages per doc) //logger.error("description: " + e.getMessage(), e); } // Extract fullText if applicable boolean bTryFullTextLater = false; try { if (s.getFullText() != null) { intializeDocIfNeeded(f, g); if (JavaScriptUtils.containsScript(s.getFullText())) { f.setFullText((String) getValueFromScript(s.getFullText(), null, null)); } else { f.setFullText(getFormattedTextFromField(s.getFullText(), null)); } if (null == f.getFullText()) { bTryFullTextLater = true; } } } catch (Exception e) { this._context.getHarvestStatus().logMessage("fullText: " + e.getMessage(), true); //DEBUG (don't output log messages per doc) //logger.error("fullText: " + e.getMessage(), e); } // Published date is done after the UAH // (since the UAH can't access it, and it might be populated via the UAH) // 2. UAH/extraction properties // Add fields to metadata that can be used to create entities and associations // (Either with the UAH, or with the entity extractor) try { boolean bMetadataChanged = false; if (null != this._unstructuredHandler) { try { this._unstructuredHandler.set_sahEngine(_scriptEngine); bMetadataChanged = this._unstructuredHandler.executeHarvest(_context, source, f, (1 == nDocs), it.hasNext()); } catch (Exception e) { contextController.handleExtractError(e, source); //handle extractor error if need be it.remove(); // remove the document from the list... f.setTempSource(null); // (can safely corrupt this doc since it's been removed) // (Note: this can't be source level error, so carry on harvesting - unlike below) continue; } } if (contextController.isEntityExtractionRequired(source)) { bMetadataChanged = true; // Text/Entity Extraction List<DocumentPojo> toAdd = new ArrayList<DocumentPojo>(1); toAdd.add(f); try { contextController.extractTextAndEntities(toAdd, source, false, false); if (toAdd.isEmpty()) { // this failed... it.remove(); // remove the document from the list... f.setTempSource(null); // (can safely corrupt this doc since it's been removed) continue; } //TESTED } catch (Exception e) { contextController.handleExtractError(e, source); //handle extractor error if need be it.remove(); // remove the document from the list... f.setTempSource(null); // (can safely corrupt this doc since it's been removed) if (source.isHarvestBadSource()) { // Source error, ignore all other documents while (it.hasNext()) { f = it.next(); f.setTempSource(null); // (can safely corrupt this doc since it's been removed) it.remove(); } break; } else { continue; } //TESTED } } if (bMetadataChanged) { // Ugly, but need to re-create doc json because metadata has changed String sTmpFullText = f.getFullText(); f.setFullText(null); // (no need to serialize this, can save some cycles) _document = null; _docPojo = null; intializeDocIfNeeded(f, g); f.setFullText(sTmpFullText); //(restore) } // Can copy metadata from old documents to new ones: handleDocumentUpdates(s.getOnUpdateScript(), f); // Check (based on the metadata and entities so far) whether to retain the doc if (rejectDoc(s.getRejectDocCriteria(), f)) { it.remove(); // remove the document from the list... f.setTempSource(null); // (can safely corrupt this doc since it's been removed) continue; } } catch (Exception e) { this._context.getHarvestStatus().logMessage("SAH->UAH: " + e.getMessage(), true); //DEBUG (don't output log messages per doc) //logger.error("SAH->UAH: " + e.getMessage(), e); } // Now create document since there's no risk of having to re-serialize intializeDocIfNeeded(f, g); // 3. final doc-level metadata fields: // If description was null before might need to get it from a UAH field if (bTryTitleLater) { try { if (s.getTitle() != null) { intializeDocIfNeeded(f, g); if (JavaScriptUtils.containsScript(s.getTitle())) { f.setTitle((String) getValueFromScript(s.getTitle(), null, null)); } else { f.setTitle(getFormattedTextFromField(s.getTitle(), null)); } } } catch (Exception e) { this._context.getHarvestStatus().logMessage("title: " + e.getMessage(), true); //DEBUG (don't output log messages per doc) //logger.error("title: " + e.getMessage(), e); } } // Extract Display URL if needed if (bTryDisplayUrlLater) { try { if (s.getDisplayUrl() != null) { intializeDocIfNeeded(f, g); if (JavaScriptUtils.containsScript(s.getDisplayUrl())) { f.setDisplayUrl((String) getValueFromScript(s.getDisplayUrl(), null, null)); } else { f.setDisplayUrl(getFormattedTextFromField(s.getDisplayUrl(), null)); } } } catch (Exception e) { this._context.getHarvestStatus().logMessage("displayUrl: " + e.getMessage(), true); //DEBUG (don't output log messages per doc) //logger.error("displayUrl: " + e.getMessage(), e); } } //TOTEST // If description was null before might need to get it from a UAH field if (bTryDescriptionLater) { try { if (s.getDescription() != null) { intializeDocIfNeeded(f, g); if (JavaScriptUtils.containsScript(s.getDescription())) { f.setDescription((String) getValueFromScript(s.getDescription(), null, null)); } else { f.setDescription(getFormattedTextFromField(s.getDescription(), null)); } } } catch (Exception e) { this._context.getHarvestStatus().logMessage("description2: " + e.getMessage(), true); //DEBUG (don't output log messages per doc) //logger.error("description2: " + e.getMessage(), e); } } // If fullText was null before might need to get it from a UAH field if (bTryFullTextLater) { try { if (s.getFullText() != null) { intializeDocIfNeeded(f, g); if (JavaScriptUtils.containsScript(s.getFullText())) { f.setFullText((String) getValueFromScript(s.getFullText(), null, null)); } else { f.setFullText(getFormattedTextFromField(s.getFullText(), null)); } } } catch (Exception e) { this._context.getHarvestStatus().logMessage("fullText2: " + e.getMessage(), true); //DEBUG (don't output log messages per doc) //logger.error("fullText2: " + e.getMessage(), e); } } // Extract Published Date if applicable if (s.getPublishedDate() != null) { if (JavaScriptUtils.containsScript(s.getPublishedDate())) { try { f.setPublishedDate(new Date(DateUtility .parseDate((String) getValueFromScript(s.getPublishedDate(), null, null)))); } catch (Exception e) { this._context.getHarvestStatus().logMessage("publishedDate: " + e.getMessage(), true); } } else { try { f.setPublishedDate(new Date(DateUtility.parseDate( (String) getFormattedTextFromField(s.getPublishedDate(), null)))); } catch (Exception e) { this._context.getHarvestStatus().logMessage("publishedDate: " + e.getMessage(), true); } } } // 4. Entity level fields // Extract Document GEO if applicable if (s.getDocumentGeo() != null) { try { f.setDocGeo(getDocGeo(s.getDocumentGeo())); } catch (Exception e) { this._context.getHarvestStatus().logMessage("docGeo: " + e.getMessage(), true); } } // Extract Entities if (s.getEntities() != null) { f.setEntities(getEntities(s.getEntities(), f)); } // Extract Associations if (s.getAssociations() != null) { f.setAssociations(getAssociations(s.getAssociations(), f)); } // 5. Remove unwanted metadata fields removeUnwantedMetadataFields(s.getMetadataFields(), f); } catch (Exception e) { this._context.getHarvestStatus().logMessage("Unknown: " + e.getMessage(), true); //DEBUG (don't output log messages per doc) //logger.error("Unknown: " + e.getMessage(), e); } finally { _document = null; _docPojo = null; } } // (end loop over documents) } // (end if SAH specified) return docs; }
From source file:com.ikanow.infinit.e.harvest.enrichment.custom.UnstructuredAnalysisHarvester.java
License:Open Source License
/** * processMeta - handle an individual field *///from w ww . j a v a2 s .c o m private void processMeta(DocumentPojo f, metaField m, String text, SourcePojo source, UnstructuredAnalysisConfigPojo uap) { boolean bAllowDuplicates = false; if ((null != m.flags) && m.flags.contains("U")) { bAllowDuplicates = true; } if ((null == m.scriptlang) || m.scriptlang.equalsIgnoreCase("regex")) { Pattern metaPattern = createRegex(m.script, m.flags); int timesToRun = 1; Object[] currField = null; if ((null != m.flags) && m.flags.contains("c")) { currField = f.getMetadata().get(m.fieldName); } if (null != currField) { // chained metadata timesToRun = currField.length; text = (String) currField[0]; } //TESTED Matcher matcher = metaPattern.matcher(text); LinkedList<String> Llist = null; for (int ii = 0; ii < timesToRun; ++ii) { if (ii > 0) { // (else either just text, or in the above "chained metadata" initialization above) text = (String) currField[ii]; matcher = metaPattern.matcher(text); } //TESTED StringBuffer prefix = new StringBuffer(m.fieldName).append(':'); int nFieldNameLen = m.fieldName.length() + 1; try { while (matcher.find()) { if (null == Llist) { Llist = new LinkedList<String>(); } if (null == m.groupNum) { m.groupNum = 0; } String toAdd = matcher.group(m.groupNum); if (null != m.replace) { toAdd = metaPattern.matcher(toAdd).replaceFirst(m.replace); } if ((null != m.flags) && m.flags.contains("H")) { toAdd = StringEscapeUtils.unescapeHtml(toAdd); } prefix.setLength(nFieldNameLen); prefix.append(toAdd); String dupCheck = prefix.toString(); if (!regexDuplicates.contains(dupCheck)) { Llist.add(toAdd); if (!bAllowDuplicates) { regexDuplicates.add(dupCheck); } } } } catch (Exception e) { this._context.getHarvestStatus().logMessage("processMeta1: " + e.getMessage(), true); } } //(end metadata chaining handling) if (null != Llist) { if (null != currField) { // (overwrite) f.getMetadata().put(m.fieldName, Llist.toArray()); } else { f.addToMetadata(m.fieldName, Llist.toArray()); } } //TESTED } else if (m.scriptlang.equalsIgnoreCase("javascript")) { if (null == f.getMetadata()) { f.setMetadata(new LinkedHashMap<String, Object[]>()); } //set the script engine up if necessary if ((null != source) && (null != uap)) { //(these are null if called from new processing pipeline vs legacy code) intializeScriptEngine(source, uap); } try { //TODO (INF-2488): in new format, this should only happen in between contentMeta blocks/docs // (also should be able to use SAH _document object I think?) // Javascript: the user passes in Object[] currField = f.getMetadata().get(m.fieldName); if ((null == m.flags) || m.flags.isEmpty()) { if (null == currField) { engine.put("text", text); engine.put("_iterator", null); } //(otherwise will just pass the current fields in there) } else { // flags specified if (m.flags.contains("t")) { // text engine.put("text", text); } if (m.flags.contains("d")) { // entire document (minus ents and assocs) GsonBuilder gb = new GsonBuilder(); Gson g = gb.create(); List<EntityPojo> ents = f.getEntities(); List<AssociationPojo> assocs = f.getAssociations(); try { f.setEntities(null); f.setAssociations(null); engine.put("document", g.toJson(f)); securityManager.eval(engine, JavaScriptUtils.initScript); } finally { f.setEntities(ents); f.setAssociations(assocs); } } if (m.flags.contains("m")) { // metadata GsonBuilder gb = new GsonBuilder(); Gson g = gb.create(); engine.put("_metadata", g.toJson(f.getMetadata())); securityManager.eval(engine, JavaScriptUtils.iteratorMetaScript); } } //(end flags processing) if (null != currField) { f.getMetadata().remove(m.fieldName); GsonBuilder gb = new GsonBuilder(); Gson g = gb.create(); engine.put("_iterator", g.toJson(currField)); securityManager.eval(engine, JavaScriptUtils.iteratorDocScript); } //TESTED (handling of flags, and replacing of existing fields, including when field is null but specified) Object returnVal = securityManager.eval(engine, m.script); if (null != returnVal) { if (returnVal instanceof String) { // The only easy case Object[] array = new Object[1]; if ((null != m.flags) && m.flags.contains("H")) { returnVal = StringEscapeUtils.unescapeHtml((String) returnVal); } array[0] = returnVal; f.addToMetadata(m.fieldName, array); } else { // complex object or array - in either case the engine turns these into // internal.NativeArray or internal.NativeObject BasicDBList outList = JavaScriptUtils.parseNativeJsObject(returnVal, engine); f.addToMetadata(m.fieldName, outList.toArray()); } } } catch (ScriptException e) { _context.getHarvestStatus().logMessage(HarvestExceptionUtils.createExceptionMessage(e).toString(), true); // Just do nothing and log // e.printStackTrace(); //DEBUG (don't output log messages per doc) //logger.error(e.getMessage()); } catch (Exception e) { _context.getHarvestStatus().logMessage(HarvestExceptionUtils.createExceptionMessage(e).toString(), true); // Just do nothing and log // e.printStackTrace(); //DEBUG (don't output log messages per doc) //logger.error(e.getMessage()); } } else if (m.scriptlang.equalsIgnoreCase("xpath")) { String xpath = m.script; try { createHtmlCleanerIfNeeded(); int timesToRun = 1; Object[] currField = null; if ((null != m.flags) && m.flags.contains("c")) { currField = f.getMetadata().get(m.fieldName); } if (null != currField) { // chained metadata f.getMetadata().remove(m.fieldName); // (so will add to the end) timesToRun = currField.length; text = (String) currField[0]; } //TESTED for (int ii = 0; ii < timesToRun; ++ii) { if (ii > 0) { // (else either just text, or in the above "chained metadata" initialization above) text = (String) currField[ii]; } //TESTED TagNode node = cleaner.clean(new ByteArrayInputStream(text.getBytes())); //NewCode : Only use html cleaner for cleansing //use JAXP for full Xpath lib Document doc = new DomSerializer(new CleanerProperties()).createDOM(node); String extraRegex = extractRegexFromXpath(xpath); if (extraRegex != null) xpath = xpath.replace(extraRegex, ""); XPath xpa = XPathFactory.newInstance().newXPath(); NodeList res = (NodeList) xpa.evaluate(xpath, doc, XPathConstants.NODESET); if (res.getLength() > 0) { if ((null != m.flags) && (m.flags.contains("o"))) { // "o" for object m.groupNum = -1; // (see bConvertToObject below) } StringBuffer prefix = new StringBuffer(m.fieldName).append(':'); int nFieldNameLen = m.fieldName.length() + 1; ArrayList<Object> Llist = new ArrayList<Object>(res.getLength()); boolean bConvertToObject = ((m.groupNum != null) && (m.groupNum == -1)); boolean convertToXml = ((null != m.flags) && (m.flags.contains("x"))); for (int i = 0; i < res.getLength(); i++) { Node info_node = res.item(i); if ((null != m.flags) && (m.flags.contains("g"))) { Llist.add(parseHtmlTable(info_node, m.replace)); } else if (bConvertToObject || convertToXml) { // Try to create a JSON object out of this StringWriter writer = new StringWriter(); try { Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(new DOMSource(info_node), new StreamResult(writer)); } catch (TransformerException e1) { continue; } if (bConvertToObject) { try { JSONObject subObj = XML.toJSONObject(writer.toString()); if (xpath.endsWith("*")) { // (can have any number of different names here) Llist.add(XmlToMetadataParser.convertJsonObjectToLinkedHashMap(subObj)); } //TESTED else { String[] rootNames = JSONObject.getNames(subObj); if (1 == rootNames.length) { // (don't think it can't be any other number in fact) subObj = subObj.getJSONObject(rootNames[0]); } boolean bUnescapeHtml = ((null != m.flags) && m.flags.contains("H")); Llist.add(XmlToMetadataParser.convertJsonObjectToLinkedHashMap(subObj, bUnescapeHtml)); } //TESTED } catch (JSONException e) { // Just carry on continue; } //TESTED } else { // leave in XML form Llist.add(writer.toString().substring(38)); // +38: (step over <?xml version="1.0" encoding="UTF-8"?>) } //TESTED (xpath_test.json) } else { // Treat this as string, either directly or via regex String info = info_node.getTextContent().trim(); if (extraRegex == null || extraRegex.isEmpty()) { prefix.setLength(nFieldNameLen); prefix.append(info); String dupCheck = prefix.toString(); if (!regexDuplicates.contains(dupCheck)) { if ((null != m.flags) && m.flags.contains("H")) { info = StringEscapeUtils.unescapeHtml(info); } Llist.add(info); if (!bAllowDuplicates) { regexDuplicates.add(dupCheck); } } } else { // Apply regex to the string Pattern dataRegex = createRegex(extraRegex, m.flags); Matcher dataMatcher = dataRegex.matcher(info); boolean result = dataMatcher.find(); while (result) { String toAdd; if (m.groupNum != null) toAdd = dataMatcher.group(m.groupNum); else toAdd = dataMatcher.group(); prefix.setLength(nFieldNameLen); prefix.append(toAdd); String dupCheck = prefix.toString(); if (!regexDuplicates.contains(dupCheck)) { if ((null != m.flags) && m.flags.contains("H")) { toAdd = StringEscapeUtils.unescapeHtml(toAdd); } Llist.add(toAdd); if (!bAllowDuplicates) { regexDuplicates.add(dupCheck); } } result = dataMatcher.find(); } } //(regex vs no regex) } //(end string vs object) } if (Llist.size() > 0) { f.addToMetadata(m.fieldName, Llist.toArray()); } } } //(end loop over metadata objects if applicable) } catch (IOException ioe) { _context.getHarvestStatus().logMessage(HarvestExceptionUtils.createExceptionMessage(ioe).toString(), true); // Just do nothing and log //DEBUG (don't output log messages per doc) //logger.error(ioe.getMessage()); } catch (ParserConfigurationException e1) { _context.getHarvestStatus().logMessage(HarvestExceptionUtils.createExceptionMessage(e1).toString(), true); // Just do nothing and log //DEBUG (don't output log messages per doc) //logger.error(e1.getMessage()); } catch (XPathExpressionException e1) { _context.getHarvestStatus().logMessage("Error evaluating xpath expression: " + xpath, true); } } else if (m.scriptlang.equalsIgnoreCase("stream")) { // XML or JSON streaming interface // which one? try { boolean json = false; boolean xml = false; for (int i = 0; i < 128; ++i) { if ('<' == text.charAt(i)) { xml = true; break; } if ('{' == text.charAt(i) || '[' == text.charAt(i)) { json = true; break; } if (!Character.isSpaceChar(text.charAt(i))) { break; } } //TESTED (too many spaces: meta_stream_test, test4; incorrect chars: test3, xml: test1, json: test2) boolean textNotObject = m.flags == null || !m.flags.contains("o"); List<DocumentPojo> docs = new LinkedList<DocumentPojo>(); List<String> levelOneFields = null; if (null != m.script) { levelOneFields = Arrays.asList(m.script.split("\\s*,\\s*")); if ((1 == levelOneFields.size()) && levelOneFields.get(0).isEmpty()) { // convert [""] to null levelOneFields = null; } } //TESTED (json and xml) if (xml) { XmlToMetadataParser parser = new XmlToMetadataParser(levelOneFields, null, null, null, null, null, Integer.MAX_VALUE); XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty(XMLInputFactory.IS_COALESCING, true); factory.setProperty(XMLInputFactory.SUPPORT_DTD, false); XMLStreamReader reader = null; try { reader = factory.createXMLStreamReader(new ByteArrayInputStream(text.getBytes())); docs = parser.parseDocument(reader, textNotObject); } finally { if (null != reader) reader.close(); } } //TESTED (meta_stream_test, test1) if (json) { JsonReader jsonReader = null; try { JsonToMetadataParser parser = new JsonToMetadataParser(null, levelOneFields, null, null, Integer.MAX_VALUE); jsonReader = new JsonReader( new InputStreamReader(new ByteArrayInputStream(text.getBytes()), "UTF-8")); jsonReader.setLenient(true); docs = parser.parseDocument(jsonReader, textNotObject); } finally { if (null != jsonReader) jsonReader.close(); } } //TESTED (meta_stream_test test2) if (!docs.isEmpty()) { ArrayList<String> Llist = null; ArrayList<Object> LlistObj = null; if (textNotObject) { Llist = new ArrayList<String>(docs.size()); } else { LlistObj = new ArrayList<Object>(docs.size()); } for (DocumentPojo doc : docs) { if ((null != doc.getFullText()) || (null != doc.getMetadata())) { if (textNotObject) { Llist.add(doc.getFullText()); } //TESTED else if (xml) { LlistObj.add(doc.getMetadata()); } //TESTED else if (json) { Object o = doc.getMetadata(); if (null != o) { o = doc.getMetadata().get("json"); if (o instanceof Object[]) { LlistObj.addAll(Arrays.asList((Object[]) o)); } else if (null != o) { LlistObj.add(o); } //TESTED } } //TESTED } } //TESTED if ((null != Llist) && !Llist.isEmpty()) { f.addToMetadata(m.fieldName, Llist.toArray()); } //TESTED if ((null != LlistObj) && !LlistObj.isEmpty()) { f.addToMetadata(m.fieldName, LlistObj.toArray()); } //TESTED } //TESTED (meta_stream_test test1,test2) } //(end try) catch (Exception e) { // various parsing errors _context.getHarvestStatus().logMessage(HarvestExceptionUtils.createExceptionMessage(e).toString(), true); } } //TESTED (meta_stream_test) // (don't currently support other script types) }
From source file:com.ikanow.infinit.e.harvest.enrichment.custom.UnstructuredAnalysisHarvester.java
License:Open Source License
/** * cleanseField/*from ww w .j a v a 2s .co m*/ * * @param field * @param script * @param replaceWith */ private String cleanseField(String field, String scriptLang, String script, String flags, String replaceWith, DocumentPojo f) { if ((null == scriptLang) || scriptLang.equalsIgnoreCase("regex")) { if (null == flags) { return field.replaceAll(script, replaceWith); } else { if (flags.contains("H")) { // HTML decode return StringEscapeUtils .unescapeHtml(createRegex(script, flags).matcher(field).replaceAll(replaceWith)); } else { return createRegex(script, flags).matcher(field).replaceAll(replaceWith); } } } else if (scriptLang.equalsIgnoreCase("xpath")) { try { createHtmlCleanerIfNeeded(); TagNode node = cleaner.clean(new ByteArrayInputStream(field.getBytes())); Document doc = new DomSerializer(new CleanerProperties()).createDOM(node); XPath xpa = XPathFactory.newInstance().newXPath(); NodeList res = (NodeList) xpa.evaluate(script, doc, XPathConstants.NODESET); if (0 == res.getLength()) { // No match, just return "", unlike regex we don't want anything if we don't match... return ""; } else { StringBuffer sb = new StringBuffer(); for (int i = 0; i < res.getLength(); i++) { if (0 != i) { sb.append('\n'); } Node info_node = res.item(i); if ((null != flags) && flags.contains("H")) { // HTML decode sb.append(StringEscapeUtils.unescapeHtml(info_node.getTextContent().trim())); } else if ((null != flags) && flags.contains("x")) { // Leave as XML string StringWriter writer = new StringWriter(); try { Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(new DOMSource(info_node), new StreamResult(writer)); sb.append(writer.toString().substring(38)); // (step over <?xml etc?> see under metadata field extraction } catch (TransformerException e1) { // (do nothing just skip) } } else { sb.append(info_node.getTextContent().trim()); } } return sb.toString(); } //TESTED (xpath_test: object - multiple and single, text) } catch (IOException e) { _context.getHarvestStatus().logMessage(HarvestExceptionUtils.createExceptionMessage(e).toString(), true); } catch (XPathExpressionException e) { _context.getHarvestStatus().logMessage(HarvestExceptionUtils.createExceptionMessage(e).toString(), true); } catch (ParserConfigurationException e) { _context.getHarvestStatus().logMessage(HarvestExceptionUtils.createExceptionMessage(e).toString(), true); } } else if (scriptLang.equalsIgnoreCase("javascript")) { try { SourcePojo src = f.getTempSource(); intializeScriptEngine(src, src.getUnstructuredAnalysisConfig()); // Setup input: if (null == flags) { flags = "t"; } if (flags.contains("t")) { // text engine.put("text", field); } if (flags.contains("d")) { // entire document GsonBuilder gb = new GsonBuilder(); Gson g = gb.create(); List<EntityPojo> ents = f.getEntities(); List<AssociationPojo> assocs = f.getAssociations(); try { f.setEntities(null); f.setAssociations(null); engine.put("document", g.toJson(f)); securityManager.eval(engine, JavaScriptUtils.initScript); } finally { f.setEntities(ents); f.setAssociations(assocs); } } if (flags.contains("m")) { // metadata GsonBuilder gb = new GsonBuilder(); Gson g = gb.create(); engine.put("_metadata", g.toJson(f.getMetadata())); securityManager.eval(engine, JavaScriptUtils.iteratorMetaScript); } Object returnVal = securityManager.eval(engine, script); field = (String) returnVal; // (If not a string or is null then will exception out) if ((null != flags) && flags.contains("H") && (null != field)) { // HTML decode field = StringEscapeUtils.unescapeHtml(field); } } catch (Exception e) { _context.getHarvestStatus().logMessage(HarvestExceptionUtils.createExceptionMessage(e).toString(), true); // Just do nothing and log // e.printStackTrace(); //DEBUG (don't output log messages per doc) //logger.error(e.getMessage()); } } return field; }
From source file:com.indragie.cmput301as1.Session.java
License:Open Source License
/** * Creates a new instance of {@link Session} * @param context The current context.//w w w . j a v a 2 s . c o m * @param user The user that the session belongs to. */ public Session(Context context, User user) { this.user = user; this.context = context; // Sort by starting date descending by default Comparator<ExpenseClaim> comparator = new StartDateDescendingComparator(); ownedClaims = new ListModel<ExpenseClaim>(modelFilename(OWNED_CLAIMS_FILENAME_PREFIX, user), context); ownedClaims.addObserver(this); ownedClaims.setComparator(comparator); reviewalClaims = new ListModel<ExpenseClaim>(modelFilename(REVIEWAL_CLAIMS_FILENAME_PREFIX, user), context); reviewalClaims.addObserver(this); reviewalClaims.setComparator(comparator); pushQueue = new ElasticSearchQueue<ExpenseClaim>(context); pullQueue = new ElasticSearchQueue<List<ExpenseClaim>>(context); GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(Date.class, new DateJSONSerializer()); builder.registerTypeAdapter(Date.class, new DateJSONDeserializer()); builder.registerTypeAdapter(ExpenseItem.class, new ExpenseItemJSONSerializer()); builder.registerTypeAdapter(ExpenseItem.class, new ExpenseItemJSONDeserializer(new ExpenseItemReceiptController())); Gson gson = builder.create(); apiClient = new ElasticSearchAPIClient(ElasticSearchConfiguration.getBaseURL(), gson); }
From source file:com.inkubator.hrm.service.impl.NotificationApprovalMessagesListener.java
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override//from w w w . j a v a 2 s. c o m @Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED, timeout = 50, rollbackFor = Exception.class) public void onMessage(Message message) { try { LOGGER.info("Begin Send Email Approval"); TextMessage textMessage = (TextMessage) message; String json = textMessage.getText(); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.setDateFormat("dd-MMMM-yyyy"); Gson gson = gsonBuilder.create(); Gson gsonDateSerializer = JsonUtil.getHibernateEntityGsonBuilder() .registerTypeAdapter(Date.class, new DateJsonDeserializer()).create(); JsonObject jsonObject = (JsonObject) gson.fromJson(json, JsonObject.class); String locale = jsonObject.get("locale").getAsString(); ApprovalActivity appActivity = approvalActivityDao .getEntiyByPK(jsonObject.get("approvalActivityId").getAsLong()); HrmUser approverUser = hrmUserDao.getByUserId(appActivity.getApprovedBy()); HrmUser requesterUser = hrmUserDao.getByUserId(appActivity.getRequestBy()); VelocityTempalteModel vtm = new VelocityTempalteModel(); List<String> toSend = new ArrayList<>(); List<String> toSentCC = new ArrayList<String>(); List<String> toSentBCC = new ArrayList<String>(); vtm.setFrom(ownerEmail); /*if(appActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING) { //kirim email ke approver nya jika status waiting toSend.add(approverUser.getEmailAddress()); } else if(appActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_CANCELLED){ //kirim email ke approver nya jika status cancelled. Dan cc email ke requester toSend.add(approverUser.getEmailAddress()); toSentCC.add(requesterUser.getEmailAddress()); } else if((appActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_APPROVED) && appActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_REJECTED) { //kirim email ke requester nya jika statusnya sudah di approved/rejected. Dan cc email (if any) toSend.add(requesterUser.getEmailAddress()); for(JsonElement el:jsonObject.get("ccEmailAddresses").getAsJsonArray()){ toSentCC.add(el.getAsString()); } }*/ toSend.add("deni.arianto1606@gmail.com"); toSend.add("rizal2_dhfr@yahoo.com"); // toSend.add("yosa.mareta@gmail.com"); toSend.add("guntur@incubatechnology.com"); toSentCC.add("rizkykojek@gmail.com"); toSentCC.add("amjadicky@gmail.com"); vtm.setTo(toSend.toArray(new String[toSend.size()])); vtm.setCc(toSentCC.toArray(new String[toSentCC.size()])); vtm.setBcc(toSentBCC.toArray(new String[toSentBCC.size()])); Map maptoSend = new HashMap(); if (StringUtils.equals(locale, "en")) { //not yet implemented } else { if (Objects.equals(appActivity.getApprovalStatus(), HRMConstant.APPROVAL_STATUS_WAITING_APPROVAL)) { //configure email parameter based on approval name switch (appActivity.getApprovalDefinition().getName()) { case HRMConstant.VACANCY_ADVERTISEMENT: List<VacancyAdvertisementDetailModel> listAdvertisementDetail = gsonDateSerializer.fromJson( jsonObject.get("listAdvertisementDetail").getAsString(), new TypeToken<List<VacancyAdvertisementDetailModel>>() { }.getType()); vtm.setSubject("Pengajuan Iklan Lowongan"); vtm.setTemplatePath("email_vacancy_advertisement_waiting_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("effectiveDate", jsonObject.get("effectiveDate").getAsString()); maptoSend.put("advertisementMediaName", jsonObject.get("advertisementMediaName").getAsString()); maptoSend.put("applyDate", jsonObject.get("applyDate").getAsString()); maptoSend.put("listAdvertisementDetail", listAdvertisementDetail); maptoSend.put("dateTool", new DateTool()); maptoSend.put("numTool", new NumberTool()); maptoSend.put("locale", new Locale(locale)); break; case HRMConstant.EMP_CORRECTION_ATTENDANCE: List<WtEmpCorrectionAttendanceDetail> listCorrectionAttendance = gsonDateSerializer .fromJson(jsonObject.get("listCorrectionAttendance").getAsString(), new TypeToken<List<WtEmpCorrectionAttendanceDetail>>() { }.getType()); vtm.setTemplatePath("email_correction_attendance_waiting_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("startDate", jsonObject.get("startDate").getAsString()); maptoSend.put("endDate", jsonObject.get("endDate").getAsString()); maptoSend.put("applyDate", jsonObject.get("applyDate").getAsString()); maptoSend.put("listCorrectionAttendance", listCorrectionAttendance); maptoSend.put("dateTool", new DateTool()); maptoSend.put("locale", new Locale(locale)); break; case HRMConstant.BUSINESS_TRAVEL: vtm.setSubject("Permohonan Perjalanan Dinas"); vtm.setTemplatePath("email_travel_waiting_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("businessTravelNo", jsonObject.get("businessTravelNo").getAsString()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("destination", jsonObject.get("destination").getAsString()); maptoSend.put("start", jsonObject.get("startDate").getAsString()); maptoSend.put("end", jsonObject.get("endDate").getAsString()); maptoSend.put("description", jsonObject.get("description").getAsString()); maptoSend.put("totalAmount", jsonObject.get("totalAmount").getAsString()); maptoSend.put("deadline", jsonObject.get("deadline").getAsString()); break; case HRMConstant.REIMBURSEMENT: vtm.setSubject("Permohonan Penggantian Biaya"); vtm.setTemplatePath("email_reimbursment_waiting_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("reimbursementType", jsonObject.get("reimbursementType").getAsString()); maptoSend.put("applicationDate", jsonObject.get("applicationDate").getAsString()); maptoSend.put("nominal", jsonObject.get("nominal").getAsString()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("deadline", jsonObject.get("deadline").getAsString()); break; case HRMConstant.REIMBURSEMENT_DISBURSEMENT: vtm.setSubject("Permohonan Pencairan Penggantian Biaya"); vtm.setTemplatePath("email_rmbs_disbursement_waiting_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("deadline", jsonObject.get("deadline").getAsString()); break; case HRMConstant.LOAN: vtm.setSubject("Permohonan Pinjaman Lunak"); vtm.setTemplatePath("email_loan_waiting_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("loanSchemaName", jsonObject.get("loanSchemaName").getAsString()); maptoSend.put("nominalPrincipal", jsonObject.get("nominalPrincipal").getAsString()); maptoSend.put("interestRate", jsonObject.get("interestRate").getAsString()); maptoSend.put("nominalInstallment", jsonObject.get("nominalInstallment").getAsString()); maptoSend.put("interestInstallment", jsonObject.get("interestInstallment").getAsString()); maptoSend.put("totalNominalInstallment", jsonObject.get("totalNominalInstallment").getAsString()); break; case HRMConstant.SHIFT_SCHEDULE: vtm.setSubject("Permohonan Perubahan Jadwal Kerja Karyawan"); vtm.setTemplatePath("email_shift_schedule_waiting_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("jabatan", requesterUser.getEmpData().getJabatanByJabatanId().getName()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); break; case HRMConstant.LEAVE: vtm.setSubject("Permohonan Cuti"); vtm.setTemplatePath("email_leave_waiting_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("leaveName", jsonObject.get("leaveName").getAsString()); maptoSend.put("startDate", jsonObject.get("startDate").getAsString()); maptoSend.put("endDate", jsonObject.get("endDate").getAsString()); maptoSend.put("fillingDate", jsonObject.get("fillingDate").getAsString()); maptoSend.put("materialJobsAbandoned", jsonObject.get("materialJobsAbandoned").getAsString()); break; case HRMConstant.LEAVE_CANCELLATION: vtm.setSubject("Permohonan Pembatalan Cuti"); vtm.setTemplatePath("email_leave_cancellation_waiting_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("leaveName", jsonObject.get("leaveName").getAsString()); maptoSend.put("startDate", jsonObject.get("startDate").getAsString()); maptoSend.put("endDate", jsonObject.get("endDate").getAsString()); maptoSend.put("fillingDate", jsonObject.get("fillingDate").getAsString()); maptoSend.put("materialJobsAbandoned", jsonObject.get("materialJobsAbandoned").getAsString()); maptoSend.put("cancellationDate", jsonObject.get("cancellationDate").getAsString()); break; case HRMConstant.OVERTIME: vtm.setSubject("Permohonan Lembur"); vtm.setTemplatePath("email_overtime_waiting_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("overTimeName", jsonObject.get("overTimeName").getAsString()); maptoSend.put("hour", jsonObject.get("hour").getAsString()); maptoSend.put("minute", jsonObject.get("minute").getAsString()); maptoSend.put("overTimeDate", jsonObject.get("overTimeDate").getAsString()); maptoSend.put("implementationNumber", jsonObject.get("implementationNumber").getAsString()); break; case HRMConstant.ANNOUNCEMENT: TypeToken<List<String>> token = new TypeToken<List<String>>() { }; List<String> dataGolonganJabatan = gson.fromJson(jsonObject.get("listGolonganJabatan"), token.getType()); List<String> dataUnitKerja = gson.fromJson(jsonObject.get("listUnitKerja"), token.getType()); List<String> dataEmployeeType = gson.fromJson(jsonObject.get("listEmployeeType"), token.getType()); vtm.setSubject("Pengajuan Pengumuman"); vtm.setTemplatePath("email_announcement_waiting_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("subjek", jsonObject.get("subjek").getAsString()); maptoSend.put("content", jsonObject.get("content").getAsString()); maptoSend.put("company", jsonObject.get("company").getAsString()); maptoSend.put("listEmployeeType", dataEmployeeType); maptoSend.put("listUnitKerja", dataUnitKerja); maptoSend.put("listGolonganJabatan", dataGolonganJabatan); break; case HRMConstant.PERMIT: vtm.setSubject("Permohonan Izin"); vtm.setTemplatePath("email_permit_waiting_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("startDate", jsonObject.get("startDate").getAsString()); maptoSend.put("endDate", jsonObject.get("endDate").getAsString()); maptoSend.put("permitClassification", jsonObject.get("permitClassification").getAsString()); break; case HRMConstant.RECRUITMENT_REQUEST: vtm.setSubject("PENGAJUAN PERMINTAAN TENAGA KERJA"); vtm.setTemplatePath("email_recruitment_request_waiting_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("periodeStart", jsonObject.get("periodeStart").getAsString()); maptoSend.put("periodeEnd", jsonObject.get("periodeEnd").getAsString()); maptoSend.put("jabatan", jsonObject.get("jabatan").getAsString()); maptoSend.put("mppName", jsonObject.get("mppName").getAsString()); maptoSend.put("salaryMin", jsonObject.get("salaryMin").getAsString()); maptoSend.put("salaryMax", jsonObject.get("salaryMax").getAsString()); maptoSend.put("candidateCountRequest", jsonObject.get("candidateCountRequest").getAsString()); break; case HRMConstant.RECRUIT_MPP_APPLY: TypeToken<List<String>> token2 = new TypeToken<List<String>>() { }; List<String> listNamaJabatan = gson.fromJson(jsonObject.get("listNamaJabatan"), token2.getType()); vtm.setSubject("PERSETUJUAN RENCANA KETENAGAKERJAAN"); vtm.setTemplatePath("email_mpp_apply_waiting_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("recruitMppApplyName", jsonObject.get("recruitMppApplyName").getAsString()); maptoSend.put("applyDate", jsonObject.get("applyDate").getAsString()); maptoSend.put("startDate", jsonObject.get("startDate").getAsString()); maptoSend.put("endDate", jsonObject.get("endDate").getAsString()); maptoSend.put("listNamaJabatan", listNamaJabatan); break; case HRMConstant.EMPLOYEE_CAREER_TRANSITION: vtm.setSubject("Pengajuan Transisi Karir"); vtm.setTemplatePath("email_career_transition_waiting_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("beforeNik", jsonObject.get("beforeNik").getAsString()); maptoSend.put("beforeJoinDate", jsonObject.get("beforeJoinDate").getAsString()); maptoSend.put("beforeEmployeeType", jsonObject.get("beforeEmployeeType").getAsString()); maptoSend.put("beforeJabatan", jsonObject.get("beforeJabatan").getAsString()); maptoSend.put("beforeDepartment", jsonObject.get("beforeDepartment").getAsString()); maptoSend.put("afterNik", jsonObject.get("afterNik").getAsString()); maptoSend.put("afterJoinDate", jsonObject.get("afterJoinDate").getAsString()); maptoSend.put("afterEmployeeType", jsonObject.get("afterEmployeeType").getAsString()); maptoSend.put("afterJabatan", jsonObject.get("afterJabatan").getAsString()); maptoSend.put("afterDepartment", jsonObject.get("afterDepartment").getAsString()); break; default: break; } } else if ((appActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_APPROVED) || (appActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_REJECTED)) { //configure email parameter based on approval name switch (appActivity.getApprovalDefinition().getName()) { case HRMConstant.VACANCY_ADVERTISEMENT: List<VacancyAdvertisementDetailModel> listAdvertisementDetail = gsonDateSerializer.fromJson( jsonObject.get("listAdvertisementDetail").getAsString(), new TypeToken<List<VacancyAdvertisementDetailModel>>() { }.getType()); vtm.setSubject("Pengajuan Iklan Lowongan"); vtm.setTemplatePath("email_vacancy_advertisement_approved_or_rejected.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("effectiveDate", jsonObject.get("effectiveDate").getAsString()); maptoSend.put("advertisementMediaName", jsonObject.get("advertisementMediaName").getAsString()); maptoSend.put("applyDate", jsonObject.get("applyDate").getAsString()); maptoSend.put("listAdvertisementDetail", listAdvertisementDetail); maptoSend.put("dateTool", new DateTool()); maptoSend.put("numTool", new NumberTool()); maptoSend.put("locale", new Locale(locale)); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.EMP_CORRECTION_ATTENDANCE: List<WtEmpCorrectionAttendanceDetail> listCorrectionAttendance = gsonDateSerializer .fromJson(jsonObject.get("listCorrectionAttendance").getAsString(), new TypeToken<List<WtEmpCorrectionAttendanceDetail>>() { }.getType()); vtm.setSubject("Pengajuan Koreksi Kehadiran"); vtm.setTemplatePath("email_correction_attendance_approved_or_rejected.vm"); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("startDate", jsonObject.get("startDate").getAsString()); maptoSend.put("endDate", jsonObject.get("endDate").getAsString()); maptoSend.put("applyDate", jsonObject.get("applyDate").getAsString()); maptoSend.put("listCorrectionAttendance", listCorrectionAttendance); maptoSend.put("dateTool", new DateTool()); maptoSend.put("locale", new Locale(locale)); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.BUSINESS_TRAVEL: vtm.setSubject("Permohonan Perjalanan Dinas"); vtm.setTemplatePath("email_travel_approved_or_rejected_approval.vm"); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("businessTravelNo", jsonObject.get("businessTravelNo").getAsString()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("destination", jsonObject.get("destination").getAsString()); maptoSend.put("start", jsonObject.get("startDate").getAsString()); maptoSend.put("end", jsonObject.get("endDate").getAsString()); maptoSend.put("description", jsonObject.get("description").getAsString()); maptoSend.put("totalAmount", jsonObject.get("totalAmount").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.REIMBURSEMENT: vtm.setSubject("Permohonan Pergantian Biaya"); vtm.setTemplatePath("email_reimbursment_approved_or_rejected.vm"); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("reimbursementType", jsonObject.get("reimbursementType").getAsString()); maptoSend.put("applicationDate", jsonObject.get("applicationDate").getAsString()); maptoSend.put("nominal", jsonObject.get("nominal").getAsString()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.REIMBURSEMENT_DISBURSEMENT: vtm.setSubject("Permohonan Pencairan Pergantian Biaya"); vtm.setTemplatePath("email_rmbs_disbursement_approved_or_rejected.vm"); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.LOAN: vtm.setSubject("Permohonan Pinjaman Lunak"); vtm.setTemplatePath("email_loan_approved_or_rejected_approval.vm"); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("loanSchemaName", jsonObject.get("loanSchemaName").getAsString()); maptoSend.put("nominalPrincipal", jsonObject.get("nominalPrincipal").getAsString()); maptoSend.put("interestRate", jsonObject.get("interestRate").getAsString()); maptoSend.put("nominalInstallment", jsonObject.get("nominalInstallment").getAsString()); maptoSend.put("interestInstallment", jsonObject.get("interestInstallment").getAsString()); maptoSend.put("totalNominalInstallment", jsonObject.get("totalNominalInstallment").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.SHIFT_SCHEDULE: vtm.setSubject("Permohonan Perubahan Jadwal Kerja Karyawan"); vtm.setTemplatePath("email_shift_schedule_approved_or_rejected_approval.vm"); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.LEAVE: vtm.setSubject("Permohonan Cuti"); vtm.setTemplatePath("email_leave_approved_or_rejected_approval.vm"); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("leaveName", jsonObject.get("leaveName").getAsString()); maptoSend.put("startDate", jsonObject.get("startDate").getAsString()); maptoSend.put("endDate", jsonObject.get("endDate").getAsString()); maptoSend.put("fillingDate", jsonObject.get("fillingDate").getAsString()); maptoSend.put("materialJobsAbandoned", jsonObject.get("materialJobsAbandoned").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.LEAVE_CANCELLATION: vtm.setSubject("Permohonan Pembatalan Cuti"); vtm.setTemplatePath("email_leave_cancellation_approved_or_rejected_approval.vm"); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("leaveName", jsonObject.get("leaveName").getAsString()); maptoSend.put("startDate", jsonObject.get("startDate").getAsString()); maptoSend.put("endDate", jsonObject.get("endDate").getAsString()); maptoSend.put("fillingDate", jsonObject.get("fillingDate").getAsString()); maptoSend.put("materialJobsAbandoned", jsonObject.get("materialJobsAbandoned").getAsString()); maptoSend.put("cancellationDate", jsonObject.get("cancellationDate").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.OVERTIME: vtm.setSubject("Permohonan Lembur"); vtm.setTemplatePath("email_overtime_approved_or_rejected_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("overTimeName", jsonObject.get("overTimeName").getAsString()); maptoSend.put("hour", jsonObject.get("hour").getAsString()); maptoSend.put("minute", jsonObject.get("minute").getAsString()); maptoSend.put("overTimeDate", jsonObject.get("overTimeDate").getAsString()); maptoSend.put("implementationNumber", jsonObject.get("implementationNumber").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.ANNOUNCEMENT: TypeToken<List<String>> token = new TypeToken<List<String>>() { }; List<String> dataGolonganJabatan = gson.fromJson(jsonObject.get("listGolonganJabatan"), token.getType()); List<String> dataUnitKerja = gson.fromJson(jsonObject.get("listUnitKerja"), token.getType()); List<String> dataEmployeeType = gson.fromJson(jsonObject.get("listEmployeeType"), token.getType()); vtm.setSubject("Pengajuan Pengumuman"); vtm.setTemplatePath("email_announcement_approved_or_rejected_approval.vm"); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); maptoSend.put("subjek", jsonObject.get("subjek").getAsString()); maptoSend.put("content", jsonObject.get("content").getAsString()); maptoSend.put("company", jsonObject.get("company").getAsString()); maptoSend.put("listEmployeeType", dataEmployeeType); maptoSend.put("listUnitKerja", dataUnitKerja); maptoSend.put("listGolonganJabatan", dataGolonganJabatan); break; case HRMConstant.PERMIT: vtm.setSubject("Permohonan Izin"); vtm.setTemplatePath("email_permit_approved_and_rejected_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("startDate", jsonObject.get("startDate").getAsString()); maptoSend.put("endDate", jsonObject.get("endDate").getAsString()); maptoSend.put("permitClassification", jsonObject.get("permitClassification").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.RECRUITMENT_REQUEST: vtm.setSubject("PERSETUJUAN PERMINTAAN TENAGA KERJA"); vtm.setTemplatePath("email_recruitment_request_approved_or_reject_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("periodeStart", jsonObject.get("periodeStart").getAsString()); maptoSend.put("periodeEnd", jsonObject.get("periodeEnd").getAsString()); maptoSend.put("jabatan", jsonObject.get("jabatan").getAsString()); maptoSend.put("mppName", jsonObject.get("mppName").getAsString()); maptoSend.put("salaryMin", jsonObject.get("salaryMin").getAsString()); maptoSend.put("salaryMax", jsonObject.get("salaryMax").getAsString()); maptoSend.put("candidateCountRequest", jsonObject.get("candidateCountRequest").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.RECRUIT_MPP_APPLY: TypeToken<List<String>> tokens = new TypeToken<List<String>>() { }; List<String> listNamaJabatan = gson.fromJson(jsonObject.get("listNamaJabatan"), tokens.getType()); vtm.setSubject("PERSETUJUAN RENCANA KETENAGAKERJAAN"); vtm.setTemplatePath("email_mpp_apply_approved_or_rejected_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("recruitMppApplyName", jsonObject.get("recruitMppApplyName").getAsString()); maptoSend.put("applyDate", jsonObject.get("applyDate").getAsString()); maptoSend.put("startDate", jsonObject.get("startDate").getAsString()); maptoSend.put("endDate", jsonObject.get("endDate").getAsString()); maptoSend.put("listNamaJabatan", listNamaJabatan); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.EMPLOYEE_CAREER_TRANSITION: vtm.setSubject("Pengajuan Transisi Karir"); if (appActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_APPROVED) { vtm.setTemplatePath("email_career_transition_approved.vm"); maptoSend.put("employeeName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("effectiveDate", jsonObject.get("effectiveDate").getAsString()); maptoSend.put("beforeNik", jsonObject.get("beforeNik").getAsString()); maptoSend.put("beforeJoinDate", jsonObject.get("beforeJoinDate").getAsString()); maptoSend.put("beforeEmployeeType", jsonObject.get("beforeEmployeeType").getAsString()); maptoSend.put("beforeJabatan", jsonObject.get("beforeJabatan").getAsString()); maptoSend.put("beforeDepartment", jsonObject.get("beforeDepartment").getAsString()); maptoSend.put("afterNik", jsonObject.get("afterNik").getAsString()); maptoSend.put("afterJoinDate", jsonObject.get("afterJoinDate").getAsString()); maptoSend.put("afterEmployeeType", jsonObject.get("afterEmployeeType").getAsString()); maptoSend.put("afterJabatan", jsonObject.get("afterJabatan").getAsString()); maptoSend.put("afterDepartment", jsonObject.get("afterDepartment").getAsString()); } else { vtm.setTemplatePath("email_career_transition_rejected.vm"); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("beforeNik", jsonObject.get("beforeNik").getAsString()); maptoSend.put("beforeJoinDate", jsonObject.get("beforeJoinDate").getAsString()); maptoSend.put("beforeEmployeeType", jsonObject.get("beforeEmployeeType").getAsString()); maptoSend.put("beforeJabatan", jsonObject.get("beforeJabatan").getAsString()); maptoSend.put("beforeDepartment", jsonObject.get("beforeDepartment").getAsString()); maptoSend.put("afterNik", jsonObject.get("afterNik").getAsString()); maptoSend.put("afterJoinDate", jsonObject.get("afterJoinDate").getAsString()); maptoSend.put("afterEmployeeType", jsonObject.get("afterEmployeeType").getAsString()); maptoSend.put("afterJabatan", jsonObject.get("afterJabatan").getAsString()); maptoSend.put("afterDepartment", jsonObject.get("afterDepartment").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); } break; default: break; } } else if ((appActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_CANCELLED)) { //configure email parameter based on approval name switch (appActivity.getApprovalDefinition().getName()) { case HRMConstant.BUSINESS_TRAVEL: vtm.setSubject("Permohonan Perjalanan Dinas"); vtm.setTemplatePath("email_travel_cancelled_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("businessTravelNo", jsonObject.get("businessTravelNo").getAsString()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("destination", jsonObject.get("destination").getAsString()); maptoSend.put("start", jsonObject.get("startDate").getAsString()); maptoSend.put("end", jsonObject.get("endDate").getAsString()); maptoSend.put("description", jsonObject.get("description").getAsString()); maptoSend.put("totalAmount", jsonObject.get("totalAmount").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.REIMBURSEMENT: vtm.setSubject("Permohonan Pergantian Biaya"); vtm.setTemplatePath("email_reimbursment_cancelled.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("reimbursementType", jsonObject.get("reimbursementType").getAsString()); maptoSend.put("applicationDate", jsonObject.get("applicationDate").getAsString()); maptoSend.put("nominal", jsonObject.get("nominal").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.LOAN: vtm.setSubject("Permohonan Pinjaman Lunak"); vtm.setTemplatePath("email_loan_cancelled_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("loanSchemaName", jsonObject.get("loanSchemaName").getAsString()); maptoSend.put("nominalPrincipal", jsonObject.get("nominalPrincipal").getAsString()); maptoSend.put("interestRate", jsonObject.get("interestRate").getAsString()); maptoSend.put("nominalInstallment", jsonObject.get("nominalInstallment").getAsString()); maptoSend.put("interestInstallment", jsonObject.get("interestInstallment").getAsString()); maptoSend.put("totalNominalInstallment", jsonObject.get("totalNominalInstallment").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.SHIFT_SCHEDULE: vtm.setSubject("Permohonan Perubahan Jadwal Kerja Karyawan"); vtm.setTemplatePath("email_shift_schedule_cancelled_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.LEAVE: vtm.setSubject("Permohonan Cuti"); vtm.setTemplatePath("email_leave_cancelled_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("leaveName", jsonObject.get("leaveName").getAsString()); maptoSend.put("startDate", jsonObject.get("startDate").getAsString()); maptoSend.put("endDate", jsonObject.get("endDate").getAsString()); maptoSend.put("fillingDate", jsonObject.get("fillingDate").getAsString()); maptoSend.put("materialJobsAbandoned", jsonObject.get("materialJobsAbandoned").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; case HRMConstant.OVERTIME: vtm.setSubject("Permohonan Lembur"); vtm.setTemplatePath("email_overtime_cancelled_approval.vm"); maptoSend.put("approverName", approverUser.getEmpData().getBioData().getFullName()); maptoSend.put("requesterName", requesterUser.getEmpData().getBioData().getFullName()); maptoSend.put("nik", requesterUser.getEmpData().getNik()); maptoSend.put("proposeDate", jsonObject.get("proposeDate").getAsString()); maptoSend.put("overTimeName", jsonObject.get("overTimeName").getAsString()); maptoSend.put("hour", jsonObject.get("hour").getAsString()); maptoSend.put("minute", jsonObject.get("minute").getAsString()); maptoSend.put("overTimeDate", jsonObject.get("overTimeDate").getAsString()); maptoSend.put("implementationNumber", jsonObject.get("implementationNumber").getAsString()); maptoSend.put("statusDesc", getStatusDesc(appActivity.getApprovalStatus(), locale)); break; default: break; } } if (jsonObject.get("urlLinkToApprove").getAsString() != null) { String urlLinkToApprove = serverName + "" + jsonObject.get("urlLinkToApprove").getAsString(); maptoSend.put("urlLinkToApprove", urlLinkToApprove); } else { maptoSend.put("urlLinkToApprove", applicationUrl); } maptoSend.put("ownerAdministrator", ownerAdministrator); maptoSend.put("ownerCompany", ownerCompany); maptoSend.put("applicationUrl", applicationUrl); maptoSend.put("applicationName", applicationName); velocityTemplateSender.sendMail(vtm, maptoSend); //update approval activity, set notification true if (appActivity.getNotificationSend() == false) { appActivity.setNotificationSend(true); this.approvalActivityDao.update(appActivity); } } } catch (Exception ex) { LOGGER.error("Error", ex); } }
From source file:com.intellij.tasks.jira.JiraUtil.java
License:Apache License
private static Gson buildGson() { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapter(Date.class, new DateDeserializer()); return gson.create(); }