Package org.openbp.core.model

Examples of org.openbp.core.model.Model


  public void moveItem(Item item, ModelQualifier destinationQualifier)
  {
    String destinationItemName = destinationQualifier.getItem();

    String destinationModelName = destinationQualifier.getModel();
    Model destinationModel = item.getModel();
    if (destinationModelName != null)
      destinationModel = getModelByQualifier(ModelQualifier.constructModelQualifier(destinationModelName));

    if (CommonUtil.equalsNull(item.getName(), destinationItemName) && CommonUtil.equalsNull(item.getModel(), destinationModel))
      return;

    // TODO Fix 5: This does not account any artifacts (e. g. class files) that accompany the item.

    removeItemFromStore(item);

    Model sourceModel = item.getModel();
    sourceModel.removeItem(item);

    if (destinationItemName != null)
      item.setName(destinationItemName);

    destinationModel.addItem(item);
View Full Code Here


    else
    {
      // Reset all model class loaders only
      for (Iterator it = allModels.values().iterator(); it.hasNext();)
      {
        Model model = (Model) it.next();
        model.resetModel();
      }
    }

    // Initialize the models
    initializeModels();
View Full Code Here

  {
    String itemType = qualifier.getItemType();

    if (itemType == null)
    {
      Model model;
      switch (mode)
      {
      case ModelNotificationService.ADDED:
        // Read the model and repair hiearchy, establish links and instantiate the model
        model = readModelFromStore(qualifier);
        if (model != null)
        {
          model.maintainReferences(ModelObject.RESOLVE_GLOBAL_REFS | ModelObject.RESOLVE_LOCAL_REFS | ModelObject.INSTANTIATE_ITEM);
        }
        break;

      case ModelNotificationService.UPDATED:
        model = getOptionalModelByQualifier(qualifier);
        if (model != null)
        {
          reloadModelAfterModelUpdate(model);
        }
        break;

      case ModelNotificationService.REMOVED:
        model = getOptionalModelByQualifier(qualifier);
        if (model != null)
        {
          unregisterModel(model);
        }
        break;
      }
    }
    else
    {
      Item item;
      Model model;
      switch (mode)
      {
      case ModelNotificationService.ADDED:
        item = readItemFromStore(qualifier);
        if (item != null)
        {
          model = item.getModel();
          model.addItem(item);
        }
        break;

      case ModelNotificationService.UPDATED:
        item = getItemByQualifier(qualifier, false);
        if (item != null)
        {
          reloadItemAfterModelUpdate(item);
        }
        break;

      case ModelNotificationService.REMOVED:
        item = getItemByQualifier(qualifier, false);
        if (item != null)
        {
          model = item.getModel();
          model.removeItem(item);
        }
        break;
      }
    }
  }
View Full Code Here

    if (isInstantiateItems())
      flag |= ModelObject.INSTANTIATE_ITEM;

    for (Iterator it = allModels.values().iterator(); it.hasNext();)
    {
      Model model = (Model) it.next();

      // After a model has been read, the links to other objects must be established
      // and the objects instantiated if necessary
      model.maintainReferences(flag);

      // TODO Feature 4 Trigger unit event
    }
  }
View Full Code Here

      throw new ModelException("Operation", "Model '" + qualifier + "' already exists");

    // Then, check in other model managers
    if (getParentModelMgr() != null)
    {
      Model existingModel = getParentModelMgr().getOptionalModelByQualifier(qualifier);;
      if (existingModel != null)
      {
        throw new ModelException("Operation", "Model '" + qualifier + "' already loaded by model manager '" + existingModel.getModelMgr().getClass().getName() + "'.");
      }
    }

    // Now that the model descriptor has been written, we can link the new model
    // into the top level/all models list.
View Full Code Here

    // Set the initial state of the item tree
    ItemTreeState state = new ItemTreeState();

    // Open the tree at the model of the target item
    Model currentModel = getParam().getProcess().getOwningModel();
    state.addExpandedQualifier(currentModel.getQualifier());

    // Select the current data type if present
    if (getExpression() != null)
    {
      // Try to determine the new data type and perform a default configuration
      // of the member according to its new type
      DataTypeItem type = (DataTypeItem) currentModel.resolveItemRef(getExpression(), ItemTypes.TYPE);
      if (type != null)
      {
        state.addSelectedQualifier(type.getQualifier());
      }
      else
      {
        state.addSelectedQualifier(currentModel.getQualifier());
      }
    }

    itemTree.rebuildTree();
    itemTree.expand(1);
View Full Code Here

    if (mode == MODE_COPY)
    {
      // Check for target models
      for (String modelName : modelList)
      {
        Model model = getModel(modelName, targetMgr);
        if (model != null)
        {
          if (isOverwrite())
          {
            removeModel(model, targetMgr, targetMgrType);
          }
          else
          {
            printError("Cannot overwrite model '" + modelName + "' in target model manager.");
          }
        }
      }

      // Perform operation
      for (String modelName : modelList)
      {
        Model model = getModel(modelName, sourceMgr);
        if (model == null)
        {
          printError("Model '" + modelName + "' not found in source model manager.");
        }

        copyModel(model);
      }
    }
    else if (mode == MODE_REMOVE)
    {
      // Perform operation
      for (String modelName : modelList)
      {
        Model model = getModel(modelName, targetMgr);
        if (model == null)
        {
          printError("Model '" + modelName + "' not found in source target manager.");
        }
View Full Code Here

      Dumper dumper = new Dumper();

      if (testMode.equals("Children"))
      {
        // Get the process to execute
        Model model = ModelConnector.getInstance().getModelByQualifier(ModelQualifier.constructModelQualifier("AddressBookDemo"));
        List l = new ArrayList();
        l.add(model);

        showObjectList(l);
      }
View Full Code Here

  private void copyModel(Model model)
    throws Exception
  {
    printMsg("Copying model '" + model.getName() + "' from " + sourceMgrType + " model manager to " + targetMgrType + " model manager.");

    Model newModel = new ModelImpl();
    newModel.copyFrom(model, Copyable.COPY_SHALLOW);
    ((ModelImpl) newModel).internalResetItems();
    targetMgr.addModel(newModel);

    copyItems(newModel, model, ItemTypes.TYPE, targetMgr);
    copyItems(newModel, model, ItemTypes.ACTOR, targetMgr);
View Full Code Here

   * @param modelPath Fully qualified name of the model to read
   * @return The new model or null (error messages go to the message container)
   */
  private Model readModelByPath(String modelPath)
  {
    Model model = readModelDescriptor(modelPath);
    if (model == null)
      return null;

    // Save the model manager reference and the custom model dir, if any.
    model.setModelPath(modelPath);

    // Register the model
    try
    {
      registerModel(model);
    }
    catch (ModelException e)
    {
      getMsgContainer().addMsg(null, "Error registering model $0 in model manager $1", new Object[]
      {
        model.getName(), getClass().getName(), e
      });
      return null;
    }

    // Read the model items
    ItemTypeDescriptor[] itds = getItemTypeDescriptors(ItemTypeRegistry.SKIP_MODEL | ItemTypeRegistry.SKIP_INVISIBLE);
    for (int i = 0; i < itds.length; ++i)
    {
      readItems(model, modelPath, itds[i]);
    }

    LogUtil.info(getClass(), "Loaded model $0 from file system.", model.getQualifier());
    return model;
  }
View Full Code Here

TOP

Related Classes of org.openbp.core.model.Model

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.