Package org.openbp.core.model

Examples of org.openbp.core.model.Model


        item.setGeneratorInfo(source.getGeneratorInfo());

        // TODONOW Item item = (Item) source.clone();

        Model model = getSelectedModel(ItemBrowserPlugin.GUESS_MODEL | ItemBrowserPlugin.USE_CURRENT_MODEL);
        item.setModel(model);

        item.maintainReferences(ModelObject.SYNC_GLOBAL_REFNAMES | ModelObject.RESOLVE_LOCAL_REFS);

        // Find a new name for the item; we generate the name by appending a running number to the item type
View Full Code Here


   * @param modelDescriptorResource Resource that identifies the model descriptor file
   * @return The new model or null (error messages go to the message container)
   */
  private Model readModelByPath(Resource modelDescriptorResource)
  {
    Model model = readModelDescriptor(modelDescriptorResource);
    if (model == null)
      return null;

    // Determine the model URL from the descriptor URL
    // TODO Cleanup 4: This is very rough, there should be some better way... In fact, the modelPath property should be a modelUrl property
    URL url = null;
    try
    {
      url = modelDescriptorResource.getURL();
    }
    catch (IOException e1)
    {
      throw new ModelException("ClassPathOperation", "Error accessing model URL '" + modelDescriptorResource.getDescription() + "'.");
    }
    String modelPath = url.toString();
    int index = modelPath.lastIndexOf(StringUtil.FOLDER_SEP_CHAR);
    if (index > 0)
    {
      modelPath = modelPath.substring(0, index);
    }
    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 classpath.", model.getQualifier());
    return model;
  }
View Full Code Here

   * @return The new item or null (error messages go to the message container)
   */
  protected Item readItemFromStore(ModelQualifier itemQualifier)
  {
    ModelQualifier modelQualifier = ModelQualifier.constructModelQualifier(itemQualifier.getModel());
    Model model = getOptionalModelByQualifier(modelQualifier);
    if (model != null)
    {
      String itemType = itemQualifier.getItemType();
      ItemTypeDescriptor itd = getItemTypeDescriptor(itemType);
      if (itd == null)
View Full Code Here

  private String determineModelPath(final PathEditor editor)
  {
    Object editedObject = editor.getObject();
    if (editedObject instanceof ModelObject)
    {
      Model model = ((ModelObject) editedObject).getOwningModel();
      if (model != null)
        return model.getModelPath();
    }
    return null;
  }
View Full Code Here

  public boolean saveItem(Item item, boolean isNew)
  {
    try
    {
      // Add or update the item
      Model model = item.getModel();

      if (item instanceof Model)
      {
        Model modelToUpdate = (Model) item;

        if (isNew)
        {
          addModel(modelToUpdate);
        }
View Full Code Here

    if (getParentModelMgr() != null)
    {
      return getParentModelMgr().getModelByQualifier(modelQualifier);
    }

    Model model = internalGetModelByQualifier(modelQualifier);
    if (model == null)
      throw new ModelException("ObjectNotFound", "Model '" + modelQualifier + "' does not exist");
    return model;
  }
View Full Code Here

  {
    // The update is performed by copying the data from the update model
    // to the actual model in order not to loose relations to any dependent
    // objects that might be contained in or referenced by the item

    Model currentModel = getModelByQualifier(model.getQualifier());

    // Update the model item from the argument item
    // Perform a flat copy only, the contained objects will remain the same
    try
    {
      // copyFrom will overwrite the parent model information; save it
      Model parentModel = currentModel.getModel();

      // In contrast to updateItem, we will do a shallow copy here or else all
      // sub models and items will be copied
      currentModel.copyFrom(model, Copyable.COPY_SHALLOW);
View Full Code Here

    if (qualifier.getModel() == null)
      throw new ModelException("Operation", "Missing model name");
    if (qualifier.getItem() == null)
      throw new ModelException("Operation", "Missing component name");

    Model model = null;
    if (required)
    {
      model = getModelByQualifier(ModelQualifier.constructModelQualifier(qualifier.getModel()));
    }
    else
    {
      model = getOptionalModelByQualifier(ModelQualifier.constructModelQualifier(qualifier.getModel()));
    }
    if (model != null)
      return model.getItem(qualifier.getItem(), qualifier.getItemType(), required);
    return null;
  }
View Full Code Here

    // Update the model item from the argument item
    // Perform a flat copy only, the contained objects will remain the same
    try
    {
      // copyFrom will overwrite the parent model information; save it
      Model currentModel = currentItem.getModel();

      // Copy the item data
      currentItem.copyFrom(argItem, Copyable.COPY_DEEP);

      // Repair hiearchy and establish links
View Full Code Here

  {
    // Remove item file
    removeItemFromStore(item);

    // Remove the item from the model finally
    Model model = item.getModel();

    model.removeItem(item);
  }
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.