Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ADITO_Update_Upgrade
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Gitlab Maintenance 11.04.2025 | 20:00 - 23:00 MEZ
Show more breadcrumbs
xrm
ADITO_Update_Upgrade
Commits
349752b4
Commit
349752b4
authored
6 years ago
by
Andre Loreth
Browse files
Options
Downloads
Patches
Plain Diff
#1035782: Context_lib: updated selectMap
parent
a9d41ef2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
process/Context_lib/process.js
+107
-38
107 additions, 38 deletions
process/Context_lib/process.js
with
107 additions
and
38 deletions
process/Context_lib/process.js
+
107
−
38
View file @
349752b4
...
...
@@ -2,24 +2,25 @@ import("system.translate");
import
(
"
system.project
"
);
import
(
"
system.vars
"
);
import
(
"
system.SQLTYPES
"
);
import
(
"
Keyword_lib
"
);
import
(
"
Sql_lib
"
);
import
(
"
Contact_lib
"
);
/**
* Methods to manage contexts.
* Do not create an instance of this!
*
*
* @class
*/
function
ContextUtils
()
{}
/**
* Get the id of the current context
* TODO: use a UUID of the current context which doesn't change
*
*
* @return {String} Id of the current context
*/
ContextUtils
.
getCurrentContextId
=
function
()
ContextUtils
.
getCurrentContextId
=
function
()
{
return
vars
.
getString
(
"
$sys.currentcontextname
"
);
}
...
...
@@ -27,40 +28,40 @@ ContextUtils.getCurrentContextId = function()
/**
* TODO: use System function. Currently the Name is also the id.
* Returns the Name of a context by the Id
*
*
* @param {String} pContextId the id of a context
* @return {String} Name of the current context
*/
ContextUtils
.
getContextName
=
function
(
pContextId
)
ContextUtils
.
getContextName
=
function
(
pContextId
)
{
// TODO: currently the Id is the context name. This will be changed maybe
return
pContextId
;
}
/**
*
*
* @param {Boolean} [pFilter=false] filter only for contexts which have a mapping in ContextUtils._getSelectMap
*
*
* @return {String[][]} the contexts [[contextId, contextName, contextTitle], [... ], ...]
*/
ContextUtils
.
getContexts
=
function
(
pFilter
)
{
if
(
pFilter
==
undefined
)
if
(
pFilter
==
undefined
)
pFilter
=
false
;
var
contexts
=
project
.
getDataModels
(
project
.
DATAMODEL_KIND_CONTEXT
);
if
(
pFilter
)
{
contexts
=
contexts
.
filter
(
function
(
pContext
)
contexts
=
contexts
.
filter
(
function
(
pContext
)
{
// filter only contexts which have defined mappings in Context_lib
return
ContextUtils
.
_getSelectMap
()[
pContext
[
0
]]
!=
undefined
;
});
}
return
contexts
.
map
(
ContextUtils
.
_contextDataMapping
).
sort
(
function
(
pContext1
,
pContext2
)
return
contexts
.
map
(
ContextUtils
.
_contextDataMapping
).
sort
(
function
(
pContext1
,
pContext2
)
{
// sort after ContextTitle
if
(
pContext1
[
2
]
>
pContext2
[
2
])
...
...
@@ -75,9 +76,9 @@ ContextUtils.getContexts = function(pFilter)
/**
* get the data of a context
*
*
* @param {String} pContextId the id of the context
*
*
* @return {String[]} the contextdata [contextId, contextName, contextTitle]
*/
ContextUtils
.
getContext
=
function
(
pContextId
)
...
...
@@ -87,9 +88,9 @@ ContextUtils.getContext = function(pContextId)
/**
* map the contextData from the system.project-lib to [contextId, contextName, contextTitle]
*
*
* @param {String[]} pContext the data of a context (e.g. from project.getDataModel())
*
*
* @return {String[]} the contextdata [contextId, contextName, contextTitle]
* @ignore
*/
...
...
@@ -107,19 +108,87 @@ ContextUtils._getSelectMap = function()
{
var
maskingUtils
=
new
SqlMaskingUtils
();
return
{
// contextId nameField Tablename (or from-part inc, joins), IDField, RelationField, override Tablename (needed if Tablename is a join clause)
"
Organisation
"
:
[
"
\"
NAME
\"
"
,
"
ORGANISATION
"
,
"
ORGANISATIONID
"
,
""
],
"
Person
"
:
[(
new
ContactTitleRenderer
(
Contact
.
createWithColumnPreset
()).
asSql
()),
"
PERSON join CONTACT on PERSON.PERSONID = CONTACT.PERSON_ID join ORGANISATION on ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID
"
,
"
CONTACTID
"
,
""
,
"
CONTACT
"
],
"
Activity
"
:
[
"
SUBJECT
"
,
"
ACTIVITY
"
,
"
ACTIVITYID
"
,
""
],
"
Salesproject
"
:
[
maskingUtils
.
concat
([
maskingUtils
.
cast
(
"
PROJECTCODE
"
,
SQLTYPES
.
VARCHAR
,
10
),
"
':'
"
,
"
PROJECTTITLE
"
]),
"
SALESPROJECT
"
,
"
SALESPROJECTID
"
,
"
CONTACT_ID
"
],
// TODO: keywords sind noch nicht in der DB somit gibt es nichts ähnliches zu getKeySQL.
// maskingUtils.concat([SqlMaskingUtils.cast("CONTRACTCODE", "varchar", 10), getKeySQL("CONTRACTTYPE", "CONTRACTTYPE" )])
"
Contract
"
:
[
maskingUtils
.
cast
(
"
CONTRACTCODE
"
,
SQLTYPES
.
VARCHAR
,
10
),
"
CONTRACT
"
,
"
CONTRACTID
"
,
"
CONTACT_ID
"
],
// "Appointment": ["SUMMARY", "ASYS_CALENDARBACKEND", "UID"]
"
Offer
"
:
[
maskingUtils
.
cast
(
"
OFFERCODE
"
,
SQLTYPES
.
VARCHAR
,
10
),
"
OFFER
"
,
"
OFFERID
"
,
"
CONTACT_ID
"
],
"
Order
"
:
[
maskingUtils
.
cast
(
"
SALESORDERCODE
"
,
SQLTYPES
.
VARCHAR
,
10
),
"
SALESORDER
"
,
"
SALESORDERID
"
,
"
CONTACT_ID
"
],
"
Product
"
:
[
"
PRODUCTNAME
"
,
"
PRODUCT
"
,
"
PRODUCTID
"
,
""
],
"
Task
"
:
[
"
SUBJECT
"
,
"
TASK
"
,
"
TASKID
"
,
translate
.
text
(
"
Task
"
),
""
]
// contextId nameField Tablename (or from-part inc, joins), IDField, RelationField, override Tablename (needed if Tablename is a join clause)
// "Appointment": ["SUMMARY", "ASYS_CALENDARBACKEND", "UID"]
"
Organisation
"
:
[
"
\"
NAME
\"
"
,
"
ORGANISATION
"
,
"
ORGANISATIONID
"
,
""
],
"
Person
"
:
[
(
new
ContactTitleRenderer
(
Contact
.
createWithColumnPreset
()).
asSql
()),
"
PERSON join CONTACT on PERSON.PERSONID = CONTACT.PERSON_ID join ORGANISATION on ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID
"
,
"
CONTACTID
"
,
""
,
"
CONTACT
"
],
"
Activity
"
:
[
"
SUBJECT
"
,
"
ACTIVITY
"
,
"
ACTIVITYID
"
,
""
],
"
Salesproject
"
:
[
maskingUtils
.
concat
([
"
'
"
+
translate
.
text
(
"
Salesproject
"
)
+
"
'
"
,
"
' '
"
,
maskingUtils
.
cast
(
"
PROJECTCODE
"
,
SQLTYPES
.
VARCHAR
,
10
),
"
' | '
"
,
"
PROJECTTITLE
"
],
""
,
false
),
"
SALESPROJECT
"
,
"
SALESPROJECTID
"
,
"
CONTACT_ID
"
],
"
Contract
"
:
[
maskingUtils
.
concat
([
KeywordUtils
.
getResolvedTitleSqlPart
(
"
ContractType
"
,
"
CONTRACTTYPE
"
),
maskingUtils
.
cast
(
"
CONTRACTCODE
"
,
SQLTYPES
.
VARCHAR
,
10
)
],
"
"
),
"
CONTRACT
"
,
"
CONTRACTID
"
,
"
CONTACT_ID
"
],
"
Offer
"
:
[
maskingUtils
.
concat
([
"
'
"
+
translate
.
text
(
"
Offer
"
)
+
"
'
"
,
"
' '
"
,
maskingUtils
.
cast
(
"
OFFERCODE
"
,
SQLTYPES
.
VARCHAR
,
10
),
"
'-'
"
,
maskingUtils
.
cast
(
"
VERSNR
"
,
SQLTYPES
.
VARCHAR
,
10
)
],
""
,
false
),
"
OFFER
"
,
"
OFFERID
"
,
"
CONTACT_ID
"
],
"
Order
"
:
[
maskingUtils
.
concat
([
"
'
"
+
translate
.
text
(
"
Order
"
)
+
"
'
"
,
"
' '
"
,
maskingUtils
.
cast
(
"
SALESORDERCODE
"
,
SQLTYPES
.
VARCHAR
,
10
),
"
'-'
"
,
maskingUtils
.
cast
(
"
VERSNR
"
,
SQLTYPES
.
VARCHAR
,
10
)
],
""
,
false
),
"
SALESORDER
"
,
"
SALESORDERID
"
,
"
CONTACT_ID
"
],
"
Product
"
:
[
maskingUtils
.
concat
([
"
PRODUCTCODE
"
,
"
' | '
"
,
"
PRODUCTNAME
"
],
""
,
false
),
"
PRODUCT
"
,
"
PRODUCTID
"
,
""
],
"
Task
"
:
[
"
SUBJECT
"
,
"
TASK
"
,
"
TASKID
"
,
translate
.
text
(
"
Task
"
),
""
]
}
}
...
...
@@ -127,7 +196,7 @@ ContextUtils.getFieldTitle = function(pContextId, pDefault)
{
if
(
ContextUtils
.
_getSelectMap
()[
pContextId
]
!=
undefined
&&
ContextUtils
.
_getSelectMap
()[
pContextId
].
length
>=
3
)
return
ContextUtils
.
_getSelectMap
()[
pContextId
][
3
];
return
pDefault
;
}
...
...
@@ -138,16 +207,16 @@ ContextUtils.getFieldTitle = function(pContextId, pDefault)
ContextUtils
.
getNameSubselectSql
=
function
(
pContextIdDbField
,
pRowIdDbField
)
{
var
select
=
"
(case
"
+
pContextIdDbField
+
"
"
;
var
selectMap
=
ContextUtils
.
_getSelectMap
()
for
(
let
contextId
in
selectMap
)
for
(
let
contextId
in
selectMap
)
{
select
+=
"
when '
"
+
contextId
+
"
' then (select
"
+
selectMap
[
contextId
][
0
]
+
"
from
"
+
selectMap
[
contextId
][
1
]
+
(
pRowIdDbField
?
"
where
"
+
selectMap
[
contextId
][
2
]
+
"
=
"
+
pRowIdDbField
:
"
"
)
+
"
)
"
;
}
select
+=
"
else 'Not defined in ContextUtils.getNameSql()!'
"
;
select
+=
"
end)
"
;
return
select
;
}
...
...
@@ -174,7 +243,7 @@ ContextUtils.getContextDataSql = function(pContextId, pRowId)
{
cond
.
andPrepare
(
selectMap
[
pContextId
][
1
]
+
"
.
"
+
selectMap
[
pContextId
][
3
],
pRowId
)
}
return
cond
.
buildSql
(
"
select
"
+
selectMap
[
pContextId
][
2
]
+
"
,
"
+
selectMap
[
pContextId
][
0
]
+
"
from
"
+
selectMap
[
pContextId
][
1
],
"
1=1
"
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment