package org.butterfaces.component.showcase;

import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;

@Named
@ViewScoped
public class DependencyExample implements Serializable {

    @Inject
    private org.butterfaces.component.showcase.Version version;

    public String getButterFacesMavenDependency() {
        return createDependency("Bootstrap 4.0, JQuery 3.3.1","org.butterfaces", "components", "3.0.1");
    }

    public String getButterFacesV3JEE7MavenDependency() {
        return createDependency("Bootstrap 4.0, JQuery 3.3.1","org.butterfaces", "components", "3.0.0-JEE7");
    }

    public String getButterFacesV2MavenDependency() {
        return createDependency("Bootstrap 3.3.7, JQuery 2.7.1","de.larmic.butterfaces", "components", "2.1.25");
    }

    private String createDependency(String hint, String groupId, String artifactId, String version) {
        final StringBuilder sb = new StringBuilder();

        sb.append("<dependency>\n");
        sb.append("   <!-- " + hint + "-->\n");
        sb.append("   <groupId>" + groupId + "</groupId>\n");
        sb.append("   <artifactId>" + artifactId + "</artifactId>\n");
        sb.append("   <version>" + version + "</version>\n");
        sb.append("</dependency>");

        return sb.toString();
    }

}

@@ -357,32 +357,253 @@
 nDependency() %7B%0A
+        final String lastestReleaseVersion = version.getLastestReleaseVersion();%0A        final String v = lastestReleaseVersion.contains(%223.%22) && !lastestReleaseVersion.contains(%22JEE7%22) ? lastestReleaseVersion : %223.0.2%22;%0A
         return c
@@ -685,15 +685,9 @@
 s%22, 
-%223.0.1%22
+v
 );%0A 

update version in easy-to-use-showcase