Package org.woped.core.model.petrinet

Examples of org.woped.core.model.petrinet.ResourceClassModel


       if(selectedGroupsList==null&&selectedRolesList!=null){       
        try{
          Object [] selectedRoles = selectedRolesList.getSelectedValues();

              String superRole = dialogFrameTextField.getText();
              ResourceClassModel newSuperRole = new ResourceClassModel(superRole, ResourceClassModel.TYPE_ROLE);
              getPetrinet().addRole(newSuperRole);
              RolesListModel.addElement(newSuperRole);
              SuperRolesTreeNode superRoleNode = new SuperRolesTreeNode(superRole);
              RolesTreeModel.insertNodeInto(superRoleNode, superRolesTopNode,  superRolesTopNode.getChildCount());
           
              for(int i=0;i<selectedRoles.length;i++){
                String RoleName = selectedRoles[i].toString();
                int j = getPetrinet().containsRole(RoleName);
                ResourceClassModel currentRole = getPetrinet().getRoles().get(j);
                currentRole.addSuperModel(newSuperRole);

                // Assign the objects of the selected Roles to the compound Role
                DefaultMutableTreeNode child = new DefaultMutableTreeNode(RoleName);
                superRolesTreeModel.insertNodeInto(child, superRoleNode, superRoleNode.getChildCount());
                ArrayList <String> objects = getObjectsAssignedToResource(currentRole, ResourceClassModel.TYPE_ROLE);
                for(int a = 0; a< objects.size();a++ ){
                  String currentObject = objects.get(a);
                  petrinet.addResourceMapping(newSuperRole.toString(), currentObject);
                }

            }   
                refreshRolesFromModel();
                refreshGroupsFromModel();
                refreshObjectsFromModel();
                refreshGUI();
          selectedRolesList =null;
          selectedGroupsList =null;
          getEditor().setSaved(false);
          dialogFrame.dispose();
        }catch(Exception exc){
          exc.printStackTrace();
        }
        }
       // create a new compound Group
      if(selectedRolesList==null&&selectedGroupsList!=null){
          Object [] selectedGroups = selectedGroupsList.getSelectedValues();
              String superGroup = dialogFrameTextField.getText();
              ResourceClassModel newSuperGroup = new ResourceClassModel(superGroup, ResourceClassModel.TYPE_ORGUNIT);
              getPetrinet().addOrgUnit(newSuperGroup);
              GroupsListModel.addElement(newSuperGroup);
              SuperGroupsTreeNode superGroupNode = new SuperGroupsTreeNode(superGroup);
              GroupsTreeModel.insertNodeInto(superGroupNode, superGroupsTopNode,  superGroupsTopNode.getChildCount());
           
              for(int i=0;i<selectedGroups.length;i++){
                String GroupName = selectedGroups[i].toString();
                int j = getPetrinet().containsOrgunit(GroupName);
                ResourceClassModel currentGroup = getPetrinet().getOrganizationUnits().get(j);
                currentGroup.addSuperModel(newSuperGroup);
                // Assign the objects of the selected Groups to the compound Group
                DefaultMutableTreeNode child = new DefaultMutableTreeNode(GroupName);
                superRolesTreeModel.insertNodeInto(child, superGroupNode, superGroupNode.getChildCount());
                ArrayList <String> objects = getObjectsAssignedToResource(currentGroup, ResourceClassModel.TYPE_ORGUNIT);
                for(int a = 0; a< objects.size();a++ ){
View Full Code Here


     private void editSuperResource (){
           // edit compound Role
           if(selectedGroupsList==null){       
          Object [] selectedRoles = selectedRolesList.getSelectedValues();
                String superRoleNewName = dialogFrameTextField.getText();
                ResourceClassModel newSuperRole = new ResourceClassModel(superRoleNewName, ResourceClassModel.TYPE_ROLE);
                String superRoleOldName = superRolesTree.getLastSelectedPathComponent().toString();
                SuperRolesTreeNode superRole = (SuperRolesTreeNode) superRolesTree.getLastSelectedPathComponent();
                 for(int i=0;i<superRole.getChildCount();i++){
                   String Role = superRole.getChildAt(i).toString();
                   int j = getPetrinet().containsRole(Role);
                   ResourceClassModel RoleModel = (ResourceClassModel) getPetrinet().getRoles().get(j);
                   ResourceClassModel superRoleModel= new ResourceClassModel(superRoleOldName,
                       ResourceClassModel.TYPE_ROLE);
                   RoleModel.removeSuperModel(superRoleModel);
                  }
               
                int j = getPetrinet().containsRole(superRoleOldName);
                ResourceClassModel RoleModel = (ResourceClassModel) getPetrinet().getRoles().get(j);
                        RoleModel.setName(superRoleNewName);
                       
                        updateRolesInPetrinet(superRoleOldName, superRoleNewName);
                       
                        int path = superRolesTopNode.getIndex(superRole);
             
                for(int i=0;i<selectedRoles.length;i++){
                  String RoleName = selectedRoles[i].toString();
                  int a = getPetrinet().containsRole(RoleName);
                  ResourceClassModel currentRole = getPetrinet().getRoles().get(a);
                  currentRole.addSuperModel(newSuperRole);
                  ArrayList <String> objects = getObjectsAssignedToResource(currentRole, ResourceClassModel.TYPE_ROLE);
                  for(int b = 0; b< objects.size();b++ ){
                    String currentObject = objects.get(b);
                 
                    petrinet.addResourceMapping(newSuperRole.toString(), currentObject);
                  }
                }
                  refreshRolesFromModel();
                  refreshGroupsFromModel();
                  refreshObjectsFromModel();
                  refreshGUI();
                superRolesTree.expandRow(path);
                getEditor().setSaved(false);
             
                superRolesEditButton.setEnabled(false);
                superRolesDeleteButton.setEnabled(false);   
          }
          
             // edit compound Group
          if(selectedRolesList==null){
            Object [] selectedGroups = selectedGroupsList.getSelectedValues();
                String superGroupNewName = dialogFrameTextField.getText();
                ResourceClassModel newSuperGroup = new ResourceClassModel(superGroupNewName,
                    ResourceClassModel.TYPE_ORGUNIT);
                String superGroupOldName = superGroupsTree.getLastSelectedPathComponent().toString();
                SuperGroupsTreeNode superGroup = (SuperGroupsTreeNode) superGroupsTree.getLastSelectedPathComponent();
                 for(int i=0;i<superGroup.getChildCount();i++){
                   String Group = superGroup.getChildAt(i).toString();
                   int j = getPetrinet().containsOrgunit(Group);
                   ResourceClassModel GroupModel = (ResourceClassModel) getPetrinet().getOrganizationUnits().get(j);
                   ResourceClassModel superGroupModel= new ResourceClassModel(superGroupOldName,
                       ResourceClassModel.TYPE_ORGUNIT);
                   GroupModel.removeSuperModel(superGroupModel);
                  }
               
                int j = getPetrinet().containsOrgunit(superGroupOldName);
                ResourceClassModel GroupModel = (ResourceClassModel) getPetrinet().getOrganizationUnits().get(j);
                        GroupModel.setName(superGroupNewName);
                       
                        updateRolesInPetrinet(superGroupOldName, superGroupNewName)
             
                        int path = superGroupsTopNode.getIndex(superGroup);
                       
                        for(int i=0;i<selectedGroups.length;i++){
                  String GroupName = selectedGroups[i].toString();
                  int a = getPetrinet().containsOrgunit(GroupName);
                  ResourceClassModel currentGroup = getPetrinet().getOrganizationUnits().get(a);
                  currentGroup.addSuperModel(newSuperGroup);
                  ArrayList <String> objects = getObjectsAssignedToResource(currentGroup,
                      ResourceClassModel.TYPE_ORGUNIT);
                  for(int b = 0; b< objects.size();b++ ){
                    String currentObject = objects.get(b);
                   
View Full Code Here

              RolesListModel.addElement((ResourceClassModel)getPetrinet().getRoles().get(i))
            }
            for (int i = 0; i < getPetrinet().getRoles().size(); i++){
              if(getPetrinet().getRoles().get(i).getSuperModels()!=null){
                for(Iterator<ResourceClassModel> j = getPetrinet().getRoles().get(i).getSuperModels();j.hasNext();){
                  ResourceClassModel superRole = j.next();
                  if(!superRolesListModel.contains(superRole.toString())){
                    superRolesListModel.addElement(superRole.toString())
                    for(int k=0;k<RolesListModel.size();k++){
                      String Role = RolesListModel.get(k).toString();
                      if(Role.equalsIgnoreCase(superRole.toString())){
                        RolesListModel.remove(k);
                      }
                    }
                  }
                }
View Full Code Here

              GroupsListModel.addElement((ResourceClassModel)getPetrinet().getOrganizationUnits().get(i))
          }
          for (int i = 0; i < getPetrinet().getOrganizationUnits().size(); i++){
            if(getPetrinet().getOrganizationUnits().get(i).getSuperModels()!=null){
              for(Iterator<ResourceClassModel> j = getPetrinet().getOrganizationUnits().get(i).getSuperModels();j.hasNext();){
                ResourceClassModel superGroup = j.next();
                if(!superGroupsListModel.contains(superGroup.toString())){
                  superGroupsListModel.addElement(superGroup.toString())
                  for(int k=0;k<GroupsListModel.size();k++){
                    String Group = GroupsListModel.get(k).toString();
                    if(Group.equalsIgnoreCase(superGroup.toString())){
                      GroupsListModel.remove(k);
                    }
                  }
                }
              }
View Full Code Here

          superRolesTreeModel.insertNodeInto(parent, superRolesTopNode, i);
                 
          for (int j = 0; j < getPetrinet().getRoles().size(); j++){
            if(getPetrinet().getRoles().get(j).getSuperModels()!=null){
              for(Iterator<ResourceClassModel> k = getPetrinet().getRoles().get(j).getSuperModels();k.hasNext();){
                ResourceClassModel currentSuperRole = k.next();
                if(currentSuperRole.toString().equalsIgnoreCase(superRole)){
                  superRolesTreeModel.insertNodeInto(new SuperRolesTreeNode(getPetrinet().getRoles().get(j).toString()), parent, parent.getChildCount());       
                }
              }
            }
          }
View Full Code Here

          superGroupsTreeModel.insertNodeInto(parent, superGroupsTopNode, i);
                 
          for (int j = 0; j < getPetrinet().getOrganizationUnits().size(); j++){
            if(getPetrinet().getOrganizationUnits().get(j).getSuperModels()!=null){
              for(Iterator<ResourceClassModel> k = getPetrinet().getOrganizationUnits().get(j).getSuperModels();k.hasNext();){
                ResourceClassModel currentSuperGroup = k.next();
                if(currentSuperGroup.toString().equalsIgnoreCase(superGroup )){
                  superGroupsTreeModel.insertNodeInto(new SuperGroupsTreeNode(getPetrinet().getOrganizationUnits().get(j).toString()), parent, parent.getChildCount());       
                }
              }
            }
          }
View Full Code Here

                  .getToolspecificArray(j).getResources()
                  .getResourceMappingArray();

              RoleType[] roles = currentNet.getToolspecificArray(
                  j).getResources().getRoleArray();
              ResourceClassModel roleModelTemp;
              for (int k = 0; k < roles.length; k++) {
                roleModelTemp = new ResourceClassModel(roles[k]
                    .getName(),
                    ResourceClassModel.TYPE_ROLE);
                currentPetrinet.addRole(roleModelTemp);
                SuperModelType[] supermodels = roles[k].getSuperModelArray();
                ResourceClassModel superModelTemp;
                for( int l=0;l<supermodels.length;l++){
                  superModelTemp = new ResourceClassModel(supermodels[l]
                       .getName(),ResourceClassModel.TYPE_ROLE);
                  roleModelTemp.addSuperModel(superModelTemp);
                }
              }
              
             

              OrganizationUnitType[] units = currentNet
                  .getToolspecificArray(j).getResources()
                  .getOrganizationUnitArray();
              ResourceClassModel orgUnitTemp;
              for (int l = 0; l < units.length; l++) {
                orgUnitTemp = new ResourceClassModel(units[l]
                    .getName(),
                    ResourceClassModel.TYPE_ORGUNIT);
                currentPetrinet.addOrgUnit(orgUnitTemp);
               
                SuperModelType[] supermodels = units[l].getSuperModelArray();
                ResourceClassModel superModelTemp;
                for( int m=0;m<supermodels.length;m++){
                  superModelTemp = new ResourceClassModel(supermodels[m]
                       .getName(),ResourceClassModel.TYPE_ORGUNIT);
                  orgUnitTemp.addSuperModel(superModelTemp);
                }
              }
View Full Code Here

              if(!RoleIsUsed(superRole2remove)){
                SuperRolesTreeNode superRole= (SuperRolesTreeNode) superRolesTree.getLastSelectedPathComponent();
                for(int i=0;i<superRole.getChildCount();i++){
                 String Role = superRole.getChildAt(i).toString();
                 int j = getPetrinet().containsRole(Role);
                 ResourceClassModel RoleModel = (ResourceClassModel) getPetrinet().getRoles().get(j);
                 ResourceClassModel superRoleModel=
                   new ResourceClassModel(superRole2remove,ResourceClassModel.TYPE_ROLE);
                 RoleModel.removeSuperModel(superRoleModel);
                
                }
             
                 int a = getPetrinet().containsRole(superRole2remove);
               getPetrinet().getRoles().remove(a);
               getPetrinet().getResourceMapping().remove(superRole2remove);
              
                  refreshRolesFromModel();
                  refreshGroupsFromModel();
                  refreshObjectsFromModel();
                  refreshGUI();
              
               getEditor().setSaved(false);
       
               superRolesDeleteButton.setEnabled(false);
               superRolesEditButton.setEnabled(false);
              }else{
                     JOptionPane.showMessageDialog(RolesContentPanel,
                         Messages.getString("ResourceEditor.Error.UsedResourceClass.Text"),
                         Messages.getString("ResourceEditor.Error.UsedResourceClass.Title"),
                                    JOptionPane.ERROR_MESSAGE);
                   }
          }catch (Exception exc){
            exc.printStackTrace();
          }
        }
        // delete compound Group
        if(e.getSource()==superGroupsDeleteButton){
          try{
              String superGroup2remove = (superGroupsTree.getLastSelectedPathComponent().toString());
              if(!GroupIsUsed(superGroup2remove)){
                SuperGroupsTreeNode superGroup= (SuperGroupsTreeNode) superGroupsTree.getLastSelectedPathComponent();
                for(int i=0;i<superGroup.getChildCount();i++){
                 String Group = superGroup.getChildAt(i).toString();
                 int j = getPetrinet().containsOrgunit(Group);
                 ResourceClassModel GroupModel = (ResourceClassModel) getPetrinet().getOrganizationUnits().get(j);
                 ResourceClassModel superGroupModel= new ResourceClassModel(superGroup2remove,ResourceClassModel.TYPE_ORGUNIT);
                 GroupModel.removeSuperModel(superGroupModel);
                }
             
                 int a = getPetrinet().containsOrgunit(superGroup2remove);
               getPetrinet().getOrganizationUnits().remove(a);
View Full Code Here

               if(e.getSource()== RolesNewButton ){
                 String newResourceName = JOptionPane.showInputDialog(RolesContentPanel,
                     (Object)Messages.getString("PetriNet.Resources.ResourceName"),
                     Messages.getString("PetriNet.Resources.CreateRole"),JOptionPane.QUESTION_MESSAGE);
                 if (checkClassSyntax(newResourceName )){
                   ResourceClassModel newRole = new ResourceClassModel(newResourceName, ResourceClassModel.TYPE_ROLE);
                   getPetrinet().addRole(newRole);
                   RolesListModel.addElement(newRole);
                    refreshRolesFromModel();
                    refreshGroupsFromModel();
                    refreshObjectsFromModel();
                    refreshGUI();
                   getEditor().setSaved(false);
                 }
               }
               // create a new Group
               if(e.getSource()== GroupsNewButton ){
                 String newResourceName = JOptionPane.showInputDialog(RolesContentPanel,
                     (Object)Messages.getString("PetriNet.Resources.ResourceName"),
                     Messages.getString("PetriNet.Resources.CreateGroup"),JOptionPane.QUESTION_MESSAGE);
                 if (checkClassSyntax(newResourceName )){
                   ResourceClassModel newGroup = new ResourceClassModel(newResourceName,
                       ResourceClassModel.TYPE_ORGUNIT);
                   getPetrinet().addOrgUnit(newGroup);
                   GroupsListModel.addElement(newGroup);
                    refreshRolesFromModel();
                    refreshGroupsFromModel();
View Full Code Here

                    Messages.getString("PetriNet.Resources.ResourceName"),
                    Messages.getString("PetriNet.Resources.EditRole"),
                                JOptionPane.QUESTION_MESSAGE,null,null,message);
                if (checkClassSyntax(newName )){
                  int j = getPetrinet().containsRole(oldName);
                  ResourceClassModel RoleModel = (ResourceClassModel) getPetrinet().getRoles().get(j);
                          RoleModel.setName(newName);
                          RolesListModel.set( j, RoleModel);
                          updateRolesInPetrinet(oldName, newName);
                refreshRolesFromModel();
                refreshGroupsFromModel();
                refreshObjectsFromModel();
                refreshGUI();
              
                          getEditor().setSaved(false);
                }
              }
              //edit a Group
              if(e.getSource()== GroupsEditButton){
                Object message = (Object) GroupsTree.getLastSelectedPathComponent().toString();
                String oldName = (String) message;
                JOptionPane nameDialog = new JOptionPane();
                String newName = (String) JOptionPane.showInputDialog(nameDialog,
                    Messages.getString("PetriNet.Resources.ResourceName"),
                    Messages.getString("PetriNet.Resources.EditGroup"),
                                JOptionPane.QUESTION_MESSAGE,null,null,message);
                if (checkClassSyntax(newName )){
                  int j = getPetrinet().containsOrgunit(oldName);
                  ResourceClassModel GroupModel = (ResourceClassModel) getPetrinet().getOrganizationUnits().get(j);
                          GroupModel.setName(newName);
                          GroupsListModel.set( j, GroupModel);
                          updateGroupsInPetrinet(oldName, newName);
                       
                refreshRolesFromModel();
                refreshGroupsFromModel();
View Full Code Here

TOP

Related Classes of org.woped.core.model.petrinet.ResourceClassModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.