Package org.woped.core.model

Examples of org.woped.core.model.PetriNetModelProcessor


    this.undoSupport = undoSupport;
    // initialize
    this.m_clipboard = clipboard;
 
    marqueehandler = new PetriNetMarqueeHandler(this, mediator);
    this.modelProcessor = new PetriNetModelProcessor();
    if (loadUI)
      this.m_graph = new WoPeDJGraph(new WoPeDJGraphGraphModel(this),
          marqueehandler,
          undoSupport ? new WoPeDUndoManager(this) : null,
              viewFactory);
View Full Code Here


    LoggerManager.info(Constants.CORE_LOGGER, "copySubElementContainer");
    ModelElementContainer newContainer = new ModelElementContainer();

    newContainer.setOwningElement(container.getOwningElement());

    PetriNetModelProcessor processor = new PetriNetModelProcessor();
    processor.setElementContainer(newContainer);

    // HashMap<String, String> idMapper = new HashMap<String, String>();

    // copy elements

    Map<?, ?> idMap = container.getIdMap();
    Iterator<?> keyIterator = idMap.keySet().iterator();
    CreationMap currentArcMapSub;
    AbstractPetriNetElementModel newElementSub = null;
    while (keyIterator.hasNext()) {

      AbstractPetriNetElementModel currentElementSub = (AbstractPetriNetElementModel) container
          .getElementById(keyIterator.next());

      if (!currentElementSub.isReadOnly()) {
        CreationMap newMapSub = (CreationMap) currentElementSub
            .getCreationMap().clone();
        // newMap.setId("copyof_" + newMap.getId());
        String[] splitName = newMapSub.getId().split(
            SUBELEMENT_SEPERATOR);
        if (splitName.length > 1)
          newMapSub.setId(super.getId() + SUBELEMENT_SEPERATOR
              + splitName[splitName.length - 1]);
        newMapSub.setName(newMapSub.getId());
        newElementSub = ModelElementFactory
            .createModelElement(newMapSub);
       
        if (currentElementSub instanceof TransitionModel) {
          TransitionModel newTransitionSub = (TransitionModel) newElementSub;
          newTransitionSub
              .setToolSpecific(((TransitionModel) currentElementSub)
                  .getToolSpecific());

          newContainer.addElement(newTransitionSub);

        } else

          newContainer.addElement(newElementSub);
      }
    }
    /* insert arc source/target */
    Iterator<?> arcIterSub = container.getArcMap().keySet().iterator();
    CreationMap cMapSub = CreationMap.createMap();
    String originalElementId;
    String[] splitedSourceId, splitedTargetId;
    while (arcIterSub.hasNext()) {
      currentArcMapSub = container.getArcMap().get((arcIterSub.next()))
          .getCreationMap();
      originalElementId = currentArcMapSub.getName();
      splitedSourceId = currentArcMapSub.getArcSourceId().split(
          SUBELEMENT_SEPERATOR);
      splitedTargetId = currentArcMapSub.getArcTargetId().split(
          SUBELEMENT_SEPERATOR);

      String newSourceName ;
      String newTargetName ;
     
      if ((splitedSourceId.length > 1) && (splitedTargetId.length > 1)) {
        newTargetName =super.getId() + SUBELEMENT_SEPERATOR
        + splitedTargetId[splitedTargetId.length - 1];
        newSourceName = super.getId() + SUBELEMENT_SEPERATOR
        + splitedSourceId[splitedSourceId.length - 1];
        cMapSub.setArcSourceId(newSourceName);
        cMapSub.setArcTargetId(newTargetName);
        processor.createArc(newSourceName,
            newTargetName);
      }
      else if ((splitedSourceId.length <= 1) && (splitedTargetId.length > 1)) {
        newTargetName =super.getId() + SUBELEMENT_SEPERATOR
        + splitedTargetId[splitedTargetId.length - 1];
        cMapSub.setArcTargetId(newTargetName);
        ((TransitionModel) newContainer.getElementById(newTargetName)).setIncommingTarget(true);
        processor.createArc(originalElementId,
            cMapSub.getArcTargetId());
      }
      else if ((splitedSourceId.length > 1) && (splitedTargetId.length <= 1)) {
        newSourceName = super.getId() + SUBELEMENT_SEPERATOR
        + splitedSourceId[splitedSourceId.length - 1];
View Full Code Here

  }
 
 

  private void initResourceAlloc() {
    PetriNetModelProcessor pmp = (PetriNetModelProcessor) editor
        .getModelProcessor();

    ArrayList<String> roles = new ArrayList<String>();
    ArrayList<String> groups = new ArrayList<String>();
    Vector<ResourceClassModel> rVec = pmp.getRoles();
    Vector<ResourceClassModel> gVec = pmp.getOrganizationUnits();

//    groupRoleNum = rVec.size() + gVec.size();

    for (int i = 0; i < rVec.size(); i++)
      roles.add(((ResourceClassModel) rVec.get(i)).getName());
View Full Code Here

  }

  // TODO Fehler bei TProcess setzten; neu Instanzieren
  public boolean saveFile(String Path, IEditor editor)
  {
    PetriNetModelProcessor pnp = (PetriNetModelProcessor) editor
        .getModelProcessor();

    // Generate BPEL Model
    BpelParserModel m = new BpelParserModel();
    m.createModel(pnp.getElementContainer());
    ProcessDocument doc = ProcessDocument.Factory.newInstance();
    TProcess process = doc.addNewProcess();
//    BPEL.genBpelProcess();
//    BPEL.Process.set(m.generate_bpel());
//    setGlobals(BPEL.Process, pnp);
View Full Code Here

    }
  }

  public String genPreview(IEditor editor)
  {
    PetriNetModelProcessor pnp = (PetriNetModelProcessor) editor
        .getModelProcessor();

    // Generate BPEL Model
    BpelParserModel m = new BpelParserModel();
    if(!m.createModel(pnp.getElementContainer()))
    {
      return "" + Messages.getString("BPEL.genPreview.Error");
    }
    ProcessDocument doc = ProcessDocument.Factory.newInstance();
    TProcess process = doc.addNewProcess();
View Full Code Here

   * @author Martin Meitz
   *
   */
  public void setPnmlString(){
    ModelElementContainer elementContainer = editor.getModelProcessor().getElementContainer();
        PetriNetModelProcessor petrinetModel = (PetriNetModelProcessor) editor.getModelProcessor();
        pnmlDoc = PnmlDocument.Factory.newInstance();
        PnmlType iPnml = pnmlDoc.addNewPnml();
        NetType iNet = iPnml.addNewNet();
        iNet.setType(petrinetModel.getType());
        iNet.setId(petrinetModel.getId());
             
       
        try
        {
          saveModelElementContainer(iNet, elementContainer);
View Full Code Here


    private void createJavaBeansInstances(EditorVC editor)
    {
        ModelElementContainer elementContainer = editor.getModelProcessor().getElementContainer();
        PetriNetModelProcessor petrinetModel = (PetriNetModelProcessor) editor.getModelProcessor();
        pnmlDoc = PnmlDocument.Factory.newInstance();
        PnmlType iPnml = pnmlDoc.addNewPnml();

        // Initialisieren der Statusbar
        int resources = petrinetModel.getResources().size();
        int roles = petrinetModel.getRoles().size();
        int orgaUnits = petrinetModel.getOrganizationUnits().size();
        int resourcesMapping = petrinetModel.getResourceMapping().size();
        int rootElements = elementContainer.getRootElements().size();
        int arcs = elementContainer.getArcMap().size();
        // TODO (blackfox) - extend statusbars for simulations

        for (int i = 0; i < statusBars.length; i++)
            statusBars[i].startProgress("Save to File", resources + roles + resourcesMapping + orgaUnits + rootElements + arcs);

        // ------------------------------
        // pnmlDoc.documentProperties();
        XmlCursor cursor = iPnml.newCursor();
        cursor.insertComment(comment);
        /* ##### NET ##### */
        NetType iNet = iPnml.addNewNet();
        // attr type
        iNet.setType(petrinetModel.getType());
        // attr id
        iNet.setId(petrinetModel.getId());
        // name

        if (petrinetModel.getName() != null)
        {
            iNet.addNewName().setText(petrinetModel.getName());
        }
        if (ConfigurationManager.getConfiguration().isExportToolspecific())
        {
            NetToolspecificType iNetToolSpec = iNet.addNewToolspecific();

            iNetToolSpec.setTool("WoPeD");
            iNetToolSpec.setVersion("1.0"); //TODO Version aus properties �bernehmen!?
           
            //get PartnerLinks
            TPartnerLinks iPLs = iNetToolSpec.addNewPartnerLinks();
            Iterator<Partnerlink> plist = petrinetModel.getElementContainer().getPartnerlinkList().getPartnerlinkList().iterator();
            while (plist.hasNext()){
              Partnerlink link = plist.next();
              org.woped.pnml.TPartnerLink iPL = iPLs.addNewPartnerLink();
              iPL.setName(link.getName());
              iPL.setPartnerLinkType(link.getPartnerlinkTypeByQName());
              iPL.setPartnerRole(link.getPartnerlinkRole());
              iPL.setMyRole(link.getMyRole());
              iPL.setWSDL(link.getWsdlUrl());
            }
           
            //get Variables
            TVariables iVs = iNetToolSpec.addNewVariables();
            int VarCounter=0;
            while (petrinetModel.getElementContainer().getVariableList().getBpelCode().sizeOfVariableArray()>VarCounter){
              org.woped.pnml.TVariable iVar = iVs.addNewVariable();
              iVar.setName(petrinetModel.getElementContainer().getTVariablesList().getVariableArray(VarCounter).getName());
              iVar.setType(petrinetModel.getElementContainer().getTVariablesList().getVariableArray(VarCounter).getType());
              VarCounter++;
             }
           
            // scale
            iNetToolSpec.setScale((int)(editor.getGraph().getScale() * 100));
           
            // graphics
            GraphicsSimpleType iGraphicsNet = iNetToolSpec.addNewBounds();
            EditorLayoutInfo layoutInfo = editor.getEditorPanel().getSavedLayoutInfo();
            if (layoutInfo.getSavedSize() != null)
            {
                DimensionType dim = iGraphicsNet.addNewDimension();
                dim.setX(new BigDecimal(layoutInfo.getSavedSize().getWidth()));
                dim.setY(new BigDecimal(layoutInfo.getSavedSize().getHeight()));
            }
            if (layoutInfo.getSavedLocation() != null)
            {
              PositionType location = iGraphicsNet.addNewPosition();
                location.setX(new BigDecimal(layoutInfo.getSavedLocation().getX()));
                location.setY(new BigDecimal(layoutInfo.getSavedLocation().getY()));
            }
            // Store the width of the tree view and the height of the overview
            if(layoutInfo.getTreeViewWidthRight()!=0){
              iNetToolSpec.setTreeWidthRight(layoutInfo.getTreeViewWidthRight());
            }else{
              iNetToolSpec.setTreeWidthRight(layoutInfo.getTreeViewWidth());
            }
            iNetToolSpec.setOverviewPanelVisible(layoutInfo.getOverviewPanelVisible());
            iNetToolSpec.setTreeHeightOverview(layoutInfo.getTreeHeightOverview());
            iNetToolSpec.setTreePanelVisible(layoutInfo.getTreePanelVisible());
            //verticalLayout
            iNetToolSpec.setVerticalLayout(editor.isRotateSelected());
            // resources
            ResourcesType iNetResources = iNetToolSpec.addNewResources();
            // Rescources
            ResourceType iResourceType;
            ResourceModel rModelTemp;

            for (Iterator<ResourceModel> iter = petrinetModel.getResources().iterator(); iter.hasNext();)
            {
                rModelTemp = (ResourceModel) iter.next();
                iResourceType = iNetResources.addNewResource();
                iResourceType.setName(rModelTemp.getName());
                for (int i = 0; i < statusBars.length; i++)
                    statusBars[i].nextStep();
            }
            // Roles

            RoleType iRoleType;
            ResourceClassModel roleModelTemp;
            for (Iterator<ResourceClassModel> iter = petrinetModel.getRoles().iterator(); iter.hasNext();)
            {
                roleModelTemp = (ResourceClassModel) iter.next();
                iRoleType = iNetResources.addNewRole();
                iRoleType.setName(roleModelTemp.getName());
                if(roleModelTemp.getSuperModels()!= null){
                  for (Iterator<ResourceClassModel> i = roleModelTemp.getSuperModels();i.hasNext();)
                  {               
                    ResourceClassModel superMe = i.next();
                    SuperModelType newSuper =iRoleType.addNewSuperModel();
                    newSuper.setName(superMe.getName());
                  }
                }
                for (int i = 0; i < statusBars.length; i++)
                    statusBars[i].nextStep();
            }
            // Orga Units
            OrganizationUnitType iOrganizationUnitType;
            ResourceClassModel orgunitModelTemp;
            for (Iterator<ResourceClassModel> iter = petrinetModel.getOrganizationUnits().iterator(); iter.hasNext();)
            {
                orgunitModelTemp = (ResourceClassModel) iter.next();
                iOrganizationUnitType = iNetResources.addNewOrganizationUnit();
                iOrganizationUnitType.setName(orgunitModelTemp.getName());
                if(orgunitModelTemp.getSuperModels()!=null){
                  for (Iterator<ResourceClassModel> i = orgunitModelTemp.getSuperModels();i.hasNext();)
                  {
                    ResourceClassModel superMe = i.next();
                    SuperModelType newSuper= iOrganizationUnitType.addNewSuperModel();
                    newSuper.setName(superMe.getName());
                  }
                }
                for (int i = 0; i < statusBars.length; i++)
                    statusBars[i].nextStep();
            }
            // ResourceMap
            ResourceMappingType iNetResourceMap;           
            for (Iterator<String> iter = petrinetModel.getResourceMapping().keySet().iterator();iter.hasNext();)
            {
                String tempResourceClass = (String) iter.next();
                Vector<String> values = petrinetModel.getResourceMapping().get(tempResourceClass);
                // TODO check if mapping exists NullPointerExeption bei
                // speicherung ge�nderter orgUnit die keine zugeordnete Resource
                // hat!
                for (Iterator<String> iterator = values.iterator(); iterator.hasNext();)
                {
                    iNetResourceMap = iNetResources.addNewResourceMapping();
                    iNetResourceMap.setResourceClass(tempResourceClass);
                    iNetResourceMap.setResourceID(iterator.next().toString());
                }
                for (int i = 0; i < statusBars.length; i++)
                    statusBars[i].nextStep();
            }
           
            // Simulations
            SimulationsType iNetSimulations = iNetToolSpec.addNewSimulations();
            SimulationType iSimulation;
            TransitionsequenceType iTransitionsequence;
            OccuredtransitionType iOccuredTransition;
            for (Iterator<SimulationModel> iter = petrinetModel.getSimulations().iterator();iter.hasNext();)
            {
              SimulationModel currSimulation = iter.next();
             
              // check if current fingerprint of the net equals the imported one
            // if not ask the user if he want's to keep the simulation
            //
            // this check is performed as well on:
            // - fileixport
            // - loading a simulation
            // when you change it here please do at those locations as well
              int answer = 0;
              Date simulationCreationDate = currSimulation.getSavedDate();
              if(!petrinetModel.isLogicalFingerprintEqual(currSimulation.getFingerprint()))
              {
                Object[] options = {Messages.getString("Tokengame.ChangedNetDialog.ButtonKeep"),Messages.getString("Tokengame.ChangedNetDialog.ButtonDelete")};
                // get the localized message text
                String message = Messages.getString("Tokengame.ChangedNetDialog.Export.Message");
              // fill the message text dynamically with the simulationname and simulationdate
                message = message.replaceAll("##SIMULATIONNAME##", currSimulation.getName());
                message = message.replaceAll("##SIMULATIONDATE##", DateFormat.getDateInstance().format(currSimulation.getSavedDate()));
              answer = JOptionPane.showOptionDialog(null, message, Messages.getString("Tokengame.ChangedNetDialog.Title"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
              // if the user didn't choose one of the buttons but closed the OptionDialog don't drop the simulation
              if(answer == -1)
              {
                answer = 0;
              }
              }
              if(answer == 0)
              {
                  iSimulation = iNetSimulations.addNewSimulation();
                  iSimulation.setId(currSimulation.getId());
                  iSimulation.setSimulationname(currSimulation.getName());
                  Calendar cal = Calendar.getInstance();
                  cal.setTime(simulationCreationDate);
                  iSimulation.setSimulationdate(cal);
                  iTransitionsequence = iSimulation.addNewTransitionsequence();
                  for(Iterator<TransitionModel> iterator = currSimulation.getOccuredTransitions().iterator();iterator.hasNext();)
                  {
                    iOccuredTransition = iTransitionsequence.addNewOccuredtransition();
                    iOccuredTransition.setTransitionID((iterator.next()).getId());
                  }
                  iSimulation.setNetFingerprint(currSimulation.getFingerprint());
                  LoggerManager.debug(Constants.FILE_LOGGER, "   ... Simulation (ID:" + currSimulation.getId() + ") set");
              }
              else
              {
                LoggerManager.debug(Constants.FILE_LOGGER, "   ... Simulation (ID:" + currSimulation.getId() + ") dropped by user");
              }
            }
           
            // toolspecific
            for (short i = 0; i < petrinetModel.getUnknownToolSpecs().size(); i++)
            {
                iNet.addNewToolspecific();
                if (petrinetModel.getUnknownToolSpecs().get(i) instanceof ToolspecificType)
                {
                    iNet.setToolspecificArray(iNet.getToolspecificArray().length - 1, (NetToolspecificType) petrinetModel.getUnknownToolSpecs().get(i));
                }
            }
        }
        // Now save the root model element container into the
        // NetType XMLBean holding our net
View Full Code Here

    }
    return contains;
  }

  private void initResourceAlloc() {
    PetriNetModelProcessor pmp = (PetriNetModelProcessor) editor
        .getModelProcessor();

    ArrayList<String> roles = new ArrayList<String>();
    ArrayList<String> groups = new ArrayList<String>();
    Vector<ResourceClassModel> rVec = pmp.getRoles();
    Vector<ResourceClassModel> gVec = pmp.getOrganizationUnits();

    for (int i = 0; i < rVec.size(); i++)
      roles.add(((ResourceClassModel) rVec.get(i)).getName());

    for (int i = 0; i < gVec.size(); i++)
View Full Code Here

  private void importNets(PnmlType pnml, boolean showUI) throws Exception {
    editor = new IEditor[pnml.getNetArray().length];
    NetType currentNet;
    Dimension dim;
    Point location;
    PetriNetModelProcessor currentPetrinet;
    SimulationType[] simulations;

    for (int i = 0; i < pnml.getNetArray().length; i++) {
      simulations = null;
      boolean savedFlag = true;
      currentNet = pnml.getNetArray(i);
      editor[i] = mediator.createEditor(true, showUI);
      if(showUI){
        if (((WoPeDUndoManager) editor[i].getGraph().getUndoManager()) != null) {

        ((WoPeDUndoManager) editor[i].getGraph().getUndoManager())
            .setEnabled(false);
      }
      }
      currentPetrinet = ((PetriNetModelProcessor) editor[i]
          .getModelProcessor());
      // attr. id
      currentPetrinet.setId(currentNet.getId());
      // attr. type
      // Type no other types
      // name
      if (currentNet.isSetName()) {
        currentPetrinet.setName(currentNet.getName().getText());
      }
      if(showUI) if (ConfigurationManager.getConfiguration().isImportToolspecific()) {
        // toolspecific
        for (int j = 0; j < currentNet.getToolspecificArray().length; j++) {
          if (currentNet.getToolspecificArray(j).getTool().equals(
              "WoPeD")) {
            if (currentNet.getToolspecificArray(j).isSetBounds()) {
              dim = new Dimension(currentNet
                  .getToolspecificArray(j).getBounds()
                  .getDimension().getX().intValue(),
                  currentNet.getToolspecificArray(j)
                      .getBounds().getDimension().getY()
                      .intValue());
              location = new Point(currentNet
                  .getToolspecificArray(j).getBounds()
                  .getPosition().getX().intValue(),
                  currentNet.getToolspecificArray(j)
                      .getBounds().getPosition().getY()
                      .intValue());
              if (editor[i] instanceof EditorVC) {
                // Pass read layout information on to the editor
                EditorLayoutInfo layout = new EditorLayoutInfo();
                layout.setSavedSize(dim);
                layout.setSavedLocation(location);
               
                // try to import the type of Layout (false if vertical)
                ((EditorVC) editor[i]).setRotateSelected(currentNet
                    .getToolspecificArray(j)
                    .getVerticalLayout());
               
                  //for importing a vertical net to change the rotate-button 
                  if (currentNet
                        .getToolspecificArray(j)
                        .getVerticalLayout()== true){
                      //EditorVC.setRotateSelected(true);
                    VisualController.getInstance().propertyChange(new PropertyChangeEvent(this, "Import", null, null));
                     
                   
                    // Update the UI representation
                      //EditorVC.getGraph().updateUI(); 
                    }
                 
                  if (currentNet.getToolspecificArray(j).isSetScale()) {
                    // try to import the saved scale
                    ((EditorVC) editor[i]).getGraph().setScale(currentNet
                      .getToolspecificArray(j).getScale()/100.0);
                  }
                 

                // Only if also the remaining information is
                // available,
                // try to import the width of the tree view and the height of the overview panel
                  if (currentNet.getToolspecificArray(j).isSetTreeWidth()){
                    GraphicsSimpleType bounds = currentNet.getToolspecificArray(j).getBounds();
                    DimensionType dimension = bounds.getDimension();
                    int x =(int) (dimension.getX()).doubleValue();
                    x = x - currentNet.getToolspecificArray(j).getTreeWidth();
                    layout.setTreeViewWidthRight(x);
                  } else if (currentNet.getToolspecificArray(j).isSetTreeWidthRight()){
                    layout.setTreeViewWidthRight(currentNet.getToolspecificArray(j).getTreeWidthRight());
                  }
                  else {
                    layout.setTreeViewWidthRight(currentNet
                        .getToolspecificArray(j).getBounds()
                        .getDimension().getX().intValue() - 100);                   
                  }
                 
                  if(currentNet.getToolspecificArray(j).isSetOverviewPanelVisible()){
                    layout.setOverviewPanelVisible(currentNet.getToolspecificArray(j).getOverviewPanelVisible());
                  }else{
                    layout.setOverviewPanelVisible(true);
                  }
                 
                  if (currentNet.getToolspecificArray(j).isSetTreeHeightOverview()){
                    if(currentNet.getToolspecificArray(j).getTreeHeightOverview() < 1){
                      layout.setTreeHeightOverview(100);
                    }else{
                    layout.setTreeHeightOverview(currentNet.getToolspecificArray(j).getTreeHeightOverview());
                    }
                  }else{
                    layout.setTreeHeightOverview(100);
                  }
                 
                  if(currentNet.getToolspecificArray(j).isSetTreePanelVisible()){

                    layout.setTreePanelVisible(currentNet.getToolspecificArray(j).getTreePanelVisible());
                     
                  }else{
                    layout.setTreePanelVisible(true);
                  }
                 
                  ((EditorVC) editor[i]).getEditorPanel().setSavedLayoutInfo(layout);
                }
              }
            if (currentNet.getToolspecificArray(j).isSetResources()) {
              // ResourceMapType resourceMap =
              // currentNet.getToolspecificArray(j).getResources().getResourceMap();
              ResourceMappingType[] resourceMaps = currentNet
                  .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);
                }
              }

              ResourceType[] resources = currentNet
                  .getToolspecificArray(j).getResources()
                  .getResourceArray();
              ResourceModel resourceModelTemp;
              for (int m = 0; m < resources.length; m++) {
                resourceModelTemp = new ResourceModel(
                    resources[m].getName());
                currentPetrinet.addResource(resourceModelTemp);
              }

              for (int n = 0; n < resourceMaps.length; n++) {
                currentPetrinet.addResourceMapping(
                    resourceMaps[n].getResourceClass(),
                    resourceMaps[n].getResourceID());
              }
            }
            if (currentNet.getToolspecificArray(j)
                .isSetSimulations()) {
              // only save the simulationsarray to local variable
              // here - the import itself
              // has to be done after import of the transitions
              // because the simulation
              // references transitions (which otherwise result in
              // 'null')
              // see "importSimulations([...])" below
              simulations = currentNet.getToolspecificArray(j)
                  .getSimulations().getSimulationArray();
            }

            if (currentNet.getToolspecificArray(j)
                .isSetPartnerLinks()) {
              TPartnerLinks plist = currentNet
                  .getToolspecificArray(j).getPartnerLinks();
              for (int x = 0; x < plist.sizeOfPartnerLinkArray(); x++) {
                TPartnerLink link = plist
                    .getPartnerLinkArray(x);
                if (link.isSetMyRole()
                    && link.isSetPartnerRole()) {
                  currentPetrinet.getElementContainer()
                      .addPartnerLink(
                          link.getName(),
                          link.getPartnerLinkType()
                              .getNamespaceURI(),
                          link.getPartnerLinkType()
                              .getLocalPart(),
                          link.getPartnerRole(),
                          link.getMyRole(),
                          link.getWSDL());
                } else if (link.isSetMyRole()) {
                  currentPetrinet.getElementContainer()
                      .addPartnerLinkWithoutPartnerRole(
                          link.getName(),
                          link.getPartnerLinkType()
                              .getNamespaceURI(),
                          link.getPartnerLinkType()
                              .getLocalPart(),
                          link.getMyRole(),
                          link.getWSDL());
                } else if (link.isSetPartnerRole()) {
                  currentPetrinet.getElementContainer()
                      .addPartnerLinkWithoutMyRole(
                          link.getName(),
                          link.getPartnerLinkType()
                              .getNamespaceURI(),
                          link.getPartnerLinkType()
                              .getLocalPart(),
                          link.getPartnerRole(),
                          link.getWSDL());
                }
              }
            }

            if (currentNet.getToolspecificArray(j).isSetVariables()) {
              TVariables vlist = currentNet.getToolspecificArray(
                  j).getVariables();
              for (int x = 0; x < vlist.sizeOfVariableArray(); x++) {
                TVariable var = vlist.getVariableArray(x);
                currentPetrinet.getElementContainer()
                    .addVariable(var.getName(),
                        var.getType().getLocalPart());
              }
            }
          } else {
            currentPetrinet.addUnknownToolSpecs(currentNet
                .getToolspecificArray(j));
          }
        }

      }
View Full Code Here

  private void importTransitions(NetType currentNet,
      ModelElementContainer currentContainer) throws Exception {
    // The model element processor can correctly create resources and
    // triggers
    // for transitions so we use it at this point to do so
    PetriNetModelProcessor processor = new PetriNetModelProcessor();
    processor.setElementContainer(currentContainer);

    TransitionType transitions[] = currentNet.getTransitionArray();
    CreationMap map;

    for (int i = 0; i < transitions.length; i++) {
      map = CreationMap.createMap();
      map.setEditOnCreation(false);
      map.setType(AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE);
      try {
        importNameAndLayout(transitions[i], map);
        try {
          if (ConfigurationManager.getConfiguration()
              .isImportToolspecific()) {
            for (int j = 0; j < transitions[i]
                .getToolspecificArray().length; j++) {
              if (transitions[i].getToolspecificArray(j)
                  .getTool().equals("WoPeD")) {
                if (transitions[i].getToolspecificArray(j)
                    .isSetTime()) {
                  map.setTransitionTime(transitions[i]
                      .getToolspecificArray(j).getTime());
                }
                if (transitions[i].getToolspecificArray(j)
                    .isSetTimeUnit()) {
                  map.setTransitionTimeUnit(transitions[i]
                      .getToolspecificArray(j)
                      .getTimeUnit());
                }
               
                //set operatorOrientation
                if (transitions[i].getToolspecificArray(j)
                    .isSetOrientation()) {
                  map.setOperatorPosition(transitions[i]
                      .getToolspecificArray(j)
                      .getOrientation());
                }
                if (transitions[i].getToolspecificArray(j)
                    .isSetOperator()) {
                  map.setOperatorType(transitions[i]
                      .getToolspecificArray(j)
                      .getOperator().getType());
                  map
                      .setType(TransitionModel.TRANS_OPERATOR_TYPE);
                  map.setId(transitions[i]
                      .getToolspecificArray(j)
                      .getOperator().getId());
                } else if (transitions[i].getToolspecificArray(
                    j).isSetSubprocess()) {
                  map.setType(AbstractPetriNetElementModel.SUBP_TYPE);
                }
                if (transitions[i].getToolspecificArray(j)
                    .isSetTrigger()) {
                  map.setTriggerType(transitions[i]
                      .getToolspecificArray(j)
                      .getTrigger().getType());
                  map.setTriggerPosition(transitions[i]
                      .getToolspecificArray(j)
                      .getTrigger().getGraphics()
                      .getPosition().getX().intValue(),
                      transitions[i]
                          .getToolspecificArray(j)
                          .getTrigger().getGraphics()
                          .getPosition().getY()
                          .intValue());
                }
                if (transitions[i].getToolspecificArray(j)
                    .isSetTransitionResource()) {
                  // &&
                  // transitions[i].getToolspecificArray(j).getTrigger().getType()
                  // == 200
                  map.setResourceOrgUnit(transitions[i]
                      .getToolspecificArray(j)
                      .getTransitionResource()
                      .getOrganizationalUnitName());
                  map.setResourceRole(transitions[i]
                      .getToolspecificArray(j)
                      .getTransitionResource()
                      .getRoleName());
                  map.setResourcePosition(transitions[i]
                      .getToolspecificArray(j)
                      .getTransitionResource()
                      .getGraphics().getPosition().getX()
                      .intValue(), transitions[i]
                      .getToolspecificArray(j)
                      .getTransitionResource()
                      .getGraphics().getPosition().getY()
                      .intValue());
                }
                if (transitions[i].getToolspecificArray(j)
                    .isSetEmpty()) {
                  TEmpty empty = transitions[i]
                      .getToolspecificArray(j).getEmpty();
                  Empty bpel = new Empty(empty.getName());
                  map.setBpeldata(bpel);
                }
                if (transitions[i].getToolspecificArray(j)
                    .isSetAssign()) {
                  TAssign assign = transitions[i]
                      .getToolspecificArray(j)
                      .getAssign();
                  Assign bpel = new Assign(assign.getName(),
                      assign.getCopyArray(0).getFrom()
                          .getVariable(), assign
                          .getCopyArray(0).getTo()
                          .getVariable());
                  map.setBpeldata(bpel);
                }
                if (transitions[i].getToolspecificArray(j)
                    .isSetInvoke()) {
                  TInvoke invoke = transitions[i]
                      .getToolspecificArray(j)
                      .getInvoke();
                  Invoke bpel = new Invoke(invoke.getName(),
                      invoke.getPartnerLink(), invoke
                          .getOperation(), "", invoke
                          .getInputVariable(), invoke
                          .getOutputVariable());
                  map.setBpeldata(bpel);
                }
                if (transitions[i].getToolspecificArray(j)
                    .isSetReceive()) {
                  TReceive receive = transitions[i]
                      .getToolspecificArray(j)
                      .getReceive();
                  Receive bpel = new Receive(receive
                      .getName(), receive
                      .getPartnerLink(), receive
                      .getOperation(), receive
                      .getVariable());
                  map.setBpeldata(bpel);
                }
                if (transitions[i].getToolspecificArray(j)
                    .isSetReply()) {
                  TReply reply = transitions[i]
                      .getToolspecificArray(j).getReply();
                  Reply bpel = new Reply(reply.getName(),
                      reply.getPartnerLink(), reply
                          .getOperation(), reply
                          .getVariable());
                  map.setBpeldata(bpel);
                }
                if (transitions[i].getToolspecificArray(j)
                    .isSetWait()) {
                  TWait wait = transitions[i]
                      .getToolspecificArray(j).getWait();
                  Wait bpel = new Wait(wait.getName(), wait
                      .getTyp(), wait.getYear(), wait
                      .getMonth(), wait.getDay(), wait
                      .getHour(), wait.getMinute(), wait
                      .getSecond());
                  map.setBpeldata(bpel);
                }
              } else {

                map.addUnknownToolSpec(transitions[i]
                    .getToolspecificArray(j));
              }
            }
          }
        } catch (Exception e) {
          warnings
              .add("- TRANSITION LOST INFORMATION ("
                  + transitions[i].getId()
                  + "): Exception while importing lesser important information.");
        }

        if (!currentContainer.containsElement(map.getId())) {
          // There is one fun thing about transitions:
          // They may be inner transitions which are treated specially
          // by carrying
          // some tool-specific information as to which operator they
          // belong.
          // Now, instead of the transition, an operator is created
          // for each of those inner transitions
          // and all but the first such instance are discarded here
          // because an element
          // with the same id already exists at this point
          AbstractPetriNetElementModel element = processor.createElement(map);
          currentContainer.addElement(element);
          LoggerManager.debug(Constants.FILE_LOGGER,
              " ... Transition (ID:" + map.getId() + ")imported");
          // increaseCurrent();
View Full Code Here

TOP

Related Classes of org.woped.core.model.PetriNetModelProcessor

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.