コード例 #1
0
  /**
   * @param selection
   * @return
   */
  public boolean setSelection(ISelection selection) {
    if (SelectionUtilities.isMultiSelection(selection)) return false;

    Object obj = SelectionUtilities.getSelectedObject(selection);
    // If a VDB is selected and it contains a web service model then
    // enable
    if (!(obj instanceof IFile)) return false;

    if (!isVdb(obj)) return false;

    this.selectedVDB = (IFile) obj;

    boolean result = false;
    try {
      Vdb vdb = new Vdb(this.selectedVDB, new NullProgressMonitor());
      Set<VdbModelEntry> modelEntrySet = vdb.getModelEntries();
      for (VdbModelEntry vdbModelEntry : modelEntrySet) {
        final ModelResource modelResource =
            ModelerCore.getModelWorkspace().findModelResource(vdbModelEntry.getName());
        if (!ModelIdentifier.isVirtualModelType(modelResource)) continue;

        List<RestProcedure> restfulProcedureArray = findRestProcedures(modelResource);
        if (restfulProcedureArray.size() > 0) {
          String modelName =
              FileUtils.getFilenameWithoutExtension(vdbModelEntry.getName().lastSegment());
          restfulProcedureMap.put(modelName, restfulProcedureArray);
          result = true;
        }
      }
    } catch (Exception ex) {
      DqpPlugin.Util.log(ex);
      return false;
    }

    return result;
  }
コード例 #2
0
  @Test
  public void convertDynamicVdbToXmiVdb() throws Exception {
    DynamicVdb dynVdb = VdbTestUtils.mockPortfolioDynamicVdb(modelWorkspaceMock);
    assertNotNull(dynVdb);

    IFile dynVdbSrcFile = dynVdb.getSourceFile();
    IProject parent = dynVdbSrcFile.getProject();
    assertNotNull(parent);

    File destFile = File.createTempFile(dynVdb.getName(), ITeiidVdb.VDB_DOT_EXTENSION);
    MockFileBuilder destination = new MockFileBuilder(destFile);

    XmiVdb xmiVdb = dynVdb.convert(XmiVdb.class, destination.getResourceFile(), new Properties());

    assertEquals(dynVdb.getName(), xmiVdb.getName());
    assertEquals(dynVdb.getDescription(), xmiVdb.getDescription());

    for (Map.Entry<Object, Object> entry : dynVdb.getProperties().entrySet()) {
      System.out.println(
          "VDB Property:  "
              + entry.getValue()
              + " == "
              + xmiVdb.getProperties().getProperty(entry.getKey().toString()));
      assertEquals(entry.getValue(), xmiVdb.getProperties().getProperty(entry.getKey().toString()));
    }

    assertEquals(destination.getResourceFile(), xmiVdb.getSourceFile());
    assertEquals(dynVdb.getVersion(), xmiVdb.getVersion());

    assertEquals(dynVdb.getConnectionType(), xmiVdb.getConnectionType());
    assertEquals(dynVdb.isPreview(), xmiVdb.isPreview());
    assertEquals(dynVdb.getQueryTimeout(), xmiVdb.getQueryTimeout());

    assertEquals(dynVdb.getAllowedLanguages().size(), xmiVdb.getAllowedLanguages().size());
    List<String> dynLanguageValues =
        Arrays.asList(xmiVdb.getAllowedLanguages().getAllowedLanguageValues());
    for (String language : dynVdb.getAllowedLanguages().getAllowedLanguageValues()) {
      assertTrue(dynLanguageValues.contains(language));
    }

    assertEquals(dynVdb.getSecurityDomain(), xmiVdb.getSecurityDomain());
    assertEquals(dynVdb.getGssPattern(), xmiVdb.getGssPattern());
    assertEquals(dynVdb.getPasswordPattern(), xmiVdb.getPasswordPattern());
    assertEquals(dynVdb.getAuthenticationType(), xmiVdb.getAuthenticationType());
    assertEquals(dynVdb.getValidationDateTime(), xmiVdb.getValidationDateTime());
    assertEquals(dynVdb.isAutoGenerateRESTWar(), xmiVdb.isAutoGenerateRESTWar());

    assertEquals(dynVdb.getImports().size(), xmiVdb.getImports().size());
    for (VdbImportVdbEntry entry : dynVdb.getImports()) {
      assertTrue(xmiVdb.getImports().contains(entry));
    }

    assertEquals(dynVdb.getTranslators().size(), xmiVdb.getTranslators().size());
    for (TranslatorOverride translator : dynVdb.getTranslators()) {
      assertTrue(xmiVdb.getTranslators().contains(translator));
    }

    assertEquals(dynVdb.getDataRoles().size(), xmiVdb.getDataRoles().size());
    for (DataRole role : dynVdb.getDataRoles()) {
      assertTrue(xmiVdb.getDataRoles().contains(role));
    }

    assertEquals(dynVdb.getDynamicModels().size(), xmiVdb.getModelEntries().size());
    for (DynamicModel dynModel : dynVdb.getDynamicModels()) {

      VdbModelEntry modelEntry = null;
      Collection<VdbModelEntry> entries = xmiVdb.getModelEntries();
      for (VdbModelEntry entry : entries) {
        if (dynModel.getName().equals(entry.getName())) {
          modelEntry = entry;
          break;
        }
      }
      assertNotNull(modelEntry);

      assertEquals(dynModel.getDescription(), modelEntry.getDescription());

      for (Map.Entry<Object, Object> prop : dynModel.getProperties().entrySet()) {
        assertEquals(
            prop.getValue(), modelEntry.getProperties().getProperty(prop.getKey().toString()));
      }

      VdbSourceInfo sourceInfo = modelEntry.getSourceInfo();

      assertEquals(dynModel.getModelType().toString(), modelEntry.getType());
      assertEquals(dynModel.isMultiSource(), sourceInfo.isMultiSource());
      assertEquals(dynModel.doAddColumn(), sourceInfo.isAddColumn());
      assertEquals(dynModel.getColumnAlias(), sourceInfo.getColumnAlias());

      assertEquals(dynModel.getSources().length, sourceInfo.getSources().size());
      List<VdbSource> entrySources = new ArrayList<VdbSource>(sourceInfo.getSources());
      for (VdbSource source : dynModel.getSources()) {
        assertTrue(entrySources.contains(source));
      }
    }
  }