]> git.argeo.org Git - lgpl/argeo-commons.git/blob - security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/NaturesManager.js
f15bb336b323ca3ff5247c7333b37cd33e59c1b7
[lgpl/argeo-commons.git] / security / runtime / org.argeo.security.ria / src / argeo-ria-lib / security / class / org / argeo / security / ria / components / NaturesManager.js
1 qx.Class.define("org.argeo.security.ria.components.NaturesManager",{
2 extend : qx.core.Object,
3 properties : {
4 detectedNatures : {
5 check : "Map"
6 }
7 },
8 construct : function(){
9 this.base(arguments);
10 this.detectNatures();
11 },
12 members : {
13 detectNatures : function(){
14 var natures = {};
15 for (var key in qx.Bootstrap.$$registry) {
16 if (qx.Class.hasInterface(qx.Bootstrap.$$registry[key], org.argeo.security.ria.components.INaturePane)) {
17 // FILTER BY ROLE HERE!
18 var klass = qx.Bootstrap.$$registry[key];
19 natures[klass.NATURE_TYPE] = klass;
20 }
21 }
22 this.setDetectedNatures(natures);
23 },
24 detectNaturesInData : function(userNaturesList){
25 var detected = this.getDetectedNatures();
26 var userDetected = [];
27 for(var i = 0;i<userNaturesList.length;i++){
28 var type = userNaturesList[i].type;
29 if(detected[type]){
30 userDetected.push({
31 NATURE_CLASS : detected[type],
32 NATURE_DATA : userNaturesList[i]
33 });
34 }
35 }
36 return userDetected;
37 }
38 }
39 });