Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xrm
basic
Commits
5644899c
Commit
5644899c
authored
5 years ago
by
S.Listl
Browse files
Options
Downloads
Patches
Plain Diff
1049530 - HasLinkedObjectTester implemented
parent
8810f448
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
process/Employee_lib/process.js
+12
-0
12 additions, 0 deletions
process/Employee_lib/process.js
process/Entity_lib/process.js
+143
-1
143 additions, 1 deletion
process/Entity_lib/process.js
with
155 additions
and
1 deletion
process/Employee_lib/process.js
+
12
−
0
View file @
5644899c
...
@@ -129,4 +129,16 @@ EmployeeUtils.hasRelations = function (pContactId)
...
@@ -129,4 +129,16 @@ EmployeeUtils.hasRelations = function (pContactId)
{
{
return
pSelect
.
cell
()
!=
""
;
return
pSelect
.
cell
()
!=
""
;
});
});
}
/**
* checks if a user with the given contactId exists
*
* @param {String} pContactId the contactId the user has to have
* @return {Boolean} wheter the user exists or not
*/
EmployeeUtils
.
isUser
=
function
(
pContactId
)
{
var
user
=
tools
.
getUserByAttribute
(
tools
.
CONTACTID
,
pContactId
);
return
user
!=
null
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
process/Entity_lib/process.js
+
143
−
1
View file @
5644899c
import
(
"
system.entities
"
);
import
(
"
system.result
"
);
import
(
"
system.result
"
);
import
(
"
system.neon
"
);
import
(
"
system.neon
"
);
import
(
"
system.vars
"
);
import
(
"
system.vars
"
);
...
@@ -173,4 +174,145 @@ FieldChanges._getStorage = function()
...
@@ -173,4 +174,145 @@ FieldChanges._getStorage = function()
FieldChanges
.
_setStorage
=
function
(
pAllChanges
)
FieldChanges
.
_setStorage
=
function
(
pAllChanges
)
{
{
return
vars
.
set
(
"
$context.FieldChanges
"
,
pAllChanges
);
return
vars
.
set
(
"
$context.FieldChanges
"
,
pAllChanges
);
};
};
\ No newline at end of file
/**
* Object for testing if linked datasets exists.
*
* @param {String[]} pConsumers names of the consumers to be tested
*/
function
HasLinkedObjectTester
(
pConsumers
)
{
//This array will contain objects that are used for the validation. You can put any object in this array as long as it provides
//a method 'checkForObjects' that can be invoked.
this
.
_validationObjects
=
[];
if
(
pConsumers
)
pConsumers
.
forEach
(
this
.
andNoConsumerRows
,
this
);
Object
.
defineProperty
(
this
,
"
length
"
,
{
get
:
function
()
{
return
this
.
_validationObjects
.
length
;}
});
}
/**
* @ignore
*/
HasLinkedObjectTester
.
_testForEntity
=
function
()
{
entities
.
createConfigForLoadingConsumerRows
()
var
loadConfig
=
entities
.
createConfigForLoadingRows
()
.
entity
(
this
.
entity
)
.
provider
(
this
.
provider
)
.
ignorePermissions
(
true
);
if
(
this
.
parameters
)
{
for
(
let
param
in
this
.
parameters
)
loadConfig
.
addParameter
(
param
,
this
.
parameters
[
param
]);
}
return
entities
.
getRowCount
(
loadConfig
)
==
0
;
}
/**
* @ignore
*/
HasLinkedObjectTester
.
_testForConsumer
=
function
()
{
//TODO: implement when possible
return
false
;
}
/**
* @ignore
*/
HasLinkedObjectTester
.
_testForCallback
=
function
()
{
fnResult
=
this
.
callbackFn
();
return
this
.
failValue
?
fnResult
!=
this
.
failValue
:
fnResult
;
}
/**
* !!! YOU CAN'T USE THIS FUNCTION YET !!!
*
* Adds a consumer to test for rows to the object.
*
* @ignore
*
* @param {String} pConsumer name of the consumer
* @return {HasLinkedObjectTester} current object
*/
HasLinkedObjectTester
.
prototype
.
andNoConsumerRows
=
function
(
pConsumer
)
{
throw
new
Error
(
"
HasLinkedObjectTester.prototype.andNoConsumerRows does not work yet
"
)
this
.
_validationObjects
.
push
({
checkForObjects
:
HasLinkedObjectTester
.
_testForConsumer
,
consumer
:
pConsumer
});
return
this
;
}
/**
* Adds a entity with provider to test for rows. You have to set the parameters by yourself.
*
* @param {String} pEntity name of the entity
* @param {String} pProvider provider that should be used
* @param {Object} [pParameters] parameters to set
* @return {HasLinkedObjectTester} current object
* @example
* new HasLinkedObjectTester()
* .andNoEntityRows("Activity_entity", "LinkedObjects", {ObjectId_param : currentContext, RowId_param : contactId})
*/
HasLinkedObjectTester
.
prototype
.
andNoEntityRows
=
function
(
pEntity
,
pProvider
,
pParameters
)
{
this
.
_validationObjects
.
push
({
checkForObjects
:
HasLinkedObjectTester
.
_testForEntity
,
entity
:
pEntity
,
provider
:
pProvider
,
parameters
:
pParameters
});
return
this
;
}
/**
* Adds a custom callback function that tests for linked objects.
*
* @param {String} pCallbackFn validation function, it should return true if NO linked objects were found, but the expected value can be changed
* by providing an own 'pFailValue'
* @param {Object} [pFailValue=false] if the given function returns this value, the ovarall validation will fail and return false
* @return {HasLinkedObjectTester} current object
*/
HasLinkedObjectTester
.
prototype
.
and
=
function
(
pCallbackFn
,
pFailValue
)
{
this
.
_validationObjects
.
push
({
checkForObjects
:
HasLinkedObjectTester
.
_testForCallback
,
callbackFn
:
pCallbackFn
,
failValue
:
pFailValue
});
return
this
;
}
/**
* Executes the validation of all tests that have been added to the object. If every test returns true, the result will also be true,
* but if any test returns false, the execution will stop and false is returned.
*
* @return {Boolean} true, if NO linked objects were found
*/
HasLinkedObjectTester
.
prototype
.
validate
=
function
()
{
return
this
.
_validationObjects
.
every
(
function
(
duck
)
{
return
duck
.
checkForObjects
();
});
}
/**
* @return {String} validation result as String, so that .validate() does not always have to be called explicitly
*/
HasLinkedObjectTester
.
prototype
.
toString
=
function
()
{
return
String
(
this
.
validate
());
}
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