Cloud Workflow

Check The User Is In The Organization

Check The User Is In The Organization
Questetra-userOrgPosition.xml
(md5:4e0f27cd28cb332117e52bebdfe25405)

    • I1′: I1で選択したデータ項目に格納されているユーザ
    • I2′: I2で選択したデータ項目に格納されている組織
    • If the specified user is the leader of the specified organization, this task returns “L”. If he or she is one of the its members,it returns “M”. If he or she doesn’t belong to it, it returns nothing.

    I1.User Data(Data Type:User)Data selectUserRequired
    I2.Organization Data(Data Type:Organization)Data selectOrganizationRequired
    O1.Result(Data Type:Single-line string)Data selectString(single line)Required
    -variable namevariable label
    userFieldI1.User Data(Data Type:User)
    groupFieldI2.Organization Data(Data Type:Organization)
    resultO1.Result(Data Type:Single-line string)
    main();
    
    function main() {
      //set group data from I2
      var groupIs = engine.findDataByNumber(configs.get("groupField"));
      //set user data from I2
      var userIs = engine.findDataByNumber(configs.get("userField"));
      var result = "";
      //Error
      errorCheck(groupIs, userIs);
      if (check(true, userIs, groupIs)) {
        result = "L";
      } else if (check(false, userIs, groupIs)) {
        result = "M";
      }
      //set result to O
      engine.setDataByNumber(configs.get("result"), result);
    }
    //check whether the user is the leader or a member of the group
    function check(LM, user, group) {
      var temp;
      var list = quserDao.findByQgroupAndPosition(group, LM);
      for (var i = 0; i < list.size(); i++) {
        temp = list.get(i);
        if (user.getId().equals(temp.getId())) {
          return true;
        }
      }
    }
    
    function errorCheck(group, user) {
      if (group == null && user != null) {
        throw "Organization Not Selected";
      } else if (group != null && user == null) {
        throw "User Not Selected";
      } else if (group == null && user == null) {
        throw "Organization and User Not Selected";
      }
      var userC = quserDao.findById(user.getId());
      var groupC = qgroupDao.findById(group.getId());
      if (userC == null && groupC != null) {
        throw "Selected user doesn't exist";
      } else if (userC != null && groupC == null) {
        throw "Selected Organization doesn't exist";
      } else if (userC == null && groupC == null) {
        throw "Selected Organization and User don't exist";
      }
    }