Process Mapping Logo

Process Mapping - Forums

Sharing 19 years of knowledge and experience

 
Metastorm BPM forums
Sign up Latest Topics
 
 
 


Reply
  Author   Comment  
jasonstorey

Member
Registered:
Posts: 19
Reply with quote  #1 
I have been spending a couple days trying to make some helper methods for metastorm roles.
(a lot Of which I realized too late was already in the free user solution here)
Although I feel some functions are missing and I needed some advanced functionality.
The long and the short of it is modular design for complex user selection.


e.g:

List validRoles = allRolesOf(namesToIds("John Smith","Sarah Walker","Matt Smith"));

List validUsers = allUsersWithRoles(validRoles)  

List allEmails = emailAddressOf(validUsers,"David Jones","Earl Thompson")


I built the framework with some sub-methods that query the tables for getting roles and users all using the params keyword for more advanced uses

the plan would be that they all return a metastorm list so as to be able to be passed into each other for building thinks like above:
emailAddressesOf(allUsersWithRoles(allRolesOf("bla","bla...","bla......")))

The only way I can see of doing this is to convert to dictionaries for the checks/validations/removing duplicates then return it to the woefully feature lacking metastorm list type.

Now I am aware in the case of the SelectSql method it returns a IDataContainer, and comboboxes return a List of KeyValuePairs I think?

So in short I need to make methods to convert between them (and ideally with a dictionary as an intermediary for calculations)

Can anyone give me an ideas on what the ACTUAL formats/ best conversions are for these three types.

e.g

Dictionary<string,string> toDictionary(List metastormList)
List toList(Dictionary<string,string> dictionary)

what classes implement IDataContainer?


tl;dr

How Do I convert between Lists,Dictionary<string,string> and IDatacontainers ?




__________________
JasonStorey
0
jasonstorey

Member
Registered:
Posts: 19
Reply with quote  #2 
If anyone is interested I finally figured it out.

I created a doQuery method that takes in a params object[] and converts each item into a comma delimited string array.

That way you pass anything (another query, the result of a field,combobox options list string arrays etc) and it will create an argument for you.
then it groups those arguments and populates an aray which can be passed into a string.format("select {0} from {1} where {2} IN({3})", arguments);

I felt this gave me the most flexibility.
Every query returns the IDataContainer and every query can accept as a parameter

String                     :  "euser"
comma delim string : "eusername,erole"
string[]                   : new string[]{"jsmith","sjobs"}
or an IDataContainer (Mtsm.query return value, format KvP)

an object array which can contain any of the above and BE another argument set.

usage example would be:

 String query = "select edepartment from {0} where {1} in({2})";
 object[] par = new object[]{"london_department_table","eusername",A(true,User.nameToID(User.roleToName("Supervisor")),"slynch,mtowns")}

doQuery(query,par);

So that would return the department of any london manager and of slynch and mtowns.

  
As for how it was made, 

1 - generic object array
2 - query typeof
3 - pass to sub method
4 - each sub-method returns a string[] from the classtype (if possible)
5 - parse the types and add single quotes where requested A(true,"whatever")
6 - Convert all the individual arrays to an array of comma delimited strings

pass to a metastorm query call. a full day and 300 lines but it was worth it....
my task bar now has formula buttons for

name ->id
id-> name
role->ids
id->roles
id->email
email->id

and the isIn() method for things like:

isIn("your id,"rolesToIds("Manager,CEO"))

but i did make a few simplified ones for

hasRole(username,role) and such but the above is extensible



Phew! 
That should make generic sql queries and ework table queries much easier.



__________________
JasonStorey
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:


Create your own forum with Website Toolbox!