protected void addToWar(IVirtualComponent warComp, IVirtualComponent j2eeComp, String moduleURI) {
    final IDataModel dataModel =
        DataModelFactory.createDataModel(
            new AddWebFragmentComponentToWebApplicationDataModelProvider());
    Map map =
        (Map)
            dataModel.getProperty(
                IAddWebFragmentComponentToWebApplicationDataModelProperties
                    .TARGET_COMPONENTS_TO_URI_MAP);
    map.put(j2eeComp, moduleURI);

    dataModel.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, warComp);

    List modList =
        (List)
            dataModel.getProperty(
                ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
    modList.add(j2eeComp);
    dataModel.setProperty(
        ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modList);
    dataModel.setProperty(
        ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH,
        "/WEB-INF/lib"); //$NON-NLS-1$
    try {
      dataModel.getDefaultOperation().execute(null, null);
    } catch (ExecutionException e) {
      J2EEPlugin.logError(e);
    }
  }
 private IDataModel getWebModelConfig(String warSourceDirectory, String contextRoot) {
   IDataModel webModelCfg =
       DataModelFactory.createDataModel(new WebFacetInstallDataModelProvider());
   webModelCfg.setProperty(
       IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER, warSourceDirectory);
   webModelCfg.setProperty(IWebFacetInstallDataModelProperties.CONTEXT_ROOT, contextRoot);
   webModelCfg.setProperty(IJ2EEModuleFacetInstallDataModelProperties.GENERATE_DD, false);
   return webModelCfg;
 }
 /**
  * Install a Web Facet version
  *
  * @param mavenProject
  * @param warSourceDirectory
  * @param actions
  * @param webFv
  */
 private void installWebFacet(
     MavenProject mavenProject,
     String warSourceDirectory,
     String contextRoot,
     Set<Action> actions,
     IProjectFacetVersion webFv) {
   IDataModel webModelCfg =
       DataModelFactory.createDataModel(new WebFacetInstallDataModelProvider());
   webModelCfg.setProperty(
       IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER, warSourceDirectory);
   webModelCfg.setProperty(IWebFacetInstallDataModelProperties.CONTEXT_ROOT, contextRoot);
   webModelCfg.setProperty(IJ2EEModuleFacetInstallDataModelProperties.GENERATE_DD, false);
   actions.add(
       new IFacetedProject.Action(IFacetedProject.Action.Type.INSTALL, webFv, webModelCfg));
 }
Ejemplo n.º 4
0
  private void createServiceXmlFile(String version, boolean useSample) throws Exception {
    final IProject project = createProject("serviceXmlFiles-" + version + "-" + useSample);

    final IDataModel model =
        DataModelFactory.createDataModel(new NewServiceBuilderDataModelProvider());

    model.setProperty(NewServiceBuilderDataModelProvider.AUTHOR, "junit");
    model.setProperty(NewServiceBuilderDataModelProvider.PACKAGE_PATH, "com.liferay.sample");
    model.setProperty(NewServiceBuilderDataModelProvider.NAMESPACE, "SAMPLE");
    model.setBooleanProperty(NewServiceBuilderDataModelProvider.USE_SAMPLE_TEMPLATE, useSample);

    final IFolder folder = project.getFolder("test");

    CoreUtil.prepareFolder(folder);

    final IFile serviceXmlFile = folder.getFile("service.xml");

    assertEquals(false, serviceXmlFile.exists());

    WizardUtil.createDefaultServiceBuilderFile(
        serviceXmlFile,
        version,
        model.getBooleanProperty(NewServiceBuilderDataModelProvider.USE_SAMPLE_TEMPLATE),
        model.getStringProperty(NewServiceBuilderDataModelProvider.PACKAGE_PATH),
        model.getStringProperty(NewServiceBuilderDataModelProvider.NAMESPACE),
        model.getStringProperty(NewServiceBuilderDataModelProvider.AUTHOR),
        new NullProgressMonitor());

    assertEquals(true, serviceXmlFile.exists());

    final String serviceXmlContent = CoreUtil.readStreamToString(serviceXmlFile.getContents());

    final String expectedServiceXmlContent =
        CoreUtil.readStreamToString(
            this.getClass()
                .getResourceAsStream("files/service-sample-" + version + "-" + useSample + ".xml"));

    assertEquals(
        stripCarriageReturns(expectedServiceXmlContent), stripCarriageReturns(serviceXmlContent));
  }
  public void propertyChanged(DataModelEvent event) {
    if (event.getPropertyName().equals(IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER)) {
      model.setStringProperty(
          ISeamFacetDataModelProperties.WEB_CONTENTS_FOLDER, event.getProperty().toString());
    } else if (event.getPropertyName().equals(IFacetDataModelProperties.FACET_PROJECT_NAME)) {
      String seamProjectName = event.getProperty().toString();

      model.setStringProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME, seamProjectName);

      sessionBeanPkgNameditor.setValue(getSessionPkgName(seamProjectName));
      entityBeanPkgNameditor.setValue(getEntityPkgName(seamProjectName));
      testsPkgNameditor.setValue(getTestPkgName(seamProjectName));
      if (!isWebProjectWizard()) {
        ejbProjectNameditor.setValue(getEJBProjectName(seamProjectName));
        earProjectNameditor.setValue(getEARProjectName(seamProjectName));
      }
      testProjectNameditor.setValue(getTestProjectName(seamProjectName));

      model.setStringProperty(
          ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_NAME,
          getSessionPkgName(seamProjectName));
      model.setStringProperty(
          ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME,
          getEntityPkgName(seamProjectName));
      model.setProperty(
          ISeamFacetDataModelProperties.TEST_PROJECT_CREATING,
          createTestProjectCheckboxeditor.getValue());
      model.setStringProperty(
          ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME, getTestPkgName(seamProjectName));
      model.setStringProperty(
          ISeamFacetDataModelProperties.SEAM_EAR_PROJECT, earProjectNameditor.getValueAsString());
      model.setStringProperty(
          ISeamFacetDataModelProperties.SEAM_EJB_PROJECT, ejbProjectNameditor.getValueAsString());
      model.setStringProperty(
          ISeamFacetDataModelProperties.SEAM_TEST_PROJECT, testProjectNameditor.getValueAsString());
    }
  }
 public void setConfig(Object config) {
   model = (IDataModel) config;
   model.setProperty(
       ISeamFacetDataModelProperties.HIBERNATE_DIALECT,
       HIBERNATE_HELPER.getDialectClass(getDefaultDbType()));
 }