-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gupta Shiwani
committed
Jul 28, 2019
1 parent
bd225c7
commit 842a104
Showing
34 changed files
with
2,784 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/target/ | ||
/infra/target/ | ||
/jakartaee/target/ | ||
/mvc/target/ | ||
/rest/target/ | ||
/runtime/target/ | ||
/jakarta-ee/target/ | ||
/jakarta-ee/target/ | ||
/jsf/target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<actions> | ||
<action> | ||
<actionName>run</actionName> | ||
<goals> | ||
<goal>nbm:run-ide</goal> | ||
</goals> | ||
</action> | ||
<action> | ||
<actionName>debug</actionName> | ||
<goals> | ||
<goal>nbm:run-ide</goal> | ||
</goals> | ||
<properties> | ||
<jpda.listen>true</jpda.listen> | ||
<netbeans.run.params.debug>-J-agentlib:jdwp=transport=dt_socket,suspend=n,server=n,address=${jpda.address}</netbeans.run.params.debug> | ||
</properties> | ||
</action> | ||
</actions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.github.jeddict</groupId> | ||
<artifactId>jeddict-extensions</artifactId> | ||
<version>5.2</version> | ||
</parent> | ||
<artifactId>jsf</artifactId> | ||
<name>JSF</name> | ||
<packaging>nbm</packaging> | ||
|
||
<properties> | ||
<root.dir>${basedir}/../</root.dir> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>nbm-maven-plugin</artifactId> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<moduleDependencies> | ||
<dependency> | ||
<id>org.netbeans.modules:org-netbeans-modules-maven-embedder</id> | ||
<type>impl</type> | ||
</dependency> | ||
</moduleDependencies> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>infra</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>jakarta-ee</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.netbeans.api</groupId> | ||
<artifactId>org-netbeans-modules-projectapi</artifactId> | ||
<version>${netbeans.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.netbeans.api</groupId> | ||
<artifactId>org-openide-loaders</artifactId> | ||
<version>${netbeans.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.netbeans.modules</groupId> | ||
<artifactId>org-netbeans-modules-maven-embedder</artifactId> | ||
<version>${netbeans.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
19 changes: 19 additions & 0 deletions
19
jsf/src/main/java/io/github/jeddict/jsf/controller/Bundle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
MSG_Progress_Now_Generating= Generating CDI repository : | ||
TITLE_Maven_Project_Not_Found= Maven Project | ||
MSG_Maven_Project_Not_Found= Maven(pom.xml) Project not found | ||
JsfControllerPanel.invalidPackage.message= The\u00a0Package\u00a0Name\u00a0is\u00a0not\u00a0valid | ||
JsfControllerPanel.invalidSuffix.message= The\u00a0Suffix\u00a0Name\u00a0is\u00a0not\u00a0valid | ||
JsfControllerPanel.reservedSuffix.message= 'Service' is reserved suffix, please choose another suffix | ||
JsfControllerPanel.invalidPrefix.message= The\u00a0Prefix\u00a0Name\u00a0is\u00a0not\u00a0valid | ||
JsfControllerPanel.invalidAppPackage.message= The\u00a0Application Package\u00a0Name\u00a0is\u00a0not\u00a0valid | ||
|
||
JsfControllerPanel.entityLabel.text=<entity> | ||
JsfControllerPanel.prefixField.toolTipText=Prefix | ||
JsfControllerPanel.prefixField.text= | ||
JsfControllerPanel.packageTextField.text= | ||
JsfControllerPanel.packagePrefixLabel.text=<application-package> + | ||
JsfControllerPanel.packageLabel.text=Package : | ||
JsfControllerPanel.warningLabel.text= | ||
JsfControllerPanel.nameLabel.text=File Pattern : | ||
JsfControllerPanel.suffixField.toolTipText=Suffix | ||
JsfControllerPanel.suffixField.text=Repository |
112 changes: 112 additions & 0 deletions
112
jsf/src/main/java/io/github/jeddict/jsf/controller/JsfControllerData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/** | ||
* Copyright 2013-2018 the original author or authors from the Jeddict project (https://jeddict.github.io/). | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package io.github.jeddict.jsf.controller; | ||
|
||
import io.github.jeddict.jcode.LayerConfigData; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import org.apache.commons.lang.StringUtils; | ||
|
||
/** | ||
* | ||
* @author Shiwani Gupta | ||
*/ | ||
public class JsfControllerData extends LayerConfigData { | ||
|
||
private String prefixName; | ||
private String suffixName; | ||
private String _package; | ||
private boolean isNamed; | ||
private boolean cdi = true; | ||
|
||
/** | ||
* @return the _package | ||
*/ | ||
public String getPackage() { | ||
return _package; | ||
} | ||
|
||
/** | ||
* @param _package the _package to set | ||
*/ | ||
public void setPackage(String _package) { | ||
this._package = _package; | ||
} | ||
|
||
/** | ||
* @return the suffixName | ||
*/ | ||
public String getSuffixName() { | ||
if(StringUtils.isBlank(suffixName)){ | ||
suffixName = "Controller"; | ||
} | ||
return suffixName; | ||
} | ||
|
||
/** | ||
* @param suffixName the suffixName to set | ||
*/ | ||
public void setSuffixName(String suffixName) { | ||
this.suffixName = suffixName; | ||
} | ||
|
||
/** | ||
* @return the prefixName | ||
*/ | ||
public String getPrefixName() { | ||
return prefixName; | ||
} | ||
|
||
/** | ||
* @param prefixName the prefixName to set | ||
*/ | ||
public void setPrefixName(String prefixName) { | ||
this.prefixName = prefixName; | ||
} | ||
|
||
/** | ||
* @return the isNamed | ||
*/ | ||
public boolean isNamed() { | ||
return isNamed; | ||
} | ||
|
||
/** | ||
* @param isNamed the isNamed to set | ||
*/ | ||
public void setNamed(boolean isNamed) { | ||
this.isNamed = isNamed; | ||
} | ||
|
||
/** | ||
* @return the isCDI | ||
*/ | ||
public boolean isCDI() { | ||
return cdi; | ||
} | ||
|
||
/** | ||
* @param cdi the cdi to set | ||
*/ | ||
public void setCDI(boolean cdi) { | ||
this.cdi = cdi; | ||
} | ||
|
||
@Override | ||
public List<String> getUsageDetails() { | ||
return Collections.<String>emptyList(); | ||
} | ||
} |
159 changes: 159 additions & 0 deletions
159
jsf/src/main/java/io/github/jeddict/jsf/controller/JsfControllerGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
/** | ||
* Copyright 2013-2018 the original author or authors from the Jeddict project (https://jeddict.github.io/). | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package io.github.jeddict.jsf.controller; | ||
|
||
import io.github.jeddict.jcode.ApplicationConfigData; | ||
import io.github.jeddict.jcode.Generator; | ||
import io.github.jeddict.jcode.annotation.ConfigData; | ||
import io.github.jeddict.jcode.annotation.Technology; | ||
import static io.github.jeddict.jcode.annotation.Technology.Type.CONTROLLER; | ||
import io.github.jeddict.jcode.task.progress.ProgressHandler; | ||
import static io.github.jeddict.jcode.util.Constants.JAVA_EXT; | ||
import static io.github.jeddict.jcode.util.ProjectHelper.getFolderForPackage; | ||
import static io.github.jeddict.jcode.util.StringHelper.firstLower; | ||
import static io.github.jeddict.jcode.util.StringHelper.firstUpper; | ||
import io.github.jeddict.jpa.spec.Entity; | ||
import io.github.jeddict.jpa.spec.EntityMappings; | ||
import io.github.jeddict.repository.RepositoryData; | ||
import io.github.jeddict.repository.RepositoryGenerator; | ||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import static java.util.stream.Collectors.toList; | ||
import org.netbeans.api.project.Project; | ||
import org.netbeans.api.project.SourceGroup; | ||
import org.openide.filesystems.FileObject; | ||
import org.openide.util.lookup.ServiceProvider; | ||
import io.github.jeddict.jcode.util.FileUtil; | ||
|
||
/** | ||
* Generates repository for entity classes. | ||
* | ||
* @author Shiwani Gupta | ||
*/ | ||
@ServiceProvider(service = Generator.class) | ||
@Technology(type = CONTROLLER, | ||
label = "JSF Controller", | ||
panel = JsfControllerPanel.class, | ||
parents = RepositoryGenerator.class | ||
) | ||
public final class JsfControllerGenerator implements Generator { | ||
|
||
private static final String TEMPLATE = "io/github/jeddict/template/"; | ||
public static final String REPOSITORY_ABSTRACT = "Abstract"; | ||
|
||
@ConfigData | ||
private JsfControllerData controllerData; | ||
|
||
@ConfigData | ||
private RepositoryData repositoryData; | ||
|
||
@ConfigData | ||
private EntityMappings entityMapping; | ||
|
||
@ConfigData | ||
private ApplicationConfigData appConfigData; | ||
|
||
@ConfigData | ||
private ProgressHandler handler; | ||
|
||
private Project targetProject; | ||
|
||
private SourceGroup targetSource; | ||
|
||
private String targetPackage; | ||
|
||
private Project gatewayProject; | ||
|
||
private SourceGroup gatewaySource; | ||
|
||
@Override | ||
public void execute() throws IOException { | ||
targetProject = appConfigData.getTargetProject(); | ||
targetSource = appConfigData.getTargetSourceGroup(); | ||
gatewayProject = appConfigData.getGatewayProject(); | ||
gatewaySource = appConfigData.getGatewaySourceGroup(); | ||
targetPackage = appConfigData.getTargetPackage(); | ||
generate(); | ||
generatePagination(); | ||
generateJsfUtil(); | ||
|
||
} | ||
|
||
private Set<FileObject> generate() throws IOException { | ||
|
||
final Set<FileObject> createdFiles = new HashSet<>(); | ||
for (Entity entity : entityMapping.getGeneratedEntity().collect(toList())) { | ||
handler.progress(controllerData.getPrefixName() + entity.getClazz() + controllerData.getSuffixName()); | ||
createdFiles.add(generateController(entity, true)); | ||
|
||
} | ||
return createdFiles; | ||
} | ||
|
||
private void generatePagination() throws IOException { | ||
String _package = targetPackage + ".util"; | ||
FileObject targetFolder = getFolderForPackage(targetSource, _package, true); | ||
String fileName = "PaginationHelper"; | ||
Map<String, Object> param = new HashMap<>(); | ||
param.put("package", _package); | ||
handler.progress(fileName); | ||
FileUtil.expandTemplate(TEMPLATE + "util/PaginationHelper.java.ftl", targetFolder, fileName + '.' + JAVA_EXT, param); | ||
} | ||
|
||
private void generateJsfUtil() throws IOException { | ||
String _package = targetPackage + ".util"; | ||
FileObject targetFolder = getFolderForPackage(targetSource, _package, true); | ||
String fileName = "JsfUtil"; | ||
Map<String, Object> param = new HashMap<>(); | ||
param.put("package", _package); | ||
handler.progress(fileName); | ||
FileUtil.expandTemplate(TEMPLATE + "util/JsfUtil.java.ftl", targetFolder, fileName + '.' + JAVA_EXT, param); | ||
} | ||
|
||
private FileObject generateController(final Entity entity, boolean overrideExisting) throws IOException { | ||
FileObject targetFolder = getFolderForPackage(targetSource, | ||
entity.getAbsolutePackage(targetPackage + '.' + controllerData.getPackage()), | ||
true); | ||
|
||
final String entitySimpleName = entity.getClazz(); | ||
String controllerName = controllerData.getPrefixName() + entitySimpleName + controllerData.getSuffixName(); | ||
String entityClass = firstUpper(entitySimpleName); | ||
String entityInstance = firstLower(entitySimpleName); | ||
String entityFQN = entity.getFQN(); | ||
|
||
String repositoryName = repositoryData.getRepositoryPrefixName() + entitySimpleName + repositoryData.getRepositorySuffixName(); | ||
String repositoryInstance = firstLower(repositoryName); | ||
String repositoryFQN = entity.getAbsolutePackage(repositoryData.getRepositoryPackage()) + '.' + repositoryName;; | ||
|
||
Map<String, Object> params = new HashMap<>(); | ||
params.put("entityInstance", entityInstance); | ||
params.put("Entity", entityClass); | ||
params.put("EntityController", controllerName); | ||
params.put("named", controllerData.isNamed()); | ||
params.put("EntityRepository", repositoryName); | ||
params.put("RepositoryInstance", repositoryInstance); | ||
params.put("EntityClass_FQN", entityFQN); | ||
params.put("RepositoryClass_FQN", targetPackage + '.' + repositoryFQN); | ||
params.put("JsfUtil_FQN", targetPackage + ".util.JsfUtil"); | ||
params.put("PaginationHelper_FQN", targetPackage + ".util.PaginationHelper"); | ||
params.put("package", targetPackage + '.' + entity.getAbsolutePackage(controllerData.getPackage())); | ||
|
||
return FileUtil.expandTemplate(TEMPLATE + "controller/EntityController.java.ftl", targetFolder, controllerName + '.' + JAVA_EXT, params); | ||
} | ||
} |
Oops, something went wrong.