Examples of BoostedModelDelegate


Examples of gluebooster.maven.model.structure.BoostedModelDelegate

      model = xpp3Reader.read(modifiedXml);
    } catch (Exception ex){
      throw new ParseException("Could not parse modified xml\n" + xmlText, ex);
    }
   
    BoostedModelDelegate modelDelegate = new BoostedModelDelegate(model);
    HashMap<String, String> developerDoku = new HashMap<String, String>();
    modelDelegate
        .getAttributes()
        .getMap()
        .put(DocumentationResourecesId.DOCUMENTATION_DEVELOPER,
            developerDoku);

    // evaluate parent
    Parent parent = model.getParent();
    if (parent != null
        && parent.getArtifactId().contains(USE_IN_DOCUMENTATION)) {
      BoostedParent newParent = new BoostedParent();
      BoostedObject.copyProperties(parent, newParent);
      newParent.getAttributes().getMap()
          .put(GeneralConstants.USE_IN_DOCUMENTATION, Boolean.TRUE);
      newParent.setArtifactId(newParent.getArtifactId().replace(
          USE_IN_DOCUMENTATION, ""));// remove text
      model.setParent(newParent);

    }

    //evaluate artifact id
    Pair<String, String> separation =  extractSoftwareDocuGenerator(model.getArtifactId());
    if (separation.getRight() != null){ //if there is a generator
      modelDelegate.getAttributes().getMap().put(GeneralConstants.SOFTWARE_DOCU_GENERATOR, separation.getRight());
      model.setArtifactId(separation.getLeft());
    }
   
    // evaluate description
    separation =  extractDeveloperDocumentation(model.getDescription());
View Full Code Here

Examples of gluebooster.maven.model.structure.BoostedModelDelegate

   * @throws IOException
   * @throws ZipException
   */
  public static void readMavenDevelopmentDocu(MavenProject project, File pomDirectoryOrZip) throws Exception
  {
    BoostedModelDelegate model = (BoostedModelDelegate) project.getModel();
   
    if (! pomDirectoryOrZip.getName().endsWith("zip")){
      //assume it is the directory
      String filename = project.getArtifactId() + "-" + project.getVersion() + "-mavenDevelopmentDocu.zip";
      File file = new File(pomDirectoryOrZip, filename);
      if (file.exists())
        readMavenDevelopmentDocu(project, file);
      else {
        file = new File(pomDirectoryOrZip, "target/" + filename);
        if (file.exists())
          readMavenDevelopmentDocu(project, file);
        else
          System.out.println("no maven development docu found: " + filename + " in directory " + pomDirectoryOrZip);
       
      }
    } else {
      System.out.println("maven development docu found: " + pomDirectoryOrZip);
      ZipFile zip = new ZipFile(pomDirectoryOrZip);
      String entryname = "mavendevelopment/docu/" + project.getGroupId() + "-" + project.getArtifactId() + ".plugins.htmlsnippet";
      ZipEntry entry = zip.getEntry(entryname);
      if (entry == null)
        System.out.println("entry not found " + entryname);
      else {
        System.out.println("entry found " + entryname);
        String html = IOUtils.toString( zip.getInputStream(entry));
        model.setRuntimePluginExecutionHtmlTable(html);
      }
       
    }
   
  }
View Full Code Here

Examples of gluebooster.maven.model.structure.BoostedModelDelegate

      DocumentationContext context, BoostedNode documentationParentOfNewArtifacts) throws Exception {
 
    getLog().debug("documentProject ", createArtifactIdentifierForDocumentation(project));
   
   
    BoostedModelDelegate model =null;
    if (project.getModel() instanceof BoostedModelDelegate)
      model =(BoostedModelDelegate) project.getModel();
   
    //document Aggregator
    Dependency moduleAggregator = model.getModuleAggregator();
    if (model != null && moduleAggregator != null){
      MavenProject parentProject = PomUtils.readMavenProjectFromRepository(moduleAggregator.getGroupId(), moduleAggregator.getArtifactId(), moduleAggregator.getVersion());
      documentProjectIfNecessary(parentProject, type, documentationParent, context, documentationParentOfNewArtifacts, documentationParent);
    }
   
    //document parent
    Parent parent = project.getModel().getParent();
    if (parent instanceof BoostedParent){
     
      BoostedParent par = (BoostedParent) parent;
      MavenProject parentProject = PomUtils.readMavenProjectFromRepository(par.getGroupId(), par.getArtifactId(), par.getVersion());
      if (Boolean.TRUE.equals( par.getAttributes().getFromMap(GeneralConstants.USE_IN_DOCUMENTATION))){
        documentProjectIfNecessary(parentProject, type, documentationParent, context, documentationParentOfNewArtifacts, documentationParent);
      }

    }
   
   
    //use enhanced description
    if (DocumentationResourecesId.DOCUMENTATION_DEVELOPER.equals(type)){
     
      //write description
      if ( project.getDescription() != null){
        String description =  project.getDescription().trim();
        if (! "".equals(description)){
          BookUtils.createDiv(documentationParent, description);
        }
      }
     
      //write additional developer documentation
      if (model != null){
       
        Map<String,String> develDoku =  (Map<String,String>) model.getAttributes().getFromMap(DocumentationResourecesId.DOCUMENTATION_DEVELOPER);
        if (develDoku != null)
        {
          if (develDoku.containsKey(GeneralConstants.DESCRIPTION)){
            BookUtils.createDiv(documentationParent, develDoku.get(GeneralConstants.DESCRIPTION));
           
          }
        }
      }
     
      //write packaging type
      BookUtils.createDiv(documentationParent, "This artifact is of type " + project.getPackaging() + ".");

      //write aggregator artifact
      if (moduleAggregator != null)
        BookUtils.createDiv(documentationParent, "The module aggregator (the artifact in the parent directory) of this artifact is " + createArtifactIdentifierForDocumentation(moduleAggregator));
     
      //write parent infos
      if (parent instanceof BoostedParent){
        BoostedParent par = (BoostedParent) parent;     
        if (Boolean.TRUE.equals( par.getAttributes().getFromMap(GeneralConstants.USE_IN_DOCUMENTATION))){
        BookUtils.createDiv(documentationParent, "The parent of this artifact is " + createArtifactIdentifierForDocumentation(par));
        }
      }
     
      //write plugin execution infos
      String pluginHtml = model.getRuntimePluginExecutionHtmlTable();
      if ( pluginHtml != null){
       
        BoostedNode pluginInfo = BookUtils.createChapter(documentationParent, "Information about executed plugins");
        BookUtils.createDivWithRawContent(pluginInfo, "<table><tbody>" + pluginHtml + "</tbody></table>");
      }

     
    }

    getLog().info("documenting dependencies");
    //document dependencies
    for (Object dependency: project.getDependencies()){
      if (dependency instanceof BoostedDependency){
        BoostedDependency dep = (BoostedDependency) dependency;
        MavenProject dependencyProject = PomUtils.readMavenProjectFromRepository(dep.getGroupId(), dep.getArtifactId(), dep.getVersion());
        if (Boolean.TRUE.equals( dep.getAttributes().getFromMap(GeneralConstants.USE_IN_DOCUMENTATION))){
          BookUtils.createDiv(documentationParent, "Add a dependency to the artifact " + createArtifactIdentifierForDocumentation(dep));
          documentProjectIfNecessary(dependencyProject, type, documentationParent, context, documentationParentOfNewArtifacts, documentationParent);
        }

      }
    }
   
    //properties
    if (project.getProperties() instanceof BoostedProperties){
      BoostedProperties properties = (BoostedProperties) project.getProperties();
      if (Boolean.TRUE.equals(properties.getAttributes().getFromMap(GeneralConstants.USE_IN_DOCUMENTATION))){
        Object docu = properties.getAttributes().getFromMap(DocumentationResourecesId.DOCUMENTATION_DEVELOPER);
        if (docu != null){
          BookUtils.createDiv(documentationParent, "There are the following important properties: ");
          BookUtils.createDiv(documentationParent, docu.toString());
        }
      }
    }
   
   
   
    getLog().info("documenting profile dependencies");
    for (Profile profile: project.getModel().getProfiles()){
      getLog().info("documenting profile " + profile.getId());
      //dependencies of profile
      for (Object dependency: profile.getDependencies()){
        if (dependency instanceof BoostedDependency){
          BoostedDependency dep = (BoostedDependency) dependency;
          MavenProject dependencyProject = PomUtils.readMavenProjectFromRepository(dep.getGroupId(), dep.getArtifactId(), dep.getVersion());
          if (Boolean.TRUE.equals( dep.getAttributes().getFromMap(GeneralConstants.USE_IN_DOCUMENTATION))){
            BookUtils.createDiv(documentationParent, "In the profile " + profile.getId() + " add a dependency to the artifact " + createArtifactIdentifierForDocumentation(dep));
            documentProjectIfNecessary(dependencyProject, type, documentationParent, context, documentationParentOfNewArtifacts, null);
          }

        }
      }
      //properties of profile
      if (profile.getProperties() instanceof BoostedProperties){
        BoostedProperties properties = (BoostedProperties) profile.getProperties();
        if (Boolean.TRUE.equals(properties.getAttributes().getFromMap(GeneralConstants.USE_IN_DOCUMENTATION))){
          Object docu = properties.getAttributes().getFromMap(DocumentationResourecesId.DOCUMENTATION_DEVELOPER);
          if (docu != null){
            BookUtils.createDiv(documentationParent, "In the profile " + profile.getId() + " there are the following important properties: ");
            BookUtils.createDiv(documentationParent, docu.toString());
          }
        }
      }
    }
    
    //plugins
    if ( project.getBuild() != null &&  project.getBuild().getPlugins() != null)
    for (Plugin plugin: project.getBuild().getPlugins()){
      if (plugin.getExecutions() != null){
        for (PluginExecution execution : plugin.getExecutions()){
          if (execution instanceof BoostedPluginExecution){
            BoostedPluginExecution exe = (BoostedPluginExecution) execution;
            MavenProject dependencyProject = PomUtils.readMavenProjectFromRepository(plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion());
            if (Boolean.TRUE.equals( exe.getAttributes().getFromMap(GeneralConstants.USE_IN_DOCUMENTATION))){
             
              BookUtils.createDiv(documentationParent, "Executes " + exe.getId() + " with goals " + exe.getGoals() + " of plugin " + createArtifactIdentifierForDocumentation(plugin));
              String pluginPath="/" + plugin.getGroupId()+ "/" + plugin.getArtifactId() + "/plugin.xml";
              InputStream pluginXml = MavenDocumentationGenerator.class.getResourceAsStream(pluginPath);
              if (pluginXml == null)
                throw new FileNotFoundException(pluginPath + " not found in jars.");
              PluginDescriptor pluginDescriptor = PomUtils.readPluginDescriptor(new InputStreamReader( pluginXml));
              BookUtils.createDiv(documentationParent, "Move this part to a separate chapter " + pluginDescriptor.getDescription());
             
              //documentProjectIfNecessary(dependencyProject, type, documentationParent, context, documentationParentOfNewArtifacts, null);
            }
           
          }
        }
       
      }
    }

   
    if (model != null){
      String softwareDocuGeneratorClass = (String) model.getAttributes().getFromMap(GeneralConstants.SOFTWARE_DOCU_GENERATOR);
      //optimization: generator may be string or class or instance
      if (softwareDocuGeneratorClass != null){
        HasDocumentation generator = (HasDocumentation) Class.forName(softwareDocuGeneratorClass).newInstance();
        generator.fillDocumentation(type, documentationParent, context);
      }
View Full Code Here

Examples of gluebooster.maven.model.structure.BoostedModelDelegate

    @Test
    public void testReadModelFromXml() throws Exception
    {
      InputStream samplePom = TestPomUtils.class.getResourceAsStream("sample-pom.xml");
      assertNotNull(samplePom);
      BoostedModelDelegate model = (BoostedModelDelegate) PomUtils.readModelFromXml(samplePom);
     
      HashMap<String, Dependency> dependencyMap = new HashMap<String, Dependency>();
     
      for (Dependency dependency: model.getDependencies()){
        dependencyMap.put(dependency.getArtifactId(), dependency);
      }
     
      Assert.assertTrue(dependencyMap.containsKey(DEFAULT_WEBAPP));
      Assert.assertTrue(dependencyMap.get(DEFAULT_WEBAPP) instanceof BoostedDependency);
      BoostedDependency dependency = (BoostedDependency) dependencyMap.get(DEFAULT_WEBAPP);
      Assert.assertTrue( (Boolean) dependency.getAttributes().getFromMap(GeneralConstants.USE_IN_DOCUMENTATION));

      Assert.assertNotNull("module aggregator not found", model.getModuleAggregator());
     
      boolean foundBoostedExecution = false;
      for (Plugin plugin: model.getBuild().getPlugins()){
        for (PluginExecution execution: plugin.getExecutions())
          if (execution instanceof BoostedPluginExecution)
            foundBoostedExecution = true;
      }
      Assert.assertTrue(foundBoostedExecution);
           
      Assert.assertNotNull("no profiles", model.getProfiles());
      Profile hasDocumentation = null;
      for (Profile profile: model.getProfiles()){
        if ("hasDocumentation".equals(profile.getId())){
          hasDocumentation = profile;
        }
      }
      Assert.assertNotNull("no profile hasDocumentation", hasDocumentation);
     
      Assert.assertNotNull("no software docu generator", model.getAttributes().getFromMap(GeneralConstants.SOFTWARE_DOCU_GENERATOR));

           
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.