예제 #1
0
  private void initialize() throws BioclipseException {

    if (dsBusinessModel == null) {
      dsBusinessModel = new DSBusinessModel();
      dsBusinessModel.initialize();
    }
    if (dsBusinessModel == null) throw new BioclipseException("Error initializing DS model.");
  }
예제 #2
0
  /**
   * Get a list of all available tests
   *
   * @return
   * @throws BioclipseException
   */
  public List<String> getEndpoints() throws BioclipseException {

    initialize();

    List<String> epIDs = new ArrayList<String>();
    for (Endpoint ep : dsBusinessModel.getEndpoints()) {
      epIDs.add(ep.getId());
    }
    return epIDs;
  }
예제 #3
0
  /**
   * Get a list of all available tests
   *
   * @return
   * @throws BioclipseException
   */
  public List<String> getTests() throws BioclipseException {

    initialize();

    List<String> testIDS = new ArrayList<String>();
    for (IDSTest test : dsBusinessModel.getTests()) {
      testIDS.add(test.getId());
    }

    return testIDS;
  }
예제 #4
0
  public IDSTest getTest(String testID) throws BioclipseException {

    if (testID == null) throw new BioclipseException("Test: " + testID + " must not be null.");

    initialize();

    for (IDSTest test : dsBusinessModel.getTests()) {
      if (testID.equals(test.getId())) return test;
    }

    logger.warn("Test: " + testID + " could not be found.");
    throw new BioclipseException("Test: " + testID + " could not be found.");
  }
예제 #5
0
  public Endpoint getEndpoint(String endpointID) throws BioclipseException {

    if (endpointID == null)
      throw new BioclipseException("Endpoint: " + endpointID + " must not be null.");

    initialize();

    for (Endpoint ep : dsBusinessModel.getEndpoints()) {
      if (endpointID.equals(ep.getId())) return ep;
    }

    logger.warn("Endpoint: " + endpointID + " could not be found.");
    throw new BioclipseException("Endpoint: " + endpointID + " could not be found.");
  }
예제 #6
0
 public List<IDSTest> getFullTests() throws BioclipseException {
   initialize();
   return dsBusinessModel.getTests();
 }
예제 #7
0
  /**
   * Removes a model. Removes extension and any files.
   *
   * @param model
   */
  public void removeModel(IDSTest model, String pluginID) {

    // Remove from DSBusinessModel
    dsBusinessModel.getTests().remove(model);
    for (Endpoint ep : dsBusinessModel.getEndpoints()) {
      if (ep.getTests() != null) {
        ep.getTests().remove(model);
        logger.debug("Removed model " + model.getName() + " from EP " + ep.getName());
      }
    }

    // Remove extensions in models.container plugin
    // =============================================
    File pluginXMLfile;
    try {
      pluginXMLfile = new File(FileUtil.getFilePath("plugin.xml", pluginID));

      Builder parser = new Builder();
      Document doc = parser.build(pluginXMLfile);
      Element root = doc.getRootElement();

      Element extension = null;

      // Find extension in plugin.xml, if exists
      Elements existingExtensions = root.getChildElements("extension");
      if (existingExtensions != null && existingExtensions.size() > 0) {
        for (int i = 0; i < existingExtensions.size(); i++) {
          extension = existingExtensions.get(i);

          // If exists a model with same name, remove it
          Elements existingTests = extension.getChildElements("test");
          if (existingTests != null && existingTests.size() > 0) {
            for (int j = 0; j < existingTests.size(); j++) {
              Element test = existingTests.get(j);
              String testName = test.getAttribute("name").getValue();

              // Remove spaces included by XML serialization
              while (testName.contains("  ")) testName = testName.replace("  ", " ");

              if (model.getName().equals(testName)) {
                test.getParent().removeChild(test);
                logger.debug("Removing existing model extension: " + model.getName());

                // Also remove the files
                Elements resources = test.getChildElements("resource");
                for (int rescnt = 0; rescnt < resources.size(); rescnt++) {
                  Element resource = resources.get(rescnt);
                  String path = resource.getAttribute("path").getValue();
                  try {
                    File reFile = new File(FileUtil.getFilePath(path, pluginID));
                    if (reFile.exists()) {
                      logger.debug("Removing file: " + reFile);
                      reFile.delete();
                    } else logger.debug("Unable to locate file to remove: " + path);
                  } catch (Exception e) {
                    logger.error("Problems removing file: " + path);
                  }
                }
              }
            }
          }
        }
      }

      // Serialize the updated plugin.xml to file
      Serializer serializer = new Serializer(new FileOutputStream(pluginXMLfile));
      serializer.setIndent(4);
      serializer.setMaxLength(64);
      serializer.write(doc);

    } catch (IllegalArgumentException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (ValidityException e) {
      e.printStackTrace();
    } catch (ParsingException e) {
      e.printStackTrace();
    }
  }
예제 #8
0
 public List<Endpoint> getFullEndpoints() throws BioclipseException {
   initialize();
   return dsBusinessModel.getEndpoints();
 }