-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1455 adaption of template sets (#1520)
* Adjust documentation (#1491) * fixed some types and links and corrected some parts of the documentation * adjust angular client guide * fixed typo * fixed requested changes * implemented independent adaption of template sets * fix adapt template cli test * ignore AdaptTemplatesCommandTest and further implementations for TemplateAdapter * added tests for the template adapter * implemented requested changes * changed TemplateAdapter
- Loading branch information
1 parent
a39ec1c
commit 4e4b6d3
Showing
15 changed files
with
801 additions
and
319 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
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
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
95 changes: 95 additions & 0 deletions
95
cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/TemplateAdapter.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,95 @@ | ||
package com.devonfw.cobigen.api; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
import com.devonfw.cobigen.api.exception.TemplateSelectionForAdaptionException; | ||
import com.devonfw.cobigen.api.exception.UpgradeTemplatesNotificationException; | ||
|
||
/** The TemplateAdapter implements methods for adapting template jars */ | ||
public interface TemplateAdapter { | ||
|
||
/** | ||
* Adapt the templates. Can either adapt an old monolithic template structure or independent template sets. | ||
* | ||
* @throws IOException If CobiGen is not able to extract the jar file to the destination folder | ||
* @throws UpgradeTemplatesNotificationException If an old monolithic structure was adapted. Can be catched to ask the | ||
* user for an upgrade of the templates. | ||
* @throws TemplateSelectionForAdaptionException If a new template structure is given. To ask the user to select the | ||
* template sets to adapt. | ||
*/ | ||
public void adaptTemplates() | ||
throws IOException, UpgradeTemplatesNotificationException, TemplateSelectionForAdaptionException; | ||
|
||
/** | ||
* Adapt a given set of template set jars. | ||
* | ||
* @param templateSetJars A {@link List} of the {@link Path} of the template set jars to adapt | ||
* @param forceOverride Indicator whether an already adapted template set should be overridden | ||
* @throws IOException If CobiGen is not able to extract the jar file to the destination folder | ||
*/ | ||
public void adaptTemplateSets(List<Path> templateSetJars, boolean forceOverride) throws IOException; | ||
|
||
/** | ||
* Adapt a set of template set jars to a given destination folder. | ||
* | ||
* @param templateSetJars A {@link List} of the {@link Path} of the template set jars to adapt | ||
* @param destinationPath The parent folder where the jars should be extracted to | ||
* @param forceOverride Indicator whether an already adapted template set should be overridden | ||
* @throws IOException If CobiGen is not able to extract the jar file to the destination folder | ||
*/ | ||
public void adaptTemplateSets(List<Path> templateSetJars, Path destinationPath, boolean forceOverride) | ||
throws IOException; | ||
|
||
/** | ||
* Adapt an old monolithic template jar structure. | ||
* | ||
* @param forceOverride Indicator whether an already adapted template set should be overridden | ||
* @throws IOException If CobiGen is not able to extract the jar file to the destination folder | ||
*/ | ||
public void adaptMonolithicTemplates(boolean forceOverride) throws IOException; | ||
|
||
/** | ||
* Adapt an old monolithic template jar structure to a given destination folder. | ||
* | ||
* @param destinationPath The folder where the jars should be extracted to | ||
* @param forceOverride Indicator whether an already adapted template set should be overridden | ||
* @throws IOException If CobiGen is not able to extract the jar file to the destination folder | ||
*/ | ||
public void adaptMonolithicTemplates(Path destinationPath, boolean forceOverride) throws IOException; | ||
|
||
/** | ||
* Get a list of available template set jars to adapt. | ||
* | ||
* @return A {@link List} of {@link Path} with all template set jar files found. | ||
*/ | ||
public List<Path> getTemplateSetJars(); | ||
|
||
/** | ||
* Checks if the template configuration consists of an old monolithic template set or independent template sets. | ||
* | ||
* @return Returns {@code true} if the template structure consists of an old monolithic template set. Otherwise false. | ||
*/ | ||
public boolean isMonolithicTemplatesConfiguration(); | ||
|
||
/** | ||
* Upgrade an adapted monolithic template structure to the new template structure consisting of template sets. | ||
*/ | ||
public void upgradeMonolithicTemplates(); | ||
|
||
/** | ||
* Get the parent location of the templates. | ||
* | ||
* @return The {@link Path} of the templates location. | ||
*/ | ||
public Path getTemplatesLocation(); | ||
|
||
/** | ||
* Checks if a given template set is already adapted | ||
* | ||
* @param templateSetJar The {@link Path} to the template set to check. | ||
* @return Returns {@code true} if the template set is already adapted. Otherwise false. | ||
*/ | ||
public boolean isTemplateSetAlreadyAdapted(Path templateSetJar); | ||
} |
37 changes: 37 additions & 0 deletions
37
...rc/main/java/com/devonfw/cobigen/api/exception/TemplateSelectionForAdaptionException.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,37 @@ | ||
package com.devonfw.cobigen.api.exception; | ||
|
||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
/** | ||
* Exception that indicates that a new template structure is available. For asking which template sets should be | ||
* adapted. | ||
*/ | ||
public class TemplateSelectionForAdaptionException extends Exception { | ||
|
||
/** Generated serial version UID */ | ||
private static final long serialVersionUID = 1; | ||
|
||
/** List of available template sets. */ | ||
private List<Path> templateSets; | ||
|
||
/** | ||
* Creates a new {@link TemplateSelectionForAdaptionException} | ||
* | ||
* @param templateSets A list with available template sets to adapt. | ||
* | ||
*/ | ||
public TemplateSelectionForAdaptionException(List<Path> templateSets) { | ||
|
||
super("Select the template sets you want to adapt."); | ||
this.templateSets = templateSets; | ||
} | ||
|
||
/** | ||
* @return templateSets All available template sets. | ||
*/ | ||
public List<Path> getTemplateSets() { | ||
|
||
return this.templateSets; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...rc/main/java/com/devonfw/cobigen/api/exception/UpgradeTemplatesNotificationException.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,22 @@ | ||
package com.devonfw.cobigen.api.exception; | ||
|
||
/** | ||
* Exception that indicates that an old monolithic template structure has been adapted. For asking if the template | ||
* structure should be upgraded. | ||
*/ | ||
public class UpgradeTemplatesNotificationException extends Exception { | ||
|
||
/** Generated serial version UID */ | ||
private static final long serialVersionUID = 1; | ||
|
||
/** | ||
* Creates a new {@link UpgradeTemplatesNotificationException} with a proper notification message | ||
* | ||
*/ | ||
public UpgradeTemplatesNotificationException() { | ||
|
||
super( | ||
"You are using an old, monolithic template project. Do you want to upgrade your template project to the new template structure with independent template sets?"); | ||
} | ||
|
||
} |
Oops, something went wrong.