Skip to content
Snippets Groups Projects
Commit 854d0553 authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

Code formatting corrections

parent c5531b1c
No related branches found
No related tags found
No related merge requests found
Showing
with 66 additions and 202 deletions
......@@ -135,7 +135,7 @@ for (let i = 0, l = allNames.length; i < l; i++)
var nameCache = {};
var res = _buildAttributeTable(attributes, usages);
logging.log(JSON.stringify(res));
result.object(res);
//sorts the records in a way that a tree can be built and adds values
......
......@@ -4,13 +4,14 @@ import("KeywordRegistry_basic");
import("system.neon");
var status = vars.get("$field.STATUS");
var fieldState = neon.COMPONENTSTATE_INVISIBLE;
if (status == $KeywordRegistry.bulkMailStatus$planned() ){
fieldState = neon.COMPONENTSTATE_EDITABLE
if (status == $KeywordRegistry.bulkMailStatus$planned())
{
fieldState = neon.COMPONENTSTATE_EDITABLE;
}
if (status == $KeywordRegistry.bulkMailStatus$missed()){
else if (status == $KeywordRegistry.bulkMailStatus$missed())
{
fieldState = neon.COMPONENTSTATE_READONLY;
}
......
import("system.logging");
import("system.vars");
import("Keyword_lib");
import("system.result");
logging.log(vars.get("$field.TAG"));
logging.log(KeywordUtils.getViewValue('LinkTags', vars.get("$field.TAG")));
result.string(KeywordUtils.getViewValue('LinkTags', vars.get("$field.TAG")))
\ No newline at end of file
result.string(KeywordUtils.getViewValue("LinkTags", vars.get("$field.TAG")));
\ No newline at end of file
......@@ -4,6 +4,7 @@ import("Placeholder_lib");
var placeholder = vars.get("$field.PLACEHOLDER");
if (placeholder){
if (placeholder)
{
result.string(PlaceholderUtils.formatPlaceholder(placeholder));
}
\ No newline at end of file
......@@ -3,17 +3,21 @@ import("system.vars");
import("Placeholder_lib");
import("Sql_lib");
if (vars.get("$local.value")){
if (vars.get("$local.value"))
{
var defaultPlaceholders = PlaceholderUtils.getPlaceholders();
var linkPlaceholders = newSelect("LINK.PLACEHOLDER")
.from("LINK")
.where("LINK.LINKID",vars.get("$field.LINKID"),SqlBuilder.NOT_EQUAL())
.and("LINK.PLACEHOLDER is not null").arrayColumn();
.from("LINK")
.where("LINK.LINKID", vars.get("$field.LINKID"), SqlBuilder.NOT_EQUAL())
.and("LINK.PLACEHOLDER is not null")
.arrayColumn();
if (defaultPlaceholders.map(function(a){
return a.placeholderName
}).indexOf(vars.get("$local.value"))!= -1 || linkPlaceholders.indexOf(vars.get("$local.value"))!= -1){
if (defaultPlaceholders.map(function(a)
{
return a.placeholderName
}).indexOf(vars.get("$local.value"))!= -1 || linkPlaceholders.indexOf(vars.get("$local.value"))!= -1)
{
result.string("Placeholders must be unique")
}
......
......@@ -5,8 +5,11 @@ import("system.neon");
var linktype = vars.get("$field.LINKTYPE");
if(linktype == $KeywordRegistry.linkType$EMail()){
if (linktype == $KeywordRegistry.linkType$EMail())
{
result.string(neon.COMPONENTSTATE_EDITABLE);
}else{
}
else
{
result.string(neon.COMPONENTSTATE_INVISIBLE);
}
\ No newline at end of file
......@@ -4,12 +4,13 @@ import("system.neon");
import("system.vars");
import("Sql_lib");
if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW && vars.get("$local.value"))
if (vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW && vars.get("$local.value"))
{
if(newSelect("URL").from("LINK").where("LINK.URL", vars.get("$local.value")).cell())
if (newSelect("URL").from("LINK").where("LINK.URL", vars.get("$local.value")).cell())
result.string(translate.text("Die Url muss eindeutig sein!"))
if(vars.get("$field.REDIRECT") == "1" && !/^(?:http(s)?:\/\/)[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/g.test(vars.get("$local.value"))){
if (vars.get("$field.REDIRECT") == "1" && !/^(?:http(s)?:\/\/)[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/g.test(vars.get("$local.value")))
{
result.string(translate.text("Redirect needs a full Url with http/https"));
}
}
......
......@@ -6,10 +6,13 @@ import("system.neon");
var linktype = vars.get("$field.LINKTYPE");
var redirect = vars.get("$field.REDIRECT");
if(linktype == $KeywordRegistry.linkType$EMail() && redirect == "1"){
if (linktype == $KeywordRegistry.linkType$EMail() && redirect == "1")
{
result.string(neon.COMPONENTSTATE_EDITABLE);
}else{
}
else
{
result.string(neon.COMPONENTSTATE_INVISIBLE);
}
\ No newline at end of file
......@@ -95,17 +95,10 @@ BulkMailUtils.sendBulkMail = function (pBulkMailId, pIsTestRun)
.addParameter("BulkMailId_param", pBulkMailId)
.addParameter("IsTestMail_param", pIsTestRun);
var recipientData = entities.getRows(recipientLoadConfig);
recipientData = entities.getRows(recipientLoadConfig);
if (pIsTestRun)
{
recipientData = newSelect("BULKMAILRECIPIENTID, BULKMAILRECIPIENT.CONTACT_ID, BULKMAILRECIPIENT.EMAIL_ADDRESS, PERSON_ID, ORGANISATION_ID")
.from("CONTACT")
.join("BULKMAILRECIPIENT", "BULKMAILRECIPIENT.CONTACT_ID = CONTACT.CONTACTID")
.where("BULKMAILRECIPIENT.BULKMAIL_ID", pBulkMailId)
.and("BULKMAILRECIPIENT.TEST_RECIPIENT",1)
.table();
testRecipientData = newSelect("BULKMAILTESTRECIPIENT.CONTACT_ID, BULKMAILTESTRECIPIENT.EMAIL_ADDRESS")
.from("BULKMAILTESTRECIPIENT")
.where("BULKMAILTESTRECIPIENT.BULKMAIL_ID", pBulkMailId)
......@@ -223,7 +216,8 @@ BulkMailUtils.sendBulkMail = function (pBulkMailId, pIsTestRun)
{
email.sender = emailSender;
email.subject = "Test: "+subjects[contactId];
for (let j =0; j<testRecipientData.length;j++){
for (let j =0; j<testRecipientData.length;j++)
{
if(testRecipientData[j][1]){
email.toRecipients = [testRecipientData[j][1]];
isSuccess = email.send();
......@@ -509,7 +503,8 @@ BulkMailUtils.copy = function(pBulkMailId)
* @param {String} pMailLogId <p>
* The id of the corresponding mail log entry.<br>
**/
BulkMailUtils.storeEmlFile = function(pBulkMailId,pMailRunId, pMailLogId,pFile){
BulkMailUtils.storeEmlFile = function(pBulkMailId,pMailRunId, pMailLogId,pFile)
{
var locationoption = project.getPreferenceValue("bulkmail.fileStorage","/bulkMailFiles/");
var path = vars.get("$sys.serverdata")+locationoption +pBulkMailId+"/"+pMailRunId+"/";
var filename = pMailLogId+".eml"
......@@ -529,7 +524,8 @@ BulkMailUtils.storeEmlFile = function(pBulkMailId,pMailRunId, pMailLogId,pFile){
* @return {String} <p>
* The file as base64 String<br>
**/
BulkMailUtils.getEmlFile = function(pBulkMailId,pMailRunId, pMailLogId){
BulkMailUtils.getEmlFile = function(pBulkMailId,pMailRunId, pMailLogId)
{
var locationoption = project.getPreferenceValue("bulkmail.fileStorage","/bulkMailFiles/");
var path = vars.get("$sys.serverdata")+locationoption +pBulkMailId+"/"+pMailRunId+"/";
var filename = pMailLogId+".eml"
......@@ -546,9 +542,11 @@ BulkMailUtils.getEmlFile = function(pBulkMailId,pMailRunId, pMailLogId){
* @return {String} <p>
* The url<br>
**/
BulkMailUtils.getRedirectLink = function(pLinkId){
BulkMailUtils.getRedirectLink = function(pLinkId)
{
var url ;
if (pLinkId){
if (pLinkId)
{
url =newSelect("LINK.URL").from("LINK").where("LINK.LINKID", pLinkId).cell();
}
return url;
......@@ -572,8 +570,10 @@ BulkMailUtils.getRedirectLink = function(pLinkId){
* The device type that was used to open the link.<br>
**/
BulkMailUtils.insertClick = function(pMailLogId,pIpAddress,pLinkId,pBrowsername,pOperatingSystemName,pDeviceType){
if (!pMailLogId || !pLinkId) {
BulkMailUtils.insertClick = function(pMailLogId,pIpAddress,pLinkId,pBrowsername,pOperatingSystemName,pDeviceType)
{
if (!pMailLogId || !pLinkId)
{
return
}
......@@ -594,7 +594,8 @@ BulkMailUtils.insertClick = function(pMailLogId,pIpAddress,pLinkId,pBrowsername,
*
**/
BulkMailUtils.getIpAddressFromHeader = function(pHttpHeader){
BulkMailUtils.getIpAddressFromHeader = function(pHttpHeader)
{
var ipAddress;
......@@ -603,12 +604,15 @@ BulkMailUtils.getIpAddressFromHeader = function(pHttpHeader){
return ipAddress;
}
BulkMailUtils.startBulkmailWorkFlow = function(pMailLogId,pLinkId){
if (!pMailLogId || !pLinkId) {
BulkMailUtils.startBulkmailWorkFlow = function(pMailLogId,pLinkId)
{
if (!pMailLogId || !pLinkId)
{
return
}
var workFlowKey = newSelect("WORKFLOWPROCESSDEFINITION_KEY").from("LINK").where("LINK.LINKID",pLinkId).cell();
if (workFlowKey){
if (workFlowKey)
{
var variables = {
"MAILLOGID": pMailLogId
};
......
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.2" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.2">
<name>gitLabWebhook_rest</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/gitLabWebhook_rest/process.js</process>
<publishAsWebservice v="true" />
<style>REST</style>
<restAcceptedMimeType>application/json</restAcceptedMimeType>
<restDeliveredMimeType>application/json</restDeliveredMimeType>
<loginTypeId>
<element>internal.none</element>
</loginTypeId>
<variants>
<element>EXECUTABLE</element>
</variants>
</process>
import("system.auth");
import("system.net");
import("system.util");
import("system.logging");
function restpost (pRequest)
{
var config = {
active: true,
gitlabToken: "youtube.com/watch?v=dQw4w9WgXcQ",
teamsUrl: "https://aditosoftware.webhook.office.com/webhookb2/85493214-0e4b-4577-8fc4-0e421a2dc196@c7308693-318b-4725-9e59-73b455c6ae05/IncomingWebhook/66a53e7f47c040eda146b372c742169b/70528b00-bbf1-45e2-9925-0cc55ff8951b",
push: {
active: true,
targetBranchRegExp: null
},
mergeRequest: {
active: true,
onlyUnassigned: true,
excludeWIP: true,
priorityLabels: ["critical"]
},
tag: {
active: true
}
};
logging.log(pRequest);
var request = JSON.parse(pRequest);
var secretToken = request.header["X-Gitlab-Token"] || request.header["X-gitlab-token"];
if (secretToken != config.gitlabToken)
{
request.response.httpStatusCode = 403;
return JSON.stringify(request);
}
var body = JSON.parse(util.decodeBase64String(request.body));
var teamsMessage = _getMessage(body, config);
if (teamsMessage)
{
var authConfig = auth.createConfigForNoAuth();
var restConfig = net.createConfigForRestWebserviceCall()
.actionType(net.POST)
.url(config.teamsUrl)
.dataTypeSend("application/json")
.dataTypeJDitoSend(util.DATA_TEXT)
.requestEntity(JSON.stringify(teamsMessage));
logging.log(JSON.stringify(teamsMessage))
net.callRestWebservice(restConfig, authConfig);
}
request.response.httpStatusCode = 200;
return JSON.stringify(request);
function _getMessage (pEvent, pConfig)
{
if (!pConfig.active)
return null;
var message = {
"@context": "https://schema.org/extensions",
"@type": "MessageCard",
"title": "Merged branch whatever into whatever",
"text": "-link- merged by That Guy",
"sections": [{
"activityTitle": "420 commits added"
}]
};
if (pEvent.object_kind == "push")
return _getPushMessage(pEvent, pConfig.push);
if (pEvent.object_kind == "merge_request")
return _getMergeRequestMessage(pEvent, pConfig.mergeRequest);
if (pEvent.object_kind == "tag_push")
return _getTagMessage(pEvent, pConfig.tag);
return null;
function _getPushMessage (pEvent, pConfig)
{
if (!pConfig.active)
return null;
return null;
}
function _getMergeRequestMessage (pEvent, pConfig)
{
if (!pConfig.active || pEvent.object_attributes.action != "open")
return null;
var info = pEvent.object_attributes;
var labels = pEvent.labels.map(function (label)
{
return label.title;
});
var isCritical = pConfig.priorityLabels.some(function (prioLabel) {return labels.includes(prioLabel);});
var isUnassigned = !pEvent.assignees || pEvent.assignees.length === 0;
var isMessageRequired = isCritical
|| ((!pConfig.onlyUnassigned || isUnassigned)
&& (!pConfig.excludeWIP || !info.work_in_progress))
if (!isMessageRequired)
return null;
var objectTitle = "Merge Request";
if (isCritical)
objectTitle = "Critical Merge Request";
else if (isUnassigned)
objectTitle = "Unassigned Merge Request";
var title = objectTitle + " opened by " + pEvent.user.name;
var message = {
"@context": "https://schema.org/extensions",
"@type": "MessageCard",
"summary": title,
"sections": [{
"activityTitle": title + " in <a href=\"" + pEvent.project.web_url + "\">" + pEvent.project.path_with_namespace + "</a>",
"activitySubtitle": "<a href=\"" + info.url + "\">!" + info.iid + "</a> " + info.title
+ " | Request to merge " + info.source_branch + " into " + info.target_branch
}]
};
if (isCritical)
message.themeColor = "F00420";
return message;
}
function _getTagMessage (pEvent, pConfig)
{
if (!pConfig.active)
return null;
return null;
}
}
}
......@@ -9,15 +9,15 @@ import("system.SQLTYPES");
var dateToSendPassedAfter = project.getInstanceConfigValue("bulkmail.dateToSendPassedAfter" , 24);
//send all Bulkmails which are currently planned and not already missed.
var bulkMailData = newSelect("BULKMAIL.BULKMAILID")
.from("BULKMAIL")
.where("BULKMAIL.STATUS",$KeywordRegistry.bulkMailStatus$planned())
.and("BULKMAIL.DATE_TO_SEND", datetime.date(), SqlBuilder.LESS_OR_EQUAL())
.and("BULKMAIL.DATE_TO_SEND",eMath.subInt(datetime.date(), eMath.mulInt(dateToSendPassedAfter, datetime.ONE_HOUR)), SqlBuilder.GREATER())
.arrayColumn();
for (let i = 0; i < bulkMailData.length; i++){
.from("BULKMAIL")
.where("BULKMAIL.STATUS",$KeywordRegistry.bulkMailStatus$planned())
.and("BULKMAIL.DATE_TO_SEND", datetime.date(), SqlBuilder.LESS_OR_EQUAL())
.and("BULKMAIL.DATE_TO_SEND",eMath.subInt(datetime.date(), eMath.mulInt(dateToSendPassedAfter, datetime.ONE_HOUR)), SqlBuilder.GREATER())
.arrayColumn();
for (let i = 0; i < bulkMailData.length; i++)
{
newWhere("BULKMAIL.BULKMAILID", bulkMailData[i])
.updateFields({"STATUS" : $KeywordRegistry.bulkMailStatus$beingSent()});
......@@ -26,5 +26,5 @@ for (let i = 0; i < bulkMailData.length; i++){
//set all missed bulkmails to status missed
newWhere("BULKMAIL.STATUS",$KeywordRegistry.bulkMailStatus$planned())
.and("BULKMAIL.DATE_TO_SEND",eMath.subInt(datetime.date(), eMath.mulInt(dateToSendPassedAfter, datetime.ONE_HOUR)), SqlBuilder.LESS_OR_EQUAL())
.updateFields({"STATUS" : $KeywordRegistry.bulkMailStatus$missed()});
\ No newline at end of file
.and("BULKMAIL.DATE_TO_SEND",eMath.subInt(datetime.date(), eMath.mulInt(dateToSendPassedAfter, datetime.ONE_HOUR)), SqlBuilder.LESS_OR_EQUAL())
.updateFields({"STATUS" : $KeywordRegistry.bulkMailStatus$missed()});
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment