From f1fe14095ec835020adeb4597d950976ae6bd050 Mon Sep 17 00:00:00 2001 From: Malte Brunnlieb Date: Mon, 17 Apr 2023 12:17:13 +0200 Subject: [PATCH] Template set deployables (#1633) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * #1452 changed dynamic groupId in master-pom.xml to fixed (#1498) * #1452 changed dynamic groupId in master-pom.xml to fixed separated all templates sets into deployables moved util tests into templates-devon4j-utils plug-in renamed devon4j-templates to devon4j-templates-tests * Update crud-java-server-app-complex/pom.xml delete relative Path * #1452 reformatted pom.xml codes Co-authored-by: LarsReinken * 1452 Prepare for new ConfigurationReader and Adapt Templates process (#1499) * #1452 changed dynamic groupId in master-pom.xml to fixed separated all templates sets into deployables moved util tests into templates-devon4j-utils plug-in renamed devon4j-templates to devon4j-templates-tests * Update crud-java-server-app-complex/pom.xml delete relative Path * #1452 reformatted pom.xml codes * #1452 added test resources for new TemplateSetTest * #1452 split ContextConfigurationReader into AbstractConfigurationReader and ContextConfigurationSetReader added new ContextConfigurationAnalyzer implemented rough template type detection * #1452 adapted core extract templates process and find templates methods to new template sets configuration ensured backwards compatibility in ConfigurationFinder and ExtractTemplatesUtil fixed some typos in ConfigurationFinder refactored CobiGenPaths class added getTemplateSetsFolderPath and createFolder methods to CobiGenPaths added new constants for downloaded, adapted and template-sets to ConfigurationConstants added processJars method to ExtractTemplatesUtil set processJar and getJarFile methods deprecated adjusted info messages in ExtractTemplatesUtil added first TemplateProcessingTest class + resources adjusted CobiGenFactory extractTemplate method * #1452 fixed resolve of doubled CobiGen_Templates directory * #1452 fixed ConfigurationUtilTest * #1452 implemented requested changes combined 3rd and 4th check into one in ConfigurationFinder fixed old templates folder detection in ExtractTemplatesUtil adjusted javadoc of processJars method in ExtractTemplatesUtil adjusted return of getTemplateSetsFolderPath * #1452 renamed variable name as requested Co-authored-by: LarsReinken * 1452 Implemented new configuration reader to read the template sets (#1504) * 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 new template set configuration reader * added new tests to check if the ContextConfigurationSetReader is able to find all context configurations properly * added new tests to check if the ContextConfigurationSetReader is able to find all context configurations properly * adapted cli and template tests for correct use of template sets * implemented requested changes * implemented requested changes * Loading of util classes from devon4j-template * implemented loading of util classes from template-sets. Fixed template and cli tests * added Javadoc * fix compilation error in tempalte test * fixed that the templates folder always was created * fix TemplateProcessingTest * implemented requested changes * implemented requested changes * adapted getJarFile to use Path instead of File * ignore Eclipse AdapteTemplatesTest * changed downloadJar * changed getJarFile from file to path in eclipse project * 1501 Separation of Java Utils across template sets (#1514) * 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 new template set configuration reader * added new tests to check if the ContextConfigurationSetReader is able to find all context configurations properly * added new tests to check if the ContextConfigurationSetReader is able to find all context configurations properly * adapted cli and template tests for correct use of template sets * implemented requested changes * implemented requested changes * Loading of util classes from devon4j-template * implemented loading of util classes from template-sets. Fixed template and cli tests * added Javadoc * fix compilation error in tempalte test * fixed that the templates folder always was created * fix TemplateProcessingTest * seperation of util classes * implemented requested changes * implemented requested changes * changed template test * changed abstractclitest * adapted getJarFile to use Path instead of File * ignore Eclipse AdapteTemplatesTest * changed downloadJar * changed getJarFile from file to path in eclipse project * updated jackson-databind version * Template set deployables test optimizations (#1515) * update mockito and Hamcrest * adapt TemplatedProcessingTest to work as expected * #1452 fixed eclipse build.properties and .classpath * #1452 implemented requested changes changed cobigenHome from File to Path * #1452 implemented requested changes * #1452 removed unnecessary lambda because of more effective mockito * Revert "#1452 removed unnecessary lambda because of more effective mockito" This reverts commit e85dde5e9ae5d4f542f521ef1a7e5bf76b37acec. * test without mockito partial mock * #1452 re-introduced mockito changes with latest changes from template-set-deployables renamed findTemplateSetJarsWithBackwardsCompatibilityTest to findTemplateSetsDownloadedFolderTest fixed logic of findTemplateSetsDownloadedFolderTest Co-authored-by: LarsReinken * Add tags, detailed description and tutorial links to config files (#1500) * #1403 changed pciture and added text to make it very clear what plugins should be installed * Adjust documentation (#1491) * fixed some types and links and corrected some parts of the documentation * adjust angular client guide * fixed typo * fixed requested changes * #1463 added options for tags, detailed descriptions and links to xsd * #1463 added new version to constants and generation to pom * #1463 updated version, rearranged newly added xsd elements, updated method getTrigger in configurationReader * #1463 adpated xsd to not have a weird method, made config version non-backwards compatible, changed config reader to read single trigger * #1463 schema version upgraded from 2.x to 2.3 in templates.xml and context.xml added new explanation attribute to the first Increment in templates.xml added links attribute to context.xml * #1463 spell correction of some explanation attributes * #1463 modified from v4.0 to v2.3 in pom.xml explanation correction for crud_java_server_app templates.xml link added to crud_java_server_app context.xml * #1463 changed versions of configs * #1463 changed config versions * #1463 removed core changes for now * added back linebreaks at file endings * #1463 removed trigger node from xsd * #1463 changed version attributes in xsds and added templateengine node from v4.0 to v5.0 * #1463 changed xsd to get a list of triggers for now, added new schema versions with upgrades * #1500 fixed failing tests, adressed requested changes, removed some tests for now * #1463 re-added accidently deleted v2.2 schema, changed versions of config files to latest versions * #1463 re-removed 2.2 schema, added missing version to upgrader * deleted unnecessary files * removed unnecessary changes * added new xsd version back to pom * readded template version 5.0 to version enum * fixed pom error * fix compilation errors * fix syntax error in context.xml * changed contextconfiguration 3.0 schema * added ignore to tests * fix whitespaces in templates.xml Co-authored-by: GuentherJulian <69513769+GuentherJulian@users.noreply.github.com> Co-authored-by: Mansour Dukhan Co-authored-by: Julian Günther * 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 * 1511 enable custom template set group ids for lookup (#1525) * #1511 added new method to read properties in ConfigurationFinder.java new TemplateSetConfiguration Class to save properties new test cases in ConfigurationFinderTest.java * #1511 fixed logic in method readTemplateSetConfiguration in ConfigurationFinder added hideTemplates variable in TemplateSetConfiguration completed 2 out of 3 tests cases * #1511 corrected CheckTemplateSetConfiguration logic in ConfigurationFinder.java Test cases Correction for CheckTemplateSetConfiguration in ConfigurationFinderTest.java New Constants for the new properties created in ConfigurationConstants.java CheckTemplateSetConfiguration Called in load function in CobiGenPropertiesReader.java * #1511 canceled the method call in load properties in CobiGenPropertiesReader.java * #1511 written Documentation Modified the properties function to read properties corrected tests * #1511 documentation correction * #1511 Documentation correction * #1511 Documentation Correction * #1511 requested changes * #1511 requested changes #2 * #1511 requested changes 2 * #1511 requested changes * #1511 fix defaultGroupId logic * 1511 enable custom template set group ids for lookup (#1535) * #1511 added new method to read properties in ConfigurationFinder.java new TemplateSetConfiguration Class to save properties new test cases in ConfigurationFinderTest.java * #1511 fixed logic in method readTemplateSetConfiguration in ConfigurationFinder added hideTemplates variable in TemplateSetConfiguration completed 2 out of 3 tests cases * #1511 corrected CheckTemplateSetConfiguration logic in ConfigurationFinder.java Test cases Correction for CheckTemplateSetConfiguration in ConfigurationFinderTest.java New Constants for the new properties created in ConfigurationConstants.java CheckTemplateSetConfiguration Called in load function in CobiGenPropertiesReader.java * #1511 canceled the method call in load properties in CobiGenPropertiesReader.java * #1511 written Documentation Modified the properties function to read properties corrected tests * #1511 documentation correction * #1511 Documentation correction * #1511 Documentation Correction * #1511 requested changes * #1511 requested changes #2 * #1511 requested changes 2 * #1511 requested changes * #1511 fix defaultGroupId logic * #1511 corrected hide annotation * #1511 requested changes * #1509 Ignore extractTemplatesWithOldCinfiguration (#1536) * #1509 Ignore extractTemplatesWithOldCinfiguration Fixed CLI adaptTemplatesTest Fixed Eclipse testAdaptTemplates Deleted generation from Eclipse Test * removed exception that was used to differenciate between test and production and added an argument instead. * #1509 Enabled extractTemplatesWithOldConfiguration * #1509 Implemented requested changes * #1509 Implemented requested changes Co-authored-by: LarsReinken * #1519 added possible Log warning places for CLI (#1538) * #1519 added possible Log warning places for CLI * #1519 Implemented requested changes * #1519 Deleted unneeded warn messages * #1519 Clear Tests * #1519 Fixed Eclipse Plugin Issues * Revert "#1519 Fixed Eclipse Plugin Issues" This reverts commit 9d4ca8b346d94c7f155d6057c5c8a73b1e5cb106. * #1519 Fix Ignore Tag (changed Order) * #1519 Fix Import Ignore * #1519 throw DeprecatedMonolithicTemplatesException in custom templates, if old templates found. Ignore CLI custom templates Test * remove duplicate DeprecatedMonolithicTemplatesException and allow creation with a force parameter which allows the createn of Cobigen with the old folder structure * remove unnecessary throw * adapt tests(ignore cli and eclipse since these tests should be adapted subsequently, force everything else) * #1519 Force Old templates in GenerateMojo to run maven-systemtest Fixed ConfigurationHolder Logger mismatch name Co-authored-by: LarsReinken * Merged master into template-set-deployables feature branch (#1543) * Adjust documentation (#1491) * fixed some types and links and corrected some parts of the documentation * adjust angular client guide * fixed typo * fixed requested changes * changed eclipse repository to https * #1291 changed nestserver version from 1.1.7 to 1.1.9 (#1523) added new testMergingOverridesExportConst test and resources * 1496 fix wrong thread in ExceptionHandler (#1527) * #1496 replaced Runnable with lambda * #1496 passed activeShell to openInvalidConfigurationErrorDialog * #1496 created a new thread for Exceptions handled by the ExceptionHandler (getActiveShell returned a wrong thread) * #1496 re-enabled and fixed testConflictConfiguration test made sure to check old context.xml case properly (context.xml in template project root) added new checkForConflict method to ContextConfigurationReader added processCobiGenWithExpectedError methods to EclipseCobiGenUtils added new ExceptionHandlingTest * #1496 added waitUntils of 10 seconds to ExceptionHandlingTest and processCobiGenWithExpectedError added screenshot to processCobiGenWithExpectedError added exception message to cleanWorkspace log replaced Files.exist with Files.isDirectory in ContextConfigurationReader * #1496 fixed project import and optimized shell handling added missing .project file removed waitUntils removed extra placeholder in debug message moved syncExec to openInvalidConfigurationErrorDialog method removed activeShell param from openInvalidConfigurationErrorDialog * #1496 added new Eclipse test troubleshoot issue * #1496 removed unnecessary/unused rule * use annotations of the patchfile, if javamerge_override is set. (#1490) * #430 use annotations of the patchfile, if javamerge_override is set. * implement merge method and use it to merge class annotation * merge implementation of fields and methods, and tests * Update JavaMerger.java Co-authored-by: Malte Brunnlieb * #1532 fixed HealthCheck not being able to handle a conflict with the old and new configuration (#1533) * #1532 fixed HealthCheck not being able to handle a conflict with the old and new configuration added new ConfigurationConflictException replaced InvalidConfigurationException with ConfigurationConflictException in checkForConflict method replaced InvalidConfigurationException with ConfigurationConflictException in testConflictConfiguration test added new case for conflicted configurations to ExceptionHandler handle method added catch of ConfigurationConflictException with adjusted message to healthCheckDialog execute * #1532 replaced File with Path * #1532 implemented requested changes moved log message from eclipse to core * added missing test files * added missing comment Co-authored-by: GuentherJulian <69513769+GuentherJulian@users.noreply.github.com> Co-authored-by: Malte Brunnlieb Co-authored-by: LarsReinken * 1465 template set documentation (#1546) * #1465 Adjusted documentation added CobiGen Home title updated template folder structure added template sets folder structure added separate CobiGen configuration file documentation * #1465 Adjusted documentation moved 'Custom template-set groupIds for lookup' into the CobiGen configuration file topic renamed 'Custom template-set groupIds for lookup' to 'Template set attributes' * #1465 Implemented requested changes replaced tab stops with white spaces removed non existing feature * 1502 config upgrade (#1528) * Adjust documentation (#1491) * fixed some types and links and corrected some parts of the documentation * adjust angular client guide * fixed typo * fixed requested changes * changed eclipse repository to https * implemented draft for template set upgrader * trigger getting converted to xml * context will be splitted, pom generation in progress * removed useless fields * removed some comments * implemented some test * upgrader implemented * added backup folder for old templates * added ignore to templatesetupgradetests * added ignore to templatesetupgradetests * chaanged upgrading process and changed the tests of the upgrade * test for sucessful backup * changed test to use multiple context files * #1502 changed context version of reader test files to lates compatible * changed context version in the jars from the test files * reworked upgrade step to work with the upgrade prozess to 3.0 * #1502 fixed latest context version in javaplugin integration test * #1502 fixed some more context versions in tests * moved template upgrade process out of the abstract class * implemented requested changes * removed some files * the requested changes have been added * changed use of validate process for the readers * removed log * removed import * #1502 added tags to template sets * used correct formatting for few files * #1502 addressed requested changes * #1502 replaced generic exceptions with CobigenRuntimeExceptions * #1502 applied proper code reformat * #1502 fixed template set upgrader and tests refactored context configuration validation into a new method validateContextConfigurationFile set all template directories to proper path using ConfigurationConstants added context configuration file exists and schema validation to testTemplateSetUpgradeCopyOfTemplates test * #1502 fixed template set upgrader and tests set all template directories to proper path using ConfigurationConstants * #1502 fixed template set upgrader and tests added exception to fail message Co-authored-by: GuentherJulian <69513769+GuentherJulian@users.noreply.github.com> Co-authored-by: Malte Brunnlieb Co-authored-by: Julian Günther Co-authored-by: MikeSchumacher Co-authored-by: jan-vcapgemini * #1531 Handle CLI Exception (#1544) * #1531 Handle CLI Exception Added 2 Test Cases for the Exception * #1531 Implement Eclipse Handler logic deleted unused CLI tests * #1531 Handled Eclipse Exception Enabled All Eclipse and CLI tests Integrated Force into CLI tests Integrated Bot to "Postpone" Exception in Tests * #1531 Implemented requested changes Integrated a handler in HealthCheck to handle MonolithicException * #1531 implemented requested changes * #1531 Deleted unnecessary comments * #1531 Deleted redundant code Added some comments * #1511 requested changes Added CLI Constants Added Warning button instead of Error Button in Eclipse * Added CLI Constants Added Warning button instead of Error Button in Eclipse * #1531 Adjusted and added missing JavaDocs * #1531 Implemented requested changes * #1531 requested Changes * 1551 merge master into template_set_deployables (#1552) * 1526 fixed infinite loop while generating from source code (#1547) * #1526 added new Eclipse text input test added a test which tests a simple generate from text input added a new processCobiGenWithTextInput method to EclipseCobiGenUtils refactored processCobiGen method added new generateWithSelectedIncrements method to EclipseCobiGenUtils * #1526 fixed infinite loop wrapped getActiveWorkbenchWindow into asynchronous runnables added workbenchWindow class variable added extra check for FileEditorInput * #1526 added missing files added .classpath and .project files * #1526 fixed Eclipse crash changed asynchronous runnable to synchronized * #1551 disabled GenerateFromTextInput test * 1516 document new configuration structure (#1565) * Documentation of upgrade steps + Link to wiki * Fixing typos * # 1521 Attached Template-set plugin for deployment (#1562) * Attached Templsate-set plugin for deployment * Artifact attached in parent pom * Update pom.xml * #1521 final Solution in templates-parent pom * #1521 modified Plugin and classifer Plugin now only in templates parent pom Added Classifier so that the additional attached artifact has name alongside the maven co-ordinates * #1521 Reformat templates-parent pom * #1521 All template-set.xml empty files deleted * 1510 allow template sets to be installed (#1554) * initial commit * template-sets will be installed at cobigen startup * added tests * removed old test * removed comments * added mavenCoordinates dataholder and reworked the functions * added systemtest * added creation of downloaded folder * trying to fix cli tests * removed unnessesary download of templates * added check for downloaded folder * revert changes to an old test * added javadoc and adjusted documentation * fixed wrong push * #1510 implemented requested changes changed test name and removed cobigen variable * implemented requested changes * initial implenetation of mocking the downloads * added todo * removed usage of Path * removed initial try to mock downloads in tests * chaged assertions to assertThat * changed variables to correct camel case and used constants, Files and improved asserts * fixed typo * implemented requested changes * fixed nullPointerbug with lates commit * implemented requested changes Co-authored-by: jan-vcapgemini * #1529 added first implementation of extensible artifact search REST API (#1556) * #1529 added first implementation of extensible artifact search REST API added new getMavenArtifactsByGroupId to MavenUtils which takes a repository type (e.g. maven, nexus, jfrog) and a groupId to search for added new SearchResponse tos to core-api utils added new MavenUtilTest class (tests for proper json string parsing and REST API requests) and resources * #1529 added missing dependencies * #1529 implemented requested changes added new RESTSearchResponseException replaced IOException with RESTSearchResponseException * #1529 fixed jFrog API * #1529 implemented requested changes changed repositoryType from String to MavenSearchRepositoryType enum added new MavenSearchRepositoryType enum * #1529 implemented requested changes replaced fixed repository URLs with constants added new MavenSearchRepositoryConstants * #1529 implemented requested changes converted MavenSearchResponseConstants to uppercase added MAVEN, NEXUS and JFROG TARGET_LINK constants added MAVEN_MAX_RESPONSE_ROWS constant added javadoc to all models (moved main model to top) renamed json response models * #1529 adjusted nexus REST API adjusted nexus REST API to v2.0 adjusted nexus REST API tests and resources to v2.0 refactored createDownloadLink method (moved to AbstractRESTSearchResponse) added new constants for MAVEN_REPOSITORY_LINK, NEXUS_REPOSITORY_URL, NEXUS_REPOSITORY_URL, NEXUS_TARGET_LINK, NEXUS_DC_ID added ec param to MavenSearchResponse * #1529 disabled jfrog REST API test * #1529 added optimizations + authentication added bearer token authentication added bearer token to jfrog renamed nexus to nexus2 repository type added nexus3 repository type added more tests for code coverage * #1529 applied factory pattern added new SearchResponse interface made all SearchResponse types inherit from SearchResponse added new SearchResponseFactory refactored getArtifactDownloadLinks method added new getAvailableSearchInterfaces method (used to register new search interfaces) added getRepositoryType to SearchResponse parent class (returns the type of repository as an enum) * #1529 moved utility methods from factory class to util class added new SearchResponseUtil class * changed javadoc * #1529 implemented requested changes renamed RESTSearchResponse signature msg to message * #1529 implemented requested changes removed limitRows functionality removed NEXUS2_DC_ID from target link adjusted MavenSearchResponseConstants javadoc * #1529 implemented requested changes converted getAvailableSearchInterfaces method to final list of SearchResponses adjusted javadoc * #1529 added missing javadoc * #1529 implemented requested changes added more detailed javadoc * #1529 implemented requested changes converted RESTSearchResponseException name to PascalCase * #1529 implemented requested changes renamed getMavenArtifactsByGroupId to retrieveMavenArtifactsByGroupId * #1529 implemented requested changes renamed getArtifactDownloadLinks to searchArtifactDownloadLinks * #1529 implemented requested changes moved multi search response classes to separate packages * #1529 implemented requested changes improved javadoc readability * #1529 implemented requested changes converted SearchResponse to AbstractSearchResponse refactored getJsonResponse added new retrieveJsonResponseWithAuthentication method to AbstractSearchResponse renamed getJsonResponse to retrieveJsonResponse * #1529 implemented requested changes refactored getDownloadURLs method added new removeDuplicatedDownloadURLs method to AbstractSearchResponse renamed getDownloadURLs to retrieveDownloadURLs * #1529 implemented requested changes refactored SearchResponseUtil methods moved SearchResponseUtil methods to AbstractSearchResponse removed SearchResponseUtil class * #1529 implemented requested changes removed throw CobiGenRuntimeExceptions to ensure that an error with the API won't stop CobiGen execution replaced CobiGenRuntimeException in MavenUtil with error log and a return of null converted testWrongRepositoryTypeThrowsException to testRetrieveMavenArtifactsWithInvalidLinkReturnsNull replaced throw exception with error log message * #1529 implemented requested changes refactored getJsonResponseStringByTargetLink replaced getJsonResponseStringByTargetLink with retrieveJsonResponseWithAuthenticationToken added MavenSearchRepositoryType to retrieveJsonResponseWithAuthenticationToken * #1529 implemented requested changes replaced fixed ignored json properties with ignore unknown param * #1529 added WireMock to tests made ignored tests functional with WireMock added WireMock stubs for each case updated jersey from 3.0.5 to 3.0.7 added wiremock-standalone 2.27.2 (used older version because of conflicts with jackson) * #1529 reduced WireMock logging added logback-test.xml (sets WireMock to WARN log level) * #1529 updated jackson updated jackson-databind from 2.13.2.2 to 2.13.3 * #1529 fixed FileUtils issue replaced readString with readAllBytes * #1529 implemented requested changes renamed baseURL to baseUrl removed LOG concatenation * #1529 implemented requested changes removed ProcessingException from SearchResponseFactory * #1529 implemented requested changes added artifactory path to jfrog target link constant * #1529 removed jersey dependencies replaced jersey with OkHttpClient restricted MavenUtilTests (added check of messages) added jackson-databind to core-api dependencies added okhttp to core-api dependencies * #1529 updated okhttp changed okhttp version from 4.9.1 to 4.10.0 * #1529 added okhttp version to root pom added latest okhttp dependeny to root pom.xml removed fixed okhttp versions from core-api and core-externalprocess-api * #1529 added okio added transitive okio dependency * #1529 implemented requested changes Changed enum values to uppercase * #1529 implemented requested changes moved status into not null if condition Co-authored-by: EduardKrieger * fixed merge errors * fix merge error (#1581) * fix merge error * changed restoreSystemProperties to withEnviromentVariable * 1518 automatically ask for upgrade on reading monolithic templates from a folder (#1553) * #1518 Integrated the context upgrader into TemplatesAdapterImpl and Into the CLI * #1518 Reactivated Ignored tests Refactored processCobiGenAndPostponeUpgrade * #1518 * #1518 Integrated the upgrader into the CLI * #1553 adjusted v5.0 template configuration file removed optional param from valid 5.0 template configuration file as it is not required for an upgrade check because of backwards compatibility * #1533 fixed upgrade tests re-introduced version to version test (removed upgrade to latest version tests) re-introduced schema version validation tests (removed validate against latest schema test) refactored resolveLatestCompatibleSchemaVersion added new maxVersion param for tests (limits the versions list to the provided maximum version) added new limitVersions method (limits the versions list to provided maximum version) added new isConfgurationFileCompatibleToSchemaVersion method (checks if the version is compatible to the configuration file) added new testV2_1IsIncompatibleToV3_0Schema test to make sure that v3.0 is not backwards compatible to v2.1 * #1518 Implement the upgrader to be dynamic with custom templates changed src/main/templates to src/main/resources in template-sets * #1518 Implemented requested changes. Implemented a class TimeStampUtil for the timestamp. Implemented a starting point to check the 30 day postpone in CLI. * #1518 Upgrader Test * #1518 Upgrader Test 2 * #1518 Integrated Timestamp into Eclipse Wrote CLI Upgrader Test New Implementation of isTemplateSet based on versioning the context.xml Collectors methods in FileSystem to collect paths of context.xml and templates.xml New TimeStampUtilTest New CLI option to upgrade the configuration in one command New FileSystemUtilTest Restored monolithic context.xmls to their original versions in tests Added a small monolithic templates project in CLI to test the upgrader Implemented a new structure for Eclipse to recognize the template-sets after the upgrade (still needs to be tested). Ignore testFindTemplateslocation (for some reason the test cannot recognize the specified user.home) Adjusted Findtemplates to prefer template-set instead of the old configuration if both folders are found in Home. * #1518 Test Correction * #1518 Test Correction * #1518 Test Correction * #1518 Test Correction * #1518 Deleted MavenXpp classes from the upgrader, now only copy the pom and replace with regex Implemented the upgrader into Eclipse After the upgrade now, Eclipse should be able to read the new template-set structure and generate from them Implemented new upgrader test for Eclipse * #1518 Test correction * #1518 Test Correction * #1518 Eclipse tests correction * #1518 Eclipse test correction * #1518 Implemented requested changes * #1518 implemented requested changes * #1518 Implemented requested changes * #1518 Implemented requested changes * #1518 Implemented requested changes * #1518 Implemented requested changes * #1518 Fixed Eclipse small Issue not identifying the template-set folder structure * #1566 Implemented requested changes * #1518 Implemented requested changes * #1518 Implemented requested changes * #1518 Implemented requested changes Deleted all public static fields in eclipse, to be solved in a new Issue * #1518 fixed null check * #1518 Implemented requested changes Modified the upgrade process to upgrade inside the original templates folder using the rename method * #1518 Core-Tests correction * #1518 reworked renaming process * #1518 Reworked renaming process 2 * #1518 rename of templates folder working for some cases * #1518 reworked templateUpgraderTests * #1518 Added Jacoco check On Cli and Maven projects * #1518 Implemented requested changes * #1518 added test of backup files * #1518 Fixed getPomLocation from Homepath * #1518 Fixed bug of arraylist and refactored some methods * #1518 Implemented requested changes * #1518 Fixed Eclipse upgrade test Co-authored-by: jan-vcapgemini Co-authored-by: EduardKrieger * 1580 rework test application using entity class (#1603) * fixed mistakes in the POC tutorial Co-authored-by: Felix felix.berger@capgemini.com * Shortened and edited the tutorial + updated screenshots * a few layout and spelling/phrasing corrections * 1517 discovery of template sets (#1585) * First implementation of settings.xml mapping * Completed mapping of the needed components, refactoring, added JavaDocs, added log output * Added test class, removed unnecessary code * #1530 added maven settings password decryption added org.codehaus.plexus sec-dispatcher dependency added org.codehaus.plexus cipher dependency added MavenSettingsUtil added MavenSettingsUtilTest and resources * #1530 adjusted test method name * Added tests, did refactoring * Added missing JavaDocs, tests are now using asserThat(), more improvements addressing change requests on the pull requests * #1530 added basic authentication type replaced authToken with password added basic username and password authentication * #1530 renamed REST search API constants * #1530 handle template-set.xml made sure that only template-set.xml files get returned as download links added new template-set.xml to ConfigurationConstants added a valid template-set.xml example to test resource files removed extra outputs (non template-set.xml) from test assertions added classifier to Nexus2Response renamed retrieveDownloadUrls to retrieveTemplateSetXmlDownloadURLs * #1530 added some fixes fixed credentials not being used fixed too many httpclient calls being used added new test for a failed basic authentication added new test for a failed token authentication enabled bad url test * #1530 cleaned up exceptions removed JsonMappingException because it is already being handled by JsonProcessingException * Switched from javax to jakarta, resolved comments from the pull request * Tidied up code * Changed path generation * Added unmarshalling for mirrors, added loading of active profiles, added preperation of settings.xml * added function, which returns repositories of all active profiles * #1530 improved log messages adjusted log messages (converted to debug, made factory process messages more transparent) converted RestSearchResponseException status code from string to integer * Added utils to operate with mirrors specified in maven's settings.xml * Optimized MavenSettingsUtilTest, added first code of MavenMirrorUtilTest * Fixed bugs, added tests for matchPattern * Completed MavenMirrorUtil class, completed tests * determined active profiles, added method to determine repositories of active profiles and inject mirrors in repository urls * Minor optimisations * Added collection of servers private key and passphrase * Refactoring of classes in a new maven module * #1530 added exception messages to constants * #1530 adjusted exception handling replaced exception strings with constants added retrieveRestSearchApiTargetLink method adjusted SearchResponseException with dynamic message adjusted tests to check for exception types and message content * Fixed merge bugs * #1517 Refactoring Refactored changes from #1530 into #1517 Moved #1530 files into MavenSearch package * #1517 Added proxy to http client * #1517 added eclipse project files * Removed MavenSettingsUtil * #1517 changed the process of getting active profiles added artifact retriever removed unsecessary code * #1517 added multiple tests * #1517 improved WireMock log messages moved logback-test.xml from core-api to core-artifact-retriever * #1517 introduced server credentials moved all server credentials into new object added new MavenSearchArtifactRetriever class added new ServerCredentials class adjusted tests to utilize server credentials deleted MavenArtifactsUtil * #1517 Added proxy util and tests * #1517 removed exceptions replaced exceptions with debug log messages adjusted tests * #1517 Reworked MavenProxyUtil, updated tests * #1517 replaced more exceptions with log messages removed obsolete retrieveMavenArtifactsByGroupId method * #1517 implemented requested changes converted null returns to empty lists added new debug message to indicate that the search is proceeding converted MavenSearchArtifactRetriever to static class added more tests adjusted test descriptions * #1517 Combined ArtifactRetriever with MavenSearch added artifactRetriever logic prepared artifactRetriever tests * #1517 ArtifactRetriever test preperation * #1517 added first ArtifactRetriever tests added example template-set.xml added example json response for WireMock added WireMock tests for proxy and non proxy connections as well as basic authentication added more log messages for proxy usage and basic authentication usage fixed NPE in MavenSettingsUtil and ArtifactRetriever * #1517 added proxy server authentication added basic authentication to proxy connection added tests for proxy authentication added proxyUsername and proxyPassword to ServerCredentials * #1517 split test classes split test classes of maven search * #1517 re-organized test resources simplified json test resource files for MavenSearchResponse tests * #1517 fixed ArtifactRetriever proxy test added 2nd WireMock server adjusted settings.xml to use proxy properly * #1517 Added ArtivactRetrieverReader Co-authored-by: Leonie leonie-heidi.schuessler@capgemini.com * Removed unused test * #1517 removed util package from mavensearch * #1517 optimizations fixed typo moved file reader from test to generateMavenTemplateSetConfiguration method adjusted javadocs added more debug information * #1517 renamed reader models * #1517 removed util package from mavensearch * #1517 added template set version and tests added retrieveTemplateSetData method (converts a list of template set files to TemplateSetArtifactReader) added more tests and test resources converted TemplateSetArtifactReader to stateful class added simple template set version retrieval adjusted tests removed tag names and increment descriptions from TemplateSetArtifactReader removed setupClass method from TemplateSetArtifactReaderTest (moved initialization to each test) * #1517 renamed MavenReaderTest resource folder renamed MavenReaderTest resource folder to TemplateSetArtifactReaderTest * #1517 set java version to 11 * #1517 Removed java 11 dependency * #1517 removed java 11 dependencies * #1517 replaced List.of with simple List * #1517 implemented requested changes renamed get... methods adjusted/added javadocs * #1517 implemented requested changes removed .classpath and .project files moved timeout values to constants converted SEARCH_RESPONSES from Object to AbstractSearchResponse moved regex version number detection to constant * #1517 implemented requested changes saved the return of Systemutils.getUserHome() and determineMvnPath in a static variable to avoid multiple calls of the method * #1517 implemented requested changes added javadoc descriptions * #1517 adjusted javadocs and class name fixed type of Nexus2SearchResponseArtifactLinks * #1517 Removed exceptions from tests, added javaDocs * #1517 implemented requested changes removed unnecessary returns * #1517 adjusted artifact reader adjusted artifact reader to latest TemplateSetConfiguration added ContextConfiguration and TemplatesConfiguration entities adjusted tests * #1517 introduced new TemplateSet entity replaced TemplateSetArtifactReader constructor with new retrieve method adjusted tests * #1517 implemented requested changes removed unnecessary caching of user home and maven paths * #1517 implemented requested changes added zeroturnaround zt-exec 1.12 to the root pom as a managed dependency * #1517 implemented requested changes removed unnecessary build of test-jar * #1517 #1517 implemented requested changes adjusted debug log message made sure that missing files won't break the retrieval process added new testRetrieveTemplateSetArtifactWithMissingFile test * #1517 implemented requested changes changed wiremock dependency to wiremock-jre8 2.35.0 * #1517 implemented requested changes changed java version to 11 Co-authored-by: jan-vcapgemini * #1619 cleanup docs * #1619 upgrade all sources to jdk 11 * #1619 fix plugins build to run on jdk 11 * spelling corrections * Added correct settings URL for cobigen setup * Fix merge error * Removed xvfb-action as ubuntu-latest already contains xvfb and the action is not under maintenance anymore * trying to fix strange execution problem in GHA * Also resolve and cache dependencies for tycho + removing ansi suppression as of strange error on windows builds * fix build on windows * fixed 2018-12 target + fixed eclipse test + fixed M2E compatibility * removed unnecessary junit headless dependency failing on sonar run * upgraded openapi parser to latest version of networknt * upgraded openapi parser to latest version of networknt * Revert "upgraded openapi parser to latest version of networknt" This reverts commit efdc183f3f7d17f5fae3e16954cc09bc7e3410fe. * Revert "upgraded openapi parser to latest version of networknt" This reverts commit b76c231efbe51a52005a66664e6e75ed524ef98a. * removed stupid non-used testdata * store workflow status for sonar analysis * store workflow status for sonar analysis * fix workflow * added maven repository cache for faster execution (#1625) * added maven repository cache for faster execution * added maven repository cache for faster execution * removed unnecessary else case * trying to flatten CI/CD to speed up * fixing dependency caching + fixing build component script + fixing matrix build * fix dependency caching * fix build script * automatically enable debug mode + better matrix parameter view on github UI * fixing detection of GHA debug mode * debug test execution * enabled new enableCrossOsArchive of github cache * Workaround for actions/cache#1059 * fix workflow * fix workflow * fix workflow * set java 17 for windows build * actions/cache#1059 workaround - trying to locate m2 repo in working directory * add logging out env to understand temporary debug mode detection * fixed automated maven debug log on runner debug + trying to fix maven cache * try to fix maven cache location consolidation accross OS * trying different local repository setting * fixing cache mismatches * fixing checkout on windows * more cache debugging! * more cache debugging! * more cache debugging * fixing odd cache path * new try for cross-os build-config * new try for cross-os build-config * new try for cross-os build-config * new try for cross-os build-config * new try for cross-os build-config * trying to fix maven repo cache * splitting dependency resolution and plugin resolution * enabling batch processing and fixing maven settings * built just once on linux + restore also p2 for tests + removed debugging * trying to fix tests by providing test settings.xml in home folder * Fix settings overwriting * enable xvfb run for linux for eclipse tests + fixing settings.xml overwriting * fix settings.xml overwriting * try fixing settings.xml rewrite * changing path to be static on cache declaration * removed coverage report to be executed everytime * fixing m-m-m NlsBundle Exception on CLI tests * fixing -h option for right color coding * fixing p2 compiler issues * debugging + cleanup * workaround for https://github.com/m-m-m/code/issues/43 * disabled debug logging + readme update * fixed a bug in findTemplates (#1630) * fixed a bug in findTemplates, added more unittest for the ConfigurationFinder and also added the lost test in AdaptTemplatesCommandIT for the monolitic structure * implemented requested changes * changed names of the tests and improved javadoc * try fixing unnecessary timeout on windows * #1495 Combine template and configuration files into template set files (#1597) * #1495 All changes in one commit * #1495 Resolved merge conflicts * #1495 Resolved conflicts * #1495 applied stash * #1495 deleted obsolete classes * #1495 removed useless method * #1495 Fixed templates.xml upgrader tests * trigger map will be loaded correctly * #1495 Fix for core-systemtests * #1495 Removed duplicates * fixed tests * Revert "fixed tests" This reverts commit da30dda55c9daf963cfa7b7ae961ddd2de3b8c27. * added cli test * #1495 new core tests for tempalate-set.xml * #1495 Implemented a specifier for the reader * Revert "#1495 Implemented a specifier for the reader" This reverts commit 0edc655d80aa65c167dd2d30071e92d639a904dd. * #1495 Changed templateSetConfiguration schema structure * #1495 Fixed TemplateSetConfigurationReader to read the new templateSetConfiguration.xsd added new Core tests and test resources * fixed install templates test * #1495 Added new test for Templatescan * #1495 Deleted unnecessary resources * Merged context.xml and templates.xml into template-set.xml for: - crud-openapi-java-server-app - crud-openapi-net - crud-typescript-angular-client-app - kafka-documentation - named-queries - openapi-documentation - rest-documentation - security-permissions - testdata-builder * #1495 Merged context.xml and templates.xml to template-set.xml * #1495 Fixed template-scan issue * #1495 Fixed syntax errors in template-set.xml Files * #1495 Fixed Templatescan not finding the templates location * #1495 TemplateSetReader combination test added new constructors to template and context readers cleaned up TemplateSetConfigurationReader added templates and context configuration getters to TemplateSetConfigurationReader changed all versioned imports to default io initialized templates and context readers in TemplateSetConfiguration readConfiguration method removed template set detection in templates and context configuration * #1495 re-added template set condition created templates and context configuration readers in template set readConfiguration method added configFilePath to TemplatesConfiguration constructor initialized templates and context configuration readers in template set readConfiguration method cleaned up template set template scan test * #1495 added more tests + resources cleaned up test resources * #1495 fixes added ConfigurationHolder to TemplateSetConfiguration added javadocs fixed configFilePath in TemplatesConfigurationReader for template-sets added templateSetConfigurationFile to TemplatesConfigurationReader fixed templates subfolder being used for rootTemplateFolder added a 2nd template-set to GenerationTestTemplateSetsXml * #1495 removed unused method * #1495 adjusted readConfiguration removed readConfiguration call from TemplateSetConfigurationReader added readConfiguration to TemplateSetConfiguration filled maps of triggers and templates in TemplateSetConfiguration readConfiguration method reformatted and adjusted test resource template-set.xmls * #1495 fixed create and generate replaced triggers in ContextConfiguration readConfiguration with template set triggers added extra check to getConfigLocationForTrigger (checks if template set is available) added getter for triggers to TemplateSetConfiguration temporary fix for missing templateFolder in trigger renamed test * #1495 Added TemplateSetConfiguration directly into the configuraion holder # cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/GenerateCommandIT.java # cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/constants/ConfigurationConstants.java # cobigen/cobigen-core/pom.xml # cobigen/cobigen-core/src/main/resources/schema/v6.0/templateSetConfiguration.xsd * #1495 fixed tests added wip hack for template_scan conflict with "templates/templates" paths moved "template/templates" root path creation into extra method initializeTemplateSetTemplatesRoot fixed templateScan paths in test resources (jar file too) * #1495 replaced mocked java plug-in added testdata_builder template-set to core-systemtest resources replaced mocked java plug-in with real input class * #1495 Made the ConfigurationHolder a singleton and some other refactors * #1495 removed ConfigurationFactory moved retrieveTemplatesConfiguration and retrieveTemplateSetConfiguration to ConfigurationHolder * #1495 removed singleeton again because this pattern didn't make sense here in the first place * #1495 Lots of optimizations and cleanup moved detection of template set from ContextConfiguration to ConfigurationHolder added lots of javadoc comments cleaned up AbstractContextConfiguration replaced TemplateSetConfiguration in ContextConfiguration with ConfigurationHolder added new Map rootTemplateFolders to ConfigurationHolder (replaces triggerConfigLocations?) * #1495 added 2nd template to overrideMerge test * #1495 more optimizations and cleanups moved isTemplateSet check from TemplatesConfiguration to ConfigurationHolder added new templatesConfigurations getter to ConfigurationHolder cleaned up ContextConfiguration constructor (made sure that triggers won't be loaded again) added a getter for increments to TemplateSetConfiguration * #1495 initialized proper templates list added templatesConfigurations to TemplateSetConfiguration passed properly initialized TemplatesConfigurations to getMatchingTemplates if we are in template set * #1495 more optimizations and cleanups removed Context and TemplatesConfigurationReaders from TemplateSetConfigurationReader initialized Context and TemplatesConfigurationReaders in TemplateSetConfiguration removed retrieveTemplatesConfiguration method (moved logic into readTemplatesConfiguration) * #1495 fixed template_scan root folder lookup * #1495 added and cleaned up tests added new classLoadingTemplateSetTest and resources added new testTemplateSetCorrectDestinationResolution test and resources reduced current test resource complexity renamed testReadTwoTemplateSetXml to testReadMultipleTemplateSetXmls * #1495 refactored loadTemplateSetFilesAdapted moved retrieval of template set root folders to new method * #1495 fixed conflict with templateRoot and utilsLocation added new retrieveTemplateSetUtilsLocationForTrigger method * #1495 fixed callClassLoadingTemplateSetTest added proper resources * #1495 added variableAssignments added variableAssignments to ClassLoading template set system test re-added fileSystemDependentPath handling to getConfigurationLocationforTrigger fixed ClassLoading template set system test * #1495 Some refactors * #1495 Fixed error from previous push * #1495 fixed fileSystem conflict replaced 2nd if condition with else fixed unit tests changed templateSetFiles field (might be unnecessary) * #1495 disabled templates generation integration test * #1495 added example template-set integration test added example template-set integration test for crud-java-server-app template set moved functions.ftl into root template folder of crud-java-server-app * #1495 refactoring * #1495 added a test for version conflict detection some cleanup added test resources * #1495 removed static call * #1495 more optimizations and fixes split adapted and downloaded paths removed duplicated methods from TemplateSetConfigurationReader (can be found in TemplateSetConfigurationManager) fixed typos added getter for configuration locations to TemplateSetConfigurationManager removed file system creation and isZipFile check in ContextConfiguration retrieveConfigRootByTrigger and retrieveTemplateSetUtilsLocaitonByTrigger * #1495 added example template-set integration test added example template-set integration test for crud-openapi-java-server-app template set moved functions.ftl and makros.ftl into root template folder of crud-openapi-java-server-app * #1495 cleanup and test fixes removed unnecessary templateSetFiles field removed getTemplateSetFiles and addTemplateSetFiles methods fixed TemplateSetConfigurationReader check if configurations were found (added downloaded template set paths check) fixed template set reader unit tests * #1495 fixed makros and functions moved makros and functions into templates folder * #1495 disabled version conflict test * #1495 fixed github workflow enabled enableCrossOsArchive for eclipse-test cache restore * #1495 implemented requested changes reverted changes on AccumulationType Matcher * #1495 implemented requested changes removed unused imports * #1495 implemented requested changes changed version float number adjusted javadoc * #1495 implemented requested changes adjusted TemplateSetConfiguration initial release description * #1495 implemented requested changes adjusted/enhanced javadocs fixed typos removed links to Path * #1495 implemented requested changes changed throws from generic Exception to more specific ones adjusted javadocs * #1495 implemented requested changes changed compare to equals (sonatype issue fixed) * #1496 removed resource build removed src/main/templates dependency * #1495 updated javadoc for templateSetConfigurations * added import that was lost in a merge * #1495 renamed test resources and changed folder structure * cleaning up the ressources and changing the structure to the new template set structure * adjusted ressources after merge * #1495 finallized test folder structure * #1495 fixed template set test structure moved templates and config files into src/main/resources * #1495 fixed template set resolving replaced src/main/templates with src/main/resources in TemplateSetConfigurationManager removed template resource folder inside downloaded template set detection removed initializeTemplateSetTemplatesRoot (will be handled by ts_scan configuration now) * #1495 fixed template set tests fixed template set resource configurations disabled testTemplateSetsDuplicatedThrowsError test added templates folder to each template set test resource configuration (fixes template_scan conflict) added downloaded projects to test resources and built them in core pom.xml (removes dependency on binaries) removed binaries from test resources added test resource jars to .gitignore * #1495 fixed template set projects moved functions and makros into src/main/resources * #1495 fixed cli tests added downloaded test project and automatic build replaced src/main/templates with src/main/resources * #1495 fixed template set resource folder fixed template set resource folder in crud-java-server-app template set test * #1495 optimized template set tests renamed single template set tests removed unnecessary file copy operations in setupDevtemplates method added test data builder test added crud angular client app test * #1495 fixed conflicted class load template set test * #1495 added crud openapi net test to template set * #1495 fixed template set jars * #1495 adjusted GenerationIT system test added template set jar test projects to system test made sure that generation of all template sets (including downloaded jars) gets tested added generated jars to .gitignore * #1495 fixed plugin loading and jar pathing added OpenApi test resource and test renamed GenerationIT tests added OpenApi dependency to core-systemtest and root pom * #1495 resolved TODO renamed src/main/resources constant to MAVEN_CONFIGURATION_RESOURCE_FOLDER * #1495 resolved TODO added javadoc for templateSetConfigurationFile removed throws declaration * #1495 modularized old monolithic template tests added individual templateSet tests and resources to each templateSet project * #1495 added missing typescript templateSet test * #1495 resolved TODO removed unused loadConfig method * #1495 resolved TODOs removed FileNotFoundException made templateSetPaths private removed TODOs which are not needed anymore * #1495 resolved TODO added extra condition for optional template folders in template sets removed todo * #1495 Fixed folder structure in crud-java-ea-uml * added missing jars to ignore * #1495 temporarily disabled test * #1495 temporarily disabled tests --------- Co-authored-by: MansourD <96188427+mdukhan@users.noreply.github.com> Co-authored-by: MansourD Co-authored-by: EduardKrieger Co-authored-by: Lurian Co-authored-by: jan-vcapgemini Co-authored-by: Malte Brunnlieb Co-authored-by: cedricarnauld123 * added TODO * added TODO * fixed eclipse tests freezes increased swt bot wait time of tests * 1622 Restore and fixed adaptTemplatesTest on eclipse (#1641) * #1509 Restored original code for adaptTemplatesAndGenerate Test #1622 * #1622 reformat to follow the next change * #1622 reintroduce changes * #1622 remove old templates update --------- Co-authored-by: Cedric Betom * #1622 fixed eclipse adapt monolithic templates test added templates folder added some comments describing the scenario * added TODO * added TODO * temporarily disabled upgrader test in eclipse * added TODO * applied proper reformat * applied proper reformat * applied proper reformat * applied proper reformat * applied proper reformat * added method to change CobiGen home use for tests only!! * added TODO adjusted javadoc * adjusted javadoc * added TODO refactored with active trigger * applied proper reformat * refactored AbstractContextConfigurationReader moved content of AbstractContextConfigurationReader into ContextConfigurationReader removed AbstractContextConfigurationReader * made fields private * made fields private * added TODO * cleanup changed to private removed configRoot field (was not used) removed configurationHolder field (was not used) * removed unused interfaces * adjusted template set documentation * updated google guava to 31.1-jre * made CobiGenFactory tests functional * moved template-set.xml into correct folder * applied proper reformat * added test path check to CobiGenPaths added some log messages to temporary CobiGen home test path usages * added TODO * applied proper reformat * removed unused test resource files * cleanup of ConfigurationFinder enabled ignored tests removed unused param removed unused exceptions added missing javadoc params * moved method beneath constructor * adjusted javadocs * removed unused files * fixed PostPoneUtil tests replaced test resource dependency with temporary file * removed extra isZipFile check * cleanup * adjusted template set upgrade documentation * 1495 fixed working branch adapt templates feature (#1645) * #1495 All changes in one commit * #1495 Resolved merge conflicts * #1495 Resolved conflicts * #1495 applied stash * #1495 deleted obsolete classes * #1495 removed useless method * #1495 Fixed templates.xml upgrader tests * trigger map will be loaded correctly * #1495 Fix for core-systemtests * #1495 Removed duplicates * fixed tests * Revert "fixed tests" This reverts commit da30dda55c9daf963cfa7b7ae961ddd2de3b8c27. * added cli test * #1495 new core tests for tempalate-set.xml * #1495 Implemented a specifier for the reader * Revert "#1495 Implemented a specifier for the reader" This reverts commit 0edc655d80aa65c167dd2d30071e92d639a904dd. * #1495 Changed templateSetConfiguration schema structure * #1495 Fixed TemplateSetConfigurationReader to read the new templateSetConfiguration.xsd added new Core tests and test resources * fixed install templates test * #1495 Added new test for Templatescan * #1495 Deleted unnecessary resources * Merged context.xml and templates.xml into template-set.xml for: - crud-openapi-java-server-app - crud-openapi-net - crud-typescript-angular-client-app - kafka-documentation - named-queries - openapi-documentation - rest-documentation - security-permissions - testdata-builder * #1495 Merged context.xml and templates.xml to template-set.xml * #1495 Fixed template-scan issue * #1495 Fixed syntax errors in template-set.xml Files * #1495 Fixed Templatescan not finding the templates location * #1495 TemplateSetReader combination test added new constructors to template and context readers cleaned up TemplateSetConfigurationReader added templates and context configuration getters to TemplateSetConfigurationReader changed all versioned imports to default io initialized templates and context readers in TemplateSetConfiguration readConfiguration method removed template set detection in templates and context configuration * #1495 re-added template set condition created templates and context configuration readers in template set readConfiguration method added configFilePath to TemplatesConfiguration constructor initialized templates and context configuration readers in template set readConfiguration method cleaned up template set template scan test * #1495 added more tests + resources cleaned up test resources * #1495 fixes added ConfigurationHolder to TemplateSetConfiguration added javadocs fixed configFilePath in TemplatesConfigurationReader for template-sets added templateSetConfigurationFile to TemplatesConfigurationReader fixed templates subfolder being used for rootTemplateFolder added a 2nd template-set to GenerationTestTemplateSetsXml * #1495 removed unused method * #1495 adjusted readConfiguration removed readConfiguration call from TemplateSetConfigurationReader added readConfiguration to TemplateSetConfiguration filled maps of triggers and templates in TemplateSetConfiguration readConfiguration method reformatted and adjusted test resource template-set.xmls * #1495 fixed create and generate replaced triggers in ContextConfiguration readConfiguration with template set triggers added extra check to getConfigLocationForTrigger (checks if template set is available) added getter for triggers to TemplateSetConfiguration temporary fix for missing templateFolder in trigger renamed test * #1495 Added TemplateSetConfiguration directly into the configuraion holder # cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/GenerateCommandIT.java # cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/constants/ConfigurationConstants.java # cobigen/cobigen-core/pom.xml # cobigen/cobigen-core/src/main/resources/schema/v6.0/templateSetConfiguration.xsd * #1495 fixed tests added wip hack for template_scan conflict with "templates/templates" paths moved "template/templates" root path creation into extra method initializeTemplateSetTemplatesRoot fixed templateScan paths in test resources (jar file too) * #1495 replaced mocked java plug-in added testdata_builder template-set to core-systemtest resources replaced mocked java plug-in with real input class * #1495 Made the ConfigurationHolder a singleton and some other refactors * #1495 removed ConfigurationFactory moved retrieveTemplatesConfiguration and retrieveTemplateSetConfiguration to ConfigurationHolder * #1495 removed singleeton again because this pattern didn't make sense here in the first place * #1495 Lots of optimizations and cleanup moved detection of template set from ContextConfiguration to ConfigurationHolder added lots of javadoc comments cleaned up AbstractContextConfiguration replaced TemplateSetConfiguration in ContextConfiguration with ConfigurationHolder added new Map rootTemplateFolders to ConfigurationHolder (replaces triggerConfigLocations?) * #1495 added 2nd template to overrideMerge test * #1495 more optimizations and cleanups moved isTemplateSet check from TemplatesConfiguration to ConfigurationHolder added new templatesConfigurations getter to ConfigurationHolder cleaned up ContextConfiguration constructor (made sure that triggers won't be loaded again) added a getter for increments to TemplateSetConfiguration * #1495 initialized proper templates list added templatesConfigurations to TemplateSetConfiguration passed properly initialized TemplatesConfigurations to getMatchingTemplates if we are in template set * #1495 more optimizations and cleanups removed Context and TemplatesConfigurationReaders from TemplateSetConfigurationReader initialized Context and TemplatesConfigurationReaders in TemplateSetConfiguration removed retrieveTemplatesConfiguration method (moved logic into readTemplatesConfiguration) * #1495 fixed template_scan root folder lookup * #1495 added and cleaned up tests added new classLoadingTemplateSetTest and resources added new testTemplateSetCorrectDestinationResolution test and resources reduced current test resource complexity renamed testReadTwoTemplateSetXml to testReadMultipleTemplateSetXmls * #1495 refactored loadTemplateSetFilesAdapted moved retrieval of template set root folders to new method * #1495 fixed conflict with templateRoot and utilsLocation added new retrieveTemplateSetUtilsLocationForTrigger method * #1495 fixed callClassLoadingTemplateSetTest added proper resources * #1495 added variableAssignments added variableAssignments to ClassLoading template set system test re-added fileSystemDependentPath handling to getConfigurationLocationforTrigger fixed ClassLoading template set system test * #1495 Some refactors * #1495 Fixed error from previous push * #1495 fixed fileSystem conflict replaced 2nd if condition with else fixed unit tests changed templateSetFiles field (might be unnecessary) * #1495 disabled templates generation integration test * #1495 added example template-set integration test added example template-set integration test for crud-java-server-app template set moved functions.ftl into root template folder of crud-java-server-app * #1495 refactoring * #1495 added a test for version conflict detection some cleanup added test resources * #1495 removed static call * #1495 more optimizations and fixes split adapted and downloaded paths removed duplicated methods from TemplateSetConfigurationReader (can be found in TemplateSetConfigurationManager) fixed typos added getter for configuration locations to TemplateSetConfigurationManager removed file system creation and isZipFile check in ContextConfiguration retrieveConfigRootByTrigger and retrieveTemplateSetUtilsLocaitonByTrigger * #1495 added example template-set integration test added example template-set integration test for crud-openapi-java-server-app template set moved functions.ftl and makros.ftl into root template folder of crud-openapi-java-server-app * #1495 cleanup and test fixes removed unnecessary templateSetFiles field removed getTemplateSetFiles and addTemplateSetFiles methods fixed TemplateSetConfigurationReader check if configurations were found (added downloaded template set paths check) fixed template set reader unit tests * #1495 fixed makros and functions moved makros and functions into templates folder * #1495 disabled version conflict test * #1495 fixed github workflow enabled enableCrossOsArchive for eclipse-test cache restore * #1495 implemented requested changes reverted changes on AccumulationType Matcher * #1495 implemented requested changes removed unused imports * #1495 implemented requested changes changed version float number adjusted javadoc * #1495 implemented requested changes adjusted TemplateSetConfiguration initial release description * #1495 implemented requested changes adjusted/enhanced javadocs fixed typos removed links to Path * #1495 implemented requested changes changed throws from generic Exception to more specific ones adjusted javadocs * #1495 implemented requested changes changed compare to equals (sonatype issue fixed) * #1496 removed resource build removed src/main/templates dependency * #1495 updated javadoc for templateSetConfigurations * added import that was lost in a merge * #1495 renamed test resources and changed folder structure * cleaning up the ressources and changing the structure to the new template set structure * adjusted ressources after merge * #1495 finallized test folder structure * Began implementing new test case * #1495 fixed template set test structure moved templates and config files into src/main/resources * #1495 fixed template set resolving replaced src/main/templates with src/main/resources in TemplateSetConfigurationManager removed template resource folder inside downloaded template set detection removed initializeTemplateSetTemplatesRoot (will be handled by ts_scan configuration now) * #1495 fixed template set tests fixed template set resource configurations disabled testTemplateSetsDuplicatedThrowsError test added templates folder to each template set test resource configuration (fixes template_scan conflict) added downloaded projects to test resources and built them in core pom.xml (removes dependency on binaries) removed binaries from test resources added test resource jars to .gitignore * #1495 fixed template set projects moved functions and makros into src/main/resources * #1495 fixed cli tests added downloaded test project and automatic build replaced src/main/templates with src/main/resources * #1495 fixed template set resource folder fixed template set resource folder in crud-java-server-app template set test * Fixed adaptTemplateSetTest * Implemented extractTemplateSetsTest * began implementing methods into new test * #1495 optimized template set tests renamed single template set tests removed unnecessary file copy operations in setupDevtemplates method added test data builder test added crud angular client app test * #1495 fixed conflicted class load template set test * #1495 added crud openapi net test to template set * #1495 fixed template set jars * #1495 adjusted GenerationIT system test added template set jar test projects to system test made sure that generation of all template sets (including downloaded jars) gets tested added generated jars to .gitignore * #1495 fixed plugin loading and jar pathing added OpenApi test resource and test renamed GenerationIT tests added OpenApi dependency to core-systemtest and root pom * #1495 resolved TODO renamed src/main/resources constant to MAVEN_CONFIGURATION_RESOURCE_FOLDER * #1495 resolved TODO added javadoc for templateSetConfigurationFile removed throws declaration * #1495 modularized old monolithic template tests added individual templateSet tests and resources to each templateSet project * #1495 added missing typescript templateSet test * #1495 resolved TODO removed unused loadConfig method * #1495 resolved TODOs removed FileNotFoundException made templateSetPaths private removed TODOs which are not needed anymore * #1495 resolved TODO added extra condition for optional template folders in template sets removed todo * Identified todos * added pattern * implemented basic logic for information gathering * simplified the new method and embedded new information into the mavencoordinatestate object * added mavencoordinates package; implemented a wrapper class for pairs of MavenCoordinateStates; implemented errors and logs into getTemplateSetJarFolderStructure * successfully implemented getTemplateSetJarFolderStructure with test * modified the test for getTemplateSetJarFolderStructure to extensively test the method * Fixed the test * extensively tested the new MavenCoordinatePair data structure * adapt command makes use of new data structure * #1495 Fixed folder structure in crud-java-ea-uml * added missing jars to ignore * #1495 temporarily disabled test * #1495 temporarily disabled tests * template adapter rework is completed and tested * template adapter rework is completed and tested * core builds now * dependency cycle dissolved * added mavencoordinates to downloadjar * #1642 made adapt template set process functional added proper adapt templates process renamed getValue0 and getValue1 to getSourcesJar and getClassesJar adjusted tests to check for correct folder structure after adapt process re-enabled CLI adaptTemplateSetTest * #1642 re-enabled CLI adaptTemplatesTest * #1642 added test resources to CLI added template set test resource projects (will be converted to downloaded jars automatically) * #1642 added build test resources to ignore * #1642 changed adaptTemplateSetsTest to use template sets from test ressources * #1645 made adapt template set process functional removed MavenCoordinateState model removed MavenCoordinateStatePair model adjusted tests added template set projects to test resources added changes from EduardKrieger to TemplateAdapterImpl * #1645 removed null return from TemplateAdapter replaced null with empty list adjusted tests added more tests * #1645 re-added template-set projects * #1645 removed javatuples dependency --------- Co-authored-by: KHucklenbroich Co-authored-by: MansourD <96188427+mdukhan@users.noreply.github.com> Co-authored-by: MansourD Co-authored-by: EduardKrieger Co-authored-by: Lurian Co-authored-by: jan-vcapgemini Co-authored-by: Malte Brunnlieb Co-authored-by: cedricarnauld123 * added missing test resource file * #1638 implemented download jar process (from properties) (#1653) * #1638 implemented download jar process (from properties) added new retrieveTemplateSetJarDownloadURLs method to ArtifactRetriever replaced old templates download with template set (uses ArtifactRetriever) added new downloadJarFromURL method to TemplatesJarUtil added lots of adjustments for SNAPSHOT handling added createRootURL method to AbstractSearchResponse (just returns the root URL of a link) adjusted Username and Password getters of ServerCredentials (workaround for missing credentials) added core-artifact-retriever to core dependencies * #1638 fixed NPE * #1638 adjusted request added Accept and Authorization headers * #1638 fixed createRootURL added port returned empty string instead of null * #1638 adjusted javadocs * #1638 added fallback added fallback to sonatype if retrieval from maven settings did not work added FALLBACK_REPOSITORY_URL to constants * #1638 removed temporary ArtifactReader removed ArtifactReader model, tests and test resources (was replaced with template set reader from core) * fixed template installation tests replaced old monolithic coordinates with new template-sets added new test for #1656 (ignored for now) added TODOs to check if tests are still valid * adjusted javadoc of test * removed unnecessary test and resources * renamed method and adjusted javadoc renamed loadTemplateSetConfigurations to retrieveCobiGenProperties adjusted javadoc description and params * adjusted javadoc added better description * adjusted javadoc * removed empty newline * applied rest of refactoring * added fallback if no repositories were found * added issue links to TODOs * fixed template set file tree * adjusted javadoc of ConfigurationFinder * adjusted javadocs * added issue to TODO * added issue to TODO * removed unused fields * added javadoc descriptions for constants * added issue to TODO * adjusted javadocs added issues to TODOs * added issue to TODO * fixed download by properties made sure that template set jars only get downloaded when template-sets.installed was set renamed fields of ConfigurationProperties * removed unused class variable * prepared template set version conflict test added issue to TODO adjusted test to check for only one matching template * cleanup of unnecessary condition * Simple fixes * applied requested changes removed unnecessary WireMockServer in tests * added TODO and link to issue * implemented requested changes changed class of ContextConfiguration from impl class to jaxb generated one * implemented requested changes removed unused configRoot field added issue to TODOs * added issue to TODO * removed unused field * moved getters under constructor * Typo fix * Finished sentence * #1667 Made template set root directories accessible for the reader removed templateSetPaths field in TemplateSetConfigurationManager adjusted addConfigRoot to provide the root template set folder added test to check for invalid template set folders removed addConfigRoot method removed getUtilSourceFolder method (now the same way to determine utility folders works for adapted and downloaded template sets) * added TODOs with linked issues * implemented requested changes removed catch of NotYetSupportedException from TemplateSetConfigurationReader validate process * implemented requested changes changed default of vaidate allowMonolothicConfiguration to false changed TemplateSetConfigurationReader validate to non monolithic removed catch of NotYetSupportedException from ContextConfigurationReader validate process * implemented requested changes added issue link to TODO adjusted javadocs * #1670 hotfix set allow monolithic templates in validator to true again (temporary workaround) added TODO with link to issue * added TODO with link to issue * #1668 added issue to TODO * #1671 added link to issue to TODO * adjusted javadoc * added issue to TODOs * sonatype-lift fixes upgraded xercesImpl from test files to 2.12.2 * removed commented code * added TODO with link to issue removed IOException from javadoc * added TODO with link to issue * added TODO with link to issue * added TODO with link to issue * sonatype-lift changes changed spring release to 4.0.4 * sonatype-lift changes changed spring release to 4.0.4 * sonatype-lift changes addressed change requests * added comment * added TODO and link to issue * fixed typo * sonatype-lift changes, hotfix changed spring release to 3.7.10 * fixed openapi-parser version * added TODO and link to issue adjusted comments + javadoc * adjusted javadoc fixed issues applied reformat * added missing javadocs * added TODO and link to issue * removed unused files * adjusted javadoc * added TODO and link to issue * added TODO and link to issue * cleanup * adjusted javadoc of test * added javadoc description * adjusted javadoc * cleanup * fix deploy script to allow local updatesite builds * fix eclipse e2e test classpath * adjusted javadocs * added TODO and link to issue * generating platform definition based on local plugins build. * removed 2nd initialization of CobiGen * spellcheck fixes * fixed last spellcheck issues * cleanup and fixing eclipse import issues with m2e * Revert "cleanup and fixing eclipse import issues with m2e" This reverts commit 603c10502ec19e1f4779b6ad2d355cbad3890616. * Revert "generating platform definition based on local plugins build." This reverts commit ebd5dec4984543a11904a3a8ce575e2512201cf4. * Revert "fix eclipse e2e test classpath" This reverts commit 5c64a1e83cf117d768c30940245b38accf1edf3d. * Fixed elif syntax --------- Co-authored-by: jan-vcapgemini <59438728+jan-vcapgemini@users.noreply.github.com> Co-authored-by: LarsReinken Co-authored-by: GuentherJulian <69513769+GuentherJulian@users.noreply.github.com> Co-authored-by: LarsReinken Co-authored-by: Mike Schumacher <38068582+MikeSchumacherCapgemini@users.noreply.github.com> Co-authored-by: Mansour Dukhan Co-authored-by: Julian Günther Co-authored-by: MansourD <96188427+mdukhan@users.noreply.github.com> Co-authored-by: EduardKrieger <79975016+EduardKrieger@users.noreply.github.com> Co-authored-by: MikeSchumacher Co-authored-by: jan-vcapgemini Co-authored-by: Felix Berger <60586680+Zylesto@users.noreply.github.com> Co-authored-by: Ali Saad <104510118+Ali7223@users.noreply.github.com> Co-authored-by: EduardKrieger Co-authored-by: leonie19s <112944994+leonie19s@users.noreply.github.com> Co-authored-by: Kevin Hucklenbroich <43209109+KHucklenbroich@users.noreply.github.com> Co-authored-by: Lurian Co-authored-by: cedricarnauld123 Co-authored-by: Cedric Betom Co-authored-by: Leon Connor Holm <62796852+quantumfate@users.noreply.github.com> Co-authored-by: KHucklenbroich Co-authored-by: Nils Neuhäusel --- .github/workflows/maven-build-test.yml | 366 +++++--------- .gitignore | 17 +- .mvn/{settings.xml => ci-settings.xml} | 1 + README.asciidoc | 2 +- build.sh | 44 +- cobigen-cli/cli-systemtest/pom.xml | 60 +++ .../cli/systemtest/AbstractCliTest.java | 117 ++++- .../systemtest/AdaptTemplatesCommandIT.java | 124 ++++- .../cli/systemtest/GenerateCommandIT.java | 78 ++- .../crud-java-server-app-complex/pom.xml | 83 ++++ .../src/main/java/com/test.java | 0 .../src/main/resources/functions.ftl | 0 .../src/main/resources/template-set.xml | 40 ++ .../to/${variables.entityName}Eto.java.ftl | 1 + .../adapted/crud-java-server-app/pom.xml | 83 ++++ .../src/main/java/com/test.java | 0 .../src/main/resources/functions.ftl | 0 .../src/main/resources/template-set.xml | 40 ++ .../to/${variables.entityName}Eto.java.ftl | 1 + .../adapted/crud-java-server-app/pom.xml | 55 +++ .../src/main/java/utils/MathUtils.java | 12 + .../src/main/resources/template-set.xml | 40 ++ .../to/${variables.entityName}Eto.java.ftl | 5 + .../downloaded/crud-java-server-app/pom.xml | 27 + .../src/main/resources/template-set.xml | 40 ++ .../to/${variables.entityName}Eto.java.ftl | 1 + .../cli/commands/AdaptTemplatesCommand.java | 115 ++++- .../cobigen/cli/commands/CommandCommons.java | 6 + .../cobigen/cli/commands/GenerateCommand.java | 90 +++- .../cli/constants/MessagesConstants.java | 29 ++ .../cobigen/cli/utils/CobiGenUtils.java | 10 +- cobigen-cli/cli/src/main/resources/pom.xml | 5 - cobigen-cli/pom.xml | 4 - .../cobigen-eclipse-feature/.project | 41 -- cobigen-eclipse/cobigen-eclipse-test/.project | 45 -- .../cobigen-eclipse-test/META-INF/MANIFEST.MF | 54 +- .../cobigen-eclipse-test/build.properties | 49 +- cobigen-eclipse/cobigen-eclipse-test/pom.xml | 55 ++- .../eclipse/test/AdaptTemplatesTest.java | 18 +- .../eclipse/test/ClassPathLoadingTest.java | 10 +- .../eclipse/test/CobigenJavaWrapperTest.java | 6 +- .../cobigen/eclipse/test/HealthCheckTest.java | 4 +- .../test/MultipleMatchingTriggerTest.java | 2 +- .../cobigen/eclipse/test/OpenAPITest.java | 16 +- .../test/UpgradeMonolithicTemplatesTest.java | 103 ++++ .../eclipse/test/VelocityGenerationTest.java | 4 +- .../eclipse/test/common/SystemTest.java | 2 - .../common/junit/TmpMavenProjectRule.java | 35 +- .../common/utils/EclipseCobiGenUtils.java | 141 +++++- .../test/common/utils/EclipseUtils.java | 9 +- .../utils/swtbot/SwtBotTestingUtilities.java | 4 +- .../utils/swtbot/SwtBotTimeoutManager.java | 5 +- .../utils/swtbot/SwtBotTreeUtilities.java | 8 +- .../templates/{template1 => }/context.xml | 2 +- .../input/test.yml | 23 + .../templates/CobiGen_Templates}/.project | 3 +- .../templates/CobiGen_Templates/pom.xml | 23 + .../src/main/templates}/context.xml | 7 +- .../templates.xml | 8 +- .../src/environments/environment.ts.ftl | 0 .../targlets/2018-12.target | 19 + .../cobigen-eclipse-updatesite/.project | 36 -- cobigen-eclipse/cobigen-eclipse/.project | 45 -- .../cobigen-eclipse/META-INF/MANIFEST.MF | 19 +- .../cobigen-eclipse/build.properties | 6 +- .../constants/InfrastructureConstants.java | 2 - .../common/tools/ExceptionHandler.java | 46 ++ .../eclipse/common/tools/PlatformUIUtil.java | 2 - .../common/tools/ResourcesPluginUtil.java | 73 ++- .../generator/GeneratorWrapperFactory.java | 97 ++-- .../generator/generic/FileInputConverter.java | 2 - .../healthcheck/HealthCheckDialog.java | 32 +- .../common/model/JavaClasspathUtil.java | 1 - .../model/stubs/ICompilationUnitStub.java | 2 - .../wizard/common/model/stubs/IFileStub.java | 2 - .../common/model/stubs/IFolderStub.java | 2 - .../model/stubs/IPackageFragmentRootStub.java | 2 - .../widget/SimulatedCheckboxTreeViewer.java | 1 - .../ConfigurationProjectListener.java | 2 - .../handler/GenerateHandler.java | 2 - .../workbenchcontrol/handler/GenerateJob.java | 26 +- .../handler/HealthCheckHandler.java | 21 +- cobigen-eclipse/pom.xml | 96 +--- .../devonfw/cobigen/maven/GenerateMojo.java | 4 +- .../devonfw/cobigen/maven/utils/XmlUtil.java | 6 - .../maven/validation/InputValidator.java | 4 - .../context.xml | 2 +- .../templates-devon4j/pom.xml | 2 +- .../context.xml | 2 +- .../templates-oasp4j/context.xml | 5 +- .../src/main/java/constants/pojo/Field.java | 2 - .../cobigen/maven/test/AbstractMavenTest.java | 14 +- .../javaplugin/model/JavaModelUtil.java | 8 +- .../javaplugin/model/ModelConstant.java | 3 - .../cobigen-javaplugin/pom.xml | 16 +- .../inputreader/JavaInputReader.java | 1 - .../inputreader/JavaParserUtil.java | 14 +- .../ReflectedJavaModelBuilder.java | 3 +- .../javaplugin/matcher/JavaMatcher.java | 2 - .../resolver/TriggerExpressionResolver.java | 2 - .../cobigen/javaplugin/merger/JavaMerger.java | 10 - .../CustomModelWriterFactory.java | 2 - .../libextension/ExtendedJavaParameter.java | 4 - .../ModifyableClassLibraryBuilder.java | 2 - .../libextension/ModifyableJavaClass.java | 3 - .../libextension/ModifyableJavaType.java | 9 +- .../libextension/ModifyableSourceLibrary.java | 9 - .../AnnotationQueryingTest.java | 2 +- .../integrationtest/ModelCreationTest.java | 8 +- .../VariablesResolutionTest.java | 2 +- .../ParsedJavaModelBuilderTest.java | 2 - .../inputreader/testdata/RootClass.java | 6 - .../inputreader/testdata/SuperClass1.java | 10 - .../inputreader/testdata/TestClass.java | 5 - .../testdata/TestClassWithAnnotations.java | 1 - ...WithAnnotationsContainingObjectArrays.java | 2 - .../inputreader/testdata/TestInterface1.java | 4 - .../inputreader/testdata/TestInterface2.java | 2 - .../testdata/subpackage/SuperClass2.java | 6 - .../unittest/merger/JavaMergerTest.java | 15 - .../javaSources/ModelCreationTest.java | 4 - .../integrationtest/templates/context.xml | 25 +- .../unittest/inputreader/TestClass.java | 4 - .../inputreader/TestClassWithAnnotations.java | 2 - ...WithAnnotationsContainingObjectArrays.java | 2 - .../TestClassWithRecursiveAnnotations.java | 2 - .../unittest/inputreader/TestInterface1.java | 3 - .../unittest/inputreader/TestInterface2.java | 2 - .../inputreader/packageFolder/RootClass.java | 6 - .../packageFolder/SuperClass1.java | 10 - .../packageFolder/subpackage/SuperClass2.java | 6 - .../merger/BaseFile_encoding_ISO-8859-1.java | 6 +- .../merger/BaseFile_encoding_UTF-8.java | 2 - .../inputreader/ModelConstant.java | 1 - .../InputReaderMatcherTest.java | 18 +- .../templates-regex/context.xml | 5 +- .../templates/context.xml | 5 +- .../propertyplugin/PropertyMerger.java | 1 - ...VelocityTemplateEngineIntegrationTest.java | 2 +- .../src/test/resources/systemtest/context.xml | 5 +- .../cobigen/textmerger/TextAppender.java | 3 - .../cobigen/textmerger/TextAppenderTest.java | 8 - .../tsplugin/matcher/TypeScriptMatcher.java | 2 - cobigen-plugins/cobigen-xmlplugin/pom.xml | 2 +- .../xmlplugin/XmlTriggerInterpreter.java | 1 - .../xmlplugin/inputreader/ModelConstant.java | 2 - .../xmlplugin/merger/delegates/MergeType.java | 5 - .../merger/delegates/XmlMergerDelegate.java | 3 - .../integrationtest/XPathGenerationTest.java | 2 +- .../XmlPluginIntegrationTest.java | 8 +- .../XmlPluginMergerIntegrationTest.java | 3 - .../integrationtest/templates/context.xml | 5 +- .../uml-basic-test/context.xml | 5 +- .../integrationtest/uml-classdiag/context.xml | 5 +- .../crud-angular-client-app/pom.xml | 21 + .../config/constant/MavenMetadata.java | 0 .../templates/devon4j/utils/JavaUtil.java | 0 .../src/main/resources/template-set.xml | 69 +++ .../resources}/templates/cobigen.properties | 0 ...oName#lower_case}-alert.component.html.ftl | 0 ...s.etoName#lower_case}-alert.component.scss | 0 ...me#lower_case}-alert.component.spec.ts.ftl | 0 ...etoName#lower_case}-alert.component.ts.ftl | 0 ...Name#lower_case}-dialog.component.html.ftl | 0 ...e#lower_case}-dialog.component.spec.ts.ftl | 0 ...toName#lower_case}-dialog.component.ts.ftl | 0 ...toName#lower_case}-grid.component.html.ftl | 0 ...es.etoName#lower_case}-grid.component.scss | 0 ...ame#lower_case}-grid.component.spec.ts.ftl | 0 ....etoName#lower_case}-grid.component.ts.ftl | 0 ....etoName#lower_case}-routing.module.ts.ftl | 0 ...ariables.etoName#lower_case}.module.ts.ftl | 0 ...es.etoName#lower_case}.service.spec.ts.ftl | 0 ...riables.etoName#lower_case}.service.ts.ftl | 0 .../src/app/app-routing.module.ts.ftl | 0 .../templates/src/app/app.module.ts.ftl | 0 .../layout/nav-bar/nav-bar.component.html.ftl | 0 .../templates/src/assets/i18n/en.json.ftl | 0 .../templates/src/assets/i18n/es.json.ftl | 0 .../CrudAngularClientAppGenerationTest.java | 100 ++++ .../TestAllTemplatesEtoInput}/logback.xml | 0 .../TestAllTemplatesEtoInput/pom.xml | 0 .../generator/logic/api/to/InputEto.java | 0 .../src/test/resources/utils/pom.xml | 99 ++++ .../templates/CrudIonicClientAppTest.java | 100 ++++ .../crud-ionic-client-app/pom.xml | 20 + .../config/constant/MavenMetadata.java | 12 + .../templates/devon4j/utils/JavaUtil.java | 464 ++++++++++++++++++ .../src/main/resources/template-set.xml | 90 ++++ .../resources}/templates/cobigen.properties | 0 .../src/app/app-routing.module.ts.ftl | 0 .../templates/src/app/app.component.ts.ftl | 0 .../templates/src/app/app.module.ts.ftl | 0 ...s.etoName#lower_case}-detail.page.html.ftl | 0 ...s.etoName#lower_case}-detail.page.scss.ftl | 0 ...les.etoName#lower_case}-detail.page.ts.ftl | 0 ...les.etoName#lower_case}-list.page.html.ftl | 0 ...les.etoName#lower_case}-list.page.scss.ftl | 0 ...ables.etoName#lower_case}-list.page.ts.ftl | 0 ...es.etoName#lower_case}-rest.service.ts.ftl | 0 ...etoName#lower_case}-search-criteria.ts.ftl | 0 .../${variables.etoName#lower_case}.ts.ftl | 0 .../app/services/interfaces/pageable.ts.ftl | 0 .../interfaces/paginated-list-to.ts.ftl | 0 .../src/app/services/interfaces/sort.ts.ftl | 0 .../shared/business-operator.service.ts.ftl | 0 .../templates/src/assets/i18n/en.json.ftl | 0 .../templates/src/assets/i18n/es.json.ftl | 0 .../environments/environment.android.ts.ftl | 0 .../src/environments/environment.prod.ts.ftl | 0 .../src/environments/environment.ts.ftl | 0 .../templates/src/theme/variables.scss.ftl | 0 .../templates/CrudIonicClientAppTest.java | 99 ++++ .../src/test/resources/application.properties | 0 .../src/test/resources}/logback.xml | 0 .../TestAllTemplatesEtoInput/logback.xml | 0 .../TestAllTemplatesEtoInput/pom.xml | 79 +++ .../generator/logic/api/to/InputEto.java | 25 + .../src/test/resources/utils/pom.xml | 100 ++++ cobigen-templates/crud-java-ea-uml/pom.xml | 19 + .../config/constant/MavenMetadata.java | 12 + .../templates/devon4j/constants/Field.java | 0 .../templates/devon4j/utils/DevonfwUtil.java | 449 +++++++++++++++++ .../templates/devon4j/utils/JavaUtil.java | 464 ++++++++++++++++++ .../devon4j/utils/uml/Connector.java | 0 .../templates/devon4j/utils/uml/UmlUtil.java | 343 +++++++++++++ .../src/main/resources}/functions.ftl | 0 .../src/main/resources/template-set.xml | 35 ++ .../api/${variables.className}.java.ftl | 0 .../api/${variables.className}Entity.java.ftl | 0 .../common/api/ApplicationEntity.java.ftl | 0 .../api/ApplicationPersistenceEntity.java.ftl | 0 .../test/templates/CrudJavaEaUmlTest.java | 98 ++++ .../src/test/resources/application.properties | 2 + .../src/test/resources}/logback.xml | 0 .../TestAllTemplatesXMLInput}/logback.xml | 0 .../TestAllTemplatesXMLInput/pom.xml | 0 .../generator/dataaccess/api/Input.xml | 0 .../src/test/resources/utils/pom.xml | 100 ++++ .../crud-java-server-app-complex/pom.xml | 19 + .../config/constant/MavenMetadata.java | 12 + .../templates/devon4j/constants/Field.java | 48 ++ .../templates/devon4j/utils/DevonfwUtil.java | 449 +++++++++++++++++ .../templates/devon4j/utils/JavaUtil.java | 464 ++++++++++++++++++ .../src/main/resources}/functions.ftl | 0 .../src/main/resources/template-set.xml | 71 +++ .../${variables.component#cap_first}.java.ftl | 0 ...ariables.component#cap_first}Ctos.java.ftl | 0 .../logic}/api/cobigen.properties | 0 .../UcFind${variables.entityName}.java.ftl | 0 ...UcFind${variables.entityName}Ctos.java.ftl | 0 .../UcManage${variables.entityName}.java.ftl | 0 ...Abstract${variables.entityName}Uc.java.ftl | 0 ...ariables.component#cap_first}Impl.java.ftl | 0 ...bles.component#cap_first}ImplCtos.java.ftl | 0 ...UcFind${variables.entityName}Impl.java.ftl | 0 ...nd${variables.entityName}ImplCtos.java.ftl | 0 ...Manage${variables.entityName}Impl.java.ftl | 0 .../base/AbstractBeanMapperSupport.java.ftl | 0 .../general/logic/base/AbstractLogic.java.ftl | 0 .../general/logic/base/AbstractUc.java.ftl | 0 .../CrudJavaServerAppComplexTest.java | 99 ++++ .../src/test/resources/application.properties | 2 + .../src/test/resources/logback.xml | 14 + .../TestAllTemplatesEntityInput/logback.xml | 14 + .../TestAllTemplatesEntityInput/pom.xml | 0 .../generator/dataaccess/api/InputEntity.java | 0 .../src/test/resources/utils/pom.xml | 100 ++++ .../crud-java-server-app/pom.xml | 19 + .../config/constant/MavenMetadata.java | 12 + .../templates/devon4j/constants/Field.java | 48 ++ .../templates/devon4j/utils/DevonfwUtil.java | 449 +++++++++++++++++ .../templates/devon4j/utils/JavaUtil.java | 464 ++++++++++++++++++ .../src/main/resources}/functions.ftl | 0 .../src/main/resources/template-set.xml | 85 ++++ .../api/${variables.entityName}.java.ftl | 0 ...ables.entityName}SearchCriteriaTo.java.ftl | 0 .../common/api}/cobigen.properties | 0 .../${variables.entityName}Entity.java.ftl | 0 ...${variables.entityName}Repository.java.ftl | 0 .../to/${variables.entityName}Cto.java.ftl | 0 .../to/${variables.entityName}Eto.java.ftl | 0 .../logic/api/to}/cobigen.properties | 0 .../service/api}/cobigen.properties | 0 ...s.component#cap_first}RestService.java.ftl | 0 ...mponent#cap_first}RestServiceCtos.java.ftl | 0 ...s.component#cap_first}SoapService.java.ftl | 0 ...mponent#cap_first}RestServiceImpl.java.ftl | 0 ...ent#cap_first}RestServiceImplCtos.java.ftl | 0 ...mponent#cap_first}SoapServiceImpl.java.ftl | 0 .../common/api/ApplicationEntity.java.ftl | 0 .../api/to/AbstractSearchCriteriaTo.java.ftl | 0 .../general/common/api/to}/cobigen.properties | 0 .../base/AbstractBeanMapperSupport.java.ftl | 0 .../api/ApplicationPersistenceEntity.java.ftl | 0 .../api/dao/ApplicationDao.java.ftl | 0 .../base/dao/ApplicationDaoImpl.java.ftl | 0 .../base/AbstractComponentFacade.java.ftl | 0 .../impl/config/ServiceConfig.java.ftl | 0 .../WebApplicationContextLocator.java.ftl | 0 .../CrudJavaServerAppGenerationTest.java | 100 ++++ .../TestAllTemplatesEntityInput/logback.xml | 14 + .../TestAllTemplatesEntityInput/pom.xml | 53 ++ .../generator/dataaccess/api/InputEntity.java | 25 + .../src/test/resources/utils/pom.xml | 100 ++++ .../crud-ngrx-client-app/pom.xml | 19 + .../config/constant/MavenMetadata.java | 12 + .../templates/devon4j/utils/JavaUtil.java | 464 ++++++++++++++++++ .../src/main/resources/template-set.xml | 110 +++++ .../resources}/templates/cobigen.properties | 0 ....etoName#lower_case}-routing.module.ts.ftl | 0 ...ariables.etoName#lower_case}.module.ts.ftl | 0 ...oName#lower_case}-alert.component.html.ftl | 0 ...s.etoName#lower_case}-alert.component.scss | 0 ...me#lower_case}-alert.component.spec.ts.ftl | 0 ...etoName#lower_case}-alert.component.ts.ftl | 0 ...Name#lower_case}-dialog.component.html.ftl | 0 ...toName#lower_case}-dialog.component.ts.ftl | 0 ...toName#lower_case}-grid.component.html.ftl | 0 ...es.etoName#lower_case}-grid.component.scss | 0 ....etoName#lower_case}-grid.component.ts.ftl | 0 ...variables.etoName#lower_case}.model.ts.ftl | 0 .../models/datadetailstest.model.ts.ftl | 0 .../models/httpresponse.model.ts.ftl | 0 .../models/searchcriteriadata.model.ts.ftl | 0 ...es.etoName#lower_case}.service.spec.ts.ftl | 0 ...riables.etoName#lower_case}.service.ts.ftl | 0 ...riables.etoName#lower_case}.actions.ts.ftl | 0 .../store/actions/actions_index.ts.ftl | 0 ...es.etoName#lower_case}.effects.spec.ts.ftl | 0 ...riables.etoName#lower_case}.effects.ts.ftl | 0 .../store/effects/effects_index.ts.ftl | 0 ...s.etoName#lower_case}.reducers.spec.ts.ftl | 0 ...iables.etoName#lower_case}.reducers.ts.ftl | 0 .../store/reducers/reducers_index.ts.ftl | 0 ...ables.etoName#lower_case}.selectors.ts.ftl | 0 .../store/selectors/selectors_index.ts.ftl | 0 .../store/store_index.ts.ftl | 0 .../src/app/app-routing.module.ts.ftl | 0 .../app/layout/header/header.component.ts.ftl | 0 .../layout/nav-bar/nav-bar.component.html.ftl | 0 .../templates/src/assets/i18n/en.json.ftl | 0 .../templates/src/assets/i18n/es.json.ftl | 0 .../src/environments/environment.prod.ts.ftl | 0 .../src/environments/environment.ts.ftl | 0 .../test/templates/CrudNgrxClientAppTest.java | 98 ++++ .../src/test/resources/application.properties | 2 + .../src/test/resources/logback.xml | 14 + .../TestAllTemplatesEtoInput/logback.xml | 14 + .../TestAllTemplatesEtoInput/pom.xml | 79 +++ .../generator/logic/api/to/InputEto.java | 25 + .../src/test/resources/utils/pom.xml | 100 ++++ .../crud-openapi-angular-client-app/pom.xml | 19 + .../config/constant/MavenMetadata.java | 12 + .../templates/devon4j/utils/JavaUtil.java | 464 ++++++++++++++++++ .../templates/devon4j/utils/OpenApiUtil.java | 0 .../src/main/resources/template-set.xml | 84 ++++ .../resources}/templates/cobigen.properties | 0 ...oName#lower_case}-alert.component.html.ftl | 0 ...s.etoName#lower_case}-alert.component.scss | 0 ...me#lower_case}-alert.component.spec.ts.ftl | 0 ...etoName#lower_case}-alert.component.ts.ftl | 0 ...Name#lower_case}-dialog.component.html.ftl | 0 ...e#lower_case}-dialog.component.spec.ts.ftl | 0 ...toName#lower_case}-dialog.component.ts.ftl | 0 ...toName#lower_case}-grid.component.html.ftl | 0 ...es.etoName#lower_case}-grid.component.scss | 0 ...ame#lower_case}-grid.component.spec.ts.ftl | 0 ....etoName#lower_case}-grid.component.ts.ftl | 0 ....etoName#lower_case}-routing.module.ts.ftl | 0 ...ariables.etoName#lower_case}.module.ts.ftl | 0 ...es.etoName#lower_case}.service.spec.ts.ftl | 0 ...riables.etoName#lower_case}.service.ts.ftl | 0 .../src/app/app-routing.module.ts.ftl | 0 .../templates/src/app/app.module.ts.ftl | 0 .../src/app/home/home.component.html.ftl | 0 .../layout/nav-bar/nav-bar.component.html.ftl | 0 .../${variables.etoName#lower_case}.ts.ftl | 0 .../templates/src/app/model/model.ts.ftl | 0 .../templates/src/assets/i18n/en.json.ftl | 0 .../templates/src/assets/i18n/es.json.ftl | 0 .../src/environments/environment.prod.ts.ftl | 0 .../src/environments/environment.ts.ftl | 0 .../CrudOpenapiAngularClientAppTest.java | 100 ++++ .../src/test/resources/application.properties | 2 + .../src/test/resources/logback.xml | 14 + .../TestAllTemplatesOpenApiInput/OpenAPI.yaml | 0 .../TestAllTemplatesOpenApiInput/logback.xml | 14 + .../TestAllTemplatesOpenApiInput/pom.xml | 0 .../src/test/resources/utils/pom.xml | 100 ++++ .../pom.xml | 13 + .../config/constant/MavenMetadata.java | 12 + .../src/main/resources/template-set.xml | 48 ++ .../resources}/templates/cobigen.properties | 0 ...t#lower_case}RestController.service.ts.ftl | 0 .../templates/src/app/api/api.ts.ftl | 0 .../src/environments/environment.prod.ts.ftl | 0 .../src/environments/environment.ts.ftl | 11 + ...CrudOpenapiAngularServiceBasedAppTest.java | 100 ++++ .../src/test/resources/application.properties | 2 + .../src/test/resources/logback.xml | 14 + .../TestAllTemplatesOpenApiInput/OpenAPI.yaml | 131 +++++ .../TestAllTemplatesOpenApiInput/logback.xml | 14 + .../TestAllTemplatesOpenApiInput/pom.xml | 84 ++++ .../src/test/resources/utils/pom.xml | 100 ++++ .../crud-openapi-ionic-client-app/pom.xml | 19 + .../config/constant/MavenMetadata.java | 12 + .../templates/devon4j/utils/JavaUtil.java | 464 ++++++++++++++++++ .../src/main/resources/template-set.xml | 96 ++++ .../resources}/templates/cobigen.properties | 0 .../src/app/app-routing.module.ts.ftl | 0 .../templates/src/app/app.component.ts.ftl | 0 .../templates/src/app/app.module.ts.ftl | 0 ...s.etoName#lower_case}-detail.page.html.ftl | 0 ...s.etoName#lower_case}-detail.page.scss.ftl | 0 ...les.etoName#lower_case}-detail.page.ts.ftl | 0 ...les.etoName#lower_case}-list.page.html.ftl | 0 ...les.etoName#lower_case}-list.page.scss.ftl | 0 ...ables.etoName#lower_case}-list.page.ts.ftl | 0 ...es.etoName#lower_case}-rest.service.ts.ftl | 0 ...etoName#lower_case}-search-criteria.ts.ftl | 0 .../${variables.etoName#lower_case}.ts.ftl | 0 .../app/services/interfaces/pageable.ts.ftl | 0 .../interfaces/paginated-list-to.ts.ftl | 0 .../src/app/services/interfaces/sort.ts.ftl | 0 .../shared/business-operator.service.ts.ftl | 0 .../templates/src/assets/i18n/en.json.ftl | 0 .../templates/src/assets/i18n/es.json.ftl | 0 .../templates/src/assets/i18n/it.json.ftl | 0 .../environments/environment.android.ts.ftl | 0 .../src/environments/environment.prod.ts.ftl | 0 .../src/environments/environment.ts.ftl | 0 .../templates/src/theme/variables.scss.ftl | 0 .../CrudOpenapiIonicClientAppTest.java | 100 ++++ .../src/test/resources/application.properties | 2 + .../src/test/resources/logback.xml | 14 + .../TestAllTemplatesOpenApiInput/OpenAPI.yaml | 131 +++++ .../TestAllTemplatesOpenApiInput/logback.xml | 14 + .../TestAllTemplatesOpenApiInput/pom.xml | 84 ++++ .../src/test/resources/utils/pom.xml | 100 ++++ .../crud-openapi-java-server-app/pom.xml | 19 + .../config/constant/MavenMetadata.java | 12 + .../templates/devon4j/constants/Field.java | 48 ++ .../templates/devon4j/utils/DevonfwUtil.java | 449 +++++++++++++++++ .../templates/devon4j/utils/JavaUtil.java | 464 ++++++++++++++++++ .../templates/devon4j/utils/OpenApiUtil.java | 255 ++++++++++ .../src/main/resources}/functions.ftl | 0 .../src/main/resources}/makros.ftl | 0 .../src/main/resources/template-set.xml | 141 ++++++ .../api/${variables.entityName}.java.ftl | 0 .../common/api/cobigen.properties | 0 .../${variables.entityName}Entity.java.ftl | 0 ...${variables.entityName}Repository.java.ftl | 0 .../${variables.component#cap_first}.java.ftl | 0 ...ariables.component#cap_first}Ctos.java.ftl | 0 .../logic/api/cobigen.properties | 0 .../to/${variables.entityName}Cto.java.ftl | 0 .../to/${variables.entityName}Eto.java.ftl | 0 ...ables.entityName}SearchCriteriaTo.java.ftl | 0 .../UcFind${variables.entityName}.java.ftl | 0 ...UcFind${variables.entityName}Ctos.java.ftl | 0 .../UcManage${variables.entityName}.java.ftl | 0 ...Abstract${variables.entityName}Uc.java.ftl | 0 ...ariables.component#cap_first}Impl.java.ftl | 0 ...bles.component#cap_first}ImplCtos.java.ftl | 0 ...UcFind${variables.entityName}Impl.java.ftl | 0 ...nd${variables.entityName}ImplCtos.java.ftl | 0 ...Manage${variables.entityName}Impl.java.ftl | 0 .../service/api/cobigen.properties | 0 ...s.component#cap_first}RestService.java.ftl | 0 ...mponent#cap_first}RestServiceCtos.java.ftl | 0 ...mponent#cap_first}RestServiceImpl.java.ftl | 0 ...ent#cap_first}RestServiceImplCtos.java.ftl | 0 .../common/api/ApplicationEntity.java.ftl | 0 .../api/to/AbstractSearchCriteriaTo.java.ftl | 0 .../general/common/api/to/cobigen.properties | 0 .../base/AbstractBeanMapperSupport.java.ftl | 0 .../api/ApplicationPersistenceEntity.java.ftl | 0 .../base/AbstractComponentFacade.java.ftl | 0 .../general/logic/base/AbstractLogic.java.ftl | 0 .../general/logic/base/AbstractUc.java.ftl | 0 .../impl/config/ServiceConfig.java.ftl | 0 .../WebApplicationContextLocator.java.ftl | 0 ...rudOpenApiJavaServerAppGenerationTest.java | 99 ++++ .../TestAllTemplatesOpenApiInput/OpenAPI.yaml | 131 +++++ .../TestAllTemplatesOpenApiInput/logback.xml | 14 + .../TestAllTemplatesOpenApiInput/pom.xml | 84 ++++ .../src/test/resources/utils/pom.xml | 99 ++++ cobigen-templates/crud-openapi-net/pom.xml | 19 + .../config/constant/MavenMetadata.java | 12 + .../templates/devon4j/constants/Field.java | 48 ++ .../templates/devon4j/utils/DevonfwUtil.java | 449 +++++++++++++++++ .../templates/devon4j/utils/JavaUtil.java | 464 ++++++++++++++++++ .../templates/devon4j/utils/OpenApiUtil.java | 255 ++++++++++ .../src/main/resources/template-set.xml | 74 +++ .../Devon4Net.Application.WebAPI/Startup.cs | 0 .../appsettings.Development.json | 0 ...bles.component#cap_first}Controller.cs.ftl | 0 ...ables.component#cap_first}Converter.cs.ftl | 0 ...me#replace('Dto', '')#cap_first}Dto.cs.ftl | 0 ...ce('Dto', '')#cap_first}ResponseDto.cs.ftl | 0 ...yName#cap_first}NotCreatedException.cs.ftl | 0 ...yName#cap_first}NotDeletedException.cs.ftl | 0 ...ityName#cap_first}NotFoundException.cs.ftl | 0 ...riables.component#cap_first}Service.cs.ftl | 0 ...riables.component#cap_first}Service.cs.ftl | 0 ...les.entityName#cap_first}Repository.cs.ftl | 0 .../Domain/Database/CobigenContext.cs | 0 .../${variables.entityName#cap_first}.cs.ftl | 0 ...les.entityName#cap_first}Repository.cs.ftl | 0 .../CrudOpenApiNetGenerationTest.java | 100 ++++ .../TestAllTemplatesOpenApiInput/OpenAPI.yaml | 131 +++++ .../TestAllTemplatesOpenApiInput/logback.xml | 14 + .../TestAllTemplatesOpenApiInput/pom.xml | 84 ++++ .../src/test/resources/utils/pom.xml | 99 ++++ .../pom.xml | 13 + .../config/constant/MavenMetadata.java | 12 + .../src/main/resources/template-set.xml | 96 ++++ .../resources}/templates/cobigen.properties | 0 ...yName#lower_case}-alert.component.html.ftl | 0 ...ntityName#lower_case}-alert.component.scss | 0 ...me#lower_case}-alert.component.spec.ts.ftl | 0 ...ityName#lower_case}-alert.component.ts.ftl | 0 ...Name#lower_case}-dialog.component.html.ftl | 0 ...e#lower_case}-dialog.component.spec.ts.ftl | 0 ...tyName#lower_case}-dialog.component.ts.ftl | 0 ...tyName#lower_case}-grid.component.html.ftl | 0 ...entityName#lower_case}-grid.component.scss | 0 ...ame#lower_case}-grid.component.spec.ts.ftl | 0 ...tityName#lower_case}-grid.component.ts.ftl | 0 ...ables.entityName#lower_case}.module.ts.ftl | 0 ...entityName#lower_case}.service.spec.ts.ftl | 0 ...bles.entityName#lower_case}.service.ts.ftl | 0 .../src/app/app-routing.module.ts.ftl | 0 .../templates/src/app/app.module.ts.ftl | 0 .../src/app/core/interfaces/sort.ts.ftl | 0 .../app/core/security/login.service.ts.ftl | 0 .../shared/business-operations.service.ts.ftl | 0 .../src/app/home/home.component.html.ftl | 0 .../${variables.entityName#lower_case}.ts.ftl | 0 .../templates/src/app/model/model.ts.ftl | 0 .../templates/src/assets/i18n/en.json.ftl | 0 .../templates/src/assets/i18n/es.json.ftl | 0 .../src/environments/environment.prod.ts.ftl | 0 .../src/environments/environment.ts.ftl | 0 .../src/main/resources}/variables.ftl | 0 .../CrudTypescriptAngularClientAppTest.java | 100 ++++ .../src/test/resources/application.properties | 2 + .../src/test/resources/logback.xml | 14 + .../baseFile.entity.ts | 22 + .../TestAllTemplatesEntityInput/logback.xml | 14 + .../TestAllTemplatesEntityInput/pom.xml | 58 +++ .../generator/dataaccess/api/InputEntity.java | 25 + .../src/test/resources/utils/pom.xml | 100 ++++ cobigen-templates/kafka-documentation/pom.xml | 24 + .../documentation/JavaDocumentationUtil.java | 0 .../src/main/resources/template-set.xml | 43 ++ .../docs/${variables.component}To.adoc.ftl | 0 .../templates/docs/Documentation.adoc.ftl | 0 cobigen-templates/named-queries/pom.xml | 13 + .../src/main/resources}/NamedQueries.java.ftl | 0 .../src/main/resources/template-set.xml | 33 ++ .../openapi-documentation/pom.xml | 13 + .../documentation/DocumentationUtil.java | 0 .../OpenApiDocumentationUtil.java | 0 .../src/main/resources}/functions.ftl | 0 .../src/main/resources/template-set.xml | 42 ++ .../docs/${variables.component}Doc.adoc.ftl | 0 .../templates/docs/Documentation.adoc.ftl | 0 cobigen-templates/pom.xml | 128 ++++- cobigen-templates/pom_patch.xml | 4 + cobigen-templates/rest-documentation/pom.xml | 24 + .../documentation/JavaDocumentationUtil.java | 346 +++++++++++++ .../src/main/resources/template-set.xml | 40 ++ ...ariables.component}RESTInterfaces.adoc.ftl | 0 .../templates/docs/Documentation.adoc.ftl | 0 .../security-permissions/pom.xml | 13 + .../resources}/PermissionConstants.java.ftl | 0 .../src/main/resources/template-set.xml | 34 ++ .../logback.xml | 0 .../templates-devon4j-tests/pom.xml | 57 +++ .../config/constant/MavenMetadata.java | 12 + .../src/main/resources/META-INF/LICENSE.txt | 0 .../main/templates/named_queries/context.xml | 9 +- .../security_permissions/context.xml | 9 +- .../templates/TemplatesGenerationTest.java | 181 +++++++ .../src/test/resources/application.properties | 2 + .../src/test/resources/logback.xml | 14 + .../TestAllTemplatesEntityInput/logback.xml | 14 + .../TestAllTemplatesEntityInput/pom.xml | 68 +++ .../generator/dataaccess/api/InputEntity.java | 25 + .../TestAllTemplatesEtoInput/logback.xml | 14 + .../TestAllTemplatesEtoInput/pom.xml | 79 +++ .../generator/logic/api/to/InputEto.java | 25 + .../TestAllTemplatesOpenApiInput/OpenAPI.yaml | 131 +++++ .../TestAllTemplatesOpenApiInput/logback.xml | 14 + .../TestAllTemplatesOpenApiInput/pom.xml | 84 ++++ .../logback.xml | 0 .../TestAllTemplatesRestServiceInput/pom.xml | 2 +- .../rest/InputNoAnnotationsRestService.java | 0 .../JavaxAnnotationsInputRestService.java | 0 .../SpringAnnotationsInputRestService.java | 0 .../TestAllTemplatesToInput}/logback.xml | 0 .../TestAllTemplatesToInput/pom.xml | 0 .../api/rest/InputNoAnnotationsTo.java | 0 .../generator/service/api/rest/InputTo.java | 0 .../TestAllTemplatesXMLInput/logback.xml | 14 + .../TestAllTemplatesXMLInput/pom.xml | 73 +++ .../generator/dataaccess/api/Input.xml} | 0 .../test/resources/testinput/InputEntity.java | 0 .../src/test/resources/testinput/XMI-UML.xml | 391 +++++++++++++++ .../src/test/resources/utils/pom.xml | 100 ++++ .../pom.xml | 36 +- .../pom_patch.xml | 3 +- .../config/constant/MavenMetadata.java | 12 + .../templates/devon4j/constants/Field.java | 48 ++ .../templates/devon4j/utils/DevonfwUtil.java | 10 +- .../templates/devon4j/utils/IDGenerator.java | 0 .../templates/devon4j/utils/JavaUtil.java | 464 ++++++++++++++++++ .../templates/devon4j/utils/OpenApiUtil.java | 255 ++++++++++ .../documentation/DocumentationUtil.java | 32 ++ .../documentation/JavaDocumentationUtil.java | 346 +++++++++++++ .../OpenApiDocumentationUtil.java | 74 +++ .../devon4j/utils/uml/Connector.java | 104 ++++ .../templates/devon4j/utils/uml/UmlUtil.java | 0 .../src/main/resources/META-INF/LICENSE.txt | 201 ++++++++ .../devon4j/test/utils/DevonfwUtilTest.java | 0 .../devon4j/test/utils/JavaUtilTest.java | 319 ++++++++++++ .../documentation/DocumentationUtilTest.java | 0 .../JavaDocumentationUtilTest.java | 0 .../OpenApiDocumentationUtilTest.java | 0 .../test/utils/resources/TestClass.java | 0 .../test/utils/resources/TestEntity.java | 0 .../test/utils/resources/TestTwoClass.java | 0 .../resources/dataaccess/api/DeepEntity.java | 0 .../dataaccess/api/TestEntityComponent.java | 0 .../utils/resources/uml/completeUmlXmi.xml | 0 .../devon4j/test/utils/uml/UmlUtilTest.java | 3 +- .../src/test/resources/application.properties | 2 + .../src/test/resources/logback.xml | 14 + .../TestAllTemplatesEntityInput/logback.xml | 14 + .../TestAllTemplatesEntityInput/pom.xml | 68 +++ .../generator/dataaccess/api/InputEntity.java | 25 + .../TestAllTemplatesEtoInput/logback.xml | 14 + .../TestAllTemplatesEtoInput/pom.xml | 79 +++ .../generator/logic/api/to/InputEto.java | 25 + .../TestAllTemplatesOpenApiInput/OpenAPI.yaml | 131 +++++ .../TestAllTemplatesOpenApiInput/logback.xml | 14 + .../TestAllTemplatesOpenApiInput/pom.xml | 84 ++++ .../logback.xml | 14 + .../TestAllTemplatesRestServiceInput/pom.xml | 88 ++++ .../rest/InputNoAnnotationsRestService.java | 11 + .../JavaxAnnotationsInputRestService.java | 46 ++ .../SpringAnnotationsInputRestService.java | 38 ++ .../TestAllTemplatesToInput/logback.xml | 14 + .../TestAllTemplatesToInput/pom.xml | 82 ++++ .../api/rest/InputNoAnnotationsTo.java | 46 ++ .../generator/service/api/rest/InputTo.java | 59 +++ .../TestAllTemplatesXMLInput/logback.xml | 14 + .../TestAllTemplatesXMLInput/pom.xml | 73 +++ .../generator/dataaccess/api/Input.xml | 391 +++++++++++++++ .../test/resources/testinput/InputEntity.java | 38 ++ .../src/test/resources/testinput/XMI-UML.xml | 391 +++++++++++++++ .../templates-devon4j/.classpath | 67 --- .../crud_angular_client_app/context.xml | 19 - .../crud_angular_client_app/templates.xml | 52 -- .../crud_ionic_client_app/context.xml | 16 - .../crud_ionic_client_app/templates.xml | 72 --- .../templates/crud_java_ea_uml/context.xml | 16 - .../templates/crud_java_ea_uml/templates.xml | 21 - .../crud_java_server_app/context.xml | 16 - .../crud_java_server_app/templates.xml | 79 --- .../crud_java_server_app_complex/context.xml | 17 - .../templates.xml | 59 --- .../crud_ngrx_client_app/context.xml | 15 - .../crud_ngrx_client_app/templates.xml | 89 ---- .../context.xml | 15 - .../templates.xml | 65 --- .../templates.xml | 30 -- .../crud_openapi_ionic_client_app/context.xml | 13 - .../templates.xml | 74 --- .../crud_openapi_java_server_app/context.xml | 16 - .../templates.xml | 113 ----- .../templates/crud_openapi_net/context.xml | 14 - .../templates/crud_openapi_net/templates.xml | 49 -- .../context.xml | 13 - .../templates.xml | 73 --- .../templates/kafka_documentation/context.xml | 14 - .../templates/named_queries/templates.xml | 11 - .../openapi_documentation/context.xml | 14 - .../openapi_documentation/templates.xml | 18 - .../templates/rest_documentation/context.xml | 16 - .../rest_documentation/templates.xml | 18 - .../security_permissions/templates.xml | 11 - .../templates/testdata_builder/context.xml | 24 - .../templates/TemplatesGenerationTest.java | 90 ---- .../devon4j/test/utils/JavaUtilTest.java | 299 ----------- cobigen-templates/testdata-builder/pom.xml | 19 + .../config/constant/MavenMetadata.java | 12 + .../templates/devon4j/utils/JavaUtil.java | 464 ++++++++++++++++++ .../main/resources}/ObjectBuilder.java.ftl | 0 .../ObjectBuilder_customFunctions.java.ftl | 0 ...ObjectBuilder_fillMandatoryFields.java.ftl | 0 .../ObjectBuilder_persistable.java.ftl | 0 .../src/main/resources}/makros.ftl | 0 .../src/main/resources/template-set.xml | 65 +++ .../TestDataBuilderGenerationTest.java | 100 ++++ .../TestAllTemplatesEntityInput/logback.xml | 14 + .../TestAllTemplatesEntityInput/pom.xml | 53 ++ .../generator/dataaccess/api/InputEntity.java | 25 + .../src/test/resources/utils/pom.xml | 99 ++++ cobigen/cobigen-core-api/pom.xml | 40 +- .../devonfw/cobigen/api/TemplateAdapter.java | 98 ++++ .../api/constants/ConfigurationConstants.java | 80 ++- .../api/constants/TemplatesJarConstants.java | 6 + ...catedMonolithicConfigurationException.java | 65 +++ .../exception/NotYetSupportedException.java | 3 - ...TemplateSelectionForAdaptionException.java | 36 ++ .../exception/UnknownExpressionException.java | 3 - ...UpgradeTemplatesNotificationException.java | 22 + .../com/devonfw/cobigen/api/to/MatcherTo.java | 4 - .../cobigen/api/util/CobiGenPaths.java | 149 +++++- .../cobigen/api/util/ExceptionUtil.java | 3 - .../cobigen/api/util/MavenCoordinate.java | 89 ++++ .../devonfw/cobigen/api/util/MavenUtil.java | 21 + .../devonfw/cobigen/api/util/StringUtil.java | 1 - .../cobigen/api/util/TemplatesJarUtil.java | 233 ++++++--- cobigen/cobigen-core-systemtest/pom.xml | 102 +++- .../cobigen/systemtest/ClassLoadingIT.java | 86 +++- .../systemtest/ContainerMatcherIT.java | 17 +- .../systemtest/DownloadTemplateSetsIT.java | 91 ++++ .../cobigen/systemtest/GenerationIT.java | 88 +++- .../systemtest/TemplateProcessingTest.java | 145 ++++++ .../cobigen/systemtest/TemplateScanIT.java | 50 +- .../systemtest/TemplatesInstallationTest.java | 130 +++++ .../systemtest/TransactionalGenerationIT.java | 6 +- .../systemtest/TriggerActivationIT.java | 18 +- .../io/generator/logic/api/to/InputEto.java | 29 ++ .../io/generator/logic/api/to/test.yaml | 131 +++++ .../templates-devon4j-0.0.1-sources.jar | Bin 0 -> 6153 bytes .../templates/templates-devon4j-0.0.1.jar | Bin 0 -> 1109 bytes .../adapted/template-set1/pom.xml | 12 + .../src/main/resources/template-set.xml | 32 ++ .../resources/templates/generated.txt.ftl | 2 + .../adapted/template-set2/pom.xml | 12 + .../src/main/resources/template-set.xml | 32 ++ .../resources/templates/generated.txt.ftl | 2 + .../expected-conflicted/generated.txt | 2 + .../expected/generated.txt | 4 + .../adapted/template-set1/pom.xml | 12 + .../src/main/java/JarredClass.java | 12 + .../src/main/resources/template-set.xml | 32 ++ .../resources/templates/generated.txt.ftl | 4 + .../ClassLoadTest/templates/context.xml | 5 +- .../accumulationType/context.xml | 5 +- .../selectiveContainerGeneration/context.xml | 5 +- .../templates/context.xml | 35 +- .../context.xml | 5 +- .../externalIncrementsGeneration/context.xml | 5 +- .../overrideMergeStrategy/context.xml | 9 +- .../testTemplates2/generated.txt.ftl | 1 + .../testTemplates2/templates.xml | 11 + .../variableAvailability/context.xml | 7 +- .../adapted/template-test/template-set.xml | 29 ++ .../template-test/templates/generated.txt.ftl | 1 + .../adapted/template-test/pom.xml | 12 + .../adapted/template-test/template-set.xml | 29 ++ .../template-test/templates/generated.txt.ftl | 1 + .../downloaded/template-test.jar | Bin 0 -> 4282 bytes .../src/main/resources/template-set.xml | 29 ++ .../resources/templates/generated.txt.ftl | 1 + .../src/main/resources/template-set.xml | 33 ++ .../resources/templates/generated.txt.ftl | 1 + .../src/main/resources/ObjectBuilder.java.ftl | 50 ++ .../src/main/resources/template-set.xml | 39 ++ .../downloaded/downloaded1-test/pom.xml | 27 + .../src/main/resources/template-set.xml | 29 ++ .../resources/templates/generated.txt.ftl | 1 + .../downloaded/downloaded2-test/pom.xml | 27 + .../src/main/resources/template-set.xml | 29 ++ .../resources/templates/generated.txt.ftl | 1 + .../crud-java-server-app-complex/pom.xml | 83 ++++ .../src/main/java/com/test.java | 0 .../src/main/resources/functions.ftl | 0 .../src/main/resources/template-set.xml | 40 ++ .../to/${variables.entityName}Eto.java.ftl | 1 + .../adapted/crud-java-server-app/pom.xml | 83 ++++ .../src/main/java/com/test.java | 0 .../src/main/resources/functions.ftl | 0 .../src/main/resources/template-set.xml | 40 ++ .../to/${variables.entityName}Eto.java.ftl | 1 + .../src/main/resources/template-set.xml | 33 ++ .../resources/templates/generated.txt.ftl | 1 + .../systemtest/TemplateScanTest/context.xml | 5 +- .../systemtest/TemplateScanTest/valid.zip | Bin 2712 -> 2730 bytes .../templates/context.xml | 5 +- .../templates/context.xml | 5 +- cobigen/cobigen-core-test/pom.xml | 2 +- cobigen/cobigen-core/pom.xml | 138 ++++-- .../devonfw/cobigen/impl/CobiGenFactory.java | 86 +++- .../impl/adapter/TemplateAdapterImpl.java | 435 ++++++++++++++++ .../devonfw/cobigen/impl/aop/BeanFactory.java | 3 +- .../cobigen/impl/aop/ProxyFactory.java | 4 +- .../impl/config/ConfigurationHolder.java | 148 +++++- .../impl/config/ConfigurationProperties.java | 122 +++++ .../impl/config/ContextConfiguration.java | 85 +++- .../impl/config/TemplateSetConfiguration.java | 266 ++++++++++ .../impl/config/TemplatesConfiguration.java | 20 + .../constant/ContextConfigurationVersion.java | 12 +- .../TemplateSetConfigurationVersion.java | 78 +++ .../TemplatesConfigurationVersion.java | 15 +- .../impl/config/constant/WikiConstants.java | 5 + .../impl/config/entity/AbstractMatcher.java | 2 - .../impl/config/entity/ContainerMatcher.java | 4 - .../cobigen/impl/config/entity/Trigger.java | 6 +- .../config/entity/VariableAssignment.java | 7 - .../cobigen/impl/config/entity/Variables.java | 15 +- .../reader/ContextConfigurationReader.java | 230 +++++---- .../TemplateSetConfigurationManager.java | 119 +++++ .../TemplateSetConfigurationReader.java | 274 +++++++++++ .../reader/TemplatesConfigurationReader.java | 21 +- .../resolver/PathExpressionResolver.java | 1 - .../AbstractConfigurationUpgrader.java | 226 ++++++--- .../upgrade/ConfigurationUpgradeResult.java | 42 +- .../upgrade/ContextConfigurationUpgrader.java | 49 +- .../TemplateConfigurationUpgrader.java | 46 +- .../config/upgrade/TemplateSetUpgrader.java | 315 ++++++++++++ .../config/versioning/VersionValidator.java | 28 +- .../UnknownContextVariableException.java | 4 +- .../exceptions/UnknownTemplateException.java | 2 - .../ConfigurationInterpreterImpl.java | 11 + .../generator/GenerationProcessorImpl.java | 61 ++- .../impl/generator/MatcherEvaluatorImpl.java | 2 +- .../impl/healthcheck/HealthCheckImpl.java | 1 - .../impl/model/ContextVariableResolver.java | 1 - .../util/ConfigurationClassLoaderUtil.java | 37 +- .../impl/util/ConfigurationFinder.java | 193 +++++--- .../impl/util/ExtractTemplatesUtil.java | 193 -------- .../cobigen/impl/util/FileSystemUtil.java | 3 +- .../impl/util/MavenCoordinateUtil.java | 46 ++ .../cobigen/impl/util/PostponeUtil.java | 160 ++++++ .../schema/v2.2/contextConfiguration.xsd | 55 --- .../schema/v3.0/contextConfiguration.xsd | 77 +++ .../schema/v5.0/templatesConfiguration.xsd | 82 ++++ .../schema/v6.0/contextConfiguration.xsd | 77 +++ .../schema/v6.0/templateSetConfiguration.xsd | 23 + .../schema/v6.0/templatesConfiguration.xsd | 82 ++++ .../cobigen/unittest/CobiGenFactoryTest.java | 67 +++ .../unittest/adapter/TemplateAdapterTest.java | 156 ++++++ .../config/ConfigurationFinderTest.java | 338 +++++++++++++ .../ContextConfigurationReaderTest.java | 60 +-- .../TemplateSetConfigurationReaderTest.java | 172 +++++++ .../TemplatesConfigurationReaderTest.java | 6 +- .../resolver/PathExpressionResolverTest.java | 6 +- .../ContextConfigurationUpgraderTest.java | 191 ++++++- .../TemplateConfigurationUpgraderTest.java | 104 +++- .../upgrade/TemplateSetUpgraderTest.java | 226 +++++++++ .../unittest/healthcheck/HealthCheckTest.java | 3 +- .../templates/TemplateJarDownloaderTest.java | 189 ++++++- .../unittest/util/ConfigurationUtilTest.java | 49 +- .../unittest/util/PostponeUtilTest.java | 66 +++ .../versioning/VersionValidatorTest.java | 16 +- .../unittest/ExternalProcess/DummyExe | Bin 142 -> 0 bytes .../unittest/ExternalProcess/DummyExe.exe | Bin 122368 -> 0 bytes .../emptyConfigProperties/config.properties | 2 + .../invalidConfigProperties/config.properties | 2 + .../validConfigProperties/config.properties | 4 + .../faulty/context.xml | 6 +- .../main/templates/test_template/context.xml | 8 - .../ContextConfigurationReaderTest/valid.zip | Bin 380 -> 404 bytes .../src/main/templates => valid}/context.xml | 7 +- .../main/templates/test_template/context.xml | 8 - .../main/templates/test_template2/context.xml | 8 - .../src/main/templates/context.xml | 7 +- .../faulty/template-set.xml | 12 + .../src/main/resources/template-set.xml | 31 ++ .../resources/templates/bar/BarClass.java.ftl | 4 + .../templates/bar/Foo2Class.java.ftl | 4 + .../resources/templates/bar/FooClass.java.ftl | 4 + .../templates/foo/Foo2Class.java.ftl | 4 + .../resources/templates/foo/FooClass.java.ftl | 4 + .../templates/foo/bar/BarClass.java.ftl | 4 + .../src/main/resources/template-set.xml | 31 ++ .../resources/templates/bar/BarClass.java.ftl | 4 + .../templates/bar/Foo2Class.java.ftl | 4 + .../resources/templates/bar/FooClass.java.ftl | 4 + .../templates/foo/Foo2Class.java.ftl | 4 + .../resources/templates/foo/FooClass.java.ftl | 4 + .../templates/foo/bar/BarClass.java.ftl | 4 + .../downloaded/crud-java-server-app/pom.xml | 27 + .../src/main/resources/template-set.xml | 40 ++ .../to/${variables.entityName}Eto.java.ftl | 1 + .../src/environments/environment.ts.ftl | 11 + .../src/main/resources/template-set.xml | 33 ++ .../src/environments/environment2.ts.ftl | 11 + .../src/main/resources/template-set.xml | 33 ++ .../downloaded/crud-java-server-app/pom.xml | 27 + .../src/main/resources/template-set.xml | 40 ++ .../to/${variables.entityName}Eto.java.ftl | 1 + .../adapted/template-set1/template-set.xml | 28 ++ .../src/environments/environment.ts.ftl | 11 + .../adapted/template-set2/template-set.xml | 33 ++ .../src/environments/environment.ts.ftl | 11 + .../context.xml | 7 +- .../valid-v2.2/context.xml | 22 - .../valid-v3.0/templateSet1/context.xml | 15 + .../valid-v3.0/templateSet2/context.xml | 15 + .../templates/CobiGen_Templates/pom.xml | 113 +++++ .../templates/devon4j/utils/JavaUtil.java | 464 ++++++++++++++++++ .../src/main/templates/context.xml | 16 + .../templateSet1/ObjectBuilder.java.ftl | 51 ++ .../ObjectBuilder_customFunctions.java.ftl | 22 + ...ObjectBuilder_fillMandatoryFields.java.ftl | 22 + .../ObjectBuilder_persistable.java.ftl | 45 ++ .../main/templates/templateSet1/makros.ftl | 53 ++ .../templates/templateSet1}/templates.xml | 0 .../templateSet2/ObjectBuilder.java.ftl | 51 ++ .../ObjectBuilder_customFunctions.java.ftl | 22 + ...ObjectBuilder_fillMandatoryFields.java.ftl | 22 + .../ObjectBuilder_persistable.java.ftl | 45 ++ .../main/templates/templateSet2/makros.ftl | 53 ++ .../main/templates/templateSet2/templates.xml | 22 + .../templates/CobiGen_Templates/pom.xml | 113 +++++ .../templates/devon4j/utils/JavaUtil.java | 464 ++++++++++++++++++ .../src/main/templates/context.xml | 16 + .../templateSet1/ObjectBuilder.java.ftl | 51 ++ .../ObjectBuilder_customFunctions.java.ftl | 22 + ...ObjectBuilder_fillMandatoryFields.java.ftl | 22 + .../ObjectBuilder_persistable.java.ftl | 45 ++ .../main/templates/templateSet1/makros.ftl | 53 ++ .../main/templates/templateSet1/templates.xml | 22 + .../templateSet2/ObjectBuilder.java.ftl | 51 ++ .../ObjectBuilder_customFunctions.java.ftl | 22 + ...ObjectBuilder_fillMandatoryFields.java.ftl | 22 + .../ObjectBuilder_persistable.java.ftl | 45 ++ .../main/templates/templateSet2/makros.ftl | 53 ++ .../main/templates/templateSet2/templates.xml | 22 + .../valid-v2.1/templates.xml | 24 +- .../valid-v4.0/templates.xml | 24 + .../valid-v5.0/templates.xml | 25 + cobigen/core-artifact-retriever/pom.xml | 81 +++ .../cobigen/retriever/ArtifactRetriever.java | 171 +++++++ .../MavenSearchArtifactRetriever.java | 41 ++ .../MavenSearchRepositoryConstants.java | 113 +++++ .../constants/MavenSearchRepositoryType.java | 28 ++ .../RestSearchResponseException.java | 56 +++ .../to/model/AbstractSearchResponse.java | 285 +++++++++++ .../to/model/SearchResponseFactory.java | 111 +++++ .../to/model/ServerCredentials.java | 116 +++++ .../to/model/jfrog/JfrogSearchResponse.java | 89 ++++ .../jfrog/JfrogSearchResponseResult.java | 24 + .../to/model/maven/MavenSearchResponse.java | 99 ++++ .../model/maven/MavenSearchResponseDoc.java | 93 ++++ .../maven/MavenSearchResponseResponse.java | 43 ++ .../to/model/nexus2/Nexus2SearchResponse.java | 99 ++++ .../Nexus2SearchResponseArtifactHits.java | 18 + .../Nexus2SearchResponseArtifactLinks.java | 33 ++ .../nexus2/Nexus2SearchResponseData.java | 54 ++ .../to/model/nexus3/Nexus3SearchResponse.java | 84 ++++ .../nexus3/Nexus3SearchResponseAsset.java | 16 + .../nexus3/Nexus3SearchResponseItem.java | 18 + .../retriever/settings/MavenMirror.java | 174 +++++++ .../retriever/settings/MavenProxy.java | 71 +++ .../retriever/settings/MavenSettings.java | 196 ++++++++ .../model/MavenSettingsActivationModel.java | 30 ++ .../MavenSettingsActiveProfilesModel.java | 35 ++ .../to/model/MavenSettingsMirrorModel.java | 90 ++++ .../to/model/MavenSettingsMirrorsModel.java | 32 ++ .../settings/to/model/MavenSettingsModel.java | 112 +++++ .../to/model/MavenSettingsProfileModel.java | 69 +++ .../to/model/MavenSettingsProfilesModel.java | 32 ++ .../to/model/MavenSettingsProxiesModel.java | 32 ++ .../to/model/MavenSettingsProxyModel.java | 130 +++++ .../model/MavenSettingsRepositoriesModel.java | 36 ++ .../model/MavenSettingsRepositoryModel.java | 89 ++++ .../to/model/MavenSettingsServerModel.java | 70 +++ .../to/model/MavenSettingsServersModel.java | 32 ++ .../retriever/ArtifactRetrieverTest.java | 116 +++++ .../cobigen/retriever/MavenMirrorTest.java | 201 ++++++++ .../cobigen/retriever/MavenProxyTest.java | 120 +++++ .../cobigen/retriever/MavenSettingsTest.java | 221 +++++++++ .../MavenSearchArtifactRetrieverTest.java | 156 ++++++ .../unittest/MavenSearchResponseTest.java | 120 +++++ .../unittest/SearchResponseFactoryTest.java | 245 +++++++++ .../unittest/SearchResponseTest.java | 81 +++ .../src/test/resources/logback-test.xml | 17 + .../ArtifactRetrieverTest/jfrogJsonTest.json | 7 + .../settingsNonProxy.xml | 27 + .../ArtifactRetrieverTest/settingsProxy.xml | 40 ++ .../unittest/MavenMirrorTest/settings.xml | 68 +++ .../unittest/MavenProxyTest/settings.xml | 59 +++ .../jfrogJsonTest.json | 11 + .../mavenJsonTest.json | 138 ++++++ .../nexus2JsonTest.json | 139 ++++++ .../nexus3JsonTest.json | 42 ++ .../jfrogJsonTest.json | 7 + .../mavenJsonTest.json | 37 ++ .../nexus2JsonTest.json | 42 ++ .../nexus3JsonTest.json | 22 + .../MavenSearchTest/jfrogJsonTest.json | 11 + .../MavenSearchTest/mavenJsonTest.json | 138 ++++++ .../MavenSearchTest/nexus2JsonTest.json | 139 ++++++ .../MavenSearchTest/nexus3JsonTest.json | 42 ++ .../MavenSettingsTest/settings-security.xml | 4 + .../unittest/MavenSettingsTest/settings.xml | 95 ++++ .../mavenJsonTest.json | 37 ++ cobigen/core-externalprocess-api/pom.xml | 5 +- cobigen/pom.xml | 4 +- deploy.sh | 58 ++- documentation/DoD.asciidoc | 2 +- .../cobigen-core_configuration.asciidoc | 225 ++++++++- .../cobigen-intellij-installation.asciidoc | 12 +- .../guide_dev_troubleshooting.asciidoc | 4 +- .../images/howtos/e2e_gen/image14.png | Bin 53153 -> 42217 bytes .../images/howtos/e2e_gen/image20.png | Bin 74047 -> 80553 bytes .../images/howtos/e2e_gen/image22.png | Bin 87193 -> 34749 bytes .../images/howtos/e2e_gen/image23.png | Bin 111018 -> 39242 bytes .../images/howtos/e2e_gen/image37.png | Bin 75368 -> 66921 bytes .../images/howtos/e2e_gen/image39.png | Bin 274895 -> 274895 bytes documentation/mgmt_ide-setup.asciidoc | 2 +- functions.sh | 211 +++++--- pom.xml | 54 +- sonar-report/pom.xml | 4 - 1023 files changed, 36976 insertions(+), 3713 deletions(-) rename .mvn/{settings.xml => ci-settings.xml} (88%) create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/pom.xml create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/src/main/java/com/test.java create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/src/main/resources/functions.ftl create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/src/main/resources/template-set.xml create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/pom.xml create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/src/main/java/com/test.java create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/src/main/resources/functions.ftl create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/src/main/resources/template-set.xml create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/pom.xml create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/src/main/java/utils/MathUtils.java create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/src/main/resources/template-set.xml create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/downloaded/crud-java-server-app/pom.xml create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/downloaded/crud-java-server-app/src/main/resources/template-set.xml create mode 100644 cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/downloaded/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl delete mode 100644 cobigen-eclipse/cobigen-eclipse-feature/.project delete mode 100644 cobigen-eclipse/cobigen-eclipse-test/.project create mode 100644 cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/UpgradeMonolithicTemplatesTest.java rename cobigen-eclipse/cobigen-eclipse-test/src/main/resources/GenerateFromTextInputTest/templates/src/main/templates/{template1 => }/context.xml (80%) create mode 100644 cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/input/test.yml rename {cobigen-templates/templates-devon4j => cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates}/.project (93%) create mode 100644 cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/pom.xml rename {cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app => cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/src/main/templates}/context.xml (84%) rename {cobigen-templates/templates-devon4j/src/main/templates/kafka_documentation => cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/src/main/templates/crud_openapi_angular_service_based_app}/templates.xml (56%) rename {cobigen-templates/templates-devon4j => cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates}/src/main/templates/crud_openapi_angular_service_based_app/templates/src/environments/environment.ts.ftl (100%) create mode 100644 cobigen-eclipse/cobigen-eclipse-test/targlets/2018-12.target delete mode 100644 cobigen-eclipse/cobigen-eclipse-updatesite/.project delete mode 100644 cobigen-eclipse/cobigen-eclipse/.project create mode 100644 cobigen-templates/crud-angular-client-app/pom.xml rename cobigen-templates/{templates-devon4j => crud-angular-client-app}/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java (100%) rename cobigen-templates/{templates-devon4j => crud-angular-client-app}/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java (100%) create mode 100644 cobigen-templates/crud-angular-client-app/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/cobigen.properties (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.scss (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.scss (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-routing.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/app-routing.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/app.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/app/layout/nav-bar/nav-bar.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/assets/i18n/en.json.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_angular_client_app => crud-angular-client-app/src/main/resources}/templates/src/assets/i18n/es.json.ftl (100%) create mode 100644 cobigen-templates/crud-angular-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudAngularClientAppGenerationTest.java rename cobigen-templates/{templates-devon4j/src/test/resources => crud-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput}/logback.xml (100%) rename cobigen-templates/{templates-devon4j => crud-angular-client-app}/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/pom.xml (100%) rename cobigen-templates/{templates-devon4j => crud-angular-client-app}/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/src/main/java/io/github/devonfw/cobigen/generator/logic/api/to/InputEto.java (100%) create mode 100644 cobigen-templates/crud-angular-client-app/src/test/resources/utils/pom.xml create mode 100644 cobigen-templates/crud-ionic-client-app/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudIonicClientAppTest.java create mode 100644 cobigen-templates/crud-ionic-client-app/pom.xml create mode 100644 cobigen-templates/crud-ionic-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java create mode 100644 cobigen-templates/crud-ionic-client-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java create mode 100644 cobigen-templates/crud-ionic-client-app/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/cobigen.properties (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/app-routing.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/app.component.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/app.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.scss.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.scss.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/services/${variables.etoName#lower_case}-rest.service.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/services/interfaces/${variables.etoName#lower_case}-search-criteria.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/services/interfaces/${variables.etoName#lower_case}.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/services/interfaces/pageable.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/services/interfaces/paginated-list-to.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/services/interfaces/sort.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/app/services/shared/business-operator.service.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/assets/i18n/en.json.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/assets/i18n/es.json.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/environments/environment.android.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/environments/environment.prod.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/environments/environment.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ionic_client_app => crud-ionic-client-app/src/main/resources}/templates/src/theme/variables.scss.ftl (100%) create mode 100644 cobigen-templates/crud-ionic-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudIonicClientAppTest.java rename cobigen-templates/{templates-devon4j => crud-ionic-client-app}/src/test/resources/application.properties (100%) rename cobigen-templates/{templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput => crud-ionic-client-app/src/test/resources}/logback.xml (100%) rename cobigen-templates/{templates-devon4j => crud-ionic-client-app}/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/logback.xml (100%) create mode 100644 cobigen-templates/crud-ionic-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/pom.xml create mode 100644 cobigen-templates/crud-ionic-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/src/main/java/io/github/devonfw/cobigen/generator/logic/api/to/InputEto.java create mode 100644 cobigen-templates/crud-ionic-client-app/src/test/resources/utils/pom.xml create mode 100644 cobigen-templates/crud-java-ea-uml/pom.xml create mode 100644 cobigen-templates/crud-java-ea-uml/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java rename cobigen-templates/{templates-devon4j => crud-java-ea-uml}/src/main/java/com/devonfw/cobigen/templates/devon4j/constants/Field.java (100%) create mode 100644 cobigen-templates/crud-java-ea-uml/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/DevonfwUtil.java create mode 100644 cobigen-templates/crud-java-ea-uml/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java rename cobigen-templates/{templates-devon4j => crud-java-ea-uml}/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/uml/Connector.java (100%) create mode 100644 cobigen-templates/crud-java-ea-uml/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/uml/UmlUtil.java rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_ea_uml => crud-java-ea-uml/src/main/resources}/functions.ftl (100%) create mode 100644 cobigen-templates/crud-java-ea-uml/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_ea_uml => crud-java-ea-uml/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/common/api/${variables.className}.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_ea_uml => crud-java-ea-uml/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/dataaccess/api/${variables.className}Entity.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_ea_uml => crud-java-ea-uml/src/main/resources}/templates/java/${variables.rootPackage}/general/common/api/ApplicationEntity.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_ea_uml => crud-java-ea-uml/src/main/resources}/templates/java/${variables.rootPackage}/general/dataaccess/api/ApplicationPersistenceEntity.java.ftl (100%) create mode 100644 cobigen-templates/crud-java-ea-uml/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudJavaEaUmlTest.java create mode 100644 cobigen-templates/crud-java-ea-uml/src/test/resources/application.properties rename cobigen-templates/{templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput => crud-java-ea-uml/src/test/resources}/logback.xml (100%) rename cobigen-templates/{templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput => crud-java-ea-uml/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput}/logback.xml (100%) rename cobigen-templates/{templates-devon4j => crud-java-ea-uml}/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/pom.xml (100%) rename cobigen-templates/{templates-devon4j => crud-java-ea-uml}/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/src/main/xml/io/github/devonfw/cobigen/generator/dataaccess/api/Input.xml (100%) create mode 100644 cobigen-templates/crud-java-ea-uml/src/test/resources/utils/pom.xml create mode 100644 cobigen-templates/crud-java-server-app-complex/pom.xml create mode 100644 cobigen-templates/crud-java-server-app-complex/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java create mode 100644 cobigen-templates/crud-java-server-app-complex/src/main/java/com/devonfw/cobigen/templates/devon4j/constants/Field.java create mode 100644 cobigen-templates/crud-java-server-app-complex/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/DevonfwUtil.java create mode 100644 cobigen-templates/crud-java-server-app-complex/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex => crud-java-server-app-complex/src/main/resources}/functions.ftl (100%) create mode 100644 cobigen-templates/crud-java-server-app-complex/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex => crud-java-server-app-complex/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/logic/api/${variables.component#cap_first}.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex => crud-java-server-app-complex/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/logic/api/${variables.component#cap_first}Ctos.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/common => crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic}/api/cobigen.properties (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex => crud-java-server-app-complex/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/logic/api/usecase/UcFind${variables.entityName}.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex => crud-java-server-app-complex/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/logic/api/usecase/UcFind${variables.entityName}Ctos.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex => crud-java-server-app-complex/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/logic/api/usecase/UcManage${variables.entityName}.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex => crud-java-server-app-complex/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/logic/base/usecase/Abstract${variables.entityName}Uc.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex => crud-java-server-app-complex/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/${variables.component#cap_first}Impl.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex => crud-java-server-app-complex/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/${variables.component#cap_first}ImplCtos.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex => crud-java-server-app-complex/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/usecase/UcFind${variables.entityName}Impl.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex => crud-java-server-app-complex/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/usecase/UcFind${variables.entityName}ImplCtos.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex => crud-java-server-app-complex/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/usecase/UcManage${variables.entityName}Impl.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app-complex/src/main/resources}/templates/java/${variables.rootPackage}/general/common/base/AbstractBeanMapperSupport.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex => crud-java-server-app-complex/src/main/resources}/templates/java/${variables.rootPackage}/general/logic/base/AbstractLogic.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex => crud-java-server-app-complex/src/main/resources}/templates/java/${variables.rootPackage}/general/logic/base/AbstractUc.java.ftl (100%) create mode 100644 cobigen-templates/crud-java-server-app-complex/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudJavaServerAppComplexTest.java create mode 100644 cobigen-templates/crud-java-server-app-complex/src/test/resources/application.properties create mode 100644 cobigen-templates/crud-java-server-app-complex/src/test/resources/logback.xml create mode 100644 cobigen-templates/crud-java-server-app-complex/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml rename cobigen-templates/{templates-devon4j => crud-java-server-app-complex}/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml (100%) rename cobigen-templates/{templates-devon4j => crud-java-server-app-complex}/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java (100%) create mode 100644 cobigen-templates/crud-java-server-app-complex/src/test/resources/utils/pom.xml create mode 100644 cobigen-templates/crud-java-server-app/pom.xml create mode 100644 cobigen-templates/crud-java-server-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java create mode 100644 cobigen-templates/crud-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/constants/Field.java create mode 100644 cobigen-templates/crud-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/DevonfwUtil.java create mode 100644 cobigen-templates/crud-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/functions.ftl (100%) create mode 100644 cobigen-templates/crud-java-server-app/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/common/api/${variables.entityName}.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/common/api/${variables.entityName}SearchCriteriaTo.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to => crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/common/api}/cobigen.properties (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/dataaccess/api/${variables.entityName}Entity.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/dataaccess/api/repo/${variables.entityName}Repository.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Cto.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/service/api => crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to}/cobigen.properties (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/common/api/to => crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/service/api}/cobigen.properties (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/service/api/rest/${variables.component#cap_first}RestService.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/service/api/rest/${variables.component#cap_first}RestServiceCtos.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/service/api/soap/${variables.component#cap_first}SoapService.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/service/impl/rest/${variables.component#cap_first}RestServiceImpl.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/service/impl/rest/${variables.component#cap_first}RestServiceImplCtos.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component}/service/impl/soap/${variables.component#cap_first}SoapServiceImpl.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/common/api/ApplicationEntity.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/common/api/to/AbstractSearchCriteriaTo.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/api => crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/api/to}/cobigen.properties (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app_complex => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/common/base/AbstractBeanMapperSupport.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/dataaccess/api/ApplicationPersistenceEntity.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/dataaccess/api/dao/ApplicationDao.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/dataaccess/base/dao/ApplicationDaoImpl.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/logic/base/AbstractComponentFacade.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/service/impl/config/ServiceConfig.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_java_server_app => crud-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/service/impl/config/WebApplicationContextLocator.java.ftl (100%) create mode 100644 cobigen-templates/crud-java-server-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudJavaServerAppGenerationTest.java create mode 100644 cobigen-templates/crud-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml create mode 100644 cobigen-templates/crud-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml create mode 100644 cobigen-templates/crud-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java create mode 100644 cobigen-templates/crud-java-server-app/src/test/resources/utils/pom.xml create mode 100644 cobigen-templates/crud-ngrx-client-app/pom.xml create mode 100644 cobigen-templates/crud-ngrx-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java create mode 100644 cobigen-templates/crud-ngrx-client-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java create mode 100644 cobigen-templates/crud-ngrx-client-app/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/cobigen.properties (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-routing.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.scss (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.scss (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/models/${variables.etoName#lower_case}.model.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/models/datadetailstest.model.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/models/httpresponse.model.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/models/searchcriteriadata.model.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/store/actions/${variables.etoName#lower_case}.actions.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/store/actions/actions_index.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/store/effects/${variables.etoName#lower_case}.effects.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/store/effects/${variables.etoName#lower_case}.effects.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/store/effects/effects_index.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/store/reducers/${variables.etoName#lower_case}.reducers.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/store/reducers/${variables.etoName#lower_case}.reducers.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/store/reducers/reducers_index.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/store/selectors/${variables.etoName#lower_case}.selectors.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/store/selectors/selectors_index.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/store/store_index.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/app-routing.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/layout/header/header.component.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/app/layout/nav-bar/nav-bar.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/assets/i18n/en.json.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/assets/i18n/es.json.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/environments/environment.prod.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_ngrx_client_app => crud-ngrx-client-app/src/main/resources}/templates/src/environments/environment.ts.ftl (100%) create mode 100644 cobigen-templates/crud-ngrx-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudNgrxClientAppTest.java create mode 100644 cobigen-templates/crud-ngrx-client-app/src/test/resources/application.properties create mode 100644 cobigen-templates/crud-ngrx-client-app/src/test/resources/logback.xml create mode 100644 cobigen-templates/crud-ngrx-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/logback.xml create mode 100644 cobigen-templates/crud-ngrx-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/pom.xml create mode 100644 cobigen-templates/crud-ngrx-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/src/main/java/io/github/devonfw/cobigen/generator/logic/api/to/InputEto.java create mode 100644 cobigen-templates/crud-ngrx-client-app/src/test/resources/utils/pom.xml create mode 100644 cobigen-templates/crud-openapi-angular-client-app/pom.xml create mode 100644 cobigen-templates/crud-openapi-angular-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java create mode 100644 cobigen-templates/crud-openapi-angular-client-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java rename cobigen-templates/{templates-devon4j => crud-openapi-angular-client-app}/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/OpenApiUtil.java (100%) create mode 100644 cobigen-templates/crud-openapi-angular-client-app/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/cobigen.properties (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.scss (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.scss (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-routing.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/app-routing.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/app.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/home/home.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/layout/nav-bar/nav-bar.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/model/${variables.etoName#lower_case}.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/app/model/model.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/assets/i18n/en.json.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/assets/i18n/es.json.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/environments/environment.prod.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_client_app => crud-openapi-angular-client-app/src/main/resources}/templates/src/environments/environment.ts.ftl (100%) create mode 100644 cobigen-templates/crud-openapi-angular-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenapiAngularClientAppTest.java create mode 100644 cobigen-templates/crud-openapi-angular-client-app/src/test/resources/application.properties create mode 100644 cobigen-templates/crud-openapi-angular-client-app/src/test/resources/logback.xml rename cobigen-templates/{templates-devon4j => crud-openapi-angular-client-app}/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml (100%) create mode 100644 cobigen-templates/crud-openapi-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml rename cobigen-templates/{templates-devon4j => crud-openapi-angular-client-app}/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml (100%) create mode 100644 cobigen-templates/crud-openapi-angular-client-app/src/test/resources/utils/pom.xml create mode 100644 cobigen-templates/crud-openapi-angular-service-based-app/pom.xml create mode 100644 cobigen-templates/crud-openapi-angular-service-based-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java create mode 100644 cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app => crud-openapi-angular-service-based-app/src/main/resources}/templates/cobigen.properties (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app => crud-openapi-angular-service-based-app/src/main/resources}/templates/src/app/api/${variables.component#lower_case}/${variables.component#lower_case}RestController.service.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app => crud-openapi-angular-service-based-app/src/main/resources}/templates/src/app/api/api.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app => crud-openapi-angular-service-based-app/src/main/resources}/templates/src/environments/environment.prod.ts.ftl (100%) create mode 100644 cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/templates/src/environments/environment.ts.ftl create mode 100644 cobigen-templates/crud-openapi-angular-service-based-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenapiAngularServiceBasedAppTest.java create mode 100644 cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/application.properties create mode 100644 cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/logback.xml create mode 100644 cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml create mode 100644 cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml create mode 100644 cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml create mode 100644 cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/utils/pom.xml create mode 100644 cobigen-templates/crud-openapi-ionic-client-app/pom.xml create mode 100644 cobigen-templates/crud-openapi-ionic-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java create mode 100644 cobigen-templates/crud-openapi-ionic-client-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java create mode 100644 cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/cobigen.properties (100%) mode change 100755 => 100644 rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/app-routing.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/app.component.ts.ftl (100%) mode change 100755 => 100644 rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/app.module.ts.ftl (100%) mode change 100755 => 100644 rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.scss.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.scss.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/services/${variables.etoName#lower_case}-rest.service.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/services/interfaces/${variables.etoName#lower_case}-search-criteria.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/services/interfaces/${variables.etoName#lower_case}.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/services/interfaces/pageable.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/services/interfaces/paginated-list-to.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/services/interfaces/sort.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/app/services/shared/business-operator.service.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/assets/i18n/en.json.ftl (100%) mode change 100755 => 100644 rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/assets/i18n/es.json.ftl (100%) mode change 100755 => 100644 rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/assets/i18n/it.json.ftl (100%) mode change 100755 => 100644 rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/environments/environment.android.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/environments/environment.prod.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/environments/environment.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_ionic_client_app => crud-openapi-ionic-client-app/src/main/resources}/templates/src/theme/variables.scss.ftl (100%) create mode 100644 cobigen-templates/crud-openapi-ionic-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenapiIonicClientAppTest.java create mode 100644 cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/application.properties create mode 100644 cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/logback.xml create mode 100644 cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml create mode 100644 cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml create mode 100644 cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml create mode 100644 cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/utils/pom.xml create mode 100644 cobigen-templates/crud-openapi-java-server-app/pom.xml create mode 100644 cobigen-templates/crud-openapi-java-server-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java create mode 100644 cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/constants/Field.java create mode 100644 cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/DevonfwUtil.java create mode 100644 cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java create mode 100644 cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/OpenApiUtil.java rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/functions.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/makros.ftl (100%) create mode 100644 cobigen-templates/crud-openapi-java-server-app/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/common/api/${variables.entityName}.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/common/api/cobigen.properties (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/dataaccess/api/${variables.entityName}Entity.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/dataaccess/api/repo/${variables.entityName}Repository.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/${variables.component#cap_first}.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/${variables.component#cap_first}Ctos.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/cobigen.properties (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/to/${variables.entityName}Cto.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/to/${variables.entityName}Eto.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/to/${variables.entityName}SearchCriteriaTo.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/usecase/UcFind${variables.entityName}.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/usecase/UcFind${variables.entityName}Ctos.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/usecase/UcManage${variables.entityName}.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/base/usecase/Abstract${variables.entityName}Uc.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/${variables.component#cap_first}Impl.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/${variables.component#cap_first}ImplCtos.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/usecase/UcFind${variables.entityName}Impl.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/usecase/UcFind${variables.entityName}ImplCtos.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/usecase/UcManage${variables.entityName}Impl.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/api/cobigen.properties (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/api/rest/${variables.component#cap_first}RestService.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/api/rest/${variables.component#cap_first}RestServiceCtos.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/impl/rest/${variables.component#cap_first}RestServiceImpl.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/impl/rest/${variables.component#cap_first}RestServiceImplCtos.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/common/api/ApplicationEntity.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/common/api/to/AbstractSearchCriteriaTo.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/common/api/to/cobigen.properties (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/common/base/AbstractBeanMapperSupport.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/dataaccess/api/ApplicationPersistenceEntity.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/logic/base/AbstractComponentFacade.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/logic/base/AbstractLogic.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/logic/base/AbstractUc.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/service/impl/config/ServiceConfig.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_java_server_app => crud-openapi-java-server-app/src/main/resources}/templates/java/${variables.rootPackage}/general/service/impl/config/WebApplicationContextLocator.java.ftl (100%) create mode 100644 cobigen-templates/crud-openapi-java-server-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenApiJavaServerAppGenerationTest.java create mode 100644 cobigen-templates/crud-openapi-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml create mode 100644 cobigen-templates/crud-openapi-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml create mode 100644 cobigen-templates/crud-openapi-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml create mode 100644 cobigen-templates/crud-openapi-java-server-app/src/test/resources/utils/pom.xml create mode 100644 cobigen-templates/crud-openapi-net/pom.xml create mode 100644 cobigen-templates/crud-openapi-net/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java create mode 100644 cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/constants/Field.java create mode 100644 cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/DevonfwUtil.java create mode 100644 cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java create mode 100644 cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/OpenApiUtil.java create mode 100644 cobigen-templates/crud-openapi-net/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_net => crud-openapi-net/src/main/resources}/templates/Devon4Net.Application.WebAPI/Startup.cs (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_net => crud-openapi-net/src/main/resources}/templates/Devon4Net.Application.WebAPI/appsettings.Development.json (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_net => crud-openapi-net/src/main/resources}/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Controller/${variables.component#cap_first}Controller.cs.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_net => crud-openapi-net/src/main/resources}/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Converter/${variables.component#cap_first}Converter.cs.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_net => crud-openapi-net/src/main/resources}/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Dto/${variables.entityName#replace('Dto', '')#cap_first}Dto.cs.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_net => crud-openapi-net/src/main/resources}/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Dto/${variables.entityName#replace('Dto', '')#cap_first}ResponseDto.cs.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_net => crud-openapi-net/src/main/resources}/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Exceptions/${variables.entityName#cap_first}NotCreatedException.cs.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_net => crud-openapi-net/src/main/resources}/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Exceptions/${variables.entityName#cap_first}NotDeletedException.cs.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_net => crud-openapi-net/src/main/resources}/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Exceptions/${variables.entityName#cap_first}NotFoundException.cs.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_net => crud-openapi-net/src/main/resources}/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Service/${variables.component#cap_first}Service.cs.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_net => crud-openapi-net/src/main/resources}/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Service/I${variables.component#cap_first}Service.cs.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_net => crud-openapi-net/src/main/resources}/templates/Devon4Net.WebAPI.Implementation/Data/Repositories/${variables.entityName#cap_first}Repository.cs.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_net => crud-openapi-net/src/main/resources}/templates/Devon4Net.WebAPI.Implementation/Domain/Database/CobigenContext.cs (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_net => crud-openapi-net/src/main/resources}/templates/Devon4Net.WebAPI.Implementation/Domain/Entities/${variables.entityName#cap_first}.cs.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_openapi_net => crud-openapi-net/src/main/resources}/templates/Devon4Net.WebAPI.Implementation/Domain/RepositoryInterfaces/I${variables.entityName#cap_first}Repository.cs.ftl (100%) create mode 100644 cobigen-templates/crud-openapi-net/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenApiNetGenerationTest.java create mode 100644 cobigen-templates/crud-openapi-net/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml create mode 100644 cobigen-templates/crud-openapi-net/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml create mode 100644 cobigen-templates/crud-openapi-net/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml create mode 100644 cobigen-templates/crud-openapi-net/src/test/resources/utils/pom.xml create mode 100644 cobigen-templates/crud-typescript-angular-client-app/pom.xml create mode 100644 cobigen-templates/crud-typescript-angular-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java create mode 100644 cobigen-templates/crud-typescript-angular-client-app/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/cobigen.properties (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.scss (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-dialog/${variables.entityName#lower_case}-dialog.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-dialog/${variables.entityName#lower_case}-dialog.component.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-dialog/${variables.entityName#lower_case}-dialog.component.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.scss (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/${variables.entityName#lower_case}/services/${variables.entityName#lower_case}.service.spec.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/${variables.entityName#lower_case}/services/${variables.entityName#lower_case}.service.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/app-routing.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/app.module.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/core/interfaces/sort.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/core/security/login.service.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/core/shared/business-operations.service.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/home/home.component.html.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/model/${variables.entityName#lower_case}.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/app/model/model.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/assets/i18n/en.json.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/assets/i18n/es.json.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/environments/environment.prod.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/templates/src/environments/environment.ts.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/crud_typescript_angular_client_app => crud-typescript-angular-client-app/src/main/resources}/variables.ftl (100%) create mode 100644 cobigen-templates/crud-typescript-angular-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudTypescriptAngularClientAppTest.java create mode 100644 cobigen-templates/crud-typescript-angular-client-app/src/test/resources/application.properties create mode 100644 cobigen-templates/crud-typescript-angular-client-app/src/test/resources/logback.xml create mode 100644 cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/baseFile.entity.ts create mode 100644 cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml create mode 100644 cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml create mode 100644 cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java create mode 100644 cobigen-templates/crud-typescript-angular-client-app/src/test/resources/utils/pom.xml create mode 100644 cobigen-templates/kafka-documentation/pom.xml rename cobigen-templates/{templates-devon4j => kafka-documentation}/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/JavaDocumentationUtil.java (100%) create mode 100644 cobigen-templates/kafka-documentation/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j/src/main/templates/kafka_documentation => kafka-documentation/src/main/resources}/templates/docs/${variables.component}To.adoc.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/kafka_documentation => kafka-documentation/src/main/resources}/templates/docs/Documentation.adoc.ftl (100%) create mode 100644 cobigen-templates/named-queries/pom.xml rename cobigen-templates/{templates-devon4j/src/main/templates/named_queries => named-queries/src/main/resources}/NamedQueries.java.ftl (100%) create mode 100644 cobigen-templates/named-queries/src/main/resources/template-set.xml create mode 100644 cobigen-templates/openapi-documentation/pom.xml rename cobigen-templates/{templates-devon4j => openapi-documentation}/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/DocumentationUtil.java (100%) rename cobigen-templates/{templates-devon4j => openapi-documentation}/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/OpenApiDocumentationUtil.java (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/openapi_documentation => openapi-documentation/src/main/resources}/functions.ftl (100%) create mode 100644 cobigen-templates/openapi-documentation/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j/src/main/templates/openapi_documentation => openapi-documentation/src/main/resources}/templates/docs/${variables.component}Doc.adoc.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/openapi_documentation => openapi-documentation/src/main/resources}/templates/docs/Documentation.adoc.ftl (100%) create mode 100644 cobigen-templates/pom_patch.xml create mode 100644 cobigen-templates/rest-documentation/pom.xml create mode 100644 cobigen-templates/rest-documentation/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/JavaDocumentationUtil.java create mode 100644 cobigen-templates/rest-documentation/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j/src/main/templates/rest_documentation => rest-documentation/src/main/resources}/templates/docs/${variables.component}RESTInterfaces.adoc.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/rest_documentation => rest-documentation/src/main/resources}/templates/docs/Documentation.adoc.ftl (100%) create mode 100644 cobigen-templates/security-permissions/pom.xml rename cobigen-templates/{templates-devon4j/src/main/templates/security_permissions => security-permissions/src/main/resources}/PermissionConstants.java.ftl (100%) create mode 100644 cobigen-templates/security-permissions/src/main/resources/template-set.xml rename cobigen-templates/{templates-devon4j => templates-devon4j-tests}/logback.xml (100%) create mode 100644 cobigen-templates/templates-devon4j-tests/pom.xml create mode 100644 cobigen-templates/templates-devon4j-tests/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java rename cobigen-templates/{templates-devon4j => templates-devon4j-tests}/src/main/resources/META-INF/LICENSE.txt (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-tests}/src/main/templates/named_queries/context.xml (54%) rename cobigen-templates/{templates-devon4j => templates-devon4j-tests}/src/main/templates/security_permissions/context.xml (59%) create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/TemplatesGenerationTest.java create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/resources/application.properties create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/resources/logback.xml create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/logback.xml create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/pom.xml create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/src/main/java/io/github/devonfw/cobigen/generator/logic/api/to/InputEto.java create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml rename cobigen-templates/{templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesToInput => templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput}/logback.xml (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-tests}/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/pom.xml (98%) rename cobigen-templates/{templates-devon4j => templates-devon4j-tests}/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputNoAnnotationsRestService.java (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-tests}/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/JavaxAnnotationsInputRestService.java (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-tests}/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/SpringAnnotationsInputRestService.java (100%) rename cobigen-templates/{templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput => templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesToInput}/logback.xml (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-tests}/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/pom.xml (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-tests}/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputNoAnnotationsTo.java (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-tests}/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputTo.java (100%) create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/logback.xml create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/pom.xml rename cobigen-templates/{templates-devon4j/src/test/resources/testinput/XMI-UML.xml => templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/src/main/xml/io/github/devonfw/cobigen/generator/dataaccess/api/Input.xml} (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-tests}/src/test/resources/testinput/InputEntity.java (100%) create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/resources/testinput/XMI-UML.xml create mode 100644 cobigen-templates/templates-devon4j-tests/src/test/resources/utils/pom.xml rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/pom.xml (75%) rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/pom_patch.xml (72%) create mode 100644 cobigen-templates/templates-devon4j-utils/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java create mode 100644 cobigen-templates/templates-devon4j-utils/src/main/java/com/devonfw/cobigen/templates/devon4j/constants/Field.java rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/DevonfwUtil.java (98%) rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/IDGenerator.java (100%) create mode 100644 cobigen-templates/templates-devon4j-utils/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java create mode 100644 cobigen-templates/templates-devon4j-utils/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/OpenApiUtil.java create mode 100644 cobigen-templates/templates-devon4j-utils/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/DocumentationUtil.java create mode 100644 cobigen-templates/templates-devon4j-utils/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/JavaDocumentationUtil.java create mode 100644 cobigen-templates/templates-devon4j-utils/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/OpenApiDocumentationUtil.java create mode 100644 cobigen-templates/templates-devon4j-utils/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/uml/Connector.java rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/uml/UmlUtil.java (100%) create mode 100644 cobigen-templates/templates-devon4j-utils/src/main/resources/META-INF/LICENSE.txt rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/src/test/java/com/devonfw/cobigen/templates/devon4j/test/utils/DevonfwUtilTest.java (100%) create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/java/com/devonfw/cobigen/templates/devon4j/test/utils/JavaUtilTest.java rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/src/test/java/com/devonfw/cobigen/templates/devon4j/test/utils/documentation/DocumentationUtilTest.java (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/src/test/java/com/devonfw/cobigen/templates/devon4j/test/utils/documentation/JavaDocumentationUtilTest.java (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/src/test/java/com/devonfw/cobigen/templates/devon4j/test/utils/documentation/OpenApiDocumentationUtilTest.java (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/src/test/java/com/devonfw/cobigen/templates/devon4j/test/utils/resources/TestClass.java (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/src/test/java/com/devonfw/cobigen/templates/devon4j/test/utils/resources/TestEntity.java (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/src/test/java/com/devonfw/cobigen/templates/devon4j/test/utils/resources/TestTwoClass.java (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/src/test/java/com/devonfw/cobigen/templates/devon4j/test/utils/resources/dataaccess/api/DeepEntity.java (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/src/test/java/com/devonfw/cobigen/templates/devon4j/test/utils/resources/dataaccess/api/TestEntityComponent.java (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/src/test/java/com/devonfw/cobigen/templates/devon4j/test/utils/resources/uml/completeUmlXmi.xml (100%) rename cobigen-templates/{templates-devon4j => templates-devon4j-utils}/src/test/java/com/devonfw/cobigen/templates/devon4j/test/utils/uml/UmlUtilTest.java (97%) create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/application.properties create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/logback.xml create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/logback.xml create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/pom.xml create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/src/main/java/io/github/devonfw/cobigen/generator/logic/api/to/InputEto.java create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/logback.xml create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/pom.xml create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputNoAnnotationsRestService.java create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/JavaxAnnotationsInputRestService.java create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/SpringAnnotationsInputRestService.java create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/logback.xml create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/pom.xml create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputNoAnnotationsTo.java create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputTo.java create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/logback.xml create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/pom.xml create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/src/main/xml/io/github/devonfw/cobigen/generator/dataaccess/api/Input.xml create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testinput/InputEntity.java create mode 100644 cobigen-templates/templates-devon4j-utils/src/test/resources/testinput/XMI-UML.xml delete mode 100644 cobigen-templates/templates-devon4j/.classpath delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_angular_client_app/context.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_angular_client_app/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_ionic_client_app/context.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_ionic_client_app/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_java_ea_uml/context.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_java_ea_uml/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/context.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/context.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/context.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/context.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/context.xml delete mode 100755 cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/context.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/context.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/context.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/kafka_documentation/context.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/named_queries/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/openapi_documentation/context.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/openapi_documentation/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/rest_documentation/context.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/rest_documentation/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/security_permissions/templates.xml delete mode 100644 cobigen-templates/templates-devon4j/src/main/templates/testdata_builder/context.xml delete mode 100644 cobigen-templates/templates-devon4j/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/TemplatesGenerationTest.java delete mode 100644 cobigen-templates/templates-devon4j/src/test/java/com/devonfw/cobigen/templates/devon4j/test/utils/JavaUtilTest.java create mode 100644 cobigen-templates/testdata-builder/pom.xml create mode 100644 cobigen-templates/testdata-builder/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java create mode 100644 cobigen-templates/testdata-builder/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java rename cobigen-templates/{templates-devon4j/src/main/templates/testdata_builder => testdata-builder/src/main/resources}/ObjectBuilder.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/testdata_builder => testdata-builder/src/main/resources}/ObjectBuilder_customFunctions.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/testdata_builder => testdata-builder/src/main/resources}/ObjectBuilder_fillMandatoryFields.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/testdata_builder => testdata-builder/src/main/resources}/ObjectBuilder_persistable.java.ftl (100%) rename cobigen-templates/{templates-devon4j/src/main/templates/testdata_builder => testdata-builder/src/main/resources}/makros.ftl (100%) create mode 100644 cobigen-templates/testdata-builder/src/main/resources/template-set.xml create mode 100644 cobigen-templates/testdata-builder/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/TestDataBuilderGenerationTest.java create mode 100644 cobigen-templates/testdata-builder/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml create mode 100644 cobigen-templates/testdata-builder/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml create mode 100644 cobigen-templates/testdata-builder/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java create mode 100644 cobigen-templates/testdata-builder/src/test/resources/utils/pom.xml create mode 100644 cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/TemplateAdapter.java create mode 100644 cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/exception/DeprecatedMonolithicConfigurationException.java create mode 100644 cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/exception/TemplateSelectionForAdaptionException.java create mode 100644 cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/exception/UpgradeTemplatesNotificationException.java create mode 100644 cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/util/MavenCoordinate.java create mode 100644 cobigen/cobigen-core-systemtest/src/test/java/com/devonfw/cobigen/systemtest/DownloadTemplateSetsIT.java create mode 100644 cobigen/cobigen-core-systemtest/src/test/java/com/devonfw/cobigen/systemtest/TemplateProcessingTest.java create mode 100644 cobigen/cobigen-core-systemtest/src/test/java/com/devonfw/cobigen/systemtest/TemplatesInstallationTest.java create mode 100644 cobigen/cobigen-core-systemtest/src/test/java/com/devonfw/cobigen/systemtest/testobjects/io/generator/logic/api/to/InputEto.java create mode 100644 cobigen/cobigen-core-systemtest/src/test/java/com/devonfw/cobigen/systemtest/testobjects/io/generator/logic/api/to/test.yaml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/AdaptMonolithicTemplatesTest/templates/templates-devon4j-0.0.1-sources.jar create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/AdaptMonolithicTemplatesTest/templates/templates-devon4j-0.0.1.jar create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/ClassLoadTemplateSetTest/conflicted/template-sets/adapted/template-set1/pom.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/ClassLoadTemplateSetTest/conflicted/template-sets/adapted/template-set1/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/ClassLoadTemplateSetTest/conflicted/template-sets/adapted/template-set1/src/main/resources/templates/generated.txt.ftl create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/ClassLoadTemplateSetTest/conflicted/template-sets/adapted/template-set2/pom.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/ClassLoadTemplateSetTest/conflicted/template-sets/adapted/template-set2/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/ClassLoadTemplateSetTest/conflicted/template-sets/adapted/template-set2/src/main/resources/templates/generated.txt.ftl create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/ClassLoadTemplateSetTest/expected-conflicted/generated.txt create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/ClassLoadTemplateSetTest/expected/generated.txt create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/ClassLoadTemplateSetTest/template-sets/adapted/template-set1/pom.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/ClassLoadTemplateSetTest/template-sets/adapted/template-set1/src/main/java/JarredClass.java create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/ClassLoadTemplateSetTest/template-sets/adapted/template-set1/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/ClassLoadTemplateSetTest/template-sets/adapted/template-set1/src/main/resources/templates/generated.txt.ftl create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTest/overrideMergeStrategy/testTemplates2/generated.txt.ftl create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTest/overrideMergeStrategy/testTemplates2/templates.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets-conflicted/adapted/template-test/template-set.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets-conflicted/adapted/template-test/templates/generated.txt.ftl create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets-conflicted/template-sets/adapted/template-test/pom.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets-conflicted/template-sets/adapted/template-test/template-set.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets-conflicted/template-sets/adapted/template-test/templates/generated.txt.ftl create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets-conflicted/template-sets/downloaded/template-test.jar create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/adapted/template-test/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/adapted/template-test/src/main/resources/templates/generated.txt.ftl create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/adapted/template-test2/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/adapted/template-test2/src/main/resources/templates/generated.txt.ftl create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/adapted/template-testdata_builder/src/main/resources/ObjectBuilder.java.ftl create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/adapted/template-testdata_builder/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/downloaded/downloaded1-test/pom.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/downloaded/downloaded1-test/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/downloaded/downloaded1-test/src/main/resources/templates/generated.txt.ftl create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/downloaded/downloaded2-test/pom.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/downloaded/downloaded2-test/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/downloaded/downloaded2-test/src/main/resources/templates/generated.txt.ftl create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateProcessingTest/template-sets/adapted/crud-java-server-app-complex/pom.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateProcessingTest/template-sets/adapted/crud-java-server-app-complex/src/main/java/com/test.java create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateProcessingTest/template-sets/adapted/crud-java-server-app-complex/src/main/resources/functions.ftl create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateProcessingTest/template-sets/adapted/crud-java-server-app-complex/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateProcessingTest/template-sets/adapted/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateProcessingTest/template-sets/adapted/crud-java-server-app/pom.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateProcessingTest/template-sets/adapted/crud-java-server-app/src/main/java/com/test.java create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateProcessingTest/template-sets/adapted/crud-java-server-app/src/main/resources/functions.ftl create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateProcessingTest/template-sets/adapted/crud-java-server-app/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateProcessingTest/template-sets/adapted/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateScanTemplateSetTest/template-sets/adapted/template-set1/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateScanTemplateSetTest/template-sets/adapted/template-set1/src/main/resources/templates/generated.txt.ftl create mode 100644 cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/adapter/TemplateAdapterImpl.java create mode 100644 cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/ConfigurationProperties.java create mode 100644 cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/TemplateSetConfiguration.java create mode 100644 cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/constant/TemplateSetConfigurationVersion.java create mode 100644 cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/reader/TemplateSetConfigurationManager.java create mode 100644 cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/reader/TemplateSetConfigurationReader.java create mode 100644 cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/upgrade/TemplateSetUpgrader.java delete mode 100644 cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/util/ExtractTemplatesUtil.java create mode 100644 cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/util/MavenCoordinateUtil.java create mode 100644 cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/util/PostponeUtil.java delete mode 100644 cobigen/cobigen-core/src/main/resources/schema/v2.2/contextConfiguration.xsd create mode 100644 cobigen/cobigen-core/src/main/resources/schema/v3.0/contextConfiguration.xsd create mode 100644 cobigen/cobigen-core/src/main/resources/schema/v5.0/templatesConfiguration.xsd create mode 100644 cobigen/cobigen-core/src/main/resources/schema/v6.0/contextConfiguration.xsd create mode 100644 cobigen/cobigen-core/src/main/resources/schema/v6.0/templateSetConfiguration.xsd create mode 100644 cobigen/cobigen-core/src/main/resources/schema/v6.0/templatesConfiguration.xsd create mode 100644 cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/CobiGenFactoryTest.java create mode 100644 cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/adapter/TemplateAdapterTest.java create mode 100644 cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/ConfigurationFinderTest.java create mode 100644 cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/reader/TemplateSetConfigurationReaderTest.java create mode 100644 cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/upgrade/TemplateSetUpgraderTest.java create mode 100644 cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/util/PostponeUtilTest.java delete mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/ExternalProcess/DummyExe delete mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/ExternalProcess/DummyExe.exe create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/properties/emptyConfigProperties/config.properties create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/properties/invalidConfigProperties/config.properties create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/properties/validConfigProperties/config.properties delete mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/ContextConfigurationReaderTest/invalid_new/src/main/templates/test_template/context.xml rename cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/ContextConfigurationReaderTest/{invalid_new/src/main/templates => valid}/context.xml (84%) delete mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/ContextConfigurationReaderTest/valid_new/src/main/templates/test_template/context.xml delete mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/ContextConfigurationReaderTest/valid_new/src/main/templates/test_template2/context.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/faulty/template-set.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/adapted/template-set/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/adapted/template-set/src/main/resources/templates/bar/BarClass.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/adapted/template-set/src/main/resources/templates/bar/Foo2Class.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/adapted/template-set/src/main/resources/templates/bar/FooClass.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/adapted/template-set/src/main/resources/templates/foo/Foo2Class.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/adapted/template-set/src/main/resources/templates/foo/FooClass.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/adapted/template-set/src/main/resources/templates/foo/bar/BarClass.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/adapted/test_template/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/adapted/test_template/src/main/resources/templates/bar/BarClass.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/adapted/test_template/src/main/resources/templates/bar/Foo2Class.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/adapted/test_template/src/main/resources/templates/bar/FooClass.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/adapted/test_template/src/main/resources/templates/foo/Foo2Class.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/adapted/test_template/src/main/resources/templates/foo/FooClass.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/adapted/test_template/src/main/resources/templates/foo/bar/BarClass.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/downloaded/crud-java-server-app/pom.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/downloaded/crud-java-server-app/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/downloaded/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets_adapted/template-sets/adapted/template-set1/src/main/resources/src/environments/environment.ts.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets_adapted/template-sets/adapted/template-set1/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets_adapted/template-sets/adapted/template-set2/src/main/resources/src/environments/environment2.ts.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets_adapted/template-sets/adapted/template-set2/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets_downloaded/template-sets/downloaded/crud-java-server-app/pom.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets_downloaded/template-sets/downloaded/crud-java-server-app/src/main/resources/template-set.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets_downloaded/template-sets/downloaded/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets_duplicated/template-sets/adapted/template-set1/template-set.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets_duplicated/template-sets/adapted/template-set1/templates/src/environments/environment.ts.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets_duplicated/template-sets/adapted/template-set2/template-set.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets_duplicated/template-sets/adapted/template-set2/templates/src/environments/environment.ts.ftl delete mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/ContextConfigurationUpgraderTest/valid-v2.2/context.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/ContextConfigurationUpgraderTest/valid-v3.0/templateSet1/context.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/ContextConfigurationUpgraderTest/valid-v3.0/templateSet2/context.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.0/templates/CobiGen_Templates/pom.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.0/templates/CobiGen_Templates/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.0/templates/CobiGen_Templates/src/main/templates/context.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.0/templates/CobiGen_Templates/src/main/templates/templateSet1/ObjectBuilder.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.0/templates/CobiGen_Templates/src/main/templates/templateSet1/ObjectBuilder_customFunctions.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.0/templates/CobiGen_Templates/src/main/templates/templateSet1/ObjectBuilder_fillMandatoryFields.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.0/templates/CobiGen_Templates/src/main/templates/templateSet1/ObjectBuilder_persistable.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.0/templates/CobiGen_Templates/src/main/templates/templateSet1/makros.ftl rename {cobigen-templates/templates-devon4j/src/main/templates/testdata_builder => cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.0/templates/CobiGen_Templates/src/main/templates/templateSet1}/templates.xml (100%) create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.0/templates/CobiGen_Templates/src/main/templates/templateSet2/ObjectBuilder.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.0/templates/CobiGen_Templates/src/main/templates/templateSet2/ObjectBuilder_customFunctions.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.0/templates/CobiGen_Templates/src/main/templates/templateSet2/ObjectBuilder_fillMandatoryFields.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.0/templates/CobiGen_Templates/src/main/templates/templateSet2/ObjectBuilder_persistable.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.0/templates/CobiGen_Templates/src/main/templates/templateSet2/makros.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.0/templates/CobiGen_Templates/src/main/templates/templateSet2/templates.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.1/templates/CobiGen_Templates/pom.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.1/templates/CobiGen_Templates/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.1/templates/CobiGen_Templates/src/main/templates/context.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.1/templates/CobiGen_Templates/src/main/templates/templateSet1/ObjectBuilder.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.1/templates/CobiGen_Templates/src/main/templates/templateSet1/ObjectBuilder_customFunctions.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.1/templates/CobiGen_Templates/src/main/templates/templateSet1/ObjectBuilder_fillMandatoryFields.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.1/templates/CobiGen_Templates/src/main/templates/templateSet1/ObjectBuilder_persistable.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.1/templates/CobiGen_Templates/src/main/templates/templateSet1/makros.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.1/templates/CobiGen_Templates/src/main/templates/templateSet1/templates.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.1/templates/CobiGen_Templates/src/main/templates/templateSet2/ObjectBuilder.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.1/templates/CobiGen_Templates/src/main/templates/templateSet2/ObjectBuilder_customFunctions.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.1/templates/CobiGen_Templates/src/main/templates/templateSet2/ObjectBuilder_fillMandatoryFields.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.1/templates/CobiGen_Templates/src/main/templates/templateSet2/ObjectBuilder_persistable.java.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.1/templates/CobiGen_Templates/src/main/templates/templateSet2/makros.ftl create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplateSetUpgraderTest/valid-2.1/templates/CobiGen_Templates/src/main/templates/templateSet2/templates.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplatesConfigurationUpgraderTest/valid-v4.0/templates.xml create mode 100644 cobigen/cobigen-core/src/test/resources/testdata/unittest/config/upgrade/TemplatesConfigurationUpgraderTest/valid-v5.0/templates.xml create mode 100644 cobigen/core-artifact-retriever/pom.xml create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/ArtifactRetriever.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/MavenSearchArtifactRetriever.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/constants/MavenSearchRepositoryConstants.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/constants/MavenSearchRepositoryType.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/exception/RestSearchResponseException.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/to/model/AbstractSearchResponse.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/to/model/SearchResponseFactory.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/to/model/ServerCredentials.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/to/model/jfrog/JfrogSearchResponse.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/to/model/jfrog/JfrogSearchResponseResult.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/to/model/maven/MavenSearchResponse.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/to/model/maven/MavenSearchResponseDoc.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/to/model/maven/MavenSearchResponseResponse.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/to/model/nexus2/Nexus2SearchResponse.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/to/model/nexus2/Nexus2SearchResponseArtifactHits.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/to/model/nexus2/Nexus2SearchResponseArtifactLinks.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/to/model/nexus2/Nexus2SearchResponseData.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/to/model/nexus3/Nexus3SearchResponse.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/to/model/nexus3/Nexus3SearchResponseAsset.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/mavensearch/to/model/nexus3/Nexus3SearchResponseItem.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/MavenMirror.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/MavenProxy.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/MavenSettings.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/to/model/MavenSettingsActivationModel.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/to/model/MavenSettingsActiveProfilesModel.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/to/model/MavenSettingsMirrorModel.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/to/model/MavenSettingsMirrorsModel.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/to/model/MavenSettingsModel.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/to/model/MavenSettingsProfileModel.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/to/model/MavenSettingsProfilesModel.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/to/model/MavenSettingsProxiesModel.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/to/model/MavenSettingsProxyModel.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/to/model/MavenSettingsRepositoriesModel.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/to/model/MavenSettingsRepositoryModel.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/to/model/MavenSettingsServerModel.java create mode 100644 cobigen/core-artifact-retriever/src/main/java/com/devonfw/cobigen/retriever/settings/to/model/MavenSettingsServersModel.java create mode 100644 cobigen/core-artifact-retriever/src/test/java/com/devonfw/cobigen/retriever/ArtifactRetrieverTest.java create mode 100644 cobigen/core-artifact-retriever/src/test/java/com/devonfw/cobigen/retriever/MavenMirrorTest.java create mode 100644 cobigen/core-artifact-retriever/src/test/java/com/devonfw/cobigen/retriever/MavenProxyTest.java create mode 100644 cobigen/core-artifact-retriever/src/test/java/com/devonfw/cobigen/retriever/MavenSettingsTest.java create mode 100644 cobigen/core-artifact-retriever/src/test/java/com/devonfw/cobigen/retriever/unittest/MavenSearchArtifactRetrieverTest.java create mode 100644 cobigen/core-artifact-retriever/src/test/java/com/devonfw/cobigen/retriever/unittest/MavenSearchResponseTest.java create mode 100644 cobigen/core-artifact-retriever/src/test/java/com/devonfw/cobigen/retriever/unittest/SearchResponseFactoryTest.java create mode 100644 cobigen/core-artifact-retriever/src/test/java/com/devonfw/cobigen/retriever/unittest/SearchResponseTest.java create mode 100644 cobigen/core-artifact-retriever/src/test/resources/logback-test.xml create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/ArtifactRetrieverTest/jfrogJsonTest.json create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/ArtifactRetrieverTest/settingsNonProxy.xml create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/ArtifactRetrieverTest/settingsProxy.xml create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenMirrorTest/settings.xml create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenProxyTest/settings.xml create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenSearchArtifactRetrieverTest/jfrogJsonTest.json create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenSearchArtifactRetrieverTest/mavenJsonTest.json create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenSearchArtifactRetrieverTest/nexus2JsonTest.json create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenSearchArtifactRetrieverTest/nexus3JsonTest.json create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenSearchResponseTest/jfrogJsonTest.json create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenSearchResponseTest/mavenJsonTest.json create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenSearchResponseTest/nexus2JsonTest.json create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenSearchResponseTest/nexus3JsonTest.json create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenSearchTest/jfrogJsonTest.json create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenSearchTest/mavenJsonTest.json create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenSearchTest/nexus2JsonTest.json create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenSearchTest/nexus3JsonTest.json create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenSettingsTest/settings-security.xml create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/MavenSettingsTest/settings.xml create mode 100644 cobigen/core-artifact-retriever/src/test/resources/testdata/unittest/SearchResponseFactoryTest/mavenJsonTest.json diff --git a/.github/workflows/maven-build-test.yml b/.github/workflows/maven-build-test.yml index 995bc4b748..338be07030 100644 --- a/.github/workflows/maven-build-test.yml +++ b/.github/workflows/maven-build-test.yml @@ -19,297 +19,166 @@ on: - '**.asciidoc' env: - MVN_BATCH_MODE: '-Djansi.force=true -Djansi.passthrough=true -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn' + # if continuously builds exiting randomly, possibly add again -Djansi.force=true -Djansi.passthrough=true + MVN_BATCH_MODE: '-B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn' # fixing random connection reset of maven downloads as proposed here: https://github.com/actions/virtual-environments/issues/2715#issuecomment-797388909 MVN_HTTP_OPTIMIZATION: '-Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120' - MVN_TEST_COVERAGE: '-Dskip.code.coverage=false' + REPOSITORY_PATH: repo jobs: cache-dependencies: runs-on: ubuntu-latest - steps: + steps: + - name: Enable git support for long paths on Windows + if: ${{ runner.os == 'Windows' }} + shell: cmd + run: git config --system core.longpaths true + - name: Clone Repository uses: actions/checkout@v3 - - - uses: devonfw-actions/java-maven-setup@main with: - maven-cache-key: cobigen-dep-${{ hashFiles('**/pom.xml') }} - clone: false - - - name: Resolve non-cobigen dependencies - run: mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.2:resolve -DexcludeGroupIds=com.devonfw.cobigen -T1C -P!p2-build ${{ env.MVN_BATCH_MODE }} ${{ env.MVN_HTTP_OPTIMIZATION }} || true # never fail - - build-and-test-core: - needs: cache-dependencies - strategy: - fail-fast: false - matrix: - javaVersion: [8, 11] - os: [windows-latest, ubuntu-latest] - runs-on: ${{ matrix.os }} + path: ${{ env.REPOSITORY_PATH }} - steps: - - uses: devonfw-actions/java-maven-setup@main + - name: Checkout & Prepare + uses: devonfw-actions/java-maven-setup@main with: - maven-cache-key: ${{ runner.os }}-${{ matrix.javaVersion }}-maven-${{ github.sha }} # new key will cache - maven-cache-restore-key: cobigen-dep-${{ hashFiles('**/pom.xml') }} - java-version: ${{ matrix.javaVersion }} - jacoco-cache-key: ${{ runner.os }}-${{ matrix.javaVersion }}-jacoco-${{ github.sha }}-core-test # new key will cache + maven-cache-path: ./.m2/repository + maven-cache-key: cobigen-dep-${{ hashFiles(format('{0}/**/pom.xml', env.REPOSITORY_PATH)) }} + clone: false # checkout in a separate / earlier step to allow eager evaluation of parameter expression like workspace or hashFiles - - name: Build & Test Core + - name: Overwrite maven settings shell: bash - run: mvn install -f cobigen --projects !cobigen-core-systemtest ${{ env.MVN_BATCH_MODE }} ${{ env.MVN_HTTP_OPTIMIZATION }} ${{ env.MVN_TEST_COVERAGE }} + run: | + mkdir -p ~/.m2 + cp -rf ${{ env.REPOSITORY_PATH }}/.mvn/ci-settings.xml ~/.m2/settings.xml - build-and-test-plugins: - needs: build-and-test-core - strategy: - fail-fast: false - matrix: - javaVersion: [8, 11] - os: [windows-latest, ubuntu-latest] - runs-on: ${{ matrix.os }} + - name: Resolve non-cobigen dependencies + shell: bash + run: | + cd ${{ env.REPOSITORY_PATH }} + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.2:resolve -pl !com.devonfw.cobigen:com.devonfw.cobigen.eclipse.test -DexcludeGroupIds=com.devonfw.cobigen -T1C -Pp2-build ${{ env.MVN_BATCH_MODE }} ${{ env.MVN_HTTP_OPTIMIZATION }} || true # never fail + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.2:resolve-plugins -pl !com.devonfw.cobigen:com.devonfw.cobigen.eclipse.test -DexcludeGroupIds=com.devonfw.cobigen -T1C -Pp2-build ${{ env.MVN_BATCH_MODE }} ${{ env.MVN_HTTP_OPTIMIZATION }} || true # never fail + build: + needs: cache-dependencies + runs-on: ubuntu-latest steps: - - uses: devonfw-actions/java-maven-setup@main + - name: Enable git support for long paths on Windows + if: ${{ runner.os == 'Windows' }} + shell: cmd + run: git config --system core.longpaths true + + - name: Clone Repository + uses: actions/checkout@v3 with: - maven-cache-key: ${{ runner.os }}-${{ matrix.javaVersion }}-maven-${{ github.sha }}-plugins # new key will cache - maven-cache-restore-key: ${{ runner.os }}-${{ matrix.javaVersion }}-maven-${{ github.sha }} - java-version: ${{ matrix.javaVersion }} - jacoco-cache-key: ${{ runner.os }}-${{ matrix.javaVersion }}-jacoco-${{ github.sha }}-plugins # new key will cache - jacoco-cache-restore-key: ${{ runner.os }}-${{ matrix.javaVersion }}-jacoco-${{ github.sha }}-core-test # hit - restore - - - name: Build & Test Plugins - shell: bash - run: mvn install -f cobigen-plugins ${{ env.MVN_BATCH_MODE }} ${{ env.MVN_HTTP_OPTIMIZATION }} ${{ env.MVN_TEST_COVERAGE }} + path: ${{ env.REPOSITORY_PATH }} - build-plugins-p2: - needs: build-and-test-plugins - strategy: - fail-fast: false - matrix: - javaVersion: [8] - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - - steps: - - uses: devonfw-actions/java-maven-setup@main + - name: Checkout & Prepare + uses: devonfw-actions/java-maven-setup@main with: - maven-cache-key: ${{ runner.os }}-${{ matrix.javaVersion }}-maven-${{ github.sha }}-plugins # key hit will not update cache - java-version: ${{ matrix.javaVersion }} + maven-cache-path: ./.m2/repository + maven-cache-key: maven-${{ github.sha }}-${{ github.run_number }} # new key will cache + maven-cache-restore-key: cobigen-dep-${{ hashFiles(format('{0}/**/pom.xml', env.REPOSITORY_PATH)) }} + java-version: 11 + clone: false # checkout in a separate / earlier step to allow eager evaluation of parameter expression like workspace or hashFiles - - name: Cache p2 plugin repositories + - name: Cache built P2 repositories uses: actions/cache@v3 with: - path: ./**/target/repository/ - key: p2-plugins-${{ github.sha }} # new key will cache - - - name: Build Plugins UpdateSite + path: ./${{ env.REPOSITORY_PATH }}/**/target/repository/ + key: p2-${{ github.sha }}-${{ github.run_number }} # new key will cache + enableCrossOsArchive: true + + - name: Build all artifacts shell: bash run: | - mvn package -DskipTests -f cobigen-plugins bundle:bundle -Pp2-bundle --projects !cobigen-javaplugin-parent/cobigen-javaplugin-model,!cobigen-openapiplugin-parent/cobigen-openapiplugin-model,!:plugins-parent,!cobigen-javaplugin-parent,!cobigen-openapiplugin-parent,!cobigen-templateengines ${{ env.MVN_BATCH_MODE }} ${{ env.MVN_HTTP_OPTIMIZATION }} - mvn install -DskipTests -f cobigen-plugins bundle:bundle -Pp2-bundle p2:site --projects !cobigen-javaplugin-parent/cobigen-javaplugin-model,!cobigen-openapiplugin-parent/cobigen-openapiplugin-model,!:plugins-parent,!cobigen-javaplugin-parent,!cobigen-openapiplugin-parent,!cobigen-templateengines ${{ env.MVN_BATCH_MODE }} ${{ env.MVN_HTTP_OPTIMIZATION }} - - run-core-systemtest: - needs: build-and-test-plugins + cd ${{ env.REPOSITORY_PATH }} + ./build.sh -spb + + test: + needs: build strategy: fail-fast: false matrix: - javaVersion: [8, 11] + component: [core, plugins, templates, maven, eclipse, cli] + javaVersion: [11] os: [windows-latest, ubuntu-latest] runs-on: ${{ matrix.os }} - steps: - - uses: devonfw-actions/java-maven-setup@main + - name: Enable git support for long paths on Windows + if: ${{ runner.os == 'Windows' }} + shell: cmd + run: git config --system core.longpaths true + + - name: Clone Repository + uses: actions/checkout@v3 with: - maven-cache-key: ${{ runner.os }}-${{ matrix.javaVersion }}-maven-${{ github.sha }}-plugins # key hit will not update cache - java-version: ${{ matrix.javaVersion }} - jacoco-cache-key: ${{ runner.os }}-${{ matrix.javaVersion }}-jacoco-${{ github.sha }}-core-systemtest # new key will cache + path: ${{ env.REPOSITORY_PATH }} - - name: Run Core Systemtest - shell: bash - run: mvn install -f cobigen/cobigen-core-systemtest ${{ env.MVN_BATCH_MODE }} ${{ env.MVN_HTTP_OPTIMIZATION }} ${{ env.MVN_TEST_COVERAGE }} - - build-and-test-eclipse-plugin: - needs: build-plugins-p2 - strategy: - fail-fast: false - matrix: - javaVersion: [8, 11] - os: [windows-latest, ubuntu-latest] - runs-on: ${{ matrix.os }} - - steps: - uses: devonfw-actions/java-maven-setup@main with: - maven-cache-key: ${{ runner.os }}-${{ matrix.javaVersion }}-maven-${{ github.sha }}-plugins # key hit will not update cache + maven-cache-path: ./.m2/repository + maven-cache-key: maven-${{ github.sha }}-${{ github.run_number }} # match, restore only java-version: ${{ matrix.javaVersion }} - jacoco-cache-key: ${{ runner.os }}-${{ matrix.javaVersion }}-jacoco-${{ github.sha }}-eclipse # new key will cache - - - name: Cache Eclipse repository - uses: actions/cache@v3 - with: - path: ./**/eclipse/target/repository/ - key: p2-eclipse-${{ github.sha }} # new key will cache + jacoco-cache-key: jacoco-${{ github.sha }}-${{ matrix.component }} # new key will cache + clone: false # checkout in a separate / earlier step to allow eager evaluation of parameter expression like workspace or hashFiles - # After checkout we need to restore the built repositories - - name: Restore P2 plugins repositories + - name: Restore built P2 repositories uses: actions/cache@v3 with: - path: ./**/target/repository/ - key: p2-plugins-${{ github.sha }} # key hit will not update cache - - # There is no retry for jobs, just for steps, so doing the retry by hand - - name: Build Plugins - uses: GabrielBB/xvfb-action@v1.5 - with: - run: mvn install -f cobigen-eclipse -Pp2-build ${{ env.MVN_BATCH_MODE }} ${{ env.MVN_HTTP_OPTIMIZATION }} ${{ env.MVN_TEST_COVERAGE }} - - build-and-test-maven-plugin: - needs: build-and-test-plugins - strategy: - fail-fast: false - matrix: - javaVersion: [8, 11] - os: [windows-latest, ubuntu-latest] - runs-on: ${{ matrix.os }} - - steps: - - uses: devonfw-actions/java-maven-setup@main - with: - maven-cache-key: ${{ runner.os }}-${{ matrix.javaVersion }}-maven-${{ github.sha }}-maven # new key will cache - maven-cache-restore-key: ${{ runner.os }}-${{ matrix.javaVersion }}-maven-${{ github.sha }}-plugins - java-version: ${{ matrix.javaVersion }} - jacoco-cache-key: ${{ runner.os }}-${{ matrix.javaVersion }}-jacoco-${{ github.sha }}-maven # new key will cache - - - name: Build & Test Maven Plugin - shell: bash - run: | - mvn install -f cobigen-maven ${{ env.MVN_BATCH_MODE }} ${{ env.MVN_HTTP_OPTIMIZATION }} ${{ env.MVN_TEST_COVERAGE }} - - build-and-test-cli: - needs: build-and-test-templates - strategy: - fail-fast: false - matrix: - javaVersion: [11] # CLI does not support jdk 8 anymore - os: [windows-latest, ubuntu-latest] - runs-on: ${{ matrix.os }} - - steps: - - uses: devonfw-actions/java-maven-setup@main - with: - maven-cache-key: ${{ runner.os }}-${{ matrix.javaVersion }}-maven-${{ github.sha }}-cli # new key will cache - maven-cache-restore-key: ${{ runner.os }}-${{ matrix.javaVersion }}-maven-${{ github.sha }}-templates - java-version: ${{ matrix.javaVersion }} - jacoco-cache-key: ${{ runner.os }}-${{ matrix.javaVersion }}-jacoco-${{ github.sha }}-cli # new key will cache - - - name: Build & Test CLI + path: ./${{ env.REPOSITORY_PATH }}/**/target/repository/ + key: p2-${{ github.sha }}-${{ github.run_number }} # match, restore only + enableCrossOsArchive: true + + # need to overwrite global settings file to cath all mvn executions properly in tests + - name: Overwrite maven settings shell: bash run: | - mvn install -f cobigen-cli ${{ env.MVN_BATCH_MODE }} ${{ env.MVN_HTTP_OPTIMIZATION }} ${{ env.MVN_TEST_COVERAGE }} - - build-and-test-templates: - needs: build-and-test-maven-plugin - strategy: - fail-fast: false - matrix: - javaVersion: [8, 11] - os: [windows-latest, ubuntu-latest] - runs-on: ${{ matrix.os }} - - steps: - - uses: devonfw-actions/java-maven-setup@main - with: - maven-cache-key: ${{ runner.os }}-${{ matrix.javaVersion }}-maven-${{ github.sha }}-templates # new key will cache - maven-cache-restore-key: ${{ runner.os }}-${{ matrix.javaVersion }}-maven-${{ github.sha }}-maven - java-version: ${{ matrix.javaVersion }} - jacoco-cache-key: ${{ runner.os }}-${{ matrix.javaVersion }}-jacoco-${{ github.sha }}-templates # new key will cache + mkdir -p ~/.m2 + cp -rf ${{ env.REPOSITORY_PATH }}/.mvn/ci-settings.xml ~/.m2/settings.xml - - name: Build & Test Templates + - name: Test shell: bash + env: + M2_REPO: ${{ github.workspace }}/.m2/repository # fix for https://github.com/m-m-m/code/issues/43 run: | - mvn install -f cobigen-templates ${{ env.MVN_BATCH_MODE }} ${{ env.MVN_HTTP_OPTIMIZATION }} ${{ env.MVN_TEST_COVERAGE }} - - sonar-analysis: - needs: [build-and-test-maven-plugin, build-and-test-templates, run-core-systemtest, build-and-test-eclipse-plugin, build-and-test-cli] + cd ${{ env.REPOSITORY_PATH }} + if [[ "${{ matrix.component }}" == "eclipse" && "${{ matrix.os }}" == "ubuntu-latest" ]] + then + xvfb-run -a ./build.sh -sdtcb --components ${{ matrix.component }} + else + ./build.sh -sdtcb --components ${{ matrix.component }} + fi + + # Sonar Analysis is done in separate workflow (https://github.com/devonfw/cobigen/blob/master/.github/workflows/sonar-analysis.yml) + # as of a workaround of potential secret leaking on PRs (https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) + sonar-analysis-preparation: + needs: [test] runs-on: ubuntu-latest steps: - - name: Cache SonarCloud packages - uses: actions/cache@v3 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - - - uses: devonfw-actions/java-maven-setup@main - with: - maven-cache-key: cobigen-dep-${{ hashFiles('**/pom.xml') }} - jacoco-cache-key: Linux-11-jacoco-${{ github.sha }}-cli # hit - restore - - # Restore other parallel results as well - seems that for any reason I could not reuse caches incrementally... need to restore all caches - - name: Restore eclipse test results - uses: actions/cache@v3 - with: - path: | - **/*.exec - **/failsafe-reports/**/* - **/surefire-reports/**/* - key: Linux-11-jacoco-${{ github.sha }}-eclipse # hit - restore - - - name: Restore core systemtest results - uses: actions/cache@v3 - with: - path: | - **/*.exec - **/failsafe-reports/**/* - **/surefire-reports/**/* - key: Linux-11-jacoco-${{ github.sha }}-core-systemtest # hit - restore - - - name: Restore core template test results - uses: actions/cache@v3 - with: - path: | - **/*.exec - **/failsafe-reports/**/* - **/surefire-reports/**/* - key: Linux-11-jacoco-${{ github.sha }}-templates # hit - restore - - - name: Restore core maven results - uses: actions/cache@v3 - with: - path: | - **/*.exec - **/failsafe-reports/**/* - **/surefire-reports/**/* - key: Linux-11-jacoco-${{ github.sha }}-maven # hit - restore - - - name: Restore core plugin test results - uses: actions/cache@v3 - with: - path: | - **/*.exec - **/failsafe-reports/**/* - **/surefire-reports/**/* - key: Linux-11-jacoco-${{ github.sha }}-plugins # hit - restore - - - name: Restore core cli test results - uses: actions/cache@v3 - with: - path: | - **/*.exec - **/failsafe-reports/**/* - **/surefire-reports/**/* - key: Linux-11-jacoco-${{ github.sha }}-cli # hit - restore - - - name: SonarCloud Analysis + - name: 'Prepare workflow context for transfer' env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + # As a precaution, reference this value by an interpolated ENV var; + # instead of interpolating user controllable input directly in the shell script. + PR_TITLE: ${{ github.event.pull_request.title }} run: | - git fetch --unshallow - mvn verify sonar:sonar -DskipTests ${{ env.MVN_BATCH_MODE }} ${{ env.MVN_HTTP_OPTIMIZATION }} ${{ env.MVN_TEST_COVERAGE }} + # Save ENV for transfer + { + echo "PR_HEADSHA=${{ github.event.pull_request.head.sha }}" + echo "PR_NUMBER=${{ github.event.pull_request.number }}" + echo "PR_TITLE=${PR_TITLE}" + } >> workflow.env + tar --zstd -cf workflow.tar.zst workflow.env + + - name: 'Upload workflow context artifact' + uses: actions/upload-artifact@v3 + with: + name: maven-build-test-workflow-context + path: workflow.tar.zst + retention-days: 1 release: - needs: [build-and-test-maven-plugin, build-and-test-templates, run-core-systemtest, build-and-test-eclipse-plugin, build-and-test-cli] + needs: [test] runs-on: ubuntu-latest if: ${{ startsWith(github.repository, 'devonfw/') && github.ref == 'refs/heads/master' }} continue-on-error: true @@ -318,14 +187,21 @@ jobs: outputs: release_tag: ${{ steps.get_tag.outputs.tag }} steps: + - name: Clone Repository + uses: actions/checkout@v3 + with: + path: ${{ env.REPOSITORY_PATH }} + - uses: devonfw-actions/java-maven-setup@main with: - maven-cache-key: cobigen-dep-${{ hashFiles('**/pom.xml') }} + maven-cache-path: ./.m2/repository + maven-cache-key: cobigen-dep-${{ hashFiles(format('{0}/**/pom.xml', env.REPOSITORY_PATH)) }} GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} BUILD_USER: ${{ secrets.BUILD_USER }} BUILD_USER_PASSWD: ${{ secrets.BUILD_USER_PASSWD }} BUILD_USER_EMAIL: ${{ secrets.BUILD_USER_EMAIL }} + clone: false # checkout in a separate / earlier step to allow eager evaluation of parameter expression like workspace or hashFiles - name: Release id: release @@ -338,7 +214,9 @@ jobs: BUILD_USER: ${{ secrets.BUILD_USER }} BUILD_USER_PASSWD: ${{ secrets.BUILD_USER_PASSWD }} BUILD_USER_EMAIL: ${{ secrets.BUILD_USER_EMAIL }} - run: ./release.sh silent skip-qa repo-mvn-settings + run: | + cd ${{ env.REPOSITORY_PATH }} + ./release.sh -syb skip-qa - name: 'Get release tag' id: get_tag diff --git a/.gitignore b/.gitignore index 6e1889c17b..978e10ba4f 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,19 @@ objectdb #Intellij .idea -*.iml \ No newline at end of file +*.iml +/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets_downloaded/template-sets/downloaded/crud-java-server-app-test.jar +/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplateSetConfigurationReaderTest/valid_template_sets/template-sets/downloaded/crud-java-server-app-test.jar +/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/downloaded/crud-java-server-app-test.jar +/cobigen/cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/downloaded/downloaded-template-set1-test-test.jar +/cobigen/cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/downloaded/downloaded-template-set2-test-test.jar +cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/downloaded/downloaded-template-set2-test-test.jar +cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/GenerationTestTemplateSetsXml/template-sets/downloaded/downloaded-template-set1-test-test.jar +cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/downloaded/crud-java-server-app-1.0.0.jar +cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/downloaded/crud-java-server-app-1.0.0-sources.jar +cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/downloaded/crud-java-server-app-complex-1.0.0.jar +cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/downloaded/crud-java-server-app-complex-1.0.0-sources.jar +cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateProcessingTest/template-sets/downloaded/crud-java-server-app-1.0.0.jar +cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateProcessingTest/template-sets/downloaded/crud-java-server-app-1.0.0-sources.jar +cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateProcessingTest/template-sets/downloaded/crud-java-server-app-complex-1.0.0.jar +cobigen/cobigen-core-systemtest/src/test/resources/testdata/systemtest/TemplateProcessingTest/template-sets/downloaded/crud-java-server-app-complex-1.0.0-sources.jar diff --git a/.mvn/settings.xml b/.mvn/ci-settings.xml similarity index 88% rename from .mvn/settings.xml rename to .mvn/ci-settings.xml index f979f4ceef..2fa62a2620 100644 --- a/.mvn/settings.xml +++ b/.mvn/ci-settings.xml @@ -1,5 +1,6 @@ + ${GITHUB_WORKSPACE}/.m2/repository sonartype.releases diff --git a/README.asciidoc b/README.asciidoc index ab439dcfed..190b8a8158 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -43,7 +43,7 @@ The CobiGen repository is organized in a one-branch-per-plugin schema. By that, == Build -`bash build.sh` (on windows use git bash) +`./build.sh -h` (on windows use git bash) == Deploy diff --git a/build.sh b/build.sh index 4fc99d6232..d11bfb4998 100755 --- a/build.sh +++ b/build.sh @@ -7,28 +7,42 @@ echo "" if [[ "$NO_CLEAN" = false ]] then -log_step "Cleanup Projects" -doRunCommand "mvn clean $MVN_SETTINGS $PARALLELIZED $BATCH_MODE $DEBUG" + log_step "Cleanup Projects" + doRunCommand "mvn clean $MVN_SETTINGS $PARALLELIZED $BATCH_MODE $DEBUG" fi -log_step "Build & Test Core" -doRunCommand "mvn install $MVN_SETTINGS -f cobigen --projects !cobigen-core-systemtest $COVERAGE $ENABLED_TEST $DEBUG $PARALLELIZED $BATCH_MODE" +if [[ " ${COMPONENTS_TO_BUILD[*]} " =~ " core " ]]; then + log_step "Build & Test Core" + doRunCommand "mvn install $MVN_SETTINGS -f cobigen --projects !cobigen-core-systemtest $COVERAGE $ENABLED_TEST $DEBUG $PARALLELIZED $BATCH_MODE" +fi -log_step "Build & Test Core Plugins" -doRunCommand "mvn install $MVN_SETTINGS -f cobigen-plugins $COVERAGE $ENABLED_TEST $DEBUG $PARALLELIZED $BATCH_MODE" +if [[ " ${COMPONENTS_TO_BUILD[*]} " =~ " plugins " ]]; then + log_step "Build & Test Core Plugins" + doRunCommand "mvn install $MVN_SETTINGS -f cobigen-plugins $COVERAGE $ENABLED_TEST $DEBUG $PARALLELIZED $BATCH_MODE" -log_step "Build Core Plugins - P2 Update Sites" -doRunCommand "mvn package $MVN_SETTINGS bundle:bundle -Pp2-build,p2-bundle -DskipTests -f cobigen-plugins --projects !cobigen-javaplugin-parent/cobigen-javaplugin-model,!cobigen-openapiplugin-parent/cobigen-openapiplugin-model,!:plugins-parent,!cobigen-javaplugin-parent,!cobigen-openapiplugin-parent,!cobigen-templateengines $DEBUG $PARALLELIZED $BATCH_MODE -Dupdatesite.repository=$DEPLOY_UPDATESITE" -doRunCommand "mvn install $MVN_SETTINGS bundle:bundle -Pp2-build,p2-bundle -DskipTests p2:site -f cobigen-plugins --projects !cobigen-javaplugin-parent/cobigen-javaplugin-model,!cobigen-openapiplugin-parent/cobigen-openapiplugin-model,!:plugins-parent,!cobigen-javaplugin-parent,!cobigen-openapiplugin-parent,!cobigen-templateengines $DEBUG $PARALLELIZED $BATCH_MODE -Dupdatesite.repository=$DEPLOY_UPDATESITE" + log_step "Build Core Plugins - P2 Update Sites" + doRunCommand "mvn package $MVN_SETTINGS bundle:bundle -Pp2-build,p2-bundle -DskipTests -f cobigen-plugins --projects !cobigen-javaplugin-parent/cobigen-javaplugin-model,!cobigen-openapiplugin-parent/cobigen-openapiplugin-model,!:plugins-parent,!cobigen-javaplugin-parent,!cobigen-openapiplugin-parent,!cobigen-templateengines $DEBUG $PARALLELIZED $BATCH_MODE -Dupdatesite.repository=$DEPLOY_UPDATESITE" + doRunCommand "mvn install $MVN_SETTINGS bundle:bundle -Pp2-build,p2-bundle -DskipTests p2:site -f cobigen-plugins --projects !cobigen-javaplugin-parent/cobigen-javaplugin-model,!cobigen-openapiplugin-parent/cobigen-openapiplugin-model,!:plugins-parent,!cobigen-javaplugin-parent,!cobigen-openapiplugin-parent,!cobigen-templateengines $DEBUG $PARALLELIZED $BATCH_MODE -Dupdatesite.repository=$DEPLOY_UPDATESITE" +fi log_step "Package & Run E2E Tests" -doRunCommand "mvn integration-test $MVN_SETTINGS -f cobigen/cobigen-core-systemtest $COVERAGE $ENABLED_TEST $DEBUG $BATCH_MODE" -doRunCommand "mvn install $MVN_SETTINGS -f cobigen-cli $COVERAGE $ENABLED_TEST $DEBUG $BATCH_MODE" -doRunCommand "mvn install $MVN_SETTINGS -f cobigen-maven $COVERAGE $ENABLED_TEST $DEBUG $BATCH_MODE" -doRunCommand "mvn install $MVN_SETTINGS -f cobigen-templates $COVERAGE $ENABLED_TEST $DEBUG $BATCH_MODE" -doRunCommand "mvn install $MVN_SETTINGS -f cobigen-eclipse -Pp2-build $COVERAGE $ENABLED_TEST $DEBUG $BATCH_MODE" +if [[ " ${COMPONENTS_TO_BUILD[*]} " =~ " core " ]]; then + doRunCommand "mvn integration-test $MVN_SETTINGS -f cobigen/cobigen-core-systemtest $COVERAGE $ENABLED_TEST $DEBUG $BATCH_MODE" +fi +if [[ " ${COMPONENTS_TO_BUILD[*]} " =~ " cli " ]]; then + doRunCommand "mvn install $MVN_SETTINGS -f cobigen-cli $COVERAGE $ENABLED_TEST $DEBUG $BATCH_MODE" +fi +if [[ " ${COMPONENTS_TO_BUILD[*]} " =~ " maven " ]]; then + doRunCommand "mvn install $MVN_SETTINGS -f cobigen-maven $COVERAGE $ENABLED_TEST $DEBUG $BATCH_MODE" +fi +if [[ " ${COMPONENTS_TO_BUILD[*]} " =~ " templates " ]]; then + doRunCommand "mvn install $MVN_SETTINGS -f cobigen-templates $COVERAGE $ENABLED_TEST $DEBUG $BATCH_MODE" +fi +if [[ " ${COMPONENTS_TO_BUILD[*]} " =~ " eclipse " ]]; then + doRunCommand "mvn install $MVN_SETTINGS -f cobigen-eclipse -Pp2-build $COVERAGE $ENABLED_TEST $DEBUG $BATCH_MODE" +fi -if [[ -n "$COVERAGE" ]] +if [[ "$COV_REPORT" = true ]] then doRunCommand "mvn -DskipTests verify $COVERAGE $DEBUG $PARALLELIZED $BATCH_MODE" fi diff --git a/cobigen-cli/cli-systemtest/pom.xml b/cobigen-cli/cli-systemtest/pom.xml index 0bb50b98ad..d1d14b8730 100644 --- a/cobigen-cli/cli-systemtest/pom.xml +++ b/cobigen-cli/cli-systemtest/pom.xml @@ -12,6 +12,9 @@ src\test\resources\testdata\localmavenproject\maven.project src\test\resources\testdata\templatesproject\templates-devon4j + src\test\resources\testdata\templatesproject\template-sets\downloaded\crud-java-server-app + src\test\resources\testdata\AdaptTemplatesCommandIT\template-sets\adapted\crud-java-server-app + src\test\resources\testdata\AdaptTemplatesCommandIT\template-sets\adapted\crud-java-server-app-complex @@ -111,6 +114,63 @@ + + Install test template set downloaded project + test-compile + + exec + + + mvn + ${maven.test.templateset.downloaded.path} + + install + + -Djansi.force=true + -Djansi.passthrough=true + -B + -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn + + + + + Install AdaptTemplatesCommandIT downloaded project1 + test-compile + + exec + + + mvn + ${maven.test.AdaptTemplatesCommandIT.downloaded.path1} + + install + + -Djansi.force=true + -Djansi.passthrough=true + -B + -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn + + + + + Install AdaptTemplatesCommandIT downloaded project2 + test-compile + + exec + + + mvn + ${maven.test.AdaptTemplatesCommandIT.downloaded.path2} + + install + + -Djansi.force=true + -Djansi.passthrough=true + -B + -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn + + + diff --git a/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/AbstractCliTest.java b/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/AbstractCliTest.java index 0b0798d0f5..c49917f5b3 100644 --- a/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/AbstractCliTest.java +++ b/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/AbstractCliTest.java @@ -7,16 +7,22 @@ import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.codehaus.plexus.archiver.tar.TarGZipUnArchiver; import org.codehaus.plexus.logging.console.ConsoleLoggerManager; import org.codehaus.plexus.util.Os; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Rule; import org.junit.rules.TemporaryFolder; +import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.zeroturnaround.exec.ProcessExecutor; import org.zeroturnaround.exec.ProcessResult; @@ -30,6 +36,9 @@ /** Common test implementation for CLI tests */ public class AbstractCliTest { + /** Logger instance. */ + private static final Logger LOG = LoggerFactory.getLogger(AbstractCliTest.class); + /** Java tool options */ private static final String JAVA_TOOL_OPTIONS = "CGCLI_JAVA_OPTIONS"; @@ -37,23 +46,87 @@ public class AbstractCliTest { @Rule public TemporaryFolder tempFolder = new TemporaryFolder(); + /** Temporary directory for the templates project */ + @ClassRule + public static TemporaryFolder tempFolderTemplates = new TemporaryFolder(); + /** Current home directory */ protected Path currentHome; - /** The devon4j-templates development folder */ + /** The templates development folder */ protected static Path devTemplatesPath; + /** A temp directory containing the templates development folder */ + protected static Path devTemplatesPathTemp; + /** - * Determine the devon4j-templates development folder + * Determine the templates development folder and create a copy of it in the temp directory + * + * TODO: Replace with reduced template set projects in test resources, see: + * https://github.com/devonfw/cobigen/issues/1659 * * @throws URISyntaxException if the path could not be created properly + * @throws IOException if accessing a template directory directory fails */ @BeforeClass - public static void determineDevTemplatesPath() throws URISyntaxException { + public static void determineDevTemplatesPath() throws URISyntaxException, IOException { devTemplatesPath = new File(AbstractCliTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()) + .getParentFile().getParentFile().getParentFile().getParentFile().toPath().resolve("cobigen-templates"); + + Path utilsPom = new File(AbstractCliTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()) .getParentFile().getParentFile().getParentFile().getParentFile().toPath().resolve("cobigen-templates") - .resolve("templates-devon4j"); + .resolve("templates-devon4j-tests/src/test/resources/utils/pom.xml"); + + // create a temporary directory cobigen-templates/template-sets/adapted containing the template sets + Path tempFolderPath = tempFolderTemplates.getRoot().toPath(); + Path cobigenTemplatePath = tempFolderPath.resolve("cobigen-templates"); + if (!Files.exists(cobigenTemplatePath)) { + Files.createDirectory(cobigenTemplatePath); + + devTemplatesPathTemp = cobigenTemplatePath.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER); + Path templateSetsAdaptedFolder = devTemplatesPathTemp.resolve(ConfigurationConstants.ADAPTED_FOLDER); + Files.createDirectory(devTemplatesPathTemp); + Files.createDirectory(templateSetsAdaptedFolder); + + FileUtils.copyDirectory(devTemplatesPath.toFile(), templateSetsAdaptedFolder.toFile()); + + List devTemplateSets = new ArrayList<>(); + try (Stream files = Files.list(templateSetsAdaptedFolder)) { + files.forEach(path -> { + devTemplateSets.add(path); + }); + } + + for (Path path : devTemplateSets) { + if (Files.isDirectory(path)) { + Path resourcesFolder = path.resolve("src/main/resources"); + Path templatesFolder = path.resolve(ConfigurationConstants.MAVEN_CONFIGURATION_RESOURCE_FOLDER); + if (Files.exists(resourcesFolder) && !Files.exists(templatesFolder)) { + try { + Files.move(resourcesFolder, templatesFolder); + } catch (IOException e) { + throw new IOException("Error moving directory " + resourcesFolder, e); + } + } + + // Replace the pom.xml in the template sets. Needed so that the project in the temp directory is build + // properly + if (Files.exists(path.resolve("pom.xml"))) { + try { + Files.delete(path.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error deleting file " + path.resolve("pom.xml"), e); + } + try { + Files.copy(utilsPom, path.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error copying file " + utilsPom, e); + } + } + } + } + } } /** @@ -76,7 +149,7 @@ public void runWithLatestTemplates() throws IOException { Path configFile = this.currentHome.resolve(ConfigurationConstants.COBIGEN_CONFIG_FILE); Files.write(configFile, - (ConfigurationConstants.CONFIG_PROPERTY_TEMPLATES_PATH + "=" + devTemplatesPath.toString()).getBytes()); + (ConfigurationConstants.CONFIG_PROPERTY_TEMPLATES_PATH + "=" + devTemplatesPathTemp.toString()).getBytes()); } /** @@ -88,15 +161,27 @@ protected void execute(String[] args, boolean useDevTemplates) throws Exception execute(args, useDevTemplates, false); } + /** + * @see #execute(String[], boolean, boolean) + */ + @SuppressWarnings("javadoc") + protected void execute(String[] args, boolean useDevTemplates, boolean assureFailure) throws Exception { + + execute(args, useDevTemplates, assureFailure, false); + } + /** * This method check the return code from picocli * * @param args execution arguments * @param useDevTemplates use development devon4j-templates * @param assureFailure assure failure instead of success of the command execution + * @param allowMonolithicConfiguration ignores deprecated monolithic template folder structure and if found does not + * throw a DeprecatedMonolithicConfigurationException * @throws Exception error */ - protected void execute(String[] args, boolean useDevTemplates, boolean assureFailure) throws Exception { + protected void execute(String[] args, boolean useDevTemplates, boolean assureFailure, + boolean allowMonolithicConfiguration) throws Exception { if (useDevTemplates) { runWithLatestTemplates(); @@ -130,11 +215,21 @@ protected void execute(String[] args, boolean useDevTemplates, boolean assureFai i++; } - if (useDevTemplates) { + if (useDevTemplates && !allowMonolithicConfiguration) { debugArgs = Arrays.copyOf(debugArgs, debugArgs.length + 3); debugArgs[debugArgs.length - 3] = "-v"; debugArgs[debugArgs.length - 2] = "-tp"; - debugArgs[debugArgs.length - 1] = devTemplatesPath.toString(); + debugArgs[debugArgs.length - 1] = devTemplatesPathTemp.toString(); + } else if (useDevTemplates && allowMonolithicConfiguration) { + debugArgs = Arrays.copyOf(debugArgs, debugArgs.length + 4); + debugArgs[debugArgs.length - 4] = "--force-mc"; + debugArgs[debugArgs.length - 3] = "-v"; + debugArgs[debugArgs.length - 2] = "-tp"; + debugArgs[debugArgs.length - 1] = devTemplatesPathTemp.toString(); + } else if (allowMonolithicConfiguration) { + debugArgs = Arrays.copyOf(debugArgs, debugArgs.length + 2); + debugArgs[debugArgs.length - 2] = "--force-mc"; + debugArgs[debugArgs.length - 1] = "-v"; } else { debugArgs = Arrays.copyOf(debugArgs, debugArgs.length + 1); debugArgs[debugArgs.length - 1] = "-v"; @@ -147,11 +242,15 @@ protected void execute(String[] args, boolean useDevTemplates, boolean assureFai .redirectOutput(Slf4jStream.of(LoggerFactory.getLogger(getClass().getName() + ".cliprocess")).asInfo()); // enable jacoco coverage monitoring for external processes (especially for CI/CD) - if (!StringUtils.isEmpty(MavenMetadata.JACOCO_AGENT_ARGS)) { + if (!StringUtils.isEmpty(MavenMetadata.JACOCO_AGENT_ARGS) + && !StringUtils.startsWith(MavenMetadata.JACOCO_AGENT_ARGS, "$")) { pe.environment(JAVA_TOOL_OPTIONS, MavenMetadata.JACOCO_AGENT_ARGS + // .replaceFirst("destfile=[^,]+(,)?", "") // + ",output=tcpclient,sessionid=test,inclnolocationclasses=true,inclbootstrapclasses=true " + "" + (System.getenv(JAVA_TOOL_OPTIONS) == null ? "" : " " + System.getenv(JAVA_TOOL_OPTIONS))); + } else { + LOG.warn("No value for JACOCO is set!"); } new SystemExit().execute(() -> { diff --git a/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/AdaptTemplatesCommandIT.java b/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/AdaptTemplatesCommandIT.java index a47d183749..3edff96f91 100644 --- a/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/AdaptTemplatesCommandIT.java +++ b/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/AdaptTemplatesCommandIT.java @@ -3,44 +3,136 @@ import static org.assertj.core.api.Assertions.assertThat; import java.io.File; +import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; +import org.apache.commons.io.FileUtils; import org.junit.Test; import com.devonfw.cobigen.api.constants.ConfigurationConstants; +import com.devonfw.cobigen.api.util.TemplatesJarUtil; /** * Tests the usage of the adapt-templates command. */ public class AdaptTemplatesCommandIT extends AbstractCliTest { + /** Test resources root path */ + private static String testFileRootPath = "src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/downloaded"; + /** - * Checks if adapt-templates command successfully created cobigen templates folder and its sub folders + * Checks if adapt-templates command successfully created adapted folder and its sub folders * * @throws Exception test fails */ @Test - public void adaptTemplatesTest() throws Exception { + public void adaptTemplateSetTest() throws Exception { - String args[] = new String[1]; + Path downloadedTemplateSetsPath = this.currentHome.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER) + .resolve(ConfigurationConstants.DOWNLOADED_FOLDER); + if (!Files.exists(downloadedTemplateSetsPath)) { + Files.createDirectories(downloadedTemplateSetsPath); + } + FileUtils.copyDirectory(new File(testFileRootPath), downloadedTemplateSetsPath.toFile()); + String args[] = new String[2]; args[0] = "adapt-templates"; + args[1] = "--all"; execute(args, false); - Path cobigenTemplatesFolderPath = this.currentHome.resolve(ConfigurationConstants.TEMPLATES_FOLDER) - .resolve(ConfigurationConstants.COBIGEN_TEMPLATES); - assertThat(cobigenTemplatesFolderPath).exists(); - // check if templates exist - assertThat(Paths - .get(cobigenTemplatesFolderPath.toString() + File.separator + ConfigurationConstants.TEMPLATE_RESOURCE_FOLDER)) + Path cobigenTemplateSetsFolderPath = this.currentHome.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER); + Path downloadedTemplateSetsFolderPath = cobigenTemplateSetsFolderPath + .resolve(ConfigurationConstants.DOWNLOADED_FOLDER); + Path adaptedTemplateSetsFolderPath = cobigenTemplateSetsFolderPath.resolve(ConfigurationConstants.ADAPTED_FOLDER); + + assertThat(cobigenTemplateSetsFolderPath).exists(); + assertThat(downloadedTemplateSetsFolderPath).exists(); + assertThat(adaptedTemplateSetsFolderPath).exists(); + + Path templateSetSimple = adaptedTemplateSetsFolderPath.resolve("crud-java-server-app-1.0.0"); + Path templateSetComplex = adaptedTemplateSetsFolderPath.resolve("crud-java-server-app-complex-1.0.0"); + + // check if adapted template set exists + assertThat(templateSetSimple).exists(); + assertThat(templateSetComplex).exists(); + + Path templateSetResourcesPath = templateSetSimple + .resolve(ConfigurationConstants.MAVEN_CONFIGURATION_RESOURCE_FOLDER); + Path templateSetResourcesPathComplex = templateSetComplex + .resolve(ConfigurationConstants.MAVEN_CONFIGURATION_RESOURCE_FOLDER); + + // check if templates folder exists + assertThat(templateSetSimple.resolve(templateSetResourcesPath).resolve(ConfigurationConstants.TEMPLATES_FOLDER)) + .exists(); + assertThat( + templateSetComplex.resolve(templateSetResourcesPathComplex).resolve(ConfigurationConstants.TEMPLATES_FOLDER)) .exists(); + + // check if template-set.xml exists + assertThat(templateSetSimple.resolve(templateSetResourcesPath) + .resolve(ConfigurationConstants.TEMPLATE_SET_CONFIG_FILENAME)).exists(); + assertThat(templateSetComplex.resolve(templateSetResourcesPathComplex) + .resolve(ConfigurationConstants.TEMPLATE_SET_CONFIG_FILENAME)).exists(); + + // validate correct folder structure + assertThat(templateSetSimple.resolve(templateSetResourcesPath) + .resolve(ConfigurationConstants.TEMPLATE_SET_FREEMARKER_FUNCTIONS_FILE_NAME)).exists(); + assertThat(templateSetComplex.resolve(templateSetResourcesPathComplex) + .resolve(ConfigurationConstants.TEMPLATE_SET_FREEMARKER_FUNCTIONS_FILE_NAME)).exists(); + + // check if template set utility resource folder exists + assertThat(templateSetSimple.resolve(ConfigurationConstants.UTIL_RESOURCE_FOLDER)).exists(); + assertThat(templateSetComplex.resolve(ConfigurationConstants.UTIL_RESOURCE_FOLDER)).exists(); + + // validate maven specific contents + assertThat(templateSetSimple.resolve("pom.xml")).exists(); + assertThat(templateSetComplex.resolve("pom.xml")).exists(); + + // check if META-INF was deleted + assertThat(templateSetResourcesPath.resolve("META-INF")).doesNotExist(); + assertThat(templateSetResourcesPathComplex.resolve("META-INF")).doesNotExist(); + + } + + /** + * Checks if adapt-templates command successfully created cobigen templates folder and its sub folders + * + * @throws Exception test fails + */ + @Test + public void adaptTemplatesTest() throws Exception { + + Path templatesPath = this.currentHome.resolve(ConfigurationConstants.TEMPLATES_FOLDER); + Path CobigenTemplatesPath = templatesPath.resolve(ConfigurationConstants.COBIGEN_TEMPLATES); + if (!Files.exists(templatesPath)) { + Files.createDirectories(templatesPath); + } + + // TODO: Replace with downloadJarFromURL method and get rid of downloadJar, see: + // https://github.com/devonfw/cobigen/issues/1685 + TemplatesJarUtil.downloadJar("com.devonfw.cobigen", "templates-devon4j", "3.0.0", false, templatesPath.toFile()); + TemplatesJarUtil.downloadJar("com.devonfw.cobigen", "templates-devon4j", "3.0.0", true, templatesPath.toFile()); + + String args[] = new String[2]; + args[0] = "adapt-templates"; + args[1] = "--all"; + + execute(args, false, false, true); + + assertThat(CobigenTemplatesPath).exists(); + + Path templateRoot = CobigenTemplatesPath.resolve(ConfigurationConstants.TEMPLATE_RESOURCE_FOLDER); + // check if context configuration exists - assertThat(Paths - .get(cobigenTemplatesFolderPath.toString() + File.separator + ConfigurationConstants.TEMPLATE_RESOURCE_FOLDER - + File.separator + ConfigurationConstants.CONTEXT_CONFIG_FILENAME)).exists(); - // check if sources of utility classes exist - assertThat(Paths.get(cobigenTemplatesFolderPath.toString() + File.separator + "src" + File.separator + "main" - + File.separator + "java")).exists(); + assertThat(templateRoot.resolve(ConfigurationConstants.CONTEXT_CONFIG_FILENAME)).exists(); + + Path template = templateRoot.resolve("crud_java_server_app"); + Path templateComplex = templateRoot.resolve("crud_java_server_app_complex"); + // check if templates exists + assertThat(template).exists(); + assertThat(templateComplex).exists(); + // check if template.xml exists + assertThat(template.resolve(ConfigurationConstants.TEMPLATES_CONFIG_FILENAME)).exists(); + assertThat(templateComplex.resolve(ConfigurationConstants.TEMPLATES_CONFIG_FILENAME)).exists(); } } diff --git a/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/GenerateCommandIT.java b/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/GenerateCommandIT.java index 4d4a45505f..3d632b8f68 100644 --- a/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/GenerateCommandIT.java +++ b/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/GenerateCommandIT.java @@ -9,8 +9,11 @@ import org.apache.commons.io.FileUtils; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; +import com.devonfw.cobigen.api.constants.ConfigurationConstants; + /** * Tests the usage of the generate command. */ @@ -65,6 +68,70 @@ public void generateFromEntityTest() throws Exception { .exists(); } + /** + * + * Test the upgrade process from templates in a given path and generates from the new template-sets structure + * + * @throws Exception test fails + */ + @Test + @Ignore // TODO: re-enable when upgrade process is implemented, see: https://github.com/devonfw/cobigen/issues/1595 + public void upgradeAndGenerateFromEntityTest() throws Exception { + + FileUtils.copyDirectory(new File(testFileRootPath + "templatesproject"), this.tmpProject.toFile()); + this.tmpProject.resolve("templates-devon4j").toFile() + .renameTo(this.tmpProject.resolve(ConfigurationConstants.COBIGEN_TEMPLATES).toFile()); + File baseProject = this.tmpProject.resolve("maven.project/core/").toFile(); + File monolithicConfiguration = this.tmpProject.toFile(); + String args[] = new String[7]; + args[0] = "generate"; + args[1] = this.entityInputFile.getAbsolutePath(); + args[2] = "--increments"; + args[3] = "0"; + args[4] = "--upgrade-configuration"; + args[5] = "-tp"; + args[6] = monolithicConfiguration.getAbsolutePath(); + + execute(args, false); + + assertThat(this.currentHome.resolve(ConfigurationConstants.CONFIG_PROPERTY_TEMPLATE_SETS_PATH)).exists(); + + assertThat(baseProject.toPath().resolve("src/main/java/com/maven/project/sampledatamanagement/logic/api/to")) + .exists(); + } + + /** + * + * Integration test of the generation of template sets from a Java Entity. It does not specify the project to generate + * the folders to. + * + * @throws Exception test fails + */ + @Test + @Ignore // TODO: re-enable/fix when CLI tests were re-factored, see: https://github.com/devonfw/cobigen/issues/1659 + public void generateFromEntityWithTemplateSetTest() throws Exception { + + File baseProject = this.tmpProject.resolve("maven.project/core/").toFile(); + File templateSetsConfig = this.tmpProject.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER).toFile(); + String args[] = new String[6]; + args[0] = "generate"; + args[1] = this.entityInputFile.getAbsolutePath(); + args[2] = "--increments"; + args[3] = "0"; + args[4] = "-tp"; + args[5] = templateSetsConfig.getAbsolutePath(); + + execute(args, false); + + assertThat(this.currentHome.resolve(ConfigurationConstants.CONFIG_PROPERTY_TEMPLATE_SETS_PATH)).exists(); + + assertThat(baseProject.toPath().resolve("src/main/java/com/maven/project/sampledatamanagement/logic/api/to")) + .exists(); + } + + // TODO: Add similar test with a template-set jar file in downloaded folder, see: + // https://github.com/devonfw/cobigen/issues/1661 + /** * Integration test of the generation from a templates jar using a utility class with an extra dependency. See: * https://github.com/devonfw/cobigen/issues/1450 @@ -74,10 +141,10 @@ public void generateFromEntityTest() throws Exception { @Test public void generateFromTemplatesJarWithUtilClassDependencyTest() throws Exception { - FileUtils.copyDirectory(new File(testFileRootPath + "templatesproject"), this.tmpProject.toFile()); + FileUtils.copyDirectory(new File(testFileRootPath + "templatesproject/templates-devon4j"), + this.tmpProject.toFile()); File baseProject = this.tmpProject.resolve("maven.project/core/").toFile(); - File templatesProject = this.tmpProject.resolve("templates-devon4j/target/templates-devon4j-dev-SNAPSHOT.jar") - .toFile(); + File templatesProject = this.tmpProject.resolve("target/templates-devon4j-dev-SNAPSHOT.jar").toFile(); String args[] = new String[6]; args[0] = "generate"; @@ -87,7 +154,7 @@ public void generateFromTemplatesJarWithUtilClassDependencyTest() throws Excepti args[4] = "-tp"; args[5] = templatesProject.getAbsolutePath(); - execute(args, false); + execute(args, false, false, true); assertThat(baseProject.toPath().resolve("src/main/java/com/maven/project/sampledatamanagement/logic/api/to")) .exists(); @@ -231,7 +298,6 @@ public void generateFromMultipleTypeInputTest() throws Exception { String args[] = new String[6]; args[0] = "generate"; args[1] = openApiFile.getAbsolutePath() + "," + this.entityInputFile.getAbsolutePath(); - args[2] = "--out"; args[3] = outputRootFile.getAbsolutePath(); args[4] = "--increments"; @@ -361,4 +427,4 @@ public void generateFromEntityTwiceToTestCache() throws Exception { execute(args, true); } -} +} \ No newline at end of file diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/pom.xml b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/pom.xml new file mode 100644 index 0000000000..3c69a2539d --- /dev/null +++ b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + com.devonfw.test + crud-java-server-app-complex + 1.0.0 + jar + + 1.8 + 1.8 + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.3.1 + + ../../downloaded + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + ${skip.deployment} + ../../downloaded + + + + org.apache.maven.plugins + maven-resources-plugin + 2.7 + + UTF-8 + + + + + org.codehaus.mojo + templating-maven-plugin + 1.0.0 + + + generate-maven-properties-class + + filter-sources + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + prepare-package + + run + + + + Integrate POM manually + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/src/main/java/com/test.java b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/src/main/java/com/test.java new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/src/main/resources/functions.ftl b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/src/main/resources/functions.ftl new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/src/main/resources/template-set.xml b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/src/main/resources/template-set.xml new file mode 100644 index 0000000000..5cfe219789 --- /dev/null +++ b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/src/main/resources/template-set.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl new file mode 100644 index 0000000000..0c233890ea --- /dev/null +++ b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl @@ -0,0 +1 @@ +package test; \ No newline at end of file diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/pom.xml b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/pom.xml new file mode 100644 index 0000000000..3558920d14 --- /dev/null +++ b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + com.devonfw.test + crud-java-server-app + 1.0.0 + jar + + 1.8 + 1.8 + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.3.1 + + ../../downloaded + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + ${skip.deployment} + ../../downloaded + + + + org.apache.maven.plugins + maven-resources-plugin + 2.7 + + UTF-8 + + + + + org.codehaus.mojo + templating-maven-plugin + 1.0.0 + + + generate-maven-properties-class + + filter-sources + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + prepare-package + + run + + + + Integrate POM manually + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/src/main/java/com/test.java b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/src/main/java/com/test.java new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/src/main/resources/functions.ftl b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/src/main/resources/functions.ftl new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/src/main/resources/template-set.xml b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/src/main/resources/template-set.xml new file mode 100644 index 0000000000..4515b452ec --- /dev/null +++ b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/src/main/resources/template-set.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl new file mode 100644 index 0000000000..0c233890ea --- /dev/null +++ b/cobigen-cli/cli-systemtest/src/test/resources/testdata/AdaptTemplatesCommandIT/template-sets/adapted/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl @@ -0,0 +1 @@ +package test; \ No newline at end of file diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/pom.xml b/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/pom.xml new file mode 100644 index 0000000000..79e6e7b9c3 --- /dev/null +++ b/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + com.devonfw.test + templates-devon4j + dev-SNAPSHOT + jar + + 1.8 + 1.8 + + + + + org.apache.commons + commons-math3 + 3.6.1 + + + + + + + src/main/templates + src/main/templates + + + + + org.codehaus.mojo + flatten-maven-plugin + + + org.apache.maven.plugins + maven-antrun-plugin + + + prepare-package + + run + + + + Integrate POM manually + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/src/main/java/utils/MathUtils.java b/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/src/main/java/utils/MathUtils.java new file mode 100644 index 0000000000..79bf32afde --- /dev/null +++ b/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/src/main/java/utils/MathUtils.java @@ -0,0 +1,12 @@ +package utils; + +import org.apache.commons.math3.distribution.NormalDistribution; + +public class MathUtils { + + public double getNormalDistribution() { + NormalDistribution normalDistribution = new NormalDistribution(10, 3); + double randomValue = normalDistribution.sample(); + return randomValue; + } +} diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/src/main/resources/template-set.xml b/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/src/main/resources/template-set.xml new file mode 100644 index 0000000000..aecd8ff6ca --- /dev/null +++ b/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/src/main/resources/template-set.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl b/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl new file mode 100644 index 0000000000..dbf053f736 --- /dev/null +++ b/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/adapted/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl @@ -0,0 +1,5 @@ +package test; + +class Test{ + private final double myVar = ${MathUtils.getNormalDistribution()}; +} \ No newline at end of file diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/downloaded/crud-java-server-app/pom.xml b/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/downloaded/crud-java-server-app/pom.xml new file mode 100644 index 0000000000..338fee4ab5 --- /dev/null +++ b/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/downloaded/crud-java-server-app/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + com.devonfw.test + crud-java-server-app + test + jar + + 1.8 + 1.8 + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.3.1 + + ../../downloaded + + + + + + \ No newline at end of file diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/downloaded/crud-java-server-app/src/main/resources/template-set.xml b/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/downloaded/crud-java-server-app/src/main/resources/template-set.xml new file mode 100644 index 0000000000..4515b452ec --- /dev/null +++ b/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/downloaded/crud-java-server-app/src/main/resources/template-set.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/downloaded/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl b/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/downloaded/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl new file mode 100644 index 0000000000..0c233890ea --- /dev/null +++ b/cobigen-cli/cli-systemtest/src/test/resources/testdata/templatesproject/template-sets/downloaded/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl @@ -0,0 +1 @@ +package test; \ No newline at end of file diff --git a/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/commands/AdaptTemplatesCommand.java b/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/commands/AdaptTemplatesCommand.java index 19f3439a5b..7ceceef9d1 100644 --- a/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/commands/AdaptTemplatesCommand.java +++ b/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/commands/AdaptTemplatesCommand.java @@ -1,9 +1,22 @@ package com.devonfw.cobigen.cli.commands; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.devonfw.cobigen.api.TemplateAdapter; +import com.devonfw.cobigen.api.exception.TemplateSelectionForAdaptionException; +import com.devonfw.cobigen.api.exception.UpgradeTemplatesNotificationException; +import com.devonfw.cobigen.cli.CobiGenCLI; import com.devonfw.cobigen.cli.constants.MessagesConstants; -import com.devonfw.cobigen.impl.CobiGenFactory; +import com.devonfw.cobigen.cli.utils.ValidationUtils; +import com.devonfw.cobigen.impl.adapter.TemplateAdapterImpl; import picocli.CommandLine.Command; +import picocli.CommandLine.Option; /** * This class handles the user defined template directory e.g. determining and obtaining the latest templates jar, @@ -12,11 +25,107 @@ @Command(description = MessagesConstants.ADAPT_TEMPLATES_DESCRIPTION, name = "adapt-templates", aliases = { "a" }, mixinStandardHelpOptions = true) public class AdaptTemplatesCommand extends CommandCommons { + /** + * Logger to output useful information to the user + */ + private static Logger LOG = LoggerFactory.getLogger(CobiGenCLI.class); + + /** + * If this options is enabled, all templates are extracted. + */ + @Option(names = { "--all" }, description = MessagesConstants.ADAPT_ALL_DESCRIPTION) + boolean adaptAll; + + /** + * Allows usage of the old monolithic template structure instead of the new template sets structure. + */ + @Option(names = { "--force-monolithic-configuration", + "--force-mc" }, description = MessagesConstants.FORCE_MONOLITHIC_CONFIGURATION) + boolean forceMonolithicConfiguration; @Override public Integer doAction() throws Exception { - CobiGenFactory.extractTemplates(); + TemplateAdapter templateAdapter = new TemplateAdapterImpl(this.templatesProject); + try { + templateAdapter.adaptTemplates(); + } catch (UpgradeTemplatesNotificationException e) { + if (!this.forceMonolithicConfiguration && askUserToContinueWithUpgrade(e)) { + templateAdapter.upgradeMonolithicTemplates(this.templatesProject); + } + } catch (TemplateSelectionForAdaptionException e) { + List templateJars = e.getTemplateSets(); + if (!templateJars.isEmpty()) { + List templateJarsToAdapt = getJarsToAdapt(templateAdapter, templateJars); + if (!templateJarsToAdapt.isEmpty()) { + templateAdapter.adaptTemplateSets(templateJarsToAdapt, false); + } + } else { + LOG.info("No template set jars found to extract."); + } + } return 0; } -} + + /** + * Gives the user a selection of available template set jars to adapt. + * + * @param templateJars A {@link List} with all available template set jars. + * @return A {@link List} with the template set jars selected by the user to adapt. + */ + private List getJarsToAdapt(TemplateAdapter templateAdapter, List templateJars) { + + List jarsToAdapt = new ArrayList<>(); + if (templateJars != null && templateJars.size() > 0) { + printJarsForSelection(templateAdapter, templateJars); + List userSelection = new ArrayList<>(); + if (this.adaptAll) { + userSelection.add("0"); + } else { + for (String templateSelection : ValidationUtils.getUserInput().split(",")) { + userSelection.add(templateSelection); + } + } + if (userSelection.contains("0")) { + jarsToAdapt = templateJars; + } else { + for (String jarSelected : userSelection) { + jarsToAdapt.add(templateJars.get(Integer.parseInt(jarSelected) - 1)); + } + } + } + return jarsToAdapt; + } + + /** + * Prints the available template set jars + * + * @param templateSetJarPaths List of {@link Path} to available template jar files + */ + private void printJarsForSelection(TemplateAdapter templateAdapter, List templateSetJarPaths) { + + LOG.info("(0) " + "All"); + for (Path templateSetJarPath : templateSetJarPaths) { + LOG.info("(" + (templateSetJarPaths.indexOf(templateSetJarPath) + 1) + ") " + + templateSetJarPath.getFileName().toString().replace(".jar", "") + + (templateAdapter.isTemplateSetAlreadyAdapted(templateSetJarPath) ? " (already adapted)" : "")); + } + LOG.info("Please enter the number(s) of jar(s) that you want to adapt separated by comma."); + } + + /** + * Ask the user to continue with the upgrade of the templates. + * + * @return Returns {@code true} if the user want to continue with the uprade of the templates. + */ + private boolean askUserToContinueWithUpgrade(UpgradeTemplatesNotificationException e) { + + LOG.info(e.getMessage()); + LOG.info("Type 'y' or 'yes' to upgrade the configuration?"); + String userInput = ValidationUtils.getUserInput(); + if (userInput != null && (userInput.toLowerCase().equals("y") || userInput.toLowerCase().equals("yes"))) { + return true; + } + return false; + } +} \ No newline at end of file diff --git a/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/commands/CommandCommons.java b/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/commands/CommandCommons.java index ad9ddba393..1d34aca581 100644 --- a/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/commands/CommandCommons.java +++ b/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/commands/CommandCommons.java @@ -26,6 +26,12 @@ public abstract class CommandCommons implements Callable { @Option(names = { "--templates-project", "-tp" }, description = MessagesConstants.TEMPLATE_PATH_DESCRIPTION) Path templatesProject; + /** + * If this option is enabled, the old monolithic templates will be upgraded to the new template-set structure. + */ + @Option(names = { "--upgrade-configuration" }, description = MessagesConstants.UPGRADE_CONFIGURATION_OPTION) + boolean upgradeConfiguration; + @Override public Integer call() throws Exception { diff --git a/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/commands/GenerateCommand.java b/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/commands/GenerateCommand.java index 33f0570b0d..1642945634 100644 --- a/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/commands/GenerateCommand.java +++ b/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/commands/GenerateCommand.java @@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory; import com.devonfw.cobigen.api.CobiGen; +import com.devonfw.cobigen.api.exception.DeprecatedMonolithicConfigurationException; import com.devonfw.cobigen.api.exception.InputReaderException; import com.devonfw.cobigen.api.to.GenerableArtifact; import com.devonfw.cobigen.api.to.GenerationReportTo; @@ -36,8 +37,11 @@ import com.devonfw.cobigen.cli.utils.CobiGenUtils; import com.devonfw.cobigen.cli.utils.ParsingUtils; import com.devonfw.cobigen.cli.utils.ValidationUtils; +import com.devonfw.cobigen.impl.CobiGenFactory; +import com.devonfw.cobigen.impl.config.constant.WikiConstants; import com.devonfw.cobigen.impl.util.ConfigurationFinder; import com.devonfw.cobigen.impl.util.FileSystemUtil; +import com.devonfw.cobigen.impl.util.PostponeUtil; import com.google.googlejavaformat.java.FormatterException; import picocli.CommandLine.Command; @@ -80,6 +84,15 @@ public class GenerateCommand extends CommandCommons { @Option(names = { "--templates", "-t" }, split = ",", description = MessagesConstants.TEMPLATES_OPTION_DESCRIPTION) List templates = null; + /** + * allows usage of the old monolithic template structure instead of the new template sets structure. + * + * TODO: Check if still needed, see: https://github.com/devonfw/cobigen/issues/1683 + */ + @Option(names = { "--force-monolithic-configuration", + "--force-mc" }, description = MessagesConstants.FORCE_MONOLITHIC_CONFIGURATION) + boolean forceMonolithicConfiguration; + /** * Logger to output useful information to the user */ @@ -101,7 +114,11 @@ public Integer doAction() throws Exception { } LOG.debug("Input files and output root path confirmed to be valid."); - CobiGen cg = CobiGenUtils.initializeCobiGen(this.templatesProject); + + if ((PostponeUtil.isTimePassed()) && (!this.forceMonolithicConfiguration)) + checkMonolithicConfigurationException(); + + CobiGen cg = CobiGenUtils.initializeCobiGen(this.templatesProject, true); resolveTemplateDependencies(); @@ -118,7 +135,9 @@ public Integer doAction() throws Exception { MavenUtil.getProjectRoot(this.inputFiles.get(i), false), inputsAndArtifacts.getB(), cg, IncrementTo.class); } } + return 0; + } /** @@ -177,7 +196,7 @@ private Tuple, List> preprocess(Co "Did not detect the input as part of a maven project, the root directory of the maven project was not found."); LOG.info("Would you like to take '{}' as a root directory for output generation? \n" - + "type yes/y to continue or no/n to cancel (or hit return for yes).", System.getProperty("user.dir")); + + MessagesConstants.YES_NO_ANSWER_DESCRIPTION, System.getProperty("user.dir")); setRootOutputDirectoryWithPrompt(); @@ -243,6 +262,73 @@ private void setRootOutputDirectoryWithPrompt() { } + /** + * Uses default initialization, checks if monolithic templates exist, handles the exception and lets the user decide + * if the templates should be upgraded. + */ + private void checkMonolithicConfigurationException() { + + try { + CobiGenUtils.initializeCobiGen(this.templatesProject, false); + } catch (DeprecatedMonolithicConfigurationException e) { + LOG.warn("Found monolithic configuration at: {} {}", + DeprecatedMonolithicConfigurationException.getMonolithicConfiguration(), e.getMessage()); + + if (this.upgradeConfiguration || askUserToUpgradeTemplates()) { + startTemplatesUpgrader(); + } else { + askUserToPostponeUpgrade(); + } + } + + } + + /** + * Opens a looping prompt with a yes/no question and upgrades the templates to the newest version. + * + */ + private boolean askUserToUpgradeTemplates() { + + LOG.info( + "Would you like to upgrade your templates to the newest version? \n" + + MessagesConstants.YES_NO_ANSWER_DESCRIPTION + "For more Informations, please visit: ", + WikiConstants.WIKI_UPGRADE_MONOLITHIC_CONFIGURATION, System.getProperty("user.dir")); + + return ValidationUtils.yesNoPrompt("Upgrading templates configuration...: ", + MessagesConstants.INVALID_YES_NO_ANSWER_DESCRIPTION, "Continue generation with monolithic templates..."); + } + + /** + * Upgrades the given template configuration and sets the new template-set as the templatesProject after the upgrade + */ + private void startTemplatesUpgrader() { + + try { + this.templatesProject = CobiGenFactory.startTemplatesUpgrader(this.templatesProject); + } catch (Throwable e) { + LOG.error("An error occurred while upgrading the templates."); + throw e; + } + } + + /** + * Asks the user if he wants to postpone the upgrade message for 30 days. + */ + private void askUserToPostponeUpgrade() { + + LOG.info("Would you like to postpone the upgrade warning message for 30 days?" + + MessagesConstants.YES_NO_ANSWER_DESCRIPTION, System.getProperty("user.dir")); + // TODO: Check if this message and behavior is still valid, see: https://github.com/devonfw/cobigen/issues/1674 + boolean setToUserDir = ValidationUtils.yesNoPrompt("A timer is set for 30 days...: ", + MessagesConstants.INVALID_YES_NO_ANSWER_DESCRIPTION, "Allright..."); + + if (setToUserDir) { + PostponeUtil.addATimestampForOneMonth(); + } else { + // Do nothing, the user will be asked again. + } + } + /** * Casting class, from List to List * diff --git a/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/constants/MessagesConstants.java b/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/constants/MessagesConstants.java index 9c63da3f73..9da407a824 100644 --- a/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/constants/MessagesConstants.java +++ b/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/constants/MessagesConstants.java @@ -1,5 +1,7 @@ package com.devonfw.cobigen.cli.constants; +import com.devonfw.cobigen.impl.config.constant.WikiConstants; + /** * Messages constants printed to the user */ @@ -72,8 +74,35 @@ public class MessagesConstants { */ public static final String ADAPT_TEMPLATES_DESCRIPTION = "Generates a new templates folder next to the cobigen cli"; + /** + * Message constant: description of the adapt-templates --all command + */ + public static final String ADAPT_ALL_DESCRIPTION = "If this option is enabled, all templates will get adapted."; + /** * Message constant: description of the custom-location option */ public static final String CUSTOM_LOCATION_OPTION_DESCRIPTION = "Custom location where the unpacked templates will be stored."; + + /** + * Message constant: description of the --upgrade option + */ + public static final String UPGRADE_CONFIGURATION_OPTION = "Will upgrade the monolithc templates automatically, if enabled."; + + /** + * Message constant: description of the generate command with --force-monolithic-templates option + */ + public static final String FORCE_MONOLITHIC_CONFIGURATION = "If this option is enabled, the old monolithic template structure will be used instead of the new template sets structure..Further Information can be found at: " + + WikiConstants.WIKI_UPGRADE_MONOLITHIC_CONFIGURATION; + + /** + * Message constant: description of the CLI Yes or No answer + */ + public static final String YES_NO_ANSWER_DESCRIPTION = "Type yes/y to continue or no/n to cancel (or hit return for yes). "; + + /** + * Message constant: description of the CLI Invalid Yes or No answer + */ + public static final String INVALID_YES_NO_ANSWER_DESCRIPTION = "Invalid input. Please answer yes/n or no/n (or hit return for yes)."; + } diff --git a/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/utils/CobiGenUtils.java b/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/utils/CobiGenUtils.java index d62b624f88..c4abaf657e 100644 --- a/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/utils/CobiGenUtils.java +++ b/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/utils/CobiGenUtils.java @@ -48,18 +48,18 @@ public class CobiGenUtils { * Registers CobiGen plug-ins and instantiates CobiGen * * @param templatesProject the templates project or jar + * @param allowMonolithicConfiguration ignores deprecated monolithic template folder structure and if found does not + * throw a DeprecatedMonolithicConfigurationException * @return object of CobiGen */ - public static CobiGen initializeCobiGen(Path templatesProject) { + public static CobiGen initializeCobiGen(Path templatesProject, boolean allowMonolithicConfiguration) { registerPlugins(); - CobiGen cg; if (templatesProject != null) { - cg = CobiGenFactory.create(templatesProject.toUri()); + return CobiGenFactory.create(templatesProject.toUri(), allowMonolithicConfiguration); } else { - cg = CobiGenFactory.create(); + return CobiGenFactory.create(allowMonolithicConfiguration); } - return cg; } /** diff --git a/cobigen-cli/cli/src/main/resources/pom.xml b/cobigen-cli/cli/src/main/resources/pom.xml index 302f03cac8..bbbefc623e 100644 --- a/cobigen-cli/cli/src/main/resources/pom.xml +++ b/cobigen-cli/cli/src/main/resources/pom.xml @@ -56,11 +56,6 @@ jsonplugin ${revision} - - com.devonfw.cobigen - templates-devon4j - ${revision} - \ No newline at end of file diff --git a/cobigen-cli/pom.xml b/cobigen-cli/pom.xml index 963f3b1811..422161cea6 100644 --- a/cobigen-cli/pom.xml +++ b/cobigen-cli/pom.xml @@ -12,10 +12,6 @@ ${revision} - - 11 - - cli cli-systemtest diff --git a/cobigen-eclipse/cobigen-eclipse-feature/.project b/cobigen-eclipse/cobigen-eclipse-feature/.project deleted file mode 100644 index 7a6654cc23..0000000000 --- a/cobigen-eclipse/cobigen-eclipse-feature/.project +++ /dev/null @@ -1,41 +0,0 @@ - - - cobigen-eclipse-feature - - - cobigen-eclipse - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.FeatureBuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.jdt.core.javanature - org.eclipse.pde.FeatureNature - - - - 1664574669497 - - 30 - - org.eclipse.core.resources.regexFilterMatcher - node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ - - - - diff --git a/cobigen-eclipse/cobigen-eclipse-test/.project b/cobigen-eclipse/cobigen-eclipse-test/.project deleted file mode 100644 index 7c40ecd24c..0000000000 --- a/cobigen-eclipse/cobigen-eclipse-test/.project +++ /dev/null @@ -1,45 +0,0 @@ - - - cobigen-eclipse-test - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - - - 1664574669506 - - 30 - - org.eclipse.core.resources.regexFilterMatcher - node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ - - - - diff --git a/cobigen-eclipse/cobigen-eclipse-test/META-INF/MANIFEST.MF b/cobigen-eclipse/cobigen-eclipse-test/META-INF/MANIFEST.MF index ec983cf6f9..8fb8869f36 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/META-INF/MANIFEST.MF +++ b/cobigen-eclipse/cobigen-eclipse-test/META-INF/MANIFEST.MF @@ -4,34 +4,77 @@ Bundle-Name: CobiGen Eclipse Plug-In Tests Bundle-SymbolicName: com.devonfw.cobigen.eclipse.test;singleton:=true Bundle-Version: 2021.12.007.qualifier Bundle-Vendor: devonfw -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-ActivationPolicy: lazy Bundle-ClassPath: ., + lib/annotations.jar, + lib/ant.jar, + lib/ant-nodeps.jar, lib/assertj-core.jar, + lib/awaitility.jar, + lib/byte-buddy.jar, + lib/byte-buddy-agent.jar, lib/checker-qual.jar, + lib/com.devonfw.cobigen.eclipse.feature.jar, + lib/com.devonfw.cobigen.eclipse.jar, + lib/commons-compiler.jar, + lib/commons-compress.jar, + lib/commons-io.jar, + lib/commons-jxpath.jar, lib/commons-lang3.jar, + lib/core.jar, lib/core-api.jar, + lib/core-externalprocess-api.jar, lib/core-test.jar, lib/error_prone_annotations.jar, lib/failureaccess.jar, + lib/gson.jar, lib/guava.jar, + lib/hamcrest.jar, lib/hamcrest-core.jar, + lib/istack-commons-runtime.jar, lib/j2objc-annotations.jar, + lib/jackson-annotations.jar, + lib/jackson-core.jar, + lib/jackson-databind.jar, + lib/jakarta.activation.jar, + lib/jakarta.xml.bind-api.jar, + lib/janino.jar, + lib/javaplugin-model.jar, + lib/java-sizeof.jar, + lib/javassist.jar, + lib/javax.inject.jar, + lib/jaxb-core.jar, + lib/jaxb-impl.jar, + lib/jaxen.jar, lib/jcl-over-slf4j.jar, lib/jsr305.jar, lib/junit.jar, + lib/kotlin-stdlib.jar, + lib/kotlin-stdlib-common.jar, + lib/kotlin-stdlib-jdk7.jar, + lib/kotlin-stdlib-jdk8.jar, lib/listenablefuture.jar, lib/log4j-over-slf4j.jar, lib/logback-classic.jar, lib/logback-core.jar, + lib/maven-model.jar, + lib/mmm-base.jar, lib/mockito-core.jar, lib/objenesis.jar, + lib/okhttp.jar, + lib/okio.jar, + lib/okio-jvm.jar, + lib/orika-core.jar, + lib/paranamer.jar, + lib/plexus-cipher.jar, + lib/plexus-sec-dispatcher.jar, + lib/plexus-utils.jar, lib/slf4j-api.jar, lib/system-lambda.jar, + lib/txw2.jar, lib/xmlunit.jar, - lib/zt-exec.jar, - lib/awaitility.jar, - lib/hamcrest.jar + lib/zt-exec.jar Require-Bundle: org.eclipse.swtbot.junit4_x;bundle-version="2.4.0", org.junit;bundle-version="4.12.0", org.eclipse.ui, @@ -47,4 +90,5 @@ Require-Bundle: org.eclipse.swtbot.junit4_x;bundle-version="2.4.0", org.apache.commons.io;bundle-version="2.2.0", org.eclipse.m2e.core.ui;bundle-version="1.6.0", org.eclipse.m2e.core;bundle-version="1.6.0", - com.devonfw.cobigen.eclipse + com.devonfw.cobigen.eclipse, + org.eclipse.swtbot.swt.finder diff --git a/cobigen-eclipse/cobigen-eclipse-test/build.properties b/cobigen-eclipse/cobigen-eclipse-test/build.properties index 1943f55c16..fdd1aba796 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/build.properties +++ b/cobigen-eclipse/cobigen-eclipse-test/build.properties @@ -3,28 +3,71 @@ source.. = src/main/java/ bin.includes = .,\ META-INF/,\ plugin.xml,\ + lib/annotations.jar,\ + lib/ant.jar,\ + lib/ant-nodeps.jar,\ lib/assertj-core.jar,\ + lib/awaitility.jar,\ + lib/byte-buddy.jar,\ + lib/byte-buddy-agent.jar,\ lib/checker-qual.jar,\ + lib/com.devonfw.cobigen.eclipse.feature.jar,\ + lib/com.devonfw.cobigen.eclipse.jar,\ + lib/commons-compiler.jar,\ + lib/commons-compress.jar,\ + lib/commons-io.jar,\ + lib/commons-jxpath.jar,\ lib/commons-lang3.jar,\ + lib/core.jar,\ lib/core-api.jar,\ + lib/core-externalprocess-api.jar,\ lib/core-test.jar,\ lib/error_prone_annotations.jar,\ lib/failureaccess.jar,\ + lib/gson.jar,\ lib/guava.jar,\ + lib/hamcrest.jar,\ lib/hamcrest-core.jar,\ + lib/istack-commons-runtime.jar,\ lib/j2objc-annotations.jar,\ + lib/jackson-annotations.jar,\ + lib/jackson-core.jar,\ + lib/jackson-databind.jar,\ + lib/jakarta.activation.jar,\ + lib/jakarta.xml.bind-api.jar,\ + lib/janino.jar,\ + lib/javaplugin-model.jar,\ + lib/java-sizeof.jar,\ + lib/javassist.jar,\ + lib/javax.inject.jar,\ + lib/jaxb-core.jar,\ + lib/jaxb-impl.jar,\ + lib/jaxen.jar,\ lib/jcl-over-slf4j.jar,\ lib/jsr305.jar,\ lib/junit.jar,\ + lib/kotlin-stdlib.jar,\ + lib/kotlin-stdlib-common.jar,\ + lib/kotlin-stdlib-jdk7.jar,\ + lib/kotlin-stdlib-jdk8.jar,\ lib/listenablefuture.jar,\ lib/log4j-over-slf4j.jar,\ lib/logback-classic.jar,\ lib/logback-core.jar,\ + lib/maven-model.jar,\ + lib/mmm-base.jar,\ lib/mockito-core.jar,\ lib/objenesis.jar,\ + lib/okhttp.jar,\ + lib/okio.jar,\ + lib/okio-jvm.jar,\ + lib/orika-core.jar,\ + lib/paranamer.jar,\ + lib/plexus-cipher.jar,\ + lib/plexus-sec-dispatcher.jar,\ + lib/plexus-utils.jar,\ lib/slf4j-api.jar,\ lib/system-lambda.jar,\ + lib/txw2.jar,\ lib/xmlunit.jar,\ - lib/zt-exec.jar,\ - lib/awaitility.jar,\ - lib/hamcrest.jar + lib/zt-exec.jar diff --git a/cobigen-eclipse/cobigen-eclipse-test/pom.xml b/cobigen-eclipse/cobigen-eclipse-test/pom.xml index 7b1ac73625..8fc4f9cf42 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/pom.xml +++ b/cobigen-eclipse/cobigen-eclipse-test/pom.xml @@ -188,15 +188,54 @@ http://download.eclipse.org/technology/swtbot/releases/latest/ p2 - - - - - p2-build-photon - - eclipse-photon-sr2-test - http://download.eclipse.org/tools/orbit/downloads/drops/R20180606145124/repository/ + htmlplugin + file:///${maven.multiModuleProjectDirectory}/cobigen-plugins/cobigen-htmlplugin/target/repository + p2 + + + javaplugin + file:///${maven.multiModuleProjectDirectory}/cobigen-plugins/cobigen-javaplugin-parent/cobigen-javaplugin/target/repository + p2 + + + jsonplugin + file:///${maven.multiModuleProjectDirectory}/cobigen-plugins/cobigen-jsonplugin/target/repository + p2 + + + openapiplugin + file:///${maven.multiModuleProjectDirectory}/cobigen-plugins/cobigen-openapiplugin-parent/cobigen-openapiplugin/target/repository + p2 + + + propertyplugin + file:///${maven.multiModuleProjectDirectory}/cobigen-plugins/cobigen-propertyplugin/target/repository + p2 + + + freemarker + file:///${maven.multiModuleProjectDirectory}/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-freemarker/target/repository + p2 + + + velocity + file:///${maven.multiModuleProjectDirectory}/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-velocity/target/repository + p2 + + + textmerger + file:///${maven.multiModuleProjectDirectory}/cobigen-plugins/cobigen-textmerger/target/repository + p2 + + + tsplugin + file:///${maven.multiModuleProjectDirectory}/cobigen-plugins/cobigen-tsplugin/target/repository + p2 + + + xmlplugin + file:///${maven.multiModuleProjectDirectory}/cobigen-plugins/cobigen-xmlplugin/target/repository p2 diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/AdaptTemplatesTest.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/AdaptTemplatesTest.java index 92a0ace483..7536ade8d6 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/AdaptTemplatesTest.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/AdaptTemplatesTest.java @@ -20,6 +20,8 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; +import com.devonfw.cobigen.api.util.CobiGenPaths; +import com.devonfw.cobigen.api.util.TemplatesJarUtil; import com.devonfw.cobigen.eclipse.common.constants.external.ResourceConstants; import com.devonfw.cobigen.eclipse.test.common.SystemTest; import com.devonfw.cobigen.eclipse.test.common.swtbot.AllJobsAreFinished; @@ -68,7 +70,17 @@ public void testBasicOpenAPIGenerationWithAdaptTemplates() throws Exception { project.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); this.tmpMavenProjectRule.updateProject(); - EclipseCobiGenUtils.runAndCaptureUpdateTemplates(bot); + // retrieve CobiGen home directory (overwritten through environment variables) + File templatesDirectory = CobiGenPaths.getTemplatesFolderPath().toFile(); + + // create templates directory as this should be present in this scenario + this.tempFolder.newFolder("playground", "project", "templates"); + + // download latest monolithic templates to simulate existing template jars + TemplatesJarUtil.downloadLatestDevon4jTemplates(true, templatesDirectory); + TemplatesJarUtil.downloadLatestDevon4jTemplates(false, templatesDirectory); + + // adapt template jars into CobiGen_Templates project EclipseCobiGenUtils.runAndCaptureAdaptTemplates(bot); EclipseUtils.updateMavenProject(bot, ResourceConstants.CONFIG_PROJECT_NAME); @@ -80,7 +92,8 @@ public void testBasicOpenAPIGenerationWithAdaptTemplates() throws Exception { javaClassItem.select(); // execute CobiGen - EclipseCobiGenUtils.processCobiGen(bot, javaClassItem, 25000, "CRUD devon4j Server>CRUD REST services"); + EclipseCobiGenUtils.processCobiGenAndPostponeUpgrade(bot, javaClassItem, "CRUD devon4j Server>CRUD REST services"); + bot.waitUntil(new AllJobsAreFinished(), 10000); // increase timeout as the openAPI parser is slow on initialization EclipseCobiGenUtils.confirmSuccessfullGeneration(bot, 40000); @@ -91,6 +104,7 @@ public void testBasicOpenAPIGenerationWithAdaptTemplates() throws Exception { "src/main/java/com/devonfw/test/sampledatamanagement/service/impl/rest/SampledatamanagementRestServiceImpl.java"); assertThat(generationResult.exists()).isTrue(); + } /** diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/ClassPathLoadingTest.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/ClassPathLoadingTest.java index 8de12cedb7..a4e0e9408b 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/ClassPathLoadingTest.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/ClassPathLoadingTest.java @@ -81,7 +81,7 @@ public void testPreventClassPathShading() throws Exception { javaClassItem.select(); // execute CobiGen - EclipseCobiGenUtils.processCobiGen(bot, javaClassItem, "increment1"); + EclipseCobiGenUtils.processCobiGenAndPostponeUpgrade(bot, javaClassItem, "increment1"); EclipseCobiGenUtils.confirmSuccessfullGeneration(bot); // check assertions @@ -129,7 +129,7 @@ public void testClassPathResolutionOnInput_dependsOnMavenDependency() throws Exc javaClassItem.select(); // execute CobiGen - EclipseCobiGenUtils.processCobiGen(bot, javaClassItem, "increment1"); + EclipseCobiGenUtils.processCobiGenAndPostponeUpgrade(bot, javaClassItem, "increment1"); EclipseCobiGenUtils.confirmSuccessfullGeneration(bot); // check assertions @@ -173,7 +173,7 @@ public void testClassPathResolutionOnInput_dependsOnMavenProject() throws Except javaClassItem.select(); // execute CobiGen - EclipseCobiGenUtils.processCobiGen(bot, javaClassItem, "increment1"); + EclipseCobiGenUtils.processCobiGenAndPostponeUpgrade(bot, javaClassItem, "increment1"); EclipseCobiGenUtils.confirmSuccessfullGeneration(bot); // check assertions @@ -205,7 +205,7 @@ public void testClassloadingOfTemplateDependencies() throws Exception { javaClassItem.select(); // execute CobiGen - EclipseCobiGenUtils.processCobiGen(bot, javaClassItem, "increment2"); + EclipseCobiGenUtils.processCobiGenAndPostponeUpgrade(bot, javaClassItem, "increment2"); EclipseCobiGenUtils.confirmSuccessfullGeneration(bot); // check assertions @@ -246,7 +246,7 @@ public void testDotPathAcception() throws Exception { javaClassItem.select(); // execute CobiGen - EclipseCobiGenUtils.processCobiGen(bot, javaClassItem, "increment3"); + EclipseCobiGenUtils.processCobiGenAndPostponeUpgrade(bot, javaClassItem, "increment3"); EclipseCobiGenUtils.confirmSuccessfullGeneration(bot); // check assertions diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/CobigenJavaWrapperTest.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/CobigenJavaWrapperTest.java index a07008e8e4..84e97bbc1b 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/CobigenJavaWrapperTest.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/CobigenJavaWrapperTest.java @@ -67,7 +67,7 @@ public void testWorkspaceExternalProjectAsInput() throws Exception { javaClassItem.select(); // execute CobiGen - EclipseCobiGenUtils.processCobiGen(bot, javaClassItem, "increment2"); + EclipseCobiGenUtils.processCobiGenAndPostponeUpgrade(bot, javaClassItem, "increment2"); EclipseCobiGenUtils.confirmSuccessfullGeneration(bot); // check assertions @@ -100,7 +100,7 @@ public void testPathInvariants() throws Exception { javaClassItem.select(); // execute CobiGen - EclipseCobiGenUtils.processCobiGen(bot, javaClassItem, "increment3"); + EclipseCobiGenUtils.processCobiGenAndPostponeUpgrade(bot, javaClassItem, "increment3"); EclipseCobiGenUtils.confirmSuccessfullGeneration(bot); // check assertions @@ -132,7 +132,7 @@ public void testPackageAsInputForGeneration() throws Exception { javaClassItem.select(); // execute CobiGen - EclipseCobiGenUtils.processCobiGen(bot, javaClassItem, "increment1"); + EclipseCobiGenUtils.processCobiGenAndPostponeUpgrade(bot, javaClassItem, "increment1"); EclipseCobiGenUtils.confirmSuccessfullGeneration(bot); // check assertions diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/HealthCheckTest.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/HealthCheckTest.java index a116c5f471..f885d282ff 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/HealthCheckTest.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/HealthCheckTest.java @@ -46,6 +46,8 @@ public void testHealthCheckIfTemplateProjecNotCopiedIntoWS() throws Exception { EclipseUtils.importExistingGeneralProject(bot, tmpFolder.getAbsolutePath(), false); EclipseUtils.updateMavenProject(bot, ResourceConstants.CONFIG_PROJECT_NAME); - EclipseCobiGenUtils.runAndCaptureHealthCheck(bot); + EclipseCobiGenUtils.runAndCaptureHealthCheckWithMonolithicConfiguration(bot); } + + // TODO: Add a health check test for new template sets, see: https://github.com/devonfw/cobigen/issues/1648 } diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/MultipleMatchingTriggerTest.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/MultipleMatchingTriggerTest.java index 37c06e06d8..0a5a24576c 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/MultipleMatchingTriggerTest.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/MultipleMatchingTriggerTest.java @@ -67,7 +67,7 @@ public void testMutlipleTemplates_differentTrigger_samePath() throws Exception { javaClassItem.select(); // execute CobiGen - EclipseCobiGenUtils.processCobiGen(bot, javaClassItem, "increment1", "increment2"); + EclipseCobiGenUtils.processCobiGenAndPostponeUpgrade(bot, javaClassItem, "increment1", "increment2"); EclipseCobiGenUtils.confirmSuccessfullGeneration(bot); // check assertions diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/OpenAPITest.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/OpenAPITest.java index fd594e1d15..777640ef6c 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/OpenAPITest.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/OpenAPITest.java @@ -29,6 +29,8 @@ /** * General Eclipse Plug-in Tests. + * + * TODO: Create a copy of this test class for template sets using a regular generate (without upgrade or postpone) */ @RunWith(SWTBotJunit4ClassRunner.class) public class OpenAPITest extends SystemTest { @@ -69,7 +71,7 @@ public void testBasicOpenAPIGeneration() throws Exception { project.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); this.tmpMavenProjectRule.updateProject(); - EclipseCobiGenUtils.runAndCaptureHealthCheck(bot); + EclipseCobiGenUtils.runAndCaptureHealthCheckWithMonolithicConfiguration(bot); EclipseUtils.openErrorsTreeInProblemsView(bot); // expand the new file in the package explorer @@ -78,9 +80,9 @@ public void testBasicOpenAPIGeneration() throws Exception { javaClassItem.select(); // execute CobiGen - EclipseCobiGenUtils.processCobiGen(bot, javaClassItem, "CRUD REST services"); + EclipseCobiGenUtils.processCobiGenAndPostponeUpgrade(bot, javaClassItem, "CRUD REST services"); // increase timeout as the openAPI parser is slow on initialization - EclipseCobiGenUtils.confirmSuccessfullGeneration(bot, 40000); + EclipseCobiGenUtils.confirmSuccessfullGeneration(bot, 120000); // check assertions bot.waitUntil(new AllJobsAreFinished(), 10000); @@ -149,7 +151,7 @@ public void testServiceBasedOpenAPIGeneration() throws Exception { project.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); this.tmpMavenProjectRule.updateProject(); - EclipseCobiGenUtils.runAndCaptureHealthCheck(bot); + EclipseCobiGenUtils.runAndCaptureHealthCheckWithMonolithicConfiguration(bot); EclipseUtils.openErrorsTreeInProblemsView(bot); // expand the new file in the package explorer @@ -158,7 +160,7 @@ public void testServiceBasedOpenAPIGeneration() throws Exception { javaClassItem.select(); // execute CobiGen - EclipseCobiGenUtils.processCobiGen(bot, javaClassItem, "View Component"); + EclipseCobiGenUtils.processCobiGenAndPostponeUpgrade(bot, javaClassItem, "View Component"); // increase timeout as the openAPI parser is slow on initialization EclipseCobiGenUtils.confirmSuccessfullGeneration(bot, 40000); @@ -218,7 +220,7 @@ public void testRegexBasedOpenAPIGeneration() throws Exception { project.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); this.tmpMavenProjectRule.updateProject(); - EclipseCobiGenUtils.runAndCaptureHealthCheck(bot); + EclipseCobiGenUtils.runAndCaptureHealthCheckWithMonolithicConfiguration(bot); EclipseUtils.openErrorsTreeInProblemsView(bot); // expand the new file in the package explorer SWTBotView view = bot.viewById(JavaUI.ID_PACKAGES); @@ -226,7 +228,7 @@ public void testRegexBasedOpenAPIGeneration() throws Exception { javaClassItem.select(); // execute CobiGen - EclipseCobiGenUtils.processCobiGen(bot, javaClassItem, "generate a file for every Entity"); + EclipseCobiGenUtils.processCobiGenAndPostponeUpgrade(bot, javaClassItem, "generate a file for every Entity"); // increase timeout as the openAPI parser is slow on initialization EclipseCobiGenUtils.confirmSuccessfullGeneration(bot, 40000); diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/UpgradeMonolithicTemplatesTest.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/UpgradeMonolithicTemplatesTest.java new file mode 100644 index 0000000000..255b93282d --- /dev/null +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/UpgradeMonolithicTemplatesTest.java @@ -0,0 +1,103 @@ +package com.devonfw.cobigen.eclipse.test; + +import static com.github.stefanbirkner.systemlambda.SystemLambda.withEnvironmentVariable; +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.File; +import java.nio.file.Path; + +import org.apache.commons.io.FileUtils; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.ui.JavaUI; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.devonfw.cobigen.api.constants.ConfigurationConstants; +import com.devonfw.cobigen.eclipse.common.constants.external.ResourceConstants; +import com.devonfw.cobigen.eclipse.common.tools.ResourcesPluginUtil; +import com.devonfw.cobigen.eclipse.test.common.SystemTest; +import com.devonfw.cobigen.eclipse.test.common.swtbot.AllJobsAreFinished; +import com.devonfw.cobigen.eclipse.test.common.utils.EclipseCobiGenUtils; +import com.devonfw.cobigen.eclipse.test.common.utils.EclipseUtils; + +/** + * Test the upgrader in core and generates from the new template-set + * + */ +@Ignore // TODO: re-enable when upgrader was implemented, see: https://github.com/devonfw/cobigen/issues/1595 +@RunWith(SWTBotJunit4ClassRunner.class) +public class UpgradeMonolithicTemplatesTest extends SystemTest { + + /** Root path of the Test Resources */ + private static final String resourcesRootPath = "src/main/resources/UpgradeMonolithicTemplatesTest/"; + + /** Current home directory */ + protected Path currentHome; + + /** + * Setup workbench appropriately for tests + * + * @throws Exception test fails + */ + @BeforeClass + public static void setupClass() throws Exception { + + EclipseUtils.cleanWorkspace(bot, true); + // import the configuration project for this test + EclipseUtils.importExistingGeneralProject(bot, + new File(resourcesRootPath + "templates/CobiGen_Templates").getAbsolutePath()); + EclipseUtils.updateMavenProject(bot, ResourceConstants.CONFIG_PROJECT_NAME); + + } + + /** + * Tests if the Upgrader will work properly and generate after that + * + * Setup home path for cobigen to isolate the test (withEnvironmentVariable) + * + * @throws Exception Test fails + */ + @Test + public void testUpgradeAndGenerateFromTemplateSet() throws Exception { + + this.currentHome = this.tmpFolderRule.newFolder("cobigen-test-home").toPath(); + withEnvironmentVariable(ConfigurationConstants.CONFIG_ENV_HOME, this.currentHome.toString()).execute(() -> { + + // create a new temporary java project and copy java class used as an input for CobiGen + String testProjectName = "TestInputProj"; + IJavaProject project = this.tmpMavenProjectRule.createProject(testProjectName); + FileUtils.copyFile(new File(resourcesRootPath + "input/test.yml"), + project.getUnderlyingResource().getLocation().append("src/main/java/main/test.yml").toFile()); + project.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); + this.tmpMavenProjectRule.updateProject(); + + // expand the new file in the package explorer + SWTBotView view = bot.viewById(JavaUI.ID_PACKAGES); + SWTBotTreeItem javaClassItem = view.bot().tree().expandNode(testProjectName, "src/main/java", "main", "test.yml"); + javaClassItem.select(); + + // execute CobiGen + EclipseCobiGenUtils.processCobiGenAndUpgrade(bot, javaClassItem, "All"); + + EclipseCobiGenUtils.confirmSuccessfullGeneration(bot, 40000); + + // check assertions + bot.waitUntil(new AllJobsAreFinished(), 10000); + + IFile generationResult = project.getProject().getFile("src/environments/environment.ts"); + assertThat(generationResult.exists()).isTrue(); + }); + FileUtils.deleteDirectory(this.currentHome.toFile()); + // Set to null to to run all eclipse tests after the upgrade + ResourcesPluginUtil.setTemplateSetPathAfterUpgrade(null); + + } +} diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/VelocityGenerationTest.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/VelocityGenerationTest.java index 9918b61c47..15c065c1dc 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/VelocityGenerationTest.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/VelocityGenerationTest.java @@ -45,6 +45,8 @@ public static void setupClass() throws Exception { /** * Tests a simple generation using velocity template engine. * + * TODO: add same test for template sets using regular generate + * * @throws Exception test fails */ @Test @@ -63,7 +65,7 @@ public void simpleVelocityBasedGeneration() throws Exception { javaClassItem.select(); // execute CobiGen - EclipseCobiGenUtils.processCobiGen(bot, javaClassItem, "Velocity Test"); + EclipseCobiGenUtils.processCobiGenAndPostponeUpgrade(bot, javaClassItem, "Velocity Test"); EclipseCobiGenUtils.confirmSuccessfullGeneration(bot); // check assertions diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/SystemTest.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/SystemTest.java index dd5cd84027..bc131f67a5 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/SystemTest.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/SystemTest.java @@ -19,7 +19,6 @@ import org.slf4j.LoggerFactory; import com.devonfw.cobigen.eclipse.test.common.junit.TmpMavenProjectRule; -import com.devonfw.cobigen.eclipse.test.common.swtbot.AllJobsAreFinished; import com.devonfw.cobigen.eclipse.test.common.utils.EclipseCobiGenUtils; import com.devonfw.cobigen.eclipse.test.common.utils.EclipseUtils; @@ -74,7 +73,6 @@ protected void finished(Description description) { public static void setupTest() throws Exception { bot.resetWorkbench(); - bot.waitUntil(new AllJobsAreFinished()); // this flag is set to be true and will suppress ErrorDialogs, // which is completely strange, so we enable them again. diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/junit/TmpMavenProjectRule.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/junit/TmpMavenProjectRule.java index 976e111a46..bb71e3b78e 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/junit/TmpMavenProjectRule.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/junit/TmpMavenProjectRule.java @@ -2,6 +2,10 @@ import java.io.ByteArrayInputStream; import java.io.File; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; +import java.util.Collection; import java.util.Random; import org.eclipse.core.resources.IFile; @@ -20,6 +24,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.devonfw.cobigen.api.exception.CobiGenRuntimeException; + /** * JUnit Rule for a temporary {@link IJavaProject}. Should be created in each test method by createProject when it * should be used. @@ -35,7 +41,9 @@ public class TmpMavenProjectRule extends ExternalResource { */ private IJavaProject javaProject; - /** Maven Project specification containing group id, artifact id, and version as a pom xml description */ + /** + * Maven Project specification containing group id, artifact id, and version as a pom xml description + */ private String mvnProjectSpecification; @Override @@ -113,8 +121,29 @@ public void updateProject() throws CoreException { // make sure the contents are synchronized this.javaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); // update maven project to implicitly set classpath and so on. - new UpdateMavenProjectJob(new IProject[] { this.javaProject.getProject() }) - .runInWorkspace(new NullProgressMonitor()); + + // Need to access internal (fragile) API of M2E as command + // "org.eclipse.m2e.core.ui.command.updateProject" does not allow execution, but + // spawns dialog popup + Constructor constructor; + UpdateMavenProjectJob updateMavenJob; + try { + // M2E < v2 + constructor = UpdateMavenProjectJob.class.getConstructor(IProject[].class); + updateMavenJob = constructor.newInstance((Object) new IProject[] { this.javaProject.getProject() }); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) { + LOG.debug("Assumptions for M2E < 2 did not match, trying to connect to M2E v2 API", e); + try { + // M2E >= 2 + constructor = UpdateMavenProjectJob.class.getConstructor(Collection.class); + updateMavenJob = constructor.newInstance(Arrays.asList(this.javaProject.getProject())); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e1) { + throw new CobiGenRuntimeException( + "There might be an incompatibility with the current version of M2E installed. Please state a bug report on github including the M2E version installed in your eclipse.", + e1); + } + } + updateMavenJob.runInWorkspace(new NullProgressMonitor()); } diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/EclipseCobiGenUtils.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/EclipseCobiGenUtils.java index 1ea0de1e42..992b7cbb56 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/EclipseCobiGenUtils.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/EclipseCobiGenUtils.java @@ -5,6 +5,7 @@ import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jface.dialogs.IDialogConstants; @@ -35,7 +36,7 @@ public class EclipseCobiGenUtils { public static final int DEFAULT_TIMEOUT = 15000; /** - * Selects the the increment with the given name and generates it. + * Selects the increment with the given name and generates it. * * @param bot the {@link SWTWorkbenchBot} of the test * @param input input of CobiGen to be selected @@ -47,6 +48,34 @@ public static void processCobiGen(SWTWorkbenchBot bot, SWTBotTreeItem input, Str processCobiGen(bot, input, DEFAULT_TIMEOUT, increments); } + /** + * Selects the increment with the given name and generates it, even if monolithic templates found + * + * @param bot the {@link SWTWorkbenchBot} of the test + * @param input input of CobiGen to be selected + * @param increments increments to be generated. + * @throws Exception test fails + */ + public static void processCobiGenAndPostponeUpgrade(SWTWorkbenchBot bot, SWTBotTreeItem input, String... increments) + throws Exception { + + processCobiGenAndPostponeUpgrade(bot, input, DEFAULT_TIMEOUT, increments); + } + + /** + * Selects the increment with the given name, upgrades the monolithic templates and generates. + * + * @param bot the {@link SWTWorkbenchBot} of the test + * @param input input of CobiGen to be selected + * @param increments increments to be generated. + * @throws Exception test fails + */ + public static void processCobiGenAndUpgrade(SWTWorkbenchBot bot, SWTBotTreeItem input, String... increments) + throws Exception { + + processCobiGenAndUpgrade(bot, input, DEFAULT_TIMEOUT, increments); + } + /** * Tries a Generate process with an expected error title. * @@ -101,7 +130,7 @@ private static SWTBotTreeItem expandNodes(SWTWorkbenchBot bot, String increment) } /** - * Selects the the increment with the given name and generates it. + * Selects the increment with the given name and generates it. * * @param bot the {@link SWTWorkbenchBot} of the test * @param input input of CobiGen to be selected @@ -135,7 +164,8 @@ public static void processCobiGenWithTextInput(SWTWorkbenchBot bot, SWTBotEclips ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); bot.waitUntil(new AllJobsAreFinished(), defaultTimeout); // build might take some time input.contextMenu("CobiGen").menu("Generate...").click(); - generateWithSelectedIncrements(bot, defaultTimeout, increments); + postponeUpgradeAndContinue(bot); + generateWithSelectedIncrements(bot, 120000, increments); } /** @@ -169,6 +199,47 @@ private static void generateWithSelectedIncrements(SWTWorkbenchBot bot, int defa finishButton.click(); } + /** + * Selects the increment with the given name and generates it, even if monolithic templates found + * + * @param bot the {@link SWTWorkbenchBot} of the test + * @param input input of CobiGen to be selected + * @param increments increments to be generated. + * @throws CoreException + * @throws Exception test fails + */ + private static void processCobiGenAndPostponeUpgrade(SWTWorkbenchBot bot, SWTBotTreeItem input, int defaultTimeout, + String[] increments) throws Exception { + + // Open generation wizard with new file as Input + ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); + bot.waitUntil(new AllJobsAreFinished(), defaultTimeout); // build might take some time + input.contextMenu("CobiGen").menu("Generate...").click(); + postponeUpgradeAndContinue(bot); + generateWithSelectedIncrements(bot, 120000, increments); + } + + /** + * Selects the increment with the given name and generates it, upgrade if monolithic templates found + * + * @param bot the {@link SWTWorkbenchBot} of the test + * @param input input of CobiGen to be selected + * @param increments increments to be generated. + * @throws CoreException + * @throws Exception test fails + */ + private static void processCobiGenAndUpgrade(SWTWorkbenchBot bot, SWTBotTreeItem input, int defaultTimeout, + String[] increments) throws Exception { + + // Open generation wizard with new file as Input + ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); + bot.waitUntil(new AllJobsAreFinished(), defaultTimeout); // build might take some time + input.contextMenu("CobiGen").menu("Generate...").click(); + upgradeAndContinue(bot, defaultTimeout); + + generateWithSelectedIncrements(bot, defaultTimeout, increments); + } + /** * Tries a Generate process with an expected error title. * @@ -185,6 +256,7 @@ public static void processCobiGenWithExpectedError(SWTWorkbenchBot bot, SWTBotTr ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); bot.waitUntil(new AllJobsAreFinished(), defaultTimeout); // build might take some time input.contextMenu("CobiGen").menu("Generate...").click(); + postponeUpgradeAndContinue(bot); bot.waitUntil(new AnyShellIsActive(expectedErrorTitle), defaultTimeout); takeScreenshot(bot, "InvalidConfigurationDialog"); @@ -194,6 +266,38 @@ public static void processCobiGenWithExpectedError(SWTWorkbenchBot bot, SWTBotTr finishButton.click(); } + /** + * Skips the Upgrade Warning message with the "Postpone" button + * + * @param bot the {@link SWTWorkbenchBot} of the test + * + */ + private static void postponeUpgradeAndContinue(SWTWorkbenchBot bot) { + + takeScreenshot(bot, "Warning!"); + SWTBotShell finishDialog = bot.shell("Warning!"); + finishDialog.bot().button("Postpone").click(); + } + + /** + * Starts the upgrade process with the "Upgrade" button + * + * @param bot the {@link SWTWorkbenchBot} of the test + * @param defaultTimeout + * + */ + private static void upgradeAndContinue(SWTWorkbenchBot bot, int defaultTimeout) { + + takeScreenshot(bot, "Warning!"); + SWTBotShell finishDialog = bot.shell("Warning!"); + finishDialog.bot().button("Upgrade").click(); + bot.waitUntil(new AllJobsAreFinished(), defaultTimeout); + takeScreenshot(bot, "Success!"); + SWTBotShell successDialog = bot.shell("Success!"); + successDialog.bot().button("Ok").click(); + + } + /** * Checks the CobiGen HealthCheck and takes screenshots of it. * @@ -207,6 +311,35 @@ public static void runAndCaptureHealthCheck(SWTWorkbenchBot bot) throws Exceptio SWTBotView view = bot.viewById(JavaUI.ID_PACKAGES); view.bot().tree().expandNode("CobiGen_Templates").select().contextMenu("CobiGen").menu("Health Check...").click(); + // TODO: replace with health check reaction, see: https://github.com/devonfw/cobigen/issues/1686 + captureAdvancedHealthCheck(bot); + } + + /** + * Checks the CobiGen HealthCheck and takes screenshots of it, even if monolithic templates found. + * + * @param bot to process the health check + * @throws Exception test fails + */ + public static void runAndCaptureHealthCheckWithMonolithicConfiguration(SWTWorkbenchBot bot) throws Exception { + + ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); + bot.waitUntil(new AllJobsAreFinished(), DEFAULT_TIMEOUT); // build might take some time + + SWTBotView view = bot.viewById(JavaUI.ID_PACKAGES); + view.bot().tree().expandNode("CobiGen_Templates").select().contextMenu("CobiGen").menu("Health Check...").click(); + postponeUpgradeAndContinue(bot); + captureAdvancedHealthCheck(bot); + } + + /** + * Checks the CobiGen HealthCheck and takes screenshots of it. TODO: Split into captureHealthCheck and + * captureAdvancedHealthCheck, see: https://github.com/devonfw/cobigen/issues/1686 + * + * @param bot to process the health check + */ + private static void captureAdvancedHealthCheck(SWTWorkbenchBot bot) { + bot.waitUntil(new AnyShellIsActive(CobiGenDialogConstants.HealthCheckDialogs.DIALOG_TITLE), DEFAULT_TIMEOUT); takeScreenshot(bot, "healthCheck"); @@ -261,8 +394,8 @@ public static void runAndCaptureAdaptTemplates(SWTWorkbenchBot bot) throws Excep takeScreenshot(bot, "Adapt Templates Warning!"); SWTBotShell warningDialog = bot.shell("Warning!"); - warningDialog.bot().button("Ok").click(); + SWTBotShell informationDialog = bot.shell("Information"); bot.waitUntil(new AnyShellIsActive("Information"), DEFAULT_TIMEOUT); takeScreenshot(bot, "Adapt Templates Information"); diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/EclipseUtils.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/EclipseUtils.java index 26edf4f958..87b3a7d348 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/EclipseUtils.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/EclipseUtils.java @@ -24,6 +24,7 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; @@ -40,6 +41,7 @@ import com.devonfw.cobigen.eclipse.common.constants.external.ResourceConstants; import com.devonfw.cobigen.eclipse.test.common.swtbot.AllJobsAreFinished; +import com.devonfw.cobigen.eclipse.test.common.swtbot.HasBeenBuilt; import com.devonfw.cobigen.eclipse.test.common.utils.swtbot.SwtBotProjectActions; /** @@ -103,7 +105,12 @@ public static void importExistingGeneralProject(SWTWorkbenchBot bot, String proj bot.waitUntil(shellCloses(popup)); ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); - bot.waitUntil(new AllJobsAreFinished()); + for (IProject p : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { + IJavaProject jp = JavaCore.create(p); + if (jp != null) { + bot.waitUntil(new HasBeenBuilt(jp)); + } + } } /** diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/swtbot/SwtBotTestingUtilities.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/swtbot/SwtBotTestingUtilities.java index d583203ab8..2d3a98b78f 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/swtbot/SwtBotTestingUtilities.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/swtbot/SwtBotTestingUtilities.java @@ -34,8 +34,6 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; import org.hamcrest.Matcher; -import com.google.common.collect.Iterables; - /** * Provides helper methods to aid in SWTBot testing. */ @@ -227,7 +225,7 @@ public static void waitUntilMenuHasItem(SWTBot bot, Supplier menuSup @Override public boolean test() throws Exception { - return Iterables.any(menuSupplier.get().menuItems(), matcher::matches); + return menuSupplier.get().menuItems().stream().anyMatch(matcher::matches); } @Override diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/swtbot/SwtBotTimeoutManager.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/swtbot/SwtBotTimeoutManager.java index 2d06234f94..291925fd89 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/swtbot/SwtBotTimeoutManager.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/swtbot/SwtBotTimeoutManager.java @@ -20,10 +20,9 @@ package com.devonfw.cobigen.eclipse.test.common.utils.swtbot; +import org.assertj.core.api.Assertions; import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; -import com.google.common.base.Preconditions; - /** * Used to set the general SWTBot timeout. This class was originally to be thrown away, except that SWTBot doesn't * support a nice mechanism for temporarily changing the timeout. @@ -65,7 +64,7 @@ public static void setTimeout() { */ public static void setTimeout(long timeout) { - Preconditions.checkArgument(timeout > 0); + Assertions.assertThat(timeout).isGreaterThan(0); oldTimeoutSwtPrefs = getSwtBotPrefsTimeoutFieldValue(); setSwtBotPrefsTimeoutFieldValue(timeout); } diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/swtbot/SwtBotTreeUtilities.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/swtbot/SwtBotTreeUtilities.java index aa66497c84..89c8c723f6 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/swtbot/SwtBotTreeUtilities.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/swtbot/SwtBotTreeUtilities.java @@ -27,6 +27,7 @@ import java.util.Collections; import java.util.LinkedList; +import org.assertj.core.api.Assertions; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; @@ -40,9 +41,6 @@ import org.hamcrest.Matcher; import org.hamcrest.StringDescription; -import com.google.common.base.Preconditions; -import com.google.common.collect.Iterables; - /** Utilities for manipulating trees. */ public class SwtBotTreeUtilities { @@ -126,7 +124,7 @@ public boolean test() throws Exception { parentItem.expand(); children = parentItem.getItems(); } - return Iterables.any(parentItem.getNodes(), childMatcher::matches); + return parentItem.getNodes().stream().anyMatch(childMatcher::matches); } }); for (SWTBotTreeItem child : parentItem.getItems()) { @@ -215,7 +213,7 @@ public String getFailureMessage() { */ public static SWTBotTreeItem select(SWTWorkbenchBot bot, SWTBotTree tree, String... nodeNames) { - Preconditions.checkArgument(nodeNames.length > 0, "no children to navigate"); + Assertions.assertThat(nodeNames.length).isGreaterThan(0); int leafIndex = nodeNames.length - 1; waitUntilTreeHasItems(bot, tree); diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/GenerateFromTextInputTest/templates/src/main/templates/template1/context.xml b/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/GenerateFromTextInputTest/templates/src/main/templates/context.xml similarity index 80% rename from cobigen-eclipse/cobigen-eclipse-test/src/main/resources/GenerateFromTextInputTest/templates/src/main/templates/template1/context.xml rename to cobigen-eclipse/cobigen-eclipse-test/src/main/resources/GenerateFromTextInputTest/templates/src/main/templates/context.xml index b5774d7a5d..caa323e573 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/GenerateFromTextInputTest/templates/src/main/templates/template1/context.xml +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/GenerateFromTextInputTest/templates/src/main/templates/context.xml @@ -1,6 +1,6 @@ - + diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/input/test.yml b/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/input/test.yml new file mode 100644 index 0000000000..199c29deb3 --- /dev/null +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/input/test.yml @@ -0,0 +1,23 @@ +openapi: 3.0.0 +servers: + - url: 'https://localhost:8081/server/services/rest' + description: Just some data +info: + title: Devon Example + description: Example of a API definition + version: 1.0.0 + x-rootpackage: com.devonfw.angular.test +paths: + /shopmanagement/v1/shop/{shopId}: + x-component: shopmanagement + get: + operationId: findShop + parameters: + - name: shopId + in: path + required: true + schema: + type: integer + format: int64 + minimum: 0 + maximum: 50 diff --git a/cobigen-templates/templates-devon4j/.project b/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/.project similarity index 93% rename from cobigen-templates/templates-devon4j/.project rename to cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/.project index fccd2e4b05..b01e903d25 100644 --- a/cobigen-templates/templates-devon4j/.project +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/.project @@ -17,9 +17,8 @@ - org.sonar.ide.eclipse.core.sonarNature - org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/pom.xml b/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/pom.xml new file mode 100644 index 0000000000..5ebbd8cfe2 --- /dev/null +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + com.devonfw.cobigen + templates-devon4j + 2021.12.006 + CobiGen - devon4j Templates + A Code-based incremental Generator + https://github.com/devonfw/cobigen/templates-parent/templates-devon4j + + 1.8 + 1.8 + + + + + src/main/templates + src/main/templates + + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app/context.xml b/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/src/main/templates/context.xml similarity index 84% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app/context.xml rename to cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/src/main/templates/context.xml index 5e1c199c2b..fc1c9df45f 100644 --- a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app/context.xml +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/src/main/templates/context.xml @@ -1,8 +1,6 @@ - - - - + + @@ -10,5 +8,4 @@ - diff --git a/cobigen-templates/templates-devon4j/src/main/templates/kafka_documentation/templates.xml b/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/src/main/templates/crud_openapi_angular_service_based_app/templates.xml similarity index 56% rename from cobigen-templates/templates-devon4j/src/main/templates/kafka_documentation/templates.xml rename to cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/src/main/templates/crud_openapi_angular_service_based_app/templates.xml index 82e273ff39..484a768358 100644 --- a/cobigen-templates/templates-devon4j/src/main/templates/kafka_documentation/templates.xml +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/src/main/templates/crud_openapi_angular_service_based_app/templates.xml @@ -3,16 +3,16 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1"> - + - + - - + + diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app/templates/src/environments/environment.ts.ftl b/cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/src/main/templates/crud_openapi_angular_service_based_app/templates/src/environments/environment.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app/templates/src/environments/environment.ts.ftl rename to cobigen-eclipse/cobigen-eclipse-test/src/main/resources/UpgradeMonolithicTemplatesTest/templates/CobiGen_Templates/src/main/templates/crud_openapi_angular_service_based_app/templates/src/environments/environment.ts.ftl diff --git a/cobigen-eclipse/cobigen-eclipse-test/targlets/2018-12.target b/cobigen-eclipse/cobigen-eclipse-test/targlets/2018-12.target new file mode 100644 index 0000000000..f720b3a330 --- /dev/null +++ b/cobigen-eclipse/cobigen-eclipse-test/targlets/2018-12.target @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-eclipse/cobigen-eclipse-updatesite/.project b/cobigen-eclipse/cobigen-eclipse-updatesite/.project deleted file mode 100644 index 631967f7bd..0000000000 --- a/cobigen-eclipse/cobigen-eclipse-updatesite/.project +++ /dev/null @@ -1,36 +0,0 @@ - - - cobigen-eclipse-updatesite - - - cobigen-eclipse - cobigen-eclipse-feature - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.jdt.core.javanature - - - - 1664574669516 - - 30 - - org.eclipse.core.resources.regexFilterMatcher - node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ - - - - diff --git a/cobigen-eclipse/cobigen-eclipse/.project b/cobigen-eclipse/cobigen-eclipse/.project deleted file mode 100644 index 533bae1e4d..0000000000 --- a/cobigen-eclipse/cobigen-eclipse/.project +++ /dev/null @@ -1,45 +0,0 @@ - - - cobigen-eclipse - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - - - 1664574669486 - - 30 - - org.eclipse.core.resources.regexFilterMatcher - node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ - - - - diff --git a/cobigen-eclipse/cobigen-eclipse/META-INF/MANIFEST.MF b/cobigen-eclipse/cobigen-eclipse/META-INF/MANIFEST.MF index 224cc066c7..22fe3f42c9 100644 --- a/cobigen-eclipse/cobigen-eclipse/META-INF/MANIFEST.MF +++ b/cobigen-eclipse/cobigen-eclipse/META-INF/MANIFEST.MF @@ -17,7 +17,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.104.0", org.eclipse.ui.navigator.resources;bundle-version="3.4.400", org.eclipse.m2e.core.ui;bundle-version="1.6.0", org.eclipse.core.filesystem;bundle-version="1.5.0" -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-ActivationPolicy: lazy Bundle-ClassPath: ., lib/annotations.jar, @@ -57,14 +57,19 @@ Bundle-ClassPath: ., lib/kotlin-stdlib-common.jar, lib/listenablefuture.jar, lib/log4j-over-slf4j.jar, + lib/maven-model.jar, + lib/mmm-base.jar, + lib/okhttp.jar, + lib/orika-core.jar, + lib/zt-exec.jar, lib/logback-classic.jar, lib/logback-core.jar, - lib/mmm-util-core.jar, - lib/okhttp.jar, lib/okio.jar, - lib/orika-core.jar, lib/paranamer.jar, + lib/plexus-cipher.jar, + lib/plexus-sec-dispatcher.jar, + lib/plexus-utils.jar, lib/slf4j-api.jar, - lib/txw2.jar, - lib/zt-exec.jar -Export-Package: com.devonfw.cobigen.eclipse.common.constants.external + lib/txw2.jar +Export-Package: com.devonfw.cobigen.eclipse.common.constants.external, + com.devonfw.cobigen.eclipse.common.tools diff --git a/cobigen-eclipse/cobigen-eclipse/build.properties b/cobigen-eclipse/cobigen-eclipse/build.properties index 64d6a6e2a5..4415ea671c 100644 --- a/cobigen-eclipse/cobigen-eclipse/build.properties +++ b/cobigen-eclipse/cobigen-eclipse/build.properties @@ -42,11 +42,15 @@ bin.includes = .,\ lib/log4j-over-slf4j.jar,\ lib/logback-classic.jar,\ lib/logback-core.jar,\ - lib/mmm-util-core.jar,\ + lib/maven-model.jar,\ + lib/mmm-base.jar,\ lib/okhttp.jar,\ lib/okio.jar,\ lib/orika-core.jar,\ lib/paranamer.jar,\ + lib/plexus-cipher.jar,\ + lib/plexus-sec-dispatcher.jar,\ + lib/plexus-utils.jar,\ lib/slf4j-api.jar,\ lib/txw2.jar,\ lib/zt-exec.jar diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/constants/InfrastructureConstants.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/constants/InfrastructureConstants.java index 2ea80b33ea..bbaa521e2c 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/constants/InfrastructureConstants.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/constants/InfrastructureConstants.java @@ -2,8 +2,6 @@ /** * Constants, which are needed for technical infrastructure. - * - * @author mbrunnli (Jun 17, 2015) */ public class InfrastructureConstants { diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/tools/ExceptionHandler.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/tools/ExceptionHandler.java index 139cef1e69..1916b7994c 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/tools/ExceptionHandler.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/tools/ExceptionHandler.java @@ -9,12 +9,15 @@ import com.devonfw.cobigen.api.exception.CobiGenRuntimeException; import com.devonfw.cobigen.api.exception.ConfigurationConflictException; +import com.devonfw.cobigen.api.exception.DeprecatedMonolithicConfigurationException; import com.devonfw.cobigen.api.exception.InvalidConfigurationException; import com.devonfw.cobigen.eclipse.common.constants.external.ResourceConstants; import com.devonfw.cobigen.eclipse.common.exceptions.GeneratorCreationException; import com.devonfw.cobigen.eclipse.common.exceptions.GeneratorProjectNotExistentException; import com.devonfw.cobigen.eclipse.common.exceptions.InvalidInputException; import com.devonfw.cobigen.eclipse.healthcheck.HealthCheckDialog; +import com.devonfw.cobigen.impl.config.constant.WikiConstants; +import com.devonfw.cobigen.impl.util.PostponeUtil; /** * Util class to handle exceptions @@ -39,6 +42,9 @@ public static void handle(Throwable e, Shell activeShell) { openInvalidConfigurationErrorDialog((InvalidConfigurationException) e); } else if (ConfigurationConflictException.class.isAssignableFrom(e.getClass())) { openInvalidConfigurationErrorDialog((ConfigurationConflictException) e); + } else if (DeprecatedMonolithicConfigurationException.class.isAssignableFrom(e.getClass())) { + LOG.warn("Monolithic Templates found.", e); + openMonolithicConfigurationErrorDialog((DeprecatedMonolithicConfigurationException) e); } else if (GeneratorProjectNotExistentException.class.isAssignableFrom(e.getClass())) { LOG.error( "The project '{}' containing the configuration and templates is currently not existent. Please create one or check it out from SVN as stated in the user documentation.", @@ -95,4 +101,44 @@ private static void openInvalidConfigurationErrorDialog(InvalidConfigurationExce }); } + /** + * Opens up a message dialog for displaying further guidance on upgrading old templates. + * + * @param e {@link DeprecatedMonolithicConfigurationException} occurred + */ + private static void openMonolithicConfigurationErrorDialog(DeprecatedMonolithicConfigurationException e) { + + PlatformUIUtil.getWorkbench().getDisplay().syncExec(() -> { + MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), "Warning!", null, + e.getMessage() + " Further Information can be found at:" + + WikiConstants.WIKI_UPGRADE_MONOLITHIC_CONFIGURATION, + MessageDialog.WARNING, new String[] { "Upgrade", "Postpone", "Postpone for 30 days" }, 2); + + MessageDialog successUpgrade = new MessageDialog(Display.getDefault().getActiveShell(), "Success!", null, + "Templates were successfully upgraded. ", MessageDialog.INFORMATION, new String[] { "Ok" }, 1); + + dialog.setBlockOnOpen(true); + successUpgrade.setBlockOnOpen(true); + int result = dialog.open(); + if (result == 0) { + try { + ResourcesPluginUtil + .startTemplatesUpgrader(DeprecatedMonolithicConfigurationException.getMonolithicConfiguration()); + successUpgrade.open(); + } catch (Throwable a) { + String upgradeErrorMessage = "An error has occurred while upgrading the templates!"; + LOG.error(upgradeErrorMessage, a); + PlatformUIUtil.openErrorDialog(upgradeErrorMessage + " " + a.getMessage(), a); + } + } + if (result == 1) { + // Do nothing (Postpone and Continue) + } + if (result == 2) { + PostponeUtil.addATimestampForOneMonth(); + + } + }); + } + } diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/tools/PlatformUIUtil.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/tools/PlatformUIUtil.java index 1106de09ce..79e6080a1e 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/tools/PlatformUIUtil.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/tools/PlatformUIUtil.java @@ -21,8 +21,6 @@ /** * This class provides some helper functions in order to minimize code overhead - * - * @author Malte Brunnlieb (06.12.2012) */ public class PlatformUIUtil { diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/tools/ResourcesPluginUtil.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/tools/ResourcesPluginUtil.java index f7d1451db6..0b842712b7 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/tools/ResourcesPluginUtil.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/common/tools/ResourcesPluginUtil.java @@ -5,6 +5,7 @@ import java.net.MalformedURLException; import java.nio.file.FileSystem; import java.nio.file.FileSystems; +import java.nio.file.Files; import java.nio.file.Path; import org.apache.commons.lang3.StringUtils; @@ -20,13 +21,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.devonfw.cobigen.api.TemplateAdapter; import com.devonfw.cobigen.api.constants.ConfigurationConstants; import com.devonfw.cobigen.api.util.CobiGenPaths; import com.devonfw.cobigen.api.util.TemplatesJarUtil; import com.devonfw.cobigen.eclipse.common.constants.external.ResourceConstants; import com.devonfw.cobigen.eclipse.common.exceptions.GeneratorProjectNotExistentException; import com.devonfw.cobigen.eclipse.updatetemplates.UpdateTemplatesDialog; -import com.devonfw.cobigen.impl.util.ExtractTemplatesUtil; +import com.devonfw.cobigen.impl.CobiGenFactory; +import com.devonfw.cobigen.impl.adapter.TemplateAdapterImpl; /** Util for NPE save access of {@link ResourcesPlugin} utils */ public class ResourcesPluginUtil { @@ -51,6 +54,27 @@ public class ResourcesPluginUtil { */ static boolean userWantsToDownloadTemplates = true; + /** + * This variable is the path to the templateSet folder, when the ugrader is finished + */ + static Path templateSetPathAfterUpgrade; + + /** + * @return afterUpgradetemplateSetPath + */ + public static Path getTemplateSetPathAfterUpgrade() { + + return templateSetPathAfterUpgrade; + } + + /** + * @param afterUpgradetemplateSetPath new value of {@link #getafterUpgradetemplateSetPath}. + */ + public static void setTemplateSetPathAfterUpgrade(Path afterUpgradetemplateSetPath) { + + ResourcesPluginUtil.templateSetPathAfterUpgrade = afterUpgradetemplateSetPath; + } + /** * Refreshes the configuration project from the file system. */ @@ -88,9 +112,9 @@ public static IProject getGeneratorConfigurationProject() throws GeneratorProjec if (!generatorProj.exists()) { if (!isUpdateDialogShown) { if (templatesDirectory.exists()) { - File jarFile = TemplatesJarUtil.getJarFile(false, templatesDirectory); + Path jarFilePath = TemplatesJarUtil.getJarFile(false, templatesDirectory.toPath()); // If we don't find at least one jar, then we do need to download new templates - if (jarFile == null) { + if (jarFilePath == null || !Files.exists(jarFilePath)) { int result = createUpdateTemplatesDialog(); isUpdateDialogShown = true; if (result == 1) { @@ -113,7 +137,6 @@ public static IProject getGeneratorConfigurationProject() throws GeneratorProjec } } } - if (userWantsToDownloadTemplates) { return generatorProj; } else { @@ -168,26 +191,35 @@ public static String getJarPath(boolean isSource) { File templatesDirectory = getTemplatesDirectory(); - File jarFile = TemplatesJarUtil.getJarFile(isSource, templatesDirectory); + Path jarFilePath = TemplatesJarUtil.getJarFile(isSource, templatesDirectory.toPath()); - if (jarFile == null) { + if (jarFilePath == null || !Files.exists(jarFilePath)) { return ""; } - String fileName = jarFile.getPath().substring(jarFile.getPath().lastIndexOf(File.separator) + 1); - + String fileName = jarFilePath.toFile().getPath() + .substring(jarFilePath.toFile().getPath().lastIndexOf(File.separator) + 1); return fileName; } /** - * Gets or creates a new templates directory + * Gets or creates a new templates directory from the monolithic structure * * @return the templateDirectory */ private static File getTemplatesDirectory() { - File templatesDirectory = CobiGenPaths.getTemplatesFolderPath().toFile(); - return templatesDirectory; + return CobiGenPaths.getTemplatesFolderPath().toFile(); + } + + /** + * Gets or creates a new templates directory from the template-set structure + * + * @return the templateDirectory + */ + private static File getTemplateSetDirectory() { + + return CobiGenPaths.getTemplateSetsFolderPath().toFile(); } /** @@ -227,7 +259,9 @@ public static void processJar(String fileName) throws MalformedURLException, IOE } try { - ExtractTemplatesUtil.extractTemplates(cobigenFolderPath.resolve(ConfigurationConstants.COBIGEN_TEMPLATES), false); + TemplateAdapter templateAdapter = new TemplateAdapterImpl(null); + templateAdapter.adaptMonolithicTemplates(cobigenFolderPath.resolve(ConfigurationConstants.COBIGEN_TEMPLATES), + false); } catch (Exception e) { LOG.error("An exception occurred while processing Jar files to create CobiGen_Templates folder", e); PlatformUIUtil @@ -240,8 +274,7 @@ public static void processJar(String fileName) throws MalformedURLException, IOE */ public static IPath getWorkspaceLocation() { - IPath ws = ResourcesPlugin.getWorkspace().getRoot().getLocation(); - return ws; + return ResourcesPlugin.getWorkspace().getRoot().getLocation(); } /** @@ -254,4 +287,16 @@ public static void setUserWantsToDownloadTemplates(boolean userWantsToDownloadTe ResourcesPluginUtil.userWantsToDownloadTemplates = userWantsToDownloadTemplates; } + /** + * Upgrades the given template configuration. + * + * @param configurationPath path to the templates Configuration + */ + public static void startTemplatesUpgrader(Path configurationPath) { + + setTemplateSetPathAfterUpgrade(CobiGenFactory.startTemplatesUpgrader(configurationPath)); + + // FIXME after the upgrade adapt the new template-set folder. should be done in #1587 + } + } diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/generator/GeneratorWrapperFactory.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/generator/GeneratorWrapperFactory.java index 0a6cb781d7..be0e80590e 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/generator/GeneratorWrapperFactory.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/generator/GeneratorWrapperFactory.java @@ -1,6 +1,8 @@ package com.devonfw.cobigen.eclipse.generator; -import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Iterator; import java.util.List; @@ -11,7 +13,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jface.dialogs.MessageDialog; @@ -25,6 +26,8 @@ import org.slf4j.LoggerFactory; import com.devonfw.cobigen.api.CobiGen; +import com.devonfw.cobigen.api.constants.ConfigurationConstants; +import com.devonfw.cobigen.api.exception.DeprecatedMonolithicConfigurationException; import com.devonfw.cobigen.api.exception.InvalidConfigurationException; import com.devonfw.cobigen.api.util.CobiGenPaths; import com.devonfw.cobigen.api.util.TemplatesJarUtil; @@ -43,33 +46,35 @@ /** * Generator creation factory, which creates a specific generator instance dependent on the current selection within the * eclipse IDE - * - * @author mbrunnli (03.12.2014) */ public class GeneratorWrapperFactory { /** Logger instance. */ private static final Logger LOG = LoggerFactory.getLogger(GeneratorWrapperFactory.class); + private static IProject generatorProj = null; + /** * Creates a generator dependent on the input of the selection * * @param selection current {@link IStructuredSelection} treated as input for generation * @param monitor tracking progress + * @param allowMonolithicConfiguration ignores deprecated monolithic template folder structure and if found does not + * throw a DeprecatedMonolithicConfigurationException * @return a specific {@link CobiGenWrapper} instance * @throws GeneratorCreationException if any exception occurred during converting the inputs or creating the generator * @throws GeneratorProjectNotExistentException if the generator configuration project does not exist * @throws InvalidInputException if the selection includes non supported input types or is composed in a non supported * combination of inputs. */ - public static CobiGenWrapper createGenerator(ISelection selection, IProgressMonitor monitor) + public static CobiGenWrapper createGenerator(ISelection selection, IProgressMonitor monitor, + boolean allowMonolithicConfiguration) throws GeneratorCreationException, GeneratorProjectNotExistentException, InvalidInputException { List extractedInputs = extractValidEclipseInputs(selection); - if (extractedInputs.size() > 0) { monitor.subTask("Initialize CobiGen instance"); - CobiGen cobigen = initializeGenerator(); + CobiGen cobigen = initializeGenerator(allowMonolithicConfiguration); monitor.subTask("Reading inputs..."); monitor.worked(10); @@ -207,40 +212,76 @@ else if (selection instanceof IStructuredSelection) { * @throws InvalidConfigurationException if the context configuration is not valid * @throws GeneratorCreationException if the generator configuration project does not exist */ - private static CobiGen initializeGenerator() throws InvalidConfigurationException, GeneratorCreationException { + private static CobiGen initializeGenerator(boolean allowMonolithicConfiguration) + throws InvalidConfigurationException, GeneratorCreationException { try { ResourcesPluginUtil.refreshConfigurationProject(); - IProject generatorProj = ResourcesPluginUtil.getGeneratorConfigurationProject(); + generatorProj = ResourcesPluginUtil.getGeneratorConfigurationProject(); - if (generatorProj == null) { - throw new GeneratorCreationException( - "Configuration source could not be read. Have you downloaded the templates?"); + return initializeCobiGen(generatorProj, allowMonolithicConfiguration); + } catch (CoreException e) { + throw new GeneratorCreationException("An eclipse internal exception occurred", e); + } catch (DeprecatedMonolithicConfigurationException e) { + if (null == generatorProj.getLocationURI()) + throw e; + else { + throw new DeprecatedMonolithicConfigurationException(Paths.get(generatorProj.getLocationURI())); } + } catch (Throwable e) { + throw new GeneratorCreationException( + "Configuration source could not be read.\nIf you were updating templates, it may mean" + + " that you have no internet connection,", + e); + } + } + + /** + * Initializes the {@link CobiGen} with the correct configuration, checks if template-sets exists, if not the Jar or + * generatorProj will be used. + * + * @param generatorProj the templates project + * @param allowMonolithicConfiguration ignores deprecated monolithic template folder structure and if found does not + * throw a DeprecatedMonolithicConfigurationException + * @return the configured{@link CobiGen} + * @throws if the generator configuration project does not exist + * + */ + private static CobiGen initializeCobiGen(IProject generatorProj, boolean allowMonolithicConfiguration) + throws GeneratorCreationException { - // We need to check whether it is a valid Java Project - IJavaProject configJavaProject = JavaCore.create(generatorProj); + Path templatesDirectoryPath = CobiGenPaths.getTemplateSetsFolderPath(); + Path templateSetsAdaptedFolderPath = templatesDirectoryPath.resolve(ConfigurationConstants.ADAPTED_FOLDER); + Path templateSetsDownloadedFolderPath = templatesDirectoryPath.resolve(ConfigurationConstants.DOWNLOADED_FOLDER); - // If it is not valid, we should use the jar - if (null == generatorProj.getLocationURI() || !configJavaProject.exists()) { - File templatesDirectory = CobiGenPaths.getTemplatesFolderPath().toFile(); - File jarPath = TemplatesJarUtil.getJarFile(false, templatesDirectory); - boolean fileExists = jarPath.exists(); + if (ResourcesPluginUtil.getTemplateSetPathAfterUpgrade() != null) { + return CobiGenFactory.create(ResourcesPluginUtil.getTemplateSetPathAfterUpgrade().toUri(), + allowMonolithicConfiguration); + } + if (generatorProj == null) { + + // check adapted and downloaded folder + if (Files.exists(templateSetsAdaptedFolderPath) || Files.exists(templateSetsDownloadedFolderPath)) { + return CobiGenFactory.create(templatesDirectoryPath.toUri(), allowMonolithicConfiguration); + } + templatesDirectoryPath = CobiGenPaths.getTemplatesFolderPath(); + if (Files.exists(templatesDirectoryPath)) { + // If it is not valid, we should use the jar + Path jarPath = TemplatesJarUtil.getJarFile(false, templatesDirectoryPath); + boolean fileExists = (jarPath != null && Files.exists(jarPath)); if (!fileExists) { MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Warning", "Not Downloaded the CobiGen Template Jar"); } - return CobiGenFactory.create(jarPath.toURI()); - } else { - return CobiGenFactory.create(generatorProj.getLocationURI()); + return CobiGenFactory.create(jarPath.toUri(), allowMonolithicConfiguration); } - } catch (CoreException e) { - throw new GeneratorCreationException("An eclipse internal exception occurred", e); - } catch (Throwable e) { + } + if (generatorProj.getLocationURI() == null) { throw new GeneratorCreationException( - "Configuration source could not be read.\nIf you were updating templates, it may mean" - + " that you have no internet connection.", - e); + "Configuration source could not be read. Have you downloaded the templates?"); + } else { + return CobiGenFactory.create(generatorProj.getLocationURI(), allowMonolithicConfiguration); } } + } diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/generator/generic/FileInputConverter.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/generator/generic/FileInputConverter.java index e06e33fb5b..306b30d8c3 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/generator/generic/FileInputConverter.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/generator/generic/FileInputConverter.java @@ -20,8 +20,6 @@ /** * Converts IDE selection objects to valid CobiGen inputs - * - * @author mbrunnli (06.12.2014) */ public class FileInputConverter { diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/healthcheck/HealthCheckDialog.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/healthcheck/HealthCheckDialog.java index 146dac88bb..8e3466dabb 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/healthcheck/HealthCheckDialog.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/healthcheck/HealthCheckDialog.java @@ -1,6 +1,6 @@ package com.devonfw.cobigen.eclipse.healthcheck; -import java.io.File; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -16,6 +16,7 @@ import com.devonfw.cobigen.api.constants.BackupPolicy; import com.devonfw.cobigen.api.constants.ConfigurationConstants; import com.devonfw.cobigen.api.exception.ConfigurationConflictException; +import com.devonfw.cobigen.api.exception.DeprecatedMonolithicConfigurationException; import com.devonfw.cobigen.api.exception.InvalidConfigurationException; import com.devonfw.cobigen.api.to.HealthCheckReport; import com.devonfw.cobigen.api.util.CobiGenPaths; @@ -54,11 +55,23 @@ public HealthCheckDialog() { this.healthCheck = CobiGenFactory.createHealthCheck(); } + /** + * @see #execute(boolean) + */ + @SuppressWarnings("javadoc") + public void execute() { + + execute(false); + } + /** * Executes the simple health check, checking configuration project existence, validity of context configuration, as * well as validity of the current workbench selection as generation input. + * + * @param allowMonolithicConfiguration ignores deprecated monolithic template folder structure and if found does not + * throw a DeprecatedMonolithicConfigurationException */ - public void execute() { + public void execute(boolean allowMonolithicConfiguration) { String firstStep = "1. CobiGen configuration project '" + ResourceConstants.CONFIG_PROJECT_NAME + "'... "; String secondStep = "\n2. CobiGen context configuration '" + ConfigurationConstants.CONTEXT_CONFIG_FILENAME @@ -78,11 +91,13 @@ public void execute() { this.report = performHealthCheckReport(); if (generatorConfProj != null && generatorConfProj.getLocationURI() != null) { - CobiGenFactory.create(generatorConfProj.getLocationURI()); + + CobiGenFactory.create(generatorConfProj.getLocationURI(), allowMonolithicConfiguration); + } else { - File templatesDirectory = CobiGenPaths.getTemplatesFolderPath().toFile(); - File jarPath = TemplatesJarUtil.getJarFile(false, templatesDirectory); - boolean fileExists = jarPath.exists(); + Path templatesDirectoryPath = CobiGenPaths.getTemplatesFolderPath(); + Path jarPath = TemplatesJarUtil.getJarFile(false, templatesDirectoryPath); + boolean fileExists = (jarPath != null && Files.exists(jarPath)); if (!fileExists) { MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Warning", "Not Downloaded the CobiGen Template Jar"); @@ -133,7 +148,7 @@ public void execute() { @Override public void run() { - execute(); + execute(allowMonolithicConfiguration); } }); } @@ -149,6 +164,9 @@ public void run() { PlatformUIUtil.openErrorDialog(healthyCheckMessage, null); } LOG.warn(healthyCheckMessage, e); + } catch (DeprecatedMonolithicConfigurationException e) { + // TODO: Check what to do here, see: https://github.com/devonfw/cobigen/issues/1675 + throw e; } catch (Throwable e) { healthyCheckMessage = "An unexpected error occurred! Templates were not found."; if (this.report != null && healthyCheckMessage != null) { diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/JavaClasspathUtil.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/JavaClasspathUtil.java index 77d3b10dc2..70118ec430 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/JavaClasspathUtil.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/JavaClasspathUtil.java @@ -13,7 +13,6 @@ /** * This util provides JDT classpath operations * - * @author Malte Brunnlieb * @version $Revision$ */ public class JavaClasspathUtil { diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/ICompilationUnitStub.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/ICompilationUnitStub.java index d4238e271b..a17e589955 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/ICompilationUnitStub.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/ICompilationUnitStub.java @@ -24,8 +24,6 @@ /** * Stub for {@link ICompilationUnit} in order to simulate resources in the generate wizard - * - * @author mbrunnli (05.04.2014) */ @SuppressWarnings("deprecation") public class ICompilationUnitStub extends IJavaElementStub implements ICompilationUnit { diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/IFileStub.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/IFileStub.java index 6f881fcf39..3409528fc1 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/IFileStub.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/IFileStub.java @@ -13,8 +13,6 @@ /** * Stub for {@link IFile} in order to simulate resources in the generate wizard - * - * @author mbrunnli (06.04.2014) */ public class IFileStub extends IResourceStub implements IFile { diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/IFolderStub.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/IFolderStub.java index a15dc3957c..a3261e7cde 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/IFolderStub.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/IFolderStub.java @@ -13,8 +13,6 @@ /** * Stub for {@link IFolder} in order to simulate resources in the generate wizard - * - * @author mbrunnli (06.04.2014) */ public class IFolderStub extends IResourceStub implements IFolder { diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/IPackageFragmentRootStub.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/IPackageFragmentRootStub.java index e76de82661..fc1883d882 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/IPackageFragmentRootStub.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/model/stubs/IPackageFragmentRootStub.java @@ -17,8 +17,6 @@ /** * Stub for {@link IPackageFragmentRoot} in order to simulate resources in the generate wizard - * - * @author mbrunnli (05.04.2014) */ public class IPackageFragmentRootStub implements IPackageFragmentRoot { diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/widget/SimulatedCheckboxTreeViewer.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/widget/SimulatedCheckboxTreeViewer.java index 0fd77362a1..ead67fa160 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/widget/SimulatedCheckboxTreeViewer.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/wizard/common/widget/SimulatedCheckboxTreeViewer.java @@ -67,7 +67,6 @@ public boolean setChecked(Object element, boolean state) { * @param element to be checked * @return true if the element is currently visible
* false otherwise - * @author mbrunnli (12.03.2013) */ private boolean isVisible(Object element) { diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/ConfigurationProjectListener.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/ConfigurationProjectListener.java index 8e7bacc804..6e310e1bdd 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/ConfigurationProjectListener.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/ConfigurationProjectListener.java @@ -18,8 +18,6 @@ * {@link ConfigurationProjectListener} for starting / stopping the {@link LogbackConfigChangeListener}. This class is * an abstract, due to the potential need of having multiple nested {@link IResourceChangeListener} for the CobiGen * configuration. - * - * @author mbrunnli (08.04.2013) */ public class ConfigurationProjectListener implements IResourceChangeListener { diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/GenerateHandler.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/GenerateHandler.java index 938eec18bc..48132bd0b6 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/GenerateHandler.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/GenerateHandler.java @@ -18,8 +18,6 @@ /** * Handler for the Package-Explorer Event - * - * @author mbrunnli (13.02.2013) */ public class GenerateHandler extends AbstractHandler { diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/GenerateJob.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/GenerateJob.java index 9ae3340701..9695cd5414 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/GenerateJob.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/GenerateJob.java @@ -22,6 +22,7 @@ import com.devonfw.cobigen.eclipse.generator.GeneratorWrapperFactory; import com.devonfw.cobigen.eclipse.wizard.generate.GenerateBatchWizard; import com.devonfw.cobigen.eclipse.wizard.generate.GenerateWizard; +import com.devonfw.cobigen.impl.util.PostponeUtil; /** * @@ -59,13 +60,16 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException, Inte MDC.put(InfrastructureConstants.CORRELATION_ID, this.correlationId); - // when this handler is executed, we should we should be sure, that the selection is currently - // supported by the following implementation + // when this handler is executed, we should be sure, that the selection is currently supported by the following + // implementation try { LOG.info("Initiating CobiGen..."); monitor.beginTask("Initiating CobiGen...", 1); - CobiGenWrapper generator = GeneratorWrapperFactory.createGenerator(this.selection, monitor); + // TODO: Check this, see: https://github.com/devonfw/cobigen/issues/1679 + if (PostponeUtil.isTimePassed()) + checkMonolithicConfigurationException(monitor); + CobiGenWrapper generator = GeneratorWrapperFactory.createGenerator(this.selection, monitor, true); monitor.worked(1); if (generator == null) { LOG.error("Invalid selection. No CobiGen instance created. Exiting generate command."); @@ -109,4 +113,20 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException, Inte MDC.remove(InfrastructureConstants.CORRELATION_ID); } + /** + * Checks if monolithic configuration exists, handles the exception and lets the user decide if the templates should + * be upgraded. + * + * @param monitor of run method + */ + private void checkMonolithicConfigurationException(IProgressMonitor monitor) { + + try { + GeneratorWrapperFactory.createGenerator(this.selection, monitor, false); + } catch (Throwable e) { + ExceptionHandler.handle(e, HandlerUtil.getActiveShell(this.event)); + } + + } + } diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/HealthCheckHandler.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/HealthCheckHandler.java index 8218348617..0aba16dbc9 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/HealthCheckHandler.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/HealthCheckHandler.java @@ -28,13 +28,30 @@ public Object execute(final ExecutionEvent event) throws ExecutionException { MDC.put(InfrastructureConstants.CORRELATION_ID, UUID.randomUUID().toString()); + checkMonolithicConfigurationException(event); try { - new HealthCheckDialog().execute(); + new HealthCheckDialog().execute(true); } catch (Throwable e) { ExceptionHandler.handle(e, HandlerUtil.getActiveShell(event)); } - MDC.remove(InfrastructureConstants.CORRELATION_ID); return null; } + + /** + * checks if monolithic configuration exist, handles the exception and lets the user decide if the templates should be + * upgraded. + * + * @param event handler event executing this job. + * + */ + private void checkMonolithicConfigurationException(ExecutionEvent event) { + + try { + new HealthCheckDialog().execute(); + } catch (Throwable e) { + ExceptionHandler.handle(e, HandlerUtil.getActiveShell(event)); + } + + } } diff --git a/cobigen-eclipse/pom.xml b/cobigen-eclipse/pom.xml index 2ec7ef8031..843c8c5424 100644 --- a/cobigen-eclipse/pom.xml +++ b/cobigen-eclipse/pom.xml @@ -5,25 +5,22 @@ eclipse-parent CobiGen - Eclipse Plug-In Parent pom - com.devonfw.cobigen master-parent ${revision} - https://oss.sonatype.org/content/groups/public/ - https://download.eclipse.org/releases/photon + + https://download.eclipse.org/releases/2018-12/ - cobigen-eclipse cobigen-eclipse-test cobigen-eclipse-feature cobigen-eclipse-updatesite - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/api/${variables.component#cap_first}.java.ftl b/cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/${variables.component#cap_first}.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/api/${variables.component#cap_first}.java.ftl rename to cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/${variables.component#cap_first}.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/api/${variables.component#cap_first}Ctos.java.ftl b/cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/${variables.component#cap_first}Ctos.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/api/${variables.component#cap_first}Ctos.java.ftl rename to cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/${variables.component#cap_first}Ctos.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/common/api/cobigen.properties b/cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/cobigen.properties similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/common/api/cobigen.properties rename to cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/cobigen.properties diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/api/usecase/UcFind${variables.entityName}.java.ftl b/cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/usecase/UcFind${variables.entityName}.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/api/usecase/UcFind${variables.entityName}.java.ftl rename to cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/usecase/UcFind${variables.entityName}.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/api/usecase/UcFind${variables.entityName}Ctos.java.ftl b/cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/usecase/UcFind${variables.entityName}Ctos.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/api/usecase/UcFind${variables.entityName}Ctos.java.ftl rename to cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/usecase/UcFind${variables.entityName}Ctos.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/api/usecase/UcManage${variables.entityName}.java.ftl b/cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/usecase/UcManage${variables.entityName}.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/api/usecase/UcManage${variables.entityName}.java.ftl rename to cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/usecase/UcManage${variables.entityName}.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/base/usecase/Abstract${variables.entityName}Uc.java.ftl b/cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/base/usecase/Abstract${variables.entityName}Uc.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/base/usecase/Abstract${variables.entityName}Uc.java.ftl rename to cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/base/usecase/Abstract${variables.entityName}Uc.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/${variables.component#cap_first}Impl.java.ftl b/cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/${variables.component#cap_first}Impl.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/${variables.component#cap_first}Impl.java.ftl rename to cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/${variables.component#cap_first}Impl.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/${variables.component#cap_first}ImplCtos.java.ftl b/cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/${variables.component#cap_first}ImplCtos.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/${variables.component#cap_first}ImplCtos.java.ftl rename to cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/${variables.component#cap_first}ImplCtos.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/usecase/UcFind${variables.entityName}Impl.java.ftl b/cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/usecase/UcFind${variables.entityName}Impl.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/usecase/UcFind${variables.entityName}Impl.java.ftl rename to cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/usecase/UcFind${variables.entityName}Impl.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/usecase/UcFind${variables.entityName}ImplCtos.java.ftl b/cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/usecase/UcFind${variables.entityName}ImplCtos.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/usecase/UcFind${variables.entityName}ImplCtos.java.ftl rename to cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/usecase/UcFind${variables.entityName}ImplCtos.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/usecase/UcManage${variables.entityName}Impl.java.ftl b/cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/usecase/UcManage${variables.entityName}Impl.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/usecase/UcManage${variables.entityName}Impl.java.ftl rename to cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/impl/usecase/UcManage${variables.entityName}Impl.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/common/base/AbstractBeanMapperSupport.java.ftl b/cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/general/common/base/AbstractBeanMapperSupport.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/common/base/AbstractBeanMapperSupport.java.ftl rename to cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/general/common/base/AbstractBeanMapperSupport.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/general/logic/base/AbstractLogic.java.ftl b/cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/general/logic/base/AbstractLogic.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/general/logic/base/AbstractLogic.java.ftl rename to cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/general/logic/base/AbstractLogic.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/general/logic/base/AbstractUc.java.ftl b/cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/general/logic/base/AbstractUc.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/general/logic/base/AbstractUc.java.ftl rename to cobigen-templates/crud-java-server-app-complex/src/main/resources/templates/java/${variables.rootPackage}/general/logic/base/AbstractUc.java.ftl diff --git a/cobigen-templates/crud-java-server-app-complex/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudJavaServerAppComplexTest.java b/cobigen-templates/crud-java-server-app-complex/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudJavaServerAppComplexTest.java new file mode 100644 index 0000000000..c2bcaafac8 --- /dev/null +++ b/cobigen-templates/crud-java-server-app-complex/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudJavaServerAppComplexTest.java @@ -0,0 +1,99 @@ +package com.devonfw.cobigen.templates.devon4j.test.templates; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.apache.commons.io.FileUtils; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.devonfw.cobigen.api.constants.ConfigurationConstants; +import com.devonfw.cobigen.maven.test.AbstractMavenTest; +import com.devonfw.cobigen.templates.devon4j.config.constant.MavenMetadata; + +/** + * Smoke tests of all templates. + */ +public class CrudJavaServerAppComplexTest extends AbstractMavenTest { + + /** Root of all test resources of this test suite */ + public static final String TEST_RESOURCES_ROOT = "src/test/resources/testdata/templatetest/"; + + /** Temporary files rule to create temporary folders */ + @ClassRule + public static TemporaryFolder tempFolder = new TemporaryFolder(); + + /** The templates development folder */ + protected static Path templatesProject; + + /** The templates development folder */ + protected static Path templatesProjectTemporary; + + /** + * Creates a copy of the templates project in the temp directory + * + * @throws URISyntaxException if the path could not be created properly + * @throws IOException if accessing a directory or file fails + */ + @BeforeClass + public static void setupDevTemplates() throws URISyntaxException, IOException { + + templatesProject = new File( + CrudJavaServerAppComplexTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile() + .getParentFile().toPath(); + + Path utilsPom = new File( + CrudJavaServerAppComplexTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile() + .getParentFile().toPath().resolve("src/test/resources/utils/pom.xml"); + + // create a temporary directory cobigen-templates/template-sets/adapted containing the template sets + Path tempFolderPath = tempFolder.getRoot().toPath(); + Path cobigenTemplatePath = tempFolderPath.resolve("cobigen-templates"); + if (!Files.exists(cobigenTemplatePath)) { + Files.createDirectory(cobigenTemplatePath); + + templatesProjectTemporary = cobigenTemplatePath.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER); + Path templateSetsAdaptedFolder = templatesProjectTemporary.resolve(ConfigurationConstants.ADAPTED_FOLDER); + Files.createDirectory(templatesProjectTemporary); + Files.createDirectory(templateSetsAdaptedFolder); + + Path templateSetPath = templateSetsAdaptedFolder.resolve("template-set"); + FileUtils.copyDirectory(templatesProject.toFile(), templateSetPath.toFile()); + + if (Files.isDirectory(templateSetPath)) { + + // Replace the pom.xml in the template sets. Needed so that the project in the temp directory is build + // properly + if (Files.exists(templateSetPath.resolve("pom.xml"))) { + try { + Files.delete(templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error deleting file " + templateSetPath.resolve("pom.xml"), e); + } + try { + Files.copy(utilsPom, templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error copying file " + utilsPom, e); + } + } + } + } + } + + /** + * Test successful generation of all templates based on an entity + * + * @throws Exception test fails + */ + @Test + public void testAllTemplatesGeneration_EntityInput() throws Exception { + + File testProject = new File(TEST_RESOURCES_ROOT + "TestAllTemplatesEntityInput/"); + runMavenInvoker(testProject, templatesProjectTemporary.toFile(), MavenMetadata.LOCAL_REPO); + } +} diff --git a/cobigen-templates/crud-java-server-app-complex/src/test/resources/application.properties b/cobigen-templates/crud-java-server-app-complex/src/test/resources/application.properties new file mode 100644 index 0000000000..cf2c614efb --- /dev/null +++ b/cobigen-templates/crud-java-server-app-complex/src/test/resources/application.properties @@ -0,0 +1,2 @@ +server.port=8080 +server.context-path=/ \ No newline at end of file diff --git a/cobigen-templates/crud-java-server-app-complex/src/test/resources/logback.xml b/cobigen-templates/crud-java-server-app-complex/src/test/resources/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/crud-java-server-app-complex/src/test/resources/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/crud-java-server-app-complex/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml b/cobigen-templates/crud-java-server-app-complex/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/crud-java-server-app-complex/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml b/cobigen-templates/crud-java-server-app-complex/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml similarity index 100% rename from cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml rename to cobigen-templates/crud-java-server-app-complex/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml diff --git a/cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java b/cobigen-templates/crud-java-server-app-complex/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java similarity index 100% rename from cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java rename to cobigen-templates/crud-java-server-app-complex/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java diff --git a/cobigen-templates/crud-java-server-app-complex/src/test/resources/utils/pom.xml b/cobigen-templates/crud-java-server-app-complex/src/test/resources/utils/pom.xml new file mode 100644 index 0000000000..2f59b21378 --- /dev/null +++ b/cobigen-templates/crud-java-server-app-complex/src/test/resources/utils/pom.xml @@ -0,0 +1,100 @@ + + + 4.0.0 + com.devonfw.cobigen.templates + crud-java-server-app-complex + 2021.12.007-SNAPSHOT + Crud Java Server App Complex + A Code-based incremental Generator + https://github.com/devonfw/cobigen/templates-parent/templates-devon4j-utils + + + Apache Software License 2.0 + https://raw.githubusercontent.com/devonfw/.github/master/LICENSE + repo + + + + + + javax.ws.rs + javax.ws.rs-api + 2.0 + compile + + + org.springframework.data + spring-data-rest-webmvc + 3.7.10 + compile + + + org.apache.commons + commons-lang3 + 3.12.0 + compile + + + com.fasterxml.jackson.core + jackson-databind + 2.10.0 + compile + + + xerces + xercesImpl + 2.12.2 + compile + + + javax.persistence + javax.persistence-api + 2.2 + compile + + + org.slf4j + slf4j-api + 1.7.30 + compile + + + org.slf4j + jcl-over-slf4j + 1.7.30 + compile + + + org.slf4j + log4j-over-slf4j + 1.7.30 + compile + + + + + + false + + + true + + ossrh + OSSRH Snapshots + https://s01.oss.sonatype.org/content/repositories/snapshots/ + + + + + 1.8 + 1.8 + + + + + + src/main/java + + + \ No newline at end of file diff --git a/cobigen-templates/crud-java-server-app/pom.xml b/cobigen-templates/crud-java-server-app/pom.xml new file mode 100644 index 0000000000..ba577e68e5 --- /dev/null +++ b/cobigen-templates/crud-java-server-app/pom.xml @@ -0,0 +1,19 @@ + + 4.0.0 + crud-java-server-app + CRUD Java Server App template + + + com.devonfw.cobigen.templates + templates-parent + ${revision} + + + + + org.apache.commons + commons-lang3 + + + \ No newline at end of file diff --git a/cobigen-templates/crud-java-server-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java b/cobigen-templates/crud-java-server-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java new file mode 100644 index 0000000000..395d46154d --- /dev/null +++ b/cobigen-templates/crud-java-server-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java @@ -0,0 +1,12 @@ +package com.devonfw.cobigen.templates.devon4j.config.constant; + +/** + * Constants extracted from the maven pom by templating-maven-plugin. + * + * @see "edit template in src/main/java-templates" + */ +public class MavenMetadata { + + /** Local repository path */ + public static final String LOCAL_REPO = "${settings.localRepository}"; +} diff --git a/cobigen-templates/crud-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/constants/Field.java b/cobigen-templates/crud-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/constants/Field.java new file mode 100644 index 0000000000..5376daaea9 --- /dev/null +++ b/cobigen-templates/crud-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/constants/Field.java @@ -0,0 +1,48 @@ +package com.devonfw.cobigen.templates.devon4j.constants; + +/** + * Contains the used keys for the pojo field mapping + */ +public enum Field { + + /** + * Name of the field + */ + NAME("name"), + /** + * Type of the field + */ + TYPE("type"), + /** + * Canonical Type of the field + */ + CANONICAL_TYPE("canonicalType"), + /** + * The Javadoc of the field + */ + JAVA_DOC("javaDoc"), + /** + * Annotations + */ + ANNOTATIONS("annotations"); + + /** + * key value + */ + private String value; + + /** + * @param value of the key + */ + Field(String value) { + + this.value = value; + } + + @Override + public String toString() { + + return this.value; + } + +} diff --git a/cobigen-templates/crud-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/DevonfwUtil.java b/cobigen-templates/crud-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/DevonfwUtil.java new file mode 100644 index 0000000000..4de413b930 --- /dev/null +++ b/cobigen-templates/crud-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/DevonfwUtil.java @@ -0,0 +1,449 @@ +package com.devonfw.cobigen.templates.devon4j.utils; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.w3c.dom.Attr; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import com.devonfw.cobigen.templates.devon4j.constants.Field; + +/** + * A class for shared devon4j specific functions in the templates + * + */ +@SuppressWarnings("restriction") +public class DevonfwUtil { + + /** + * Check whether the given 'canonicalType' is a devon4j Entity, which is declared in the given 'component' + * + * @param canonicalType the type name + * @param component the component name + * @return true iff the canonicalType is a devon Entity + */ + public boolean isEntityInComponent(String canonicalType, String component) { + + return canonicalType.matches(String.format(".+%1$s\\.dataaccess\\.api\\.[A-Za-z0-9]+Entity(<.*)?", component)); + } + + /** + * Check whether the given 'canonicalType' is declared in the given 'component' + * + * @param canonicalType the type name + * @param component the component name + * @return true iff the canonicalType is inside the given component + */ + public boolean isTypeInComponent(String canonicalType, String component) { + + return canonicalType.matches(String.format("%1$s.[A-Za-z0-9]+(<.*)?", component)); + } + + /** + * Determines the ID getter for a given 'field' dependent on whether the getter should access the ID via an object + * reference or a direct ID getter + * + * @param field the field + * @param byObjectReference boolean + * @param component the devon4j component name + * @return 'get' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)} + '()' with + * capitalize=true + */ + public String resolveIdGetter(Map field, boolean byObjectReference, String component) { + + // If field comes from an UML file + if (field.getClass().toGenericString().contains("freemarker.ext.beans.HashAdapter")) { + return resolveIdGetter(field, byObjectReference, component); + } + return "get" + resolveIdVariableNameOrSetterGetterSuffix(field, byObjectReference, true, component) + "()"; + } + + /** + * Determines the ID getter for a given 'field' dependent on whether the getter should access the ID via an object + * reference or a direct ID getter + * + * This method is used when the field parameter comes from an UML file. The name and type of the attributes must be + * pre-processed for later inserting them inside the HashMap. + * + * @param field the field + * @param byObjectReference boolean + * @param component the devon4j component name + * @return 'get' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)} + '()' with + * capitalize=true + */ + public String resolveIdGetter(Node field, boolean byObjectReference, String component) { + + HashMap nodeHash = new HashMap<>(); + + // Putting the name of the attribute to the hash + nodeHash.put(Field.NAME.toString(), field.getAttributes().getNamedItem("name")); + + // Putting the type of the attribute to the hash + NodeList childs = field.getChildNodes(); + for (int i = 0; i < childs.getLength(); i++) { + // Retrieve "type" tag + if (childs.item(i).getNodeName().equals("type")) { + NamedNodeMap attrs = childs.item(i).getAttributes(); + for (int j = 0; j < attrs.getLength(); j++) { + Attr attribute = (Attr) attrs.item(j); + // Try to find the attribute that contains the type + if (attribute.getName().equals("xmi:idref")) { + nodeHash.put(Field.TYPE.toString(), attribute.getName().replace("EAJava_", "")); + } + } + } + } + return "get" + resolveIdVariableNameOrSetterGetterSuffix(nodeHash, byObjectReference, true, component) + "()"; + + } + + /** + * Determines the ID getter for a given 'field' dependent on whether the getter should access the ID via an object + * reference or a direct ID getter + * + * @param pojoClass the class object of the pojo + * @param fieldMap the field mapping + * @param byObjectReference boolean + * @param component the devon4j component name + * @return 'get' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)} + '()' with + * capitalize=true + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdGetter(Class pojoClass, Map fieldMap, boolean byObjectReference, + String component) throws NoSuchFieldException, SecurityException { + + return "get" + resolveIdVariableNameOrSetterGetterSuffix(pojoClass, fieldMap, byObjectReference, true, component) + + "()"; + } + + /** + * same as {@link #resolveIdGetter(Map, boolean, String)} but with byObjectReference=false and component="" + * + * @param field the field + * @return 'get' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map,boolean,boolean,String)} + '()' with + * capitalize=true + */ + public String resolveIdGetter(Map field) { + + return this.resolveIdGetter(field, false, ""); + } + + /** + * same as {@link #resolveIdGetter(Class,Map,boolean,String)} but with byObjectReference=false and component="" + * + * @param pojoClass the class object of the pojo + * @param fieldMap the field mapping + * @return 'get' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map,boolean,boolean,String)} + '()' with + * capitalize=true + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdGetter(Class pojoClass, Map fieldMap) + throws NoSuchFieldException, SecurityException { + + return resolveIdGetter(pojoClass, fieldMap, false, ""); + } + + /** + * Determines the ID setter for a given 'field' dependent on whether the setter should access the ID via an object + * reference or a direct ID setter. In contrast to resolveIdGetter, this function does not generate the function + * parenthesis to enable parameter declaration. + * + * @param field the field + * @param byObjectReference boolean + * @param component the devon4j component name + * @return 'set' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)} with + * capitalize=true + */ + public String resolveIdSetter(Map field, boolean byObjectReference, String component) { + + return "set" + resolveIdVariableNameOrSetterGetterSuffix(field, byObjectReference, true, component); + } + + /** + * same as {@link #resolveIdSetter(Map, boolean, String)} but with byObjectReference=false and component="" + * + * @param field the field + * @return 'set' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)} with + * capitalize=true + */ + public String resolveIdSetter(Map field) { + + return this.resolveIdSetter(field, false, ""); + } + + /** + * Determines the ID setter for a given 'field' dependent on whether the setter should access the ID via an object + * reference or a direct ID setter. In contrast to resolveIdGetter, this function does not generate the function + * parenthesis to enable parameter declaration. + * + * @param pojoClass the class object of the pojo + * @param fieldMap the field mapping + * @param byObjectReference boolean + * @param component the devon4j component name + * @return 'set'+ {@link #resolveIdVariableNameOrSetterGetterSuffix(Map,boolean,boolean,String)} with capitalize=true + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdSetter(Class pojoClass, Map fieldMap, boolean byObjectReference, + String component) throws NoSuchFieldException, SecurityException { + + return "set" + resolveIdVariableNameOrSetterGetterSuffix(pojoClass, fieldMap, byObjectReference, true, component); + } + + /** + * same as {@link #resolveIdSetter(Class,Map,boolean,String)} but with byObjectReference=false and component="" + * + * @param pojoClass the class object of the pojo + * @param fieldMap the field mapping + * @return 'set' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map,boolean,boolean,String)} with capitalize=true + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdSetter(Class pojoClass, Map fieldMap) + throws NoSuchFieldException, SecurityException { + + return resolveIdSetter(pojoClass, fieldMap, false, ""); + } + + /** + * Determines the variable name for the id value of the 'field' + * + * @param field the field + * @return {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)}) with + * byObjectReference=false, capitalize=false and component="" + */ + public String resolveIdVariableName(Map field) { + + // the component is passed down as an empty string since byObjectReference is false and therefore the + // component is + // never touched + return resolveIdVariableNameOrSetterGetterSuffix(field, false, false, ""); + } + + /** + * Determines the variable name for the id value of the specified field in the pojo + * + * @param pojoClass the class object of the pojo + * @param fieldMap the field mapping + * @return {@link #resolveIdVariableNameOrSetterGetterSuffix(Class, Map, boolean, boolean, String)}) with + * byObjectReference=false, capitalize=false and component="" + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdVariableName(Class pojoClass, Map fieldMap) + throws NoSuchFieldException, SecurityException { + + // the component is passed down as an empty string since byObjectReference is false and therefore the + // component is + // never touched + return resolveIdVariableNameOrSetterGetterSuffix(pojoClass, fieldMap, false, false, ""); + } + + /** + * Determines the ID setter/getter suffix for a given 'field' dependent on whether the setter/getter should access the + * ID via an object reference or a direct ID setter/getter + * + * @param field the field + * @param byObjectReference boolean + * @param capitalize if the field name should be capitalized + * @param component the devon4j component. Only needed if $byObjectReference is true + * @return idVariable name or getter/setter suffix + */ + public String resolveIdVariableNameOrSetterGetterSuffix(Map field, boolean byObjectReference, + boolean capitalize, String component) { + + String fieldName = (String) field.get(Field.NAME.toString()); + if (capitalize) { + fieldName = fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1); + } + String suffix = ""; + + String fieldType = (String) field.get(Field.TYPE.toString()); + String fieldCType = (String) field.get(Field.CANONICAL_TYPE.toString()); + if (fieldType.contains("Entity")) { + if (fieldCType.startsWith("java.util.List") || fieldCType.startsWith("java.util.Set")) { + suffix = "Ids"; + if (fieldName.endsWith("s")) { + // Assume trailing 's' as indicator for a plural + fieldName = fieldName.substring(0, fieldName.length() - 1); + } + } else { + suffix = "Id"; + } + if (byObjectReference && isTypeInComponent(fieldCType, component)) { + // direct references for Entities in same component, so get id of the object reference + suffix = "().getId"; + } + } + + return fieldName + suffix; + + } + + /** + * Determines the ID setter/getter suffix for a given 'field' dependent on whether the setter/getter should access the + * ID via an object reference or a direct ID setter/getter + * + * @param pojoClass the {@link Class} object of the pojo + * @param fieldMap the field mapping + * @param byObjectReference boolean + * @param capitalize if the field name should be capitalized + * @param component the devon4j component. Only needed if byObjectReference is true + * @return idVariable name or getter/setter suffix + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdVariableNameOrSetterGetterSuffix(Class pojoClass, Map fieldMap, + boolean byObjectReference, boolean capitalize, String component) throws NoSuchFieldException, SecurityException { + + String resultName = (String) fieldMap.get(Field.NAME.toString()); + if (capitalize) { + resultName = resultName.substring(0, 1).toUpperCase() + resultName.substring(1); + } + String suffix = ""; + String fieldType = (String) fieldMap.get(Field.TYPE.toString()); + String fieldName = (String) fieldMap.get(Field.NAME.toString()); + if (fieldType.contains("Entity")) { + if (Collection.class.isAssignableFrom(pojoClass.getDeclaredField(fieldName).getType())) { + suffix = "Ids"; + if (resultName.endsWith("s")) { + // Assume trailing 's' as indicator for a plural + resultName = resultName.substring(0, resultName.length() - 1); + } + } else { + suffix = "Id"; + } + if (byObjectReference + && isEntityInComponent(pojoClass.getDeclaredField(fieldName).getType().getName(), component)) { + // direct references for Entities in same component, so get id of the object reference + suffix = "().getId"; + } + } + + return resultName + suffix; + + } + + /** + * Returns the argument type of the list or set from a field. If the string contains "Entity" it will remove that + * part. For example, if we have a List <SampleEntity> it will return "Sample" + * + * @param field the field + * @param pojoClass the object class of the Entity that contains the field + * @return fieldType argument of the list + * @throws SecurityException if field type could not accessed + * @throws NoSuchFieldException if field could not be found + */ + public String getListArgumentType(Map field, Class pojoClass) + throws NoSuchFieldException, SecurityException { + + JavaUtil javaUtil = new JavaUtil(); + + String fieldType = (String) field.get(Field.TYPE.toString()); + String fieldName = (String) field.get(Field.NAME.toString()); + + if (fieldType.contains("Entity")) { + if (javaUtil.isCollection(pojoClass, fieldName)) { + + fieldType = fieldType.replace("Entity", ""); + // Regex: Extracts the argument type of the list 'List' => type + String regex = "(?<=\\<).+?(?=\\>)"; + Pattern pattern = Pattern.compile(regex); + Matcher regexMatcher = pattern.matcher(fieldType); + + if (regexMatcher.find()) { + fieldType = regexMatcher.group(0); + } + } + } + return fieldType; + + } + + /** + * Converts all occurrences of devon4j Entity types in the given 'field' simple type (possibly generic) to Longs + * + * @param field the field + * @return the field type as String. If field type contains 'Entity' the result is Long + */ + public String getSimpleEntityTypeAsLongReference(Map field) { + + String fieldType = (String) field.get(Field.TYPE.toString()); + if (fieldType.endsWith("Entity")) { + fieldType = fieldType.replaceAll("[^<>]+Entity", "Long"); + } + return fieldType; + } + + /** + * If the string last character is an 's', then it gets removed + * + * @param targetClassName string to remove plural + * @return string without 's' + */ + public String removePlural(String targetClassName) { + + if (targetClassName.charAt(targetClassName.length() - 1) == 's') { + targetClassName = targetClassName.substring(0, targetClassName.length() - 1); + } + return targetClassName; + } + + /** + * Checks whether the operation with the given ID corresponds to any standard CRUD method name. + * + * @param operationId operation ID interpreted as method name + * @param entityName entity name to check standard CRUD methods for + * @return true if the operation ID maps any standard CRUD method name, false otherwise + */ + public boolean isCrudOperation(String operationId, String entityName) { + + if (operationId == null) { + return false; + } + String opIdLowerCase = operationId.toLowerCase(); + String entityNameLowerCase = entityName.toLowerCase(); + if (opIdLowerCase.contains(entityNameLowerCase)) { + return opIdLowerCase.equals("find" + entityNameLowerCase) + || opIdLowerCase.equals("find" + entityNameLowerCase + "Etos") + || opIdLowerCase.equals("delete" + entityNameLowerCase) || opIdLowerCase.equals("save" + entityNameLowerCase); + } else { + return false; + } + } + + /** + * Converts the given media type to the spring Java enum value + * + * @param mediaType to be converted + * @return the spring enum value representing the given media type + */ + public String getSpringMediaType(String mediaType) { + + switch (mediaType) { + case "application/xml": + return "APPLICATION_XML_VALUE"; + case "application / x-www-form-urlencoded": + return "APPLICATION_FORM_URLENCODED_VALUE"; + case "multipart/form-data": + return "MULTIPART_FORM_DATA_VALUE"; + case "text/plain": + return "TEXT_PLAIN_VALUE"; + case "text/html": + return "TEXT_HTML_VALUE"; + case "application/pdf": + return "APPLICATION_PDF_VALUE"; + case "image/png": + return "IMAGE_PNG_VALUE"; + default: + return "APPLICATION_JSON_VALUE"; + } + } +} \ No newline at end of file diff --git a/cobigen-templates/crud-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java b/cobigen-templates/crud-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java new file mode 100644 index 0000000000..ced2f5fde2 --- /dev/null +++ b/cobigen-templates/crud-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java @@ -0,0 +1,464 @@ +package com.devonfw.cobigen.templates.devon4j.utils; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.Map; + +import org.apache.commons.lang3.ClassUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Provides type operations, mainly checks and casts for Java Primitives, to be used in the templates + * + */ +public class JavaUtil { + + /** + * Logger for this class + */ + private static final Logger LOG = LoggerFactory.getLogger(JavaUtil.class); + + /** + * The constructor. + */ + public JavaUtil() { + + // Empty for CobiGen to automatically instantiate it + } + + /** + * Returns the Object version of a Java primitive or the input if the input isn't a java primitive + * + * @param simpleType String + * @return the corresponding object wrapper type simple name of the input if the input is the name of a primitive java + * type. The input itself if not. (e.g. "int" results in "Integer") + * @throws ClassNotFoundException should not occur. + */ + public String boxJavaPrimitives(String simpleType) throws ClassNotFoundException { + + if (equalsJavaPrimitive(simpleType)) { + return ClassUtils.primitiveToWrapper(ClassUtils.getClass(simpleType)).getSimpleName(); + } else { + return simpleType; + } + + } + + /** + * Returns the simple name of the type of a field in the pojoClass. If the type is a java primitive the name of the + * wrapper class is returned + * + * @param pojoClass {@link Class} the class object of the pojo + * @param fieldName {@link String} the name of the field + * @return String. The simple name of the field's type. The simple name of the wrapper class in case of java + * primitives + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public String boxJavaPrimitives(Class pojoClass, String fieldName) throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + + if (equalsJavaPrimitive(pojoClass, fieldName)) { + return ClassUtils.primitiveToWrapper(pojoClass.getDeclaredField(fieldName).getType()).getSimpleName(); + } else { + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + throw new IllegalAccessError("Could not find field " + fieldName + " in class " + pojoClass); + } else { + return field.getType().getSimpleName(); + } + } + } + + /** + * Checks if the given type is a Java primitive + * + * @param simpleType the type to be checked + * @return true iff simpleType is a Java primitive + */ + public boolean equalsJavaPrimitive(String simpleType) { + + try { + return ClassUtils.getClass(simpleType).isPrimitive(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + } + + /** + * Checks if the given type is a Java primitive or wrapper + * + * @param simpleType the type to be checked + * @return true iff simpleType is a Java primitive or wrapper + */ + public boolean equalsJavaPrimitiveOrWrapper(String simpleType) { + + try { + return ClassUtils.isPrimitiveOrWrapper(ClassUtils.getClass(simpleType)); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + } + + /** + * Checks if the type of the field in the pojo's class is a java primitive + * + * @param pojoClass the {@link Class} object of the pojo + * @param fieldName the name of the field to be checked + * @return true iff the field is a java primitive + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean equalsJavaPrimitive(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + return false; + } + + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + return false; + } else { + return field.getType().isPrimitive(); + } + } + + /** + * Checks if the given type is a Java primitive or a Java primitive array + * + * @param simpleType the Type name to be checked + * @return true iff {@link #equalsJavaPrimitive(String)} is true or if simpleType is an array with a primitive + * component + */ + public boolean equalsJavaPrimitiveIncludingArrays(String simpleType) { + + Class klasse; + + try { + klasse = ClassUtils.getClass(simpleType).getComponentType(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + return equalsJavaPrimitive(simpleType) || (klasse != null && klasse.isPrimitive()); + } + + /** + * Checks if the given field in the pojo class is a java primitive or an array of java primitives + * + * @param pojoClass the class object of the pojo + * @param fieldName the name of the field to be checked + * @return true iff {@link #equalsJavaPrimitive(Class, String)} is true or the field is an array of primitives + * @throws NoSuchFieldException indicating something awfully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean equalsJavaPrimitiveIncludingArrays(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + return equalsJavaPrimitive(pojoClass, fieldName) || (pojoClass.getDeclaredField(fieldName).getType().isArray() + && pojoClass.getDeclaredField(fieldName).getType().getComponentType().isPrimitive()); + } + + /** + * Returns a cast statement for a given (java primitive, variable name) pair or nothing if the type isn't a java + * primitive + * + * @param simpleType Java Type + * @param varName Variable name + * @return String either of the form '((Java Primitive Object Type)varName)' if simpleType is a primitive or the empty + * String otherwise + * @throws ClassNotFoundException should not occur + */ + public String castJavaPrimitives(String simpleType, String varName) throws ClassNotFoundException { + + if (equalsJavaPrimitive(simpleType)) { + return String.format("((%1$s)%2$s)", boxJavaPrimitives(simpleType), varName); + } else { + return ""; + } + } + + /** + * Returns a cast statement for a given (java primitive, variable name) pair or nothing if the type isn't a java + * primitive + * + * @param pojoClass the class object of the pojo + * @param fieldName the name of the field to be casted + * @return if fieldName points to a primitive field then a casted statement (e.g. for an int field: + * '((Integer)field)') or an empty String otherwise + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public String castJavaPrimitives(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + if (equalsJavaPrimitive(pojoClass, fieldName)) { + return String.format("((%1$s)%2$s)", boxJavaPrimitives(pojoClass, fieldName), fieldName); + } else { + return ""; + } + } + + /** + * @param pojoClass {@link Class} the class object of the pojo + * @param fieldName {@link String} the name of the field + * @return true if the field is an instance of java.utils.Collections + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean isCollection(Class pojoClass, String fieldName) throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + return false; + } + + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + return false; + } else { + return Collection.class.isAssignableFrom(field.getType()); + } + + } + + /** + * Returns the Ext Type to a given java type + * + * @param simpleType any java type's simple name + * @return corresponding Ext type + */ + public String getExtType(String simpleType) { + + switch (simpleType) { + case "short": + case "Short": + case "int": + case "Integer": + case "long": + case "Long": + return "Integer"; + case "float": + case "Float": + case "double": + case "Double": + return "Number"; + case "boolean": + case "Boolean": + return "Boolean"; + case "char": + case "Character": + case "String": + return "String"; + case "Date": + return "Date"; + default: + return "Field"; + } + } + + /** + * returns the Angular5 type associated with a Java primitive + * + * @param simpleType :{@link String} the type to be parsed + * @return the corresponding Angular type or 'any' otherwise + */ + public String getAngularType(String simpleType) { + + switch (simpleType) { + case "boolean": + return "boolean"; + case "Boolean": + return "boolean"; + case "short": + return "number"; + case "Short": + return "number"; + case "int": + return "number"; + case "Integer": + return "number"; + case "long": + return "number"; + case "Long": + return "number"; + case "float": + return "number"; + case "Float": + return "number"; + case "double": + return "number"; + case "Double": + return "number"; + case "char": + return "string"; + case "Character": + return "string"; + case "String": + return "string"; + case "byte": + return "number"; + default: + return "any"; + } + } + + /** + * returns the class name of the return type of a specific method. + * + * @param pojoClass {@link Class}<?> the class object of the pojo + * @param methodName {@link String} the name of the method + * @return the class name of the return type of the specified method + * @throws SecurityException If no method of the given name can be found + * @throws NoSuchMethodException If no method of the given name can be found + */ + public String getReturnType(Class pojoClass, String methodName) throws NoSuchMethodException, SecurityException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + String s = "-"; + Method method = findMethod(pojoClass, methodName); + if (method != null && !method.getReturnType().equals(Void.TYPE)) { + s = method.getReturnType().toString(); + s = s.substring(s.lastIndexOf('.') + 1, s.length()); + } + return s; + } + + /** + * + * This methods returns the return type of the method in the given pojoClass which are annotated with the parameter + * annotatedClass + * + * @param pojoClass - The class in which to find if it has methods with annotatedClass + * @param annotatedClassName - The annotation which needs to be found + * @return Return type of the method annotated with the given annotation, else "null" + * @throws ClassNotFoundException if the annotated class name could not be found in the class path + */ + @SuppressWarnings("unchecked") + public String getReturnTypeOfMethodAnnotatedWith(Class pojoClass, String annotatedClassName) + throws ClassNotFoundException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + + Method[] methods = pojoClass.getDeclaredMethods(); + for (Method method : methods) { + if (!method.getName().startsWith("get")) { + continue; + } + for (Annotation a : method.getAnnotations()) { + // better if (method.isAnnotationPresent(classObj)) {, but postponed as of different class + // loaders of a.getClass() and pojoClass.getClass() + if (a.getClass().getCanonicalName().equals(annotatedClassName)) { + return method.getReturnType().getSimpleName(); + } + } + } + return "null"; + } + + /** + * returns the HTTP request type corresponding to an annotation type + * + * @param annotations The annotation to get the type name of + * @return the HTTP request type name of the selected annotation + */ + public String getRequestType(Map annotations) { + + if (annotations.containsKey("javax_ws_rs_GET")) { + return "GET"; + } else if (annotations.containsKey("javax_ws_rs_PUT")) { + return "PUT"; + } else if (annotations.containsKey("javax_ws_rs_POST")) { + return "POST"; + } else if (annotations.containsKey("javax_ws_rs_DELETE")) { + return "DELETE"; + } else if (annotations.containsKey("javax_ws_rs_PATCH")) { + return "PATCH"; + } else { + return "-"; + } + } + + /** + * Helper method to find a class's specific method + * + * @param pojoClass {@link Class}<?> the class object of the pojo + * @param methodName The name of the method to be found + * @return The method object of the method to be found, null if it wasn't found + */ + private Method findMethod(Class pojoClass, String methodName) { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + for (Method m : pojoClass.getMethods()) { + if (m.getName().equals(methodName)) { + return m; + } + } + return null; + } + + /** + * Checks whether the class given by the full qualified name is an enum + * + * @param className full qualified class name + * @return true if the class is an enum, false otherwise + */ + public boolean isEnum(String className) { + + try { + return ClassUtils.getClass(className).isEnum(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), className); + return false; + } + } + + /** + * Returns the first enum value of an enum class + * + * @param className full qualified class name + * @return the first enum value name found in order + */ + public String getFirstEnumValue(String className) { + + try { + Class enumClass = ClassUtils.getClass(className); + Field[] declaredFields = enumClass.getDeclaredFields(); + if (declaredFields.length > 0) { + return declaredFields[0].getName(); + } else { + return null; + } + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), className); + return null; + } + } +} diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/functions.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/functions.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/functions.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/functions.ftl diff --git a/cobigen-templates/crud-java-server-app/src/main/resources/template-set.xml b/cobigen-templates/crud-java-server-app/src/main/resources/template-set.xml new file mode 100644 index 0000000000..3f30e3a879 --- /dev/null +++ b/cobigen-templates/crud-java-server-app/src/main/resources/template-set.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/common/api/${variables.entityName}.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/common/api/${variables.entityName}.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/common/api/${variables.entityName}.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/common/api/${variables.entityName}.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/common/api/${variables.entityName}SearchCriteriaTo.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/common/api/${variables.entityName}SearchCriteriaTo.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/common/api/${variables.entityName}SearchCriteriaTo.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/common/api/${variables.entityName}SearchCriteriaTo.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/cobigen.properties b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/common/api/cobigen.properties similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/cobigen.properties rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/common/api/cobigen.properties diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/dataaccess/api/${variables.entityName}Entity.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/dataaccess/api/${variables.entityName}Entity.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/dataaccess/api/${variables.entityName}Entity.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/dataaccess/api/${variables.entityName}Entity.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/dataaccess/api/repo/${variables.entityName}Repository.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/dataaccess/api/repo/${variables.entityName}Repository.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/dataaccess/api/repo/${variables.entityName}Repository.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/dataaccess/api/repo/${variables.entityName}Repository.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Cto.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Cto.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Cto.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Cto.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/${variables.entityName}Eto.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/service/api/cobigen.properties b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/cobigen.properties similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/service/api/cobigen.properties rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/logic/api/to/cobigen.properties diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/common/api/to/cobigen.properties b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/service/api/cobigen.properties similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/common/api/to/cobigen.properties rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/service/api/cobigen.properties diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/service/api/rest/${variables.component#cap_first}RestService.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/service/api/rest/${variables.component#cap_first}RestService.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/service/api/rest/${variables.component#cap_first}RestService.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/service/api/rest/${variables.component#cap_first}RestService.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/service/api/rest/${variables.component#cap_first}RestServiceCtos.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/service/api/rest/${variables.component#cap_first}RestServiceCtos.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/service/api/rest/${variables.component#cap_first}RestServiceCtos.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/service/api/rest/${variables.component#cap_first}RestServiceCtos.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/service/api/soap/${variables.component#cap_first}SoapService.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/service/api/soap/${variables.component#cap_first}SoapService.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/service/api/soap/${variables.component#cap_first}SoapService.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/service/api/soap/${variables.component#cap_first}SoapService.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/service/impl/rest/${variables.component#cap_first}RestServiceImpl.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/service/impl/rest/${variables.component#cap_first}RestServiceImpl.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/service/impl/rest/${variables.component#cap_first}RestServiceImpl.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/service/impl/rest/${variables.component#cap_first}RestServiceImpl.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/service/impl/rest/${variables.component#cap_first}RestServiceImplCtos.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/service/impl/rest/${variables.component#cap_first}RestServiceImplCtos.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/service/impl/rest/${variables.component#cap_first}RestServiceImplCtos.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/service/impl/rest/${variables.component#cap_first}RestServiceImplCtos.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/service/impl/soap/${variables.component#cap_first}SoapServiceImpl.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/service/impl/soap/${variables.component#cap_first}SoapServiceImpl.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/${variables.component}/service/impl/soap/${variables.component#cap_first}SoapServiceImpl.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component}/service/impl/soap/${variables.component#cap_first}SoapServiceImpl.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/common/api/ApplicationEntity.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/api/ApplicationEntity.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/common/api/ApplicationEntity.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/api/ApplicationEntity.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/common/api/to/AbstractSearchCriteriaTo.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/api/to/AbstractSearchCriteriaTo.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/common/api/to/AbstractSearchCriteriaTo.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/api/to/AbstractSearchCriteriaTo.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/api/cobigen.properties b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/api/to/cobigen.properties similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/${variables.component}/logic/api/cobigen.properties rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/api/to/cobigen.properties diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/general/common/base/AbstractBeanMapperSupport.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/base/AbstractBeanMapperSupport.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app_complex/templates/java/${variables.rootPackage}/general/common/base/AbstractBeanMapperSupport.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/base/AbstractBeanMapperSupport.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/dataaccess/api/ApplicationPersistenceEntity.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/dataaccess/api/ApplicationPersistenceEntity.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/dataaccess/api/ApplicationPersistenceEntity.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/dataaccess/api/ApplicationPersistenceEntity.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/dataaccess/api/dao/ApplicationDao.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/dataaccess/api/dao/ApplicationDao.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/dataaccess/api/dao/ApplicationDao.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/dataaccess/api/dao/ApplicationDao.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/dataaccess/base/dao/ApplicationDaoImpl.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/dataaccess/base/dao/ApplicationDaoImpl.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/dataaccess/base/dao/ApplicationDaoImpl.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/dataaccess/base/dao/ApplicationDaoImpl.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/logic/base/AbstractComponentFacade.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/logic/base/AbstractComponentFacade.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/logic/base/AbstractComponentFacade.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/logic/base/AbstractComponentFacade.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/service/impl/config/ServiceConfig.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/service/impl/config/ServiceConfig.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/service/impl/config/ServiceConfig.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/service/impl/config/ServiceConfig.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/service/impl/config/WebApplicationContextLocator.java.ftl b/cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/service/impl/config/WebApplicationContextLocator.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_java_server_app/templates/java/${variables.rootPackage}/general/service/impl/config/WebApplicationContextLocator.java.ftl rename to cobigen-templates/crud-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/service/impl/config/WebApplicationContextLocator.java.ftl diff --git a/cobigen-templates/crud-java-server-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudJavaServerAppGenerationTest.java b/cobigen-templates/crud-java-server-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudJavaServerAppGenerationTest.java new file mode 100644 index 0000000000..8945626b9b --- /dev/null +++ b/cobigen-templates/crud-java-server-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudJavaServerAppGenerationTest.java @@ -0,0 +1,100 @@ +package com.devonfw.cobigen.templates.devon4j.test.templates; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.apache.commons.io.FileUtils; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.devonfw.cobigen.api.constants.ConfigurationConstants; +import com.devonfw.cobigen.maven.test.AbstractMavenTest; +import com.devonfw.cobigen.templates.devon4j.config.constant.MavenMetadata; + +/** + * Smoke tests of all templates. + */ +public class CrudJavaServerAppGenerationTest extends AbstractMavenTest { + + /** Root of all test resources of this test suite */ + public static final String TEST_RESOURCES_ROOT = "src/test/resources/testdata/templatetest/"; + + /** Temporary files rule to create temporary folders */ + @ClassRule + public static TemporaryFolder tempFolder = new TemporaryFolder(); + + /** The templates development folder */ + protected static Path templatesProject; + + /** The templates development folder */ + protected static Path templatesProjectTemporary; + + /** + * Creates a copy of the templates project in the temp directory + * + * @throws URISyntaxException if the path could not be created properly + * @throws IOException if accessing a directory or file fails + */ + @BeforeClass + public static void setupDevTemplates() throws URISyntaxException, IOException { + + templatesProject = new File( + CrudJavaServerAppGenerationTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()) + .getParentFile().getParentFile().toPath(); + + Path utilsPom = new File( + CrudJavaServerAppGenerationTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()) + .getParentFile().getParentFile().toPath().resolve("src/test/resources/utils/pom.xml"); + + // create a temporary directory cobigen-templates/template-sets/adapted containing the template sets + Path tempFolderPath = tempFolder.getRoot().toPath(); + Path cobigenTemplatePath = tempFolderPath.resolve("cobigen-templates"); + if (!Files.exists(cobigenTemplatePath)) { + Files.createDirectory(cobigenTemplatePath); + + templatesProjectTemporary = cobigenTemplatePath.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER); + Path templateSetsAdaptedFolder = templatesProjectTemporary.resolve(ConfigurationConstants.ADAPTED_FOLDER); + Files.createDirectory(templatesProjectTemporary); + Files.createDirectory(templateSetsAdaptedFolder); + + Path templateSetPath = templateSetsAdaptedFolder.resolve("template-set"); + FileUtils.copyDirectory(templatesProject.toFile(), templateSetPath.toFile()); + + if (Files.isDirectory(templateSetPath)) { + + // Replace the pom.xml in the template sets. Needed so that the project in the temp directory is build + // properly + if (Files.exists(templateSetPath.resolve("pom.xml"))) { + try { + Files.delete(templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error deleting file " + templateSetPath.resolve("pom.xml"), e); + } + try { + Files.copy(utilsPom, templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error copying file " + utilsPom, e); + } + } + } + } + } + + /** + * Test successful generation of all templates based on an entity + * + * @throws Exception test fails + */ + @Test + public void testAllTemplatesGeneration_EntityInput() throws Exception { + + File testProject = new File(TEST_RESOURCES_ROOT + "TestAllTemplatesEntityInput/"); + runMavenInvoker(testProject, templatesProjectTemporary.toFile(), MavenMetadata.LOCAL_REPO, false); + } + +} diff --git a/cobigen-templates/crud-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml b/cobigen-templates/crud-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/crud-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/crud-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml b/cobigen-templates/crud-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml new file mode 100644 index 0000000000..987f810bfd --- /dev/null +++ b/cobigen-templates/crud-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml @@ -0,0 +1,53 @@ + + 4.0.0 + com.devonfw.cobigen + devon4jTemplateTest-TestAllTemplatesEntityInput + dev-SNAPSHOT + + + 1.8 + 1.8 + + + + + + com.devonfw.cobigen + cobigen-maven-plugin + ${pluginVersion} + + + generate + package + + generate + + + + + ${templatesProject} + + src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java + + + + + true + + + + com.devonfw.cobigen + tempeng-freemarker + ${pluginVersion} + + + com.devonfw.cobigen + javaplugin + ${pluginVersion} + + + + + + diff --git a/cobigen-templates/crud-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java b/cobigen-templates/crud-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java new file mode 100644 index 0000000000..e2d76c7c9f --- /dev/null +++ b/cobigen-templates/crud-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java @@ -0,0 +1,25 @@ +package io.github.devonfw.cobigen.generator.dataaccess.api; + +public class InputEntity { + + private String input; + + private int complexity; + + public String getInput() { + return input; + } + + public void setInput(String input) { + this.input = input; + } + + public int getComplexity() { + return complexity; + } + + public void setComplexity(int complexity) { + this.complexity = complexity; + } + +} diff --git a/cobigen-templates/crud-java-server-app/src/test/resources/utils/pom.xml b/cobigen-templates/crud-java-server-app/src/test/resources/utils/pom.xml new file mode 100644 index 0000000000..3c3394ce26 --- /dev/null +++ b/cobigen-templates/crud-java-server-app/src/test/resources/utils/pom.xml @@ -0,0 +1,100 @@ + + + 4.0.0 + com.devonfw.cobigen.templates + crud-java-server-app + 2021.12.007-SNAPSHOT + CRUD Java Server App + A Code-based incremental Generator + https://github.com/devonfw/cobigen/templates-parent/templates-devon4j-utils + + + Apache Software License 2.0 + https://raw.githubusercontent.com/devonfw/.github/master/LICENSE + repo + + + + + + javax.ws.rs + javax.ws.rs-api + 2.0 + compile + + + org.springframework.data + spring-data-rest-webmvc + 3.7.10 + compile + + + org.apache.commons + commons-lang3 + 3.12.0 + compile + + + com.fasterxml.jackson.core + jackson-databind + 2.10.0 + compile + + + xerces + xercesImpl + 2.12.2 + compile + + + javax.persistence + javax.persistence-api + 2.2 + compile + + + org.slf4j + slf4j-api + 1.7.30 + compile + + + org.slf4j + jcl-over-slf4j + 1.7.30 + compile + + + org.slf4j + log4j-over-slf4j + 1.7.30 + compile + + + + + + false + + + true + + ossrh + OSSRH Snapshots + https://s01.oss.sonatype.org/content/repositories/snapshots/ + + + + + 1.8 + 1.8 + + + + + + src/main/java + + + \ No newline at end of file diff --git a/cobigen-templates/crud-ngrx-client-app/pom.xml b/cobigen-templates/crud-ngrx-client-app/pom.xml new file mode 100644 index 0000000000..b5287e0cd5 --- /dev/null +++ b/cobigen-templates/crud-ngrx-client-app/pom.xml @@ -0,0 +1,19 @@ + + 4.0.0 + crud-ngrx-client-app + CRUD NGRX Client App template + + + com.devonfw.cobigen.templates + templates-parent + ${revision} + + + + + org.apache.commons + commons-lang3 + + + \ No newline at end of file diff --git a/cobigen-templates/crud-ngrx-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java b/cobigen-templates/crud-ngrx-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java new file mode 100644 index 0000000000..395d46154d --- /dev/null +++ b/cobigen-templates/crud-ngrx-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java @@ -0,0 +1,12 @@ +package com.devonfw.cobigen.templates.devon4j.config.constant; + +/** + * Constants extracted from the maven pom by templating-maven-plugin. + * + * @see "edit template in src/main/java-templates" + */ +public class MavenMetadata { + + /** Local repository path */ + public static final String LOCAL_REPO = "${settings.localRepository}"; +} diff --git a/cobigen-templates/crud-ngrx-client-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java b/cobigen-templates/crud-ngrx-client-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java new file mode 100644 index 0000000000..2d4025071d --- /dev/null +++ b/cobigen-templates/crud-ngrx-client-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java @@ -0,0 +1,464 @@ +package com.devonfw.cobigen.templates.devon4j.utils; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.Map; + +import org.apache.commons.lang3.ClassUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Provides type operations, mainly checks and casts for Java Primitives, to be used in the templates + * + */ +public class JavaUtil { + + /** + * Logger for this class + */ + private static final Logger LOG = LoggerFactory.getLogger(JavaUtil.class); + + /** + * The constructor. + */ + public JavaUtil() { + + // Empty for CobiGen to automatically instantiate it + } + + /** + * Returns the Object version of a Java primitive or the input if the input isn't a java primitive + * + * @param simpleType String + * @return the corresponding object wrapper type simple name of the input if the input is the name of a primitive java + * type. The input itself if not. (e.g. "int" results in "Integer") + * @throws ClassNotFoundException should not occur. + */ + public String boxJavaPrimitives(String simpleType) throws ClassNotFoundException { + + if (equalsJavaPrimitive(simpleType)) { + return ClassUtils.primitiveToWrapper(ClassUtils.getClass(simpleType)).getSimpleName(); + } else { + return simpleType; + } + + } + + /** + * Returns the simple name of the type of a field in the pojoClass. If the type is a java primitive the name of the + * wrapper class is returned + * + * @param pojoClass {@link Class} the class object of the pojo + * @param fieldName {@link String} the name of the field + * @return String. The simple name of the field's type. The simple name of the wrapper class in case of java + * primitives + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public String boxJavaPrimitives(Class pojoClass, String fieldName) throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + + if (equalsJavaPrimitive(pojoClass, fieldName)) { + return ClassUtils.primitiveToWrapper(pojoClass.getDeclaredField(fieldName).getType()).getSimpleName(); + } else { + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + throw new IllegalAccessError("Could not find field " + fieldName + " in class " + pojoClass); + } else { + return field.getType().getSimpleName(); + } + } + } + + /** + * Checks if the given type is a Java primitive + * + * @param simpleType the type to be checked + * @return true iff simpleType is a Java primitive + */ + public boolean equalsJavaPrimitive(String simpleType) { + + try { + return ClassUtils.getClass(simpleType).isPrimitive(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + } + + /** + * Checks if the given type is a Java primitive or wrapper + * + * @param simpleType the type to be checked + * @return true iff simpleType is a Java primitive or wrapper + */ + public boolean equalsJavaPrimitiveOrWrapper(String simpleType) { + + try { + return ClassUtils.isPrimitiveOrWrapper(ClassUtils.getClass(simpleType)); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + } + + /** + * Checks if the type of the field in the pojo's class is a java primitive + * + * @param pojoClass the {@link Class} object of the pojo + * @param fieldName the name of the field to be checked + * @return true iff the field is a java primitive + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean equalsJavaPrimitive(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + return false; + } + + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + return false; + } else { + return field.getType().isPrimitive(); + } + } + + /** + * Checks if the given type is a Java primitive or a Java primitive array + * + * @param simpleType the Type name to be checked + * @return true iff {@link #equalsJavaPrimitive(String)} is true or if simpleType is an array with a primitive + * component + */ + public boolean equalsJavaPrimitiveIncludingArrays(String simpleType) { + + Class klasse; + + try { + klasse = ClassUtils.getClass(simpleType).getComponentType(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + return equalsJavaPrimitive(simpleType) || (klasse != null && klasse.isPrimitive()); + } + + /** + * Checks if the given field in the pojo class is a java primitive or an array of java primitives + * + * @param pojoClass the class object of the pojo + * @param fieldName the name of the field to be checked + * @return true iff {@link #equalsJavaPrimitive(Class, String)} is true or the field is an array of primitives + * @throws NoSuchFieldException indicating something awfully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean equalsJavaPrimitiveIncludingArrays(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + return equalsJavaPrimitive(pojoClass, fieldName) || (pojoClass.getDeclaredField(fieldName).getType().isArray() + && pojoClass.getDeclaredField(fieldName).getType().getComponentType().isPrimitive()); + } + + /** + * Returns a cast statement for a given (java primitive, variable name) pair or nothing if the type isn't a java + * primitive + * + * @param simpleType Java Type + * @param varName Variable name + * @return String either of the form '((Java Primitive Object Type)varName)' if simpleType is a primitive or the empty + * String otherwise + * @throws ClassNotFoundException should not occur + */ + public String castJavaPrimitives(String simpleType, String varName) throws ClassNotFoundException { + + if (equalsJavaPrimitive(simpleType)) { + return String.format("((%1$s)%2$s)", boxJavaPrimitives(simpleType), varName); + } else { + return ""; + } + } + + /** + * Returns a cast statement for a given (java primitive, variable name) pair or nothing if the type isn't a java + * primitive + * + * @param pojoClass the class object of the pojo + * @param fieldName the name of the field to be casted + * @return if fieldName points to a primitive field then a casted statement (e.g. for an int field: + * '((Integer)field)') or an empty String otherwise + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public String castJavaPrimitives(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + if (equalsJavaPrimitive(pojoClass, fieldName)) { + return String.format("((%1$s)%2$s)", boxJavaPrimitives(pojoClass, fieldName), fieldName); + } else { + return ""; + } + } + + /** + * @param pojoClass {@link Class} the class object of the pojo + * @param fieldName {@link String} the name of the field + * @return true if the field is an instance of java.utils.Collections + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean isCollection(Class pojoClass, String fieldName) throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + return false; + } + + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + return false; + } else { + return Collection.class.isAssignableFrom(field.getType()); + } + + } + + /** + * Returns the Ext Type to a given java type + * + * @param simpleType any java type's simple name + * @return corresponding Ext type + */ + public String getExtType(String simpleType) { + + switch (simpleType) { + case "short": + case "Short": + case "int": + case "Integer": + case "long": + case "Long": + return "Integer"; + case "float": + case "Float": + case "double": + case "Double": + return "Number"; + case "boolean": + case "Boolean": + return "Boolean"; + case "char": + case "Character": + case "String": + return "String"; + case "Date": + return "Date"; + default: + return "Field"; + } + } + + /** + * returns the Angular5 type associated with a Java primitive + * + * @param simpleType :{@link String} the type to be parsed + * @return the corresponding Angular type or 'any' otherwise + */ + public String getAngularType(String simpleType) { + + switch (simpleType) { + case "boolean": + return "boolean"; + case "Boolean": + return "boolean"; + case "short": + return "number"; + case "Short": + return "number"; + case "int": + return "number"; + case "Integer": + return "number"; + case "long": + return "number"; + case "Long": + return "number"; + case "float": + return "number"; + case "Float": + return "number"; + case "double": + return "number"; + case "Double": + return "number"; + case "char": + return "string"; + case "Character": + return "string"; + case "String": + return "string"; + case "byte": + return "number"; + default: + return "any"; + } + } + + /** + * returns the class name of the return type of a specific method. + * + * @param pojoClass {@link Class}<?> the class object of the pojo + * @param methodName {@link String} the name of the method + * @return the class name of the return type of the specified method + * @throws SecurityException If no method of the given name can be found + * @throws NoSuchMethodException If no method of the given name can be found + */ + public String getReturnType(Class pojoClass, String methodName) throws NoSuchMethodException, SecurityException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + String s = "-"; + Method method = findMethod(pojoClass, methodName); + if (method != null && !method.getReturnType().equals(Void.TYPE)) { + s = method.getReturnType().toString(); + s = s.substring(s.lastIndexOf('.') + 1, s.length()); + } + return s; + } + + /** + * + * This methods returns the return type of the method in the given pojoClass which are annotated with the parameter + * annotatedClass + * + * @param pojoClass - The class in which to find if it has methods with annotatedClass + * @param annotatedClassName - The annotation which needs to be found + * @return Return type of the method annotated with the given annotation, else "null" + * @throws ClassNotFoundException if the annotated class name could not be found in the class path + */ + @SuppressWarnings("unchecked") + public String getReturnTypeOfMethodAnnotatedWith(Class pojoClass, String annotatedClassName) + throws ClassNotFoundException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + + Method[] methods = pojoClass.getDeclaredMethods(); + for (Method method : methods) { + if (!method.getName().startsWith("get")) { + continue; + } + for (Annotation a : method.getAnnotations()) { + // better if (method.isAnnotationPresent(classObj)) {, but postponed as of different class + // loaders of a.getClass() and pojoClass.getClass() + if (a.getClass().getCanonicalName().equals(annotatedClassName)) { + return method.getReturnType().getSimpleName(); + } + } + } + return "null"; + } + + /** + * returns the HTTP request type corresponding to an annotation type + * + * @param annotations The annotation to get the type name of + * @return the HTTP request type name of the selected annotation + */ + public String getRequestType(Map annotations) { + + if (annotations.containsKey("javax_ws_rs_GET")) { + return "GET"; + } else if (annotations.containsKey("javax_ws_rs_PUT")) { + return "PUT"; + } else if (annotations.containsKey("javax_ws_rs_POST")) { + return "POST"; + } else if (annotations.containsKey("javax_ws_rs_DELETE")) { + return "DELETE"; + } else if (annotations.containsKey("javax_ws_rs_PATCH")) { + return "PATCH"; + } else { + return "-"; + } + } + + /** + * Helper method to find a class's specific method + * + * @param pojoClass {@link Class}<?> the class object of the pojo + * @param methodName The name of the method to be found + * @return The method object of the method to be found, null if it wasn't found + */ + private Method findMethod(Class pojoClass, String methodName) { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + for (Method m : pojoClass.getMethods()) { + if (m.getName().equals(methodName)) { + return m; + } + } + return null; + } + + /** + * Checks whether the class given by the full qualified name is an enum + * + * @param className full qualified class name + * @return true if the class is an enum, false otherwise + */ + public boolean isEnum(String className) { + + try { + return ClassUtils.getClass(className).isEnum(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), className); + return false; + } + } + + /** + * Returns the first enum value of an enum class + * + * @param className full qualified class name + * @return the first enum value name found in order + */ + public String getFirstEnumValue(String className) { + + try { + Class enumClass = ClassUtils.getClass(className); + Field[] declaredFields = enumClass.getDeclaredFields(); + if (declaredFields.length > 0) { + return declaredFields[0].getName(); + } else { + return null; + } + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), className); + return null; + } + } +} diff --git a/cobigen-templates/crud-ngrx-client-app/src/main/resources/template-set.xml b/cobigen-templates/crud-ngrx-client-app/src/main/resources/template-set.xml new file mode 100644 index 0000000000..f67beb2b39 --- /dev/null +++ b/cobigen-templates/crud-ngrx-client-app/src/main/resources/template-set.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/cobigen.properties b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/cobigen.properties similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/cobigen.properties rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/cobigen.properties diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-routing.module.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-routing.module.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-routing.module.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-routing.module.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}.module.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}.module.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}.module.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}.module.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.html.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.html.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.html.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.html.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.scss b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.scss similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.scss rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.scss diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.spec.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.spec.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.spec.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.spec.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.html.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.html.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.html.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.html.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.html.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.html.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.html.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.html.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.scss b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.scss similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.scss rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.scss diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/components/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/models/${variables.etoName#lower_case}.model.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/models/${variables.etoName#lower_case}.model.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/models/${variables.etoName#lower_case}.model.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/models/${variables.etoName#lower_case}.model.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/models/datadetailstest.model.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/models/datadetailstest.model.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/models/datadetailstest.model.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/models/datadetailstest.model.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/models/httpresponse.model.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/models/httpresponse.model.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/models/httpresponse.model.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/models/httpresponse.model.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/models/searchcriteriadata.model.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/models/searchcriteriadata.model.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/models/searchcriteriadata.model.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/models/searchcriteriadata.model.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.spec.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.spec.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.spec.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.spec.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/actions/${variables.etoName#lower_case}.actions.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/actions/${variables.etoName#lower_case}.actions.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/actions/${variables.etoName#lower_case}.actions.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/actions/${variables.etoName#lower_case}.actions.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/actions/actions_index.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/actions/actions_index.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/actions/actions_index.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/actions/actions_index.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/effects/${variables.etoName#lower_case}.effects.spec.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/effects/${variables.etoName#lower_case}.effects.spec.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/effects/${variables.etoName#lower_case}.effects.spec.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/effects/${variables.etoName#lower_case}.effects.spec.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/effects/${variables.etoName#lower_case}.effects.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/effects/${variables.etoName#lower_case}.effects.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/effects/${variables.etoName#lower_case}.effects.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/effects/${variables.etoName#lower_case}.effects.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/effects/effects_index.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/effects/effects_index.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/effects/effects_index.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/effects/effects_index.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/reducers/${variables.etoName#lower_case}.reducers.spec.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/reducers/${variables.etoName#lower_case}.reducers.spec.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/reducers/${variables.etoName#lower_case}.reducers.spec.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/reducers/${variables.etoName#lower_case}.reducers.spec.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/reducers/${variables.etoName#lower_case}.reducers.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/reducers/${variables.etoName#lower_case}.reducers.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/reducers/${variables.etoName#lower_case}.reducers.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/reducers/${variables.etoName#lower_case}.reducers.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/reducers/reducers_index.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/reducers/reducers_index.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/reducers/reducers_index.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/reducers/reducers_index.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/selectors/${variables.etoName#lower_case}.selectors.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/selectors/${variables.etoName#lower_case}.selectors.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/selectors/${variables.etoName#lower_case}.selectors.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/selectors/${variables.etoName#lower_case}.selectors.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/selectors/selectors_index.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/selectors/selectors_index.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/selectors/selectors_index.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/selectors/selectors_index.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/store_index.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/store_index.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/${variables.etoName#lower_case}/store/store_index.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/store/store_index.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/app-routing.module.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/app-routing.module.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/app-routing.module.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/app-routing.module.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/layout/header/header.component.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/layout/header/header.component.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/layout/header/header.component.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/layout/header/header.component.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/layout/nav-bar/nav-bar.component.html.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/layout/nav-bar/nav-bar.component.html.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/app/layout/nav-bar/nav-bar.component.html.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/app/layout/nav-bar/nav-bar.component.html.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/assets/i18n/en.json.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/assets/i18n/en.json.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/assets/i18n/en.json.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/assets/i18n/en.json.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/assets/i18n/es.json.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/assets/i18n/es.json.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/assets/i18n/es.json.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/assets/i18n/es.json.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/environments/environment.prod.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/environments/environment.prod.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/environments/environment.prod.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/environments/environment.prod.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/environments/environment.ts.ftl b/cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/environments/environment.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_ngrx_client_app/templates/src/environments/environment.ts.ftl rename to cobigen-templates/crud-ngrx-client-app/src/main/resources/templates/src/environments/environment.ts.ftl diff --git a/cobigen-templates/crud-ngrx-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudNgrxClientAppTest.java b/cobigen-templates/crud-ngrx-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudNgrxClientAppTest.java new file mode 100644 index 0000000000..f47b0c942d --- /dev/null +++ b/cobigen-templates/crud-ngrx-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudNgrxClientAppTest.java @@ -0,0 +1,98 @@ +package com.devonfw.cobigen.templates.devon4j.test.templates; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.apache.commons.io.FileUtils; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.devonfw.cobigen.api.constants.ConfigurationConstants; +import com.devonfw.cobigen.maven.test.AbstractMavenTest; +import com.devonfw.cobigen.templates.devon4j.config.constant.MavenMetadata; + +/** + * Smoke tests of all templates. + */ +public class CrudNgrxClientAppTest extends AbstractMavenTest { + + /** Root of all test resources of this test suite */ + public static final String TEST_RESOURCES_ROOT = "src/test/resources/testdata/templatetest/"; + + /** Temporary files rule to create temporary folders */ + @ClassRule + public static TemporaryFolder tempFolder = new TemporaryFolder(); + + /** The templates development folder */ + protected static Path templatesProject; + + /** The templates development folder */ + protected static Path templatesProjectTemporary; + + /** + * Creates a copy of the templates project in the temp directory + * + * @throws URISyntaxException if the path could not be created properly + * @throws IOException if accessing a directory or file fails + */ + @BeforeClass + public static void setupDevTemplates() throws URISyntaxException, IOException { + + templatesProject = new File(CrudNgrxClientAppTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()) + .getParentFile().getParentFile().toPath(); + + Path utilsPom = new File(CrudNgrxClientAppTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()) + .getParentFile().getParentFile().toPath().resolve("src/test/resources/utils/pom.xml"); + + // create a temporary directory cobigen-templates/template-sets/adapted containing the template sets + Path tempFolderPath = tempFolder.getRoot().toPath(); + Path cobigenTemplatePath = tempFolderPath.resolve("cobigen-templates"); + if (!Files.exists(cobigenTemplatePath)) { + Files.createDirectory(cobigenTemplatePath); + + templatesProjectTemporary = cobigenTemplatePath.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER); + Path templateSetsAdaptedFolder = templatesProjectTemporary.resolve(ConfigurationConstants.ADAPTED_FOLDER); + Files.createDirectory(templatesProjectTemporary); + Files.createDirectory(templateSetsAdaptedFolder); + + Path templateSetPath = templateSetsAdaptedFolder.resolve("template-set"); + FileUtils.copyDirectory(templatesProject.toFile(), templateSetPath.toFile()); + + if (Files.isDirectory(templateSetPath)) { + + // Replace the pom.xml in the template sets. Needed so that the project in the temp directory is build + // properly + if (Files.exists(templateSetPath.resolve("pom.xml"))) { + try { + Files.delete(templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error deleting file " + templateSetPath.resolve("pom.xml"), e); + } + try { + Files.copy(utilsPom, templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error copying file " + utilsPom, e); + } + } + } + } + } + + /** + * Test successful generation of all templates based on an ETO + * + * @throws Exception test fails + */ + @Test + public void testAllTemplatesGeneration_EtoInput() throws Exception { + + File testProject = new File(TEST_RESOURCES_ROOT + "TestAllTemplatesEtoInput/"); + runMavenInvoker(testProject, templatesProjectTemporary.toFile(), MavenMetadata.LOCAL_REPO); + } + +} diff --git a/cobigen-templates/crud-ngrx-client-app/src/test/resources/application.properties b/cobigen-templates/crud-ngrx-client-app/src/test/resources/application.properties new file mode 100644 index 0000000000..cf2c614efb --- /dev/null +++ b/cobigen-templates/crud-ngrx-client-app/src/test/resources/application.properties @@ -0,0 +1,2 @@ +server.port=8080 +server.context-path=/ \ No newline at end of file diff --git a/cobigen-templates/crud-ngrx-client-app/src/test/resources/logback.xml b/cobigen-templates/crud-ngrx-client-app/src/test/resources/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/crud-ngrx-client-app/src/test/resources/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/crud-ngrx-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/logback.xml b/cobigen-templates/crud-ngrx-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/crud-ngrx-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/crud-ngrx-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/pom.xml b/cobigen-templates/crud-ngrx-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/pom.xml new file mode 100644 index 0000000000..68371aa12b --- /dev/null +++ b/cobigen-templates/crud-ngrx-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/pom.xml @@ -0,0 +1,79 @@ + + 4.0.0 + com.devonfw.cobigen + devon4jTemplateTest-TestAllTemplatesEtoInput + dev-SNAPSHOT + + + 1.8 + 1.8 + + + + + + com.devonfw.cobigen + cobigen-maven-plugin + ${pluginVersion} + + + generate + package + + generate + + + + + ${templatesProject} + + src/main/java/io/github/devonfw/cobigen/generator/logic/api/to/InputEto.java + + + + + true + + + + com.devonfw.cobigen + tempeng-freemarker + ${pluginVersion} + + + com.devonfw.cobigen + javaplugin + ${pluginVersion} + + + com.devonfw.cobigen + xmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + htmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + tsplugin + ${pluginVersion} + + + com.devonfw.cobigen + jsonplugin + ${pluginVersion} + + + com.devonfw.cobigen + openapiplugin + ${pluginVersion} + + + + + + + diff --git a/cobigen-templates/crud-ngrx-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/src/main/java/io/github/devonfw/cobigen/generator/logic/api/to/InputEto.java b/cobigen-templates/crud-ngrx-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/src/main/java/io/github/devonfw/cobigen/generator/logic/api/to/InputEto.java new file mode 100644 index 0000000000..21ad4eeba9 --- /dev/null +++ b/cobigen-templates/crud-ngrx-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/src/main/java/io/github/devonfw/cobigen/generator/logic/api/to/InputEto.java @@ -0,0 +1,25 @@ +package io.github.devonfw.cobigen.generator.logic.api.to; + +public class InputEto { + + private String input; + + private int complexity; + + public String getInput() { + return input; + } + + public void setInput(String input) { + this.input = input; + } + + public int getComplexity() { + return complexity; + } + + public void setComplexity(int complexity) { + this.complexity = complexity; + } + +} diff --git a/cobigen-templates/crud-ngrx-client-app/src/test/resources/utils/pom.xml b/cobigen-templates/crud-ngrx-client-app/src/test/resources/utils/pom.xml new file mode 100644 index 0000000000..ee099cf3c6 --- /dev/null +++ b/cobigen-templates/crud-ngrx-client-app/src/test/resources/utils/pom.xml @@ -0,0 +1,100 @@ + + + 4.0.0 + com.devonfw.cobigen.templates + crud-ngrx-client-app + 2021.12.007-SNAPSHOT + Crud Ngrx Client App + A Code-based incremental Generator + https://github.com/devonfw/cobigen/templates-parent/templates-devon4j-utils + + + Apache Software License 2.0 + https://raw.githubusercontent.com/devonfw/.github/master/LICENSE + repo + + + + + + javax.ws.rs + javax.ws.rs-api + 2.0 + compile + + + org.springframework.data + spring-data-rest-webmvc + 3.7.10 + compile + + + org.apache.commons + commons-lang3 + 3.12.0 + compile + + + com.fasterxml.jackson.core + jackson-databind + 2.10.0 + compile + + + xerces + xercesImpl + 2.12.2 + compile + + + javax.persistence + javax.persistence-api + 2.2 + compile + + + org.slf4j + slf4j-api + 1.7.30 + compile + + + org.slf4j + jcl-over-slf4j + 1.7.30 + compile + + + org.slf4j + log4j-over-slf4j + 1.7.30 + compile + + + + + + false + + + true + + ossrh + OSSRH Snapshots + https://s01.oss.sonatype.org/content/repositories/snapshots/ + + + + + 1.8 + 1.8 + + + + + + src/main/java + + + \ No newline at end of file diff --git a/cobigen-templates/crud-openapi-angular-client-app/pom.xml b/cobigen-templates/crud-openapi-angular-client-app/pom.xml new file mode 100644 index 0000000000..f9f6d93770 --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-client-app/pom.xml @@ -0,0 +1,19 @@ + + 4.0.0 + crud-openapi-angular-client-app + CRUD OpenApi Angular Client App template + + + com.devonfw.cobigen.templates + templates-parent + ${revision} + + + + + org.apache.commons + commons-lang3 + + + \ No newline at end of file diff --git a/cobigen-templates/crud-openapi-angular-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java b/cobigen-templates/crud-openapi-angular-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java new file mode 100644 index 0000000000..395d46154d --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java @@ -0,0 +1,12 @@ +package com.devonfw.cobigen.templates.devon4j.config.constant; + +/** + * Constants extracted from the maven pom by templating-maven-plugin. + * + * @see "edit template in src/main/java-templates" + */ +public class MavenMetadata { + + /** Local repository path */ + public static final String LOCAL_REPO = "${settings.localRepository}"; +} diff --git a/cobigen-templates/crud-openapi-angular-client-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java b/cobigen-templates/crud-openapi-angular-client-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java new file mode 100644 index 0000000000..ced2f5fde2 --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-client-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java @@ -0,0 +1,464 @@ +package com.devonfw.cobigen.templates.devon4j.utils; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.Map; + +import org.apache.commons.lang3.ClassUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Provides type operations, mainly checks and casts for Java Primitives, to be used in the templates + * + */ +public class JavaUtil { + + /** + * Logger for this class + */ + private static final Logger LOG = LoggerFactory.getLogger(JavaUtil.class); + + /** + * The constructor. + */ + public JavaUtil() { + + // Empty for CobiGen to automatically instantiate it + } + + /** + * Returns the Object version of a Java primitive or the input if the input isn't a java primitive + * + * @param simpleType String + * @return the corresponding object wrapper type simple name of the input if the input is the name of a primitive java + * type. The input itself if not. (e.g. "int" results in "Integer") + * @throws ClassNotFoundException should not occur. + */ + public String boxJavaPrimitives(String simpleType) throws ClassNotFoundException { + + if (equalsJavaPrimitive(simpleType)) { + return ClassUtils.primitiveToWrapper(ClassUtils.getClass(simpleType)).getSimpleName(); + } else { + return simpleType; + } + + } + + /** + * Returns the simple name of the type of a field in the pojoClass. If the type is a java primitive the name of the + * wrapper class is returned + * + * @param pojoClass {@link Class} the class object of the pojo + * @param fieldName {@link String} the name of the field + * @return String. The simple name of the field's type. The simple name of the wrapper class in case of java + * primitives + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public String boxJavaPrimitives(Class pojoClass, String fieldName) throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + + if (equalsJavaPrimitive(pojoClass, fieldName)) { + return ClassUtils.primitiveToWrapper(pojoClass.getDeclaredField(fieldName).getType()).getSimpleName(); + } else { + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + throw new IllegalAccessError("Could not find field " + fieldName + " in class " + pojoClass); + } else { + return field.getType().getSimpleName(); + } + } + } + + /** + * Checks if the given type is a Java primitive + * + * @param simpleType the type to be checked + * @return true iff simpleType is a Java primitive + */ + public boolean equalsJavaPrimitive(String simpleType) { + + try { + return ClassUtils.getClass(simpleType).isPrimitive(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + } + + /** + * Checks if the given type is a Java primitive or wrapper + * + * @param simpleType the type to be checked + * @return true iff simpleType is a Java primitive or wrapper + */ + public boolean equalsJavaPrimitiveOrWrapper(String simpleType) { + + try { + return ClassUtils.isPrimitiveOrWrapper(ClassUtils.getClass(simpleType)); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + } + + /** + * Checks if the type of the field in the pojo's class is a java primitive + * + * @param pojoClass the {@link Class} object of the pojo + * @param fieldName the name of the field to be checked + * @return true iff the field is a java primitive + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean equalsJavaPrimitive(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + return false; + } + + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + return false; + } else { + return field.getType().isPrimitive(); + } + } + + /** + * Checks if the given type is a Java primitive or a Java primitive array + * + * @param simpleType the Type name to be checked + * @return true iff {@link #equalsJavaPrimitive(String)} is true or if simpleType is an array with a primitive + * component + */ + public boolean equalsJavaPrimitiveIncludingArrays(String simpleType) { + + Class klasse; + + try { + klasse = ClassUtils.getClass(simpleType).getComponentType(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + return equalsJavaPrimitive(simpleType) || (klasse != null && klasse.isPrimitive()); + } + + /** + * Checks if the given field in the pojo class is a java primitive or an array of java primitives + * + * @param pojoClass the class object of the pojo + * @param fieldName the name of the field to be checked + * @return true iff {@link #equalsJavaPrimitive(Class, String)} is true or the field is an array of primitives + * @throws NoSuchFieldException indicating something awfully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean equalsJavaPrimitiveIncludingArrays(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + return equalsJavaPrimitive(pojoClass, fieldName) || (pojoClass.getDeclaredField(fieldName).getType().isArray() + && pojoClass.getDeclaredField(fieldName).getType().getComponentType().isPrimitive()); + } + + /** + * Returns a cast statement for a given (java primitive, variable name) pair or nothing if the type isn't a java + * primitive + * + * @param simpleType Java Type + * @param varName Variable name + * @return String either of the form '((Java Primitive Object Type)varName)' if simpleType is a primitive or the empty + * String otherwise + * @throws ClassNotFoundException should not occur + */ + public String castJavaPrimitives(String simpleType, String varName) throws ClassNotFoundException { + + if (equalsJavaPrimitive(simpleType)) { + return String.format("((%1$s)%2$s)", boxJavaPrimitives(simpleType), varName); + } else { + return ""; + } + } + + /** + * Returns a cast statement for a given (java primitive, variable name) pair or nothing if the type isn't a java + * primitive + * + * @param pojoClass the class object of the pojo + * @param fieldName the name of the field to be casted + * @return if fieldName points to a primitive field then a casted statement (e.g. for an int field: + * '((Integer)field)') or an empty String otherwise + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public String castJavaPrimitives(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + if (equalsJavaPrimitive(pojoClass, fieldName)) { + return String.format("((%1$s)%2$s)", boxJavaPrimitives(pojoClass, fieldName), fieldName); + } else { + return ""; + } + } + + /** + * @param pojoClass {@link Class} the class object of the pojo + * @param fieldName {@link String} the name of the field + * @return true if the field is an instance of java.utils.Collections + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean isCollection(Class pojoClass, String fieldName) throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + return false; + } + + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + return false; + } else { + return Collection.class.isAssignableFrom(field.getType()); + } + + } + + /** + * Returns the Ext Type to a given java type + * + * @param simpleType any java type's simple name + * @return corresponding Ext type + */ + public String getExtType(String simpleType) { + + switch (simpleType) { + case "short": + case "Short": + case "int": + case "Integer": + case "long": + case "Long": + return "Integer"; + case "float": + case "Float": + case "double": + case "Double": + return "Number"; + case "boolean": + case "Boolean": + return "Boolean"; + case "char": + case "Character": + case "String": + return "String"; + case "Date": + return "Date"; + default: + return "Field"; + } + } + + /** + * returns the Angular5 type associated with a Java primitive + * + * @param simpleType :{@link String} the type to be parsed + * @return the corresponding Angular type or 'any' otherwise + */ + public String getAngularType(String simpleType) { + + switch (simpleType) { + case "boolean": + return "boolean"; + case "Boolean": + return "boolean"; + case "short": + return "number"; + case "Short": + return "number"; + case "int": + return "number"; + case "Integer": + return "number"; + case "long": + return "number"; + case "Long": + return "number"; + case "float": + return "number"; + case "Float": + return "number"; + case "double": + return "number"; + case "Double": + return "number"; + case "char": + return "string"; + case "Character": + return "string"; + case "String": + return "string"; + case "byte": + return "number"; + default: + return "any"; + } + } + + /** + * returns the class name of the return type of a specific method. + * + * @param pojoClass {@link Class}<?> the class object of the pojo + * @param methodName {@link String} the name of the method + * @return the class name of the return type of the specified method + * @throws SecurityException If no method of the given name can be found + * @throws NoSuchMethodException If no method of the given name can be found + */ + public String getReturnType(Class pojoClass, String methodName) throws NoSuchMethodException, SecurityException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + String s = "-"; + Method method = findMethod(pojoClass, methodName); + if (method != null && !method.getReturnType().equals(Void.TYPE)) { + s = method.getReturnType().toString(); + s = s.substring(s.lastIndexOf('.') + 1, s.length()); + } + return s; + } + + /** + * + * This methods returns the return type of the method in the given pojoClass which are annotated with the parameter + * annotatedClass + * + * @param pojoClass - The class in which to find if it has methods with annotatedClass + * @param annotatedClassName - The annotation which needs to be found + * @return Return type of the method annotated with the given annotation, else "null" + * @throws ClassNotFoundException if the annotated class name could not be found in the class path + */ + @SuppressWarnings("unchecked") + public String getReturnTypeOfMethodAnnotatedWith(Class pojoClass, String annotatedClassName) + throws ClassNotFoundException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + + Method[] methods = pojoClass.getDeclaredMethods(); + for (Method method : methods) { + if (!method.getName().startsWith("get")) { + continue; + } + for (Annotation a : method.getAnnotations()) { + // better if (method.isAnnotationPresent(classObj)) {, but postponed as of different class + // loaders of a.getClass() and pojoClass.getClass() + if (a.getClass().getCanonicalName().equals(annotatedClassName)) { + return method.getReturnType().getSimpleName(); + } + } + } + return "null"; + } + + /** + * returns the HTTP request type corresponding to an annotation type + * + * @param annotations The annotation to get the type name of + * @return the HTTP request type name of the selected annotation + */ + public String getRequestType(Map annotations) { + + if (annotations.containsKey("javax_ws_rs_GET")) { + return "GET"; + } else if (annotations.containsKey("javax_ws_rs_PUT")) { + return "PUT"; + } else if (annotations.containsKey("javax_ws_rs_POST")) { + return "POST"; + } else if (annotations.containsKey("javax_ws_rs_DELETE")) { + return "DELETE"; + } else if (annotations.containsKey("javax_ws_rs_PATCH")) { + return "PATCH"; + } else { + return "-"; + } + } + + /** + * Helper method to find a class's specific method + * + * @param pojoClass {@link Class}<?> the class object of the pojo + * @param methodName The name of the method to be found + * @return The method object of the method to be found, null if it wasn't found + */ + private Method findMethod(Class pojoClass, String methodName) { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + for (Method m : pojoClass.getMethods()) { + if (m.getName().equals(methodName)) { + return m; + } + } + return null; + } + + /** + * Checks whether the class given by the full qualified name is an enum + * + * @param className full qualified class name + * @return true if the class is an enum, false otherwise + */ + public boolean isEnum(String className) { + + try { + return ClassUtils.getClass(className).isEnum(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), className); + return false; + } + } + + /** + * Returns the first enum value of an enum class + * + * @param className full qualified class name + * @return the first enum value name found in order + */ + public String getFirstEnumValue(String className) { + + try { + Class enumClass = ClassUtils.getClass(className); + Field[] declaredFields = enumClass.getDeclaredFields(); + if (declaredFields.length > 0) { + return declaredFields[0].getName(); + } else { + return null; + } + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), className); + return null; + } + } +} diff --git a/cobigen-templates/templates-devon4j/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/OpenApiUtil.java b/cobigen-templates/crud-openapi-angular-client-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/OpenApiUtil.java similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/OpenApiUtil.java rename to cobigen-templates/crud-openapi-angular-client-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/OpenApiUtil.java diff --git a/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/template-set.xml b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/template-set.xml new file mode 100644 index 0000000000..bd2640a935 --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/template-set.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/cobigen.properties b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/cobigen.properties similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/cobigen.properties rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/cobigen.properties diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.html.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.html.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.html.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.html.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.scss b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.scss similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.scss rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.scss diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.spec.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.spec.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.spec.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.spec.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-alert/${variables.etoName#lower_case}-alert.component.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.html.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.html.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.html.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.html.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.spec.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.spec.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.spec.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.spec.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-dialog/${variables.etoName#lower_case}-dialog.component.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.html.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.html.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.html.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.html.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.scss b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.scss similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.scss rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.scss diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.spec.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.spec.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.spec.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.spec.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-grid/${variables.etoName#lower_case}-grid.component.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-routing.module.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-routing.module.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-routing.module.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}-routing.module.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}.module.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}.module.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}.module.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/${variables.etoName#lower_case}.module.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.spec.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.spec.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.spec.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.spec.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/${variables.etoName#lower_case}/services/${variables.etoName#lower_case}.service.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/app-routing.module.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/app-routing.module.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/app-routing.module.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/app-routing.module.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/app.module.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/app.module.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/app.module.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/app.module.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/home/home.component.html.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/home/home.component.html.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/home/home.component.html.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/home/home.component.html.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/layout/nav-bar/nav-bar.component.html.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/layout/nav-bar/nav-bar.component.html.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/layout/nav-bar/nav-bar.component.html.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/layout/nav-bar/nav-bar.component.html.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/model/${variables.etoName#lower_case}.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/model/${variables.etoName#lower_case}.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/model/${variables.etoName#lower_case}.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/model/${variables.etoName#lower_case}.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/model/model.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/model/model.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/app/model/model.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/app/model/model.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/assets/i18n/en.json.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/assets/i18n/en.json.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/assets/i18n/en.json.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/assets/i18n/en.json.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/assets/i18n/es.json.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/assets/i18n/es.json.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/assets/i18n/es.json.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/assets/i18n/es.json.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/environments/environment.prod.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/environments/environment.prod.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/environments/environment.prod.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/environments/environment.prod.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/environments/environment.ts.ftl b/cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/environments/environment.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_client_app/templates/src/environments/environment.ts.ftl rename to cobigen-templates/crud-openapi-angular-client-app/src/main/resources/templates/src/environments/environment.ts.ftl diff --git a/cobigen-templates/crud-openapi-angular-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenapiAngularClientAppTest.java b/cobigen-templates/crud-openapi-angular-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenapiAngularClientAppTest.java new file mode 100644 index 0000000000..28302c4458 --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenapiAngularClientAppTest.java @@ -0,0 +1,100 @@ +package com.devonfw.cobigen.templates.devon4j.test.templates; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.apache.commons.io.FileUtils; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.devonfw.cobigen.api.constants.ConfigurationConstants; +import com.devonfw.cobigen.maven.test.AbstractMavenTest; +import com.devonfw.cobigen.templates.devon4j.config.constant.MavenMetadata; + +/** + * Smoke tests of all templates. + */ +public class CrudOpenapiAngularClientAppTest extends AbstractMavenTest { + + /** Root of all test resources of this test suite */ + public static final String TEST_RESOURCES_ROOT = "src/test/resources/testdata/templatetest/"; + + /** Temporary files rule to create temporary folders */ + @ClassRule + public static TemporaryFolder tempFolder = new TemporaryFolder(); + + /** The templates development folder */ + protected static Path templatesProject; + + /** The templates development folder */ + protected static Path templatesProjectTemporary; + + /** + * Creates a copy of the templates project in the temp directory + * + * @throws URISyntaxException if the path could not be created properly + * @throws IOException if accessing a directory or file fails + */ + @BeforeClass + public static void setupDevTemplates() throws URISyntaxException, IOException { + + templatesProject = new File( + CrudOpenapiAngularClientAppTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()) + .getParentFile().getParentFile().toPath(); + + Path utilsPom = new File( + CrudOpenapiAngularClientAppTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()) + .getParentFile().getParentFile().toPath().resolve("src/test/resources/utils/pom.xml"); + + // create a temporary directory cobigen-templates/template-sets/adapted containing the template sets + Path tempFolderPath = tempFolder.getRoot().toPath(); + Path cobigenTemplatePath = tempFolderPath.resolve("cobigen-templates"); + if (!Files.exists(cobigenTemplatePath)) { + Files.createDirectory(cobigenTemplatePath); + + templatesProjectTemporary = cobigenTemplatePath.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER); + Path templateSetsAdaptedFolder = templatesProjectTemporary.resolve(ConfigurationConstants.ADAPTED_FOLDER); + Files.createDirectory(templatesProjectTemporary); + Files.createDirectory(templateSetsAdaptedFolder); + + Path templateSetPath = templateSetsAdaptedFolder.resolve("template-set"); + FileUtils.copyDirectory(templatesProject.toFile(), templateSetPath.toFile()); + + if (Files.isDirectory(templateSetPath)) { + + // Replace the pom.xml in the template sets. Needed so that the project in the temp directory is build + // properly + if (Files.exists(templateSetPath.resolve("pom.xml"))) { + try { + Files.delete(templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error deleting file " + templateSetPath.resolve("pom.xml"), e); + } + try { + Files.copy(utilsPom, templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error copying file " + utilsPom, e); + } + } + } + } + } + + /** + * Test successful generation of all templates based on an ETO + * + * @throws Exception test fails + */ + @Test + public void testAllTemplatesGeneration_OpenApiInput() throws Exception { + + File testProject = new File(TEST_RESOURCES_ROOT + "TestAllTemplatesOpenApiInput/"); + runMavenInvoker(testProject, templatesProjectTemporary.toFile(), MavenMetadata.LOCAL_REPO); + } + +} diff --git a/cobigen-templates/crud-openapi-angular-client-app/src/test/resources/application.properties b/cobigen-templates/crud-openapi-angular-client-app/src/test/resources/application.properties new file mode 100644 index 0000000000..cf2c614efb --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-client-app/src/test/resources/application.properties @@ -0,0 +1,2 @@ +server.port=8080 +server.context-path=/ \ No newline at end of file diff --git a/cobigen-templates/crud-openapi-angular-client-app/src/test/resources/logback.xml b/cobigen-templates/crud-openapi-angular-client-app/src/test/resources/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-client-app/src/test/resources/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml b/cobigen-templates/crud-openapi-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml similarity index 100% rename from cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml rename to cobigen-templates/crud-openapi-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml diff --git a/cobigen-templates/crud-openapi-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml b/cobigen-templates/crud-openapi-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml b/cobigen-templates/crud-openapi-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml similarity index 100% rename from cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml rename to cobigen-templates/crud-openapi-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml diff --git a/cobigen-templates/crud-openapi-angular-client-app/src/test/resources/utils/pom.xml b/cobigen-templates/crud-openapi-angular-client-app/src/test/resources/utils/pom.xml new file mode 100644 index 0000000000..d600eb559a --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-client-app/src/test/resources/utils/pom.xml @@ -0,0 +1,100 @@ + + + 4.0.0 + com.devonfw.cobigen.templates + crud-openapi-angular-client-app + 2021.12.007-SNAPSHOT + Crud Openapi Angular Client App + A Code-based incremental Generator + https://github.com/devonfw/cobigen/templates-parent/templates-devon4j-utils + + + Apache Software License 2.0 + https://raw.githubusercontent.com/devonfw/.github/master/LICENSE + repo + + + + + + javax.ws.rs + javax.ws.rs-api + 2.0 + compile + + + org.springframework.data + spring-data-rest-webmvc + 3.7.10 + compile + + + org.apache.commons + commons-lang3 + 3.12.0 + compile + + + com.fasterxml.jackson.core + jackson-databind + 2.10.0 + compile + + + xerces + xercesImpl + 2.12.2 + compile + + + javax.persistence + javax.persistence-api + 2.2 + compile + + + org.slf4j + slf4j-api + 1.7.30 + compile + + + org.slf4j + jcl-over-slf4j + 1.7.30 + compile + + + org.slf4j + log4j-over-slf4j + 1.7.30 + compile + + + + + + false + + + true + + ossrh + OSSRH Snapshots + https://s01.oss.sonatype.org/content/repositories/snapshots/ + + + + + 1.8 + 1.8 + + + + + + src/main/java + + + \ No newline at end of file diff --git a/cobigen-templates/crud-openapi-angular-service-based-app/pom.xml b/cobigen-templates/crud-openapi-angular-service-based-app/pom.xml new file mode 100644 index 0000000000..cf6571b0d4 --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-service-based-app/pom.xml @@ -0,0 +1,13 @@ + + 4.0.0 + crud-openapi-angular-service-based-app + CRUD OpenAPI Angular Service Based App template + + + com.devonfw.cobigen.templates + templates-parent + ${revision} + + + \ No newline at end of file diff --git a/cobigen-templates/crud-openapi-angular-service-based-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java b/cobigen-templates/crud-openapi-angular-service-based-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java new file mode 100644 index 0000000000..395d46154d --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-service-based-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java @@ -0,0 +1,12 @@ +package com.devonfw.cobigen.templates.devon4j.config.constant; + +/** + * Constants extracted from the maven pom by templating-maven-plugin. + * + * @see "edit template in src/main/java-templates" + */ +public class MavenMetadata { + + /** Local repository path */ + public static final String LOCAL_REPO = "${settings.localRepository}"; +} diff --git a/cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/template-set.xml b/cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/template-set.xml new file mode 100644 index 0000000000..c4a3b7af7b --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/template-set.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app/templates/cobigen.properties b/cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/templates/cobigen.properties similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app/templates/cobigen.properties rename to cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/templates/cobigen.properties diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app/templates/src/app/api/${variables.component#lower_case}/${variables.component#lower_case}RestController.service.ts.ftl b/cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/templates/src/app/api/${variables.component#lower_case}/${variables.component#lower_case}RestController.service.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app/templates/src/app/api/${variables.component#lower_case}/${variables.component#lower_case}RestController.service.ts.ftl rename to cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/templates/src/app/api/${variables.component#lower_case}/${variables.component#lower_case}RestController.service.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app/templates/src/app/api/api.ts.ftl b/cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/templates/src/app/api/api.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app/templates/src/app/api/api.ts.ftl rename to cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/templates/src/app/api/api.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app/templates/src/environments/environment.prod.ts.ftl b/cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/templates/src/environments/environment.prod.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_angular_service_based_app/templates/src/environments/environment.prod.ts.ftl rename to cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/templates/src/environments/environment.prod.ts.ftl diff --git a/cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/templates/src/environments/environment.ts.ftl b/cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/templates/src/environments/environment.ts.ftl new file mode 100644 index 0000000000..c311b61aca --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-service-based-app/src/main/resources/templates/src/environments/environment.ts.ftl @@ -0,0 +1,11 @@ +// The file contents for the current environment will overwrite these during build. +// The build system defaults to the dev environment which uses `environment.ts`, but if you do +// `ng build --env=prod` then `environment.prod.ts` will be used instead. +// The list of which env maps to which file can be found in `angular-cli.json`. + +export const environment = { + production: false, + restPathRoot: 'http://localhost:8081/${variables.domain}-server/', + restServiceRoot: 'http://localhost:8081/${variables.domain}-server/services/rest/', + security: 'csrf', +}; diff --git a/cobigen-templates/crud-openapi-angular-service-based-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenapiAngularServiceBasedAppTest.java b/cobigen-templates/crud-openapi-angular-service-based-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenapiAngularServiceBasedAppTest.java new file mode 100644 index 0000000000..26d650b2b4 --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-service-based-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenapiAngularServiceBasedAppTest.java @@ -0,0 +1,100 @@ +package com.devonfw.cobigen.templates.devon4j.test.templates; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.apache.commons.io.FileUtils; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.devonfw.cobigen.api.constants.ConfigurationConstants; +import com.devonfw.cobigen.maven.test.AbstractMavenTest; +import com.devonfw.cobigen.templates.devon4j.config.constant.MavenMetadata; + +/** + * Smoke tests of all templates. + */ +public class CrudOpenapiAngularServiceBasedAppTest extends AbstractMavenTest { + + /** Root of all test resources of this test suite */ + public static final String TEST_RESOURCES_ROOT = "src/test/resources/testdata/templatetest/"; + + /** Temporary files rule to create temporary folders */ + @ClassRule + public static TemporaryFolder tempFolder = new TemporaryFolder(); + + /** The templates development folder */ + protected static Path templatesProject; + + /** The templates development folder */ + protected static Path templatesProjectTemporary; + + /** + * Creates a copy of the templates project in the temp directory + * + * @throws URISyntaxException if the path could not be created properly + * @throws IOException if accessing a directory or file fails + */ + @BeforeClass + public static void setupDevTemplates() throws URISyntaxException, IOException { + + templatesProject = new File( + CrudOpenapiAngularServiceBasedAppTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()) + .getParentFile().getParentFile().toPath(); + + Path utilsPom = new File( + CrudOpenapiAngularServiceBasedAppTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()) + .getParentFile().getParentFile().toPath().resolve("src/test/resources/utils/pom.xml"); + + // create a temporary directory cobigen-templates/template-sets/adapted containing the template sets + Path tempFolderPath = tempFolder.getRoot().toPath(); + Path cobigenTemplatePath = tempFolderPath.resolve("cobigen-templates"); + if (!Files.exists(cobigenTemplatePath)) { + Files.createDirectory(cobigenTemplatePath); + + templatesProjectTemporary = cobigenTemplatePath.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER); + Path templateSetsAdaptedFolder = templatesProjectTemporary.resolve(ConfigurationConstants.ADAPTED_FOLDER); + Files.createDirectory(templatesProjectTemporary); + Files.createDirectory(templateSetsAdaptedFolder); + + Path templateSetPath = templateSetsAdaptedFolder.resolve("template-set"); + FileUtils.copyDirectory(templatesProject.toFile(), templateSetPath.toFile()); + + if (Files.isDirectory(templateSetPath)) { + + // Replace the pom.xml in the template sets. Needed so that the project in the temp directory is build + // properly + if (Files.exists(templateSetPath.resolve("pom.xml"))) { + try { + Files.delete(templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error deleting file " + templateSetPath.resolve("pom.xml"), e); + } + try { + Files.copy(utilsPom, templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error copying file " + utilsPom, e); + } + } + } + } + } + + /** + * Test successful generation of all templates based on an ETO + * + * @throws Exception test fails + */ + @Test + public void testAllTemplatesGeneration_OpenApiInput() throws Exception { + + File testProject = new File(TEST_RESOURCES_ROOT + "TestAllTemplatesOpenApiInput/"); + runMavenInvoker(testProject, templatesProjectTemporary.toFile(), MavenMetadata.LOCAL_REPO); + } + +} diff --git a/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/application.properties b/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/application.properties new file mode 100644 index 0000000000..cf2c614efb --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/application.properties @@ -0,0 +1,2 @@ +server.port=8080 +server.context-path=/ \ No newline at end of file diff --git a/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/logback.xml b/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml b/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml new file mode 100644 index 0000000000..14b9ec10cf --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml @@ -0,0 +1,131 @@ +openapi: 3.0.0 +servers: + - url: 'https://localhost:8081/server/services/rest' +info: + title: Devon Example + description: Example of a API definition + version: 1.0.0 + x-rootpackage: com.devonfw.demo +paths: + /datamanagement/v1/someData/{id}: + get: + operationId: findSomeData + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + minimum: 0 + maximum: 50 + responses: + '200': + description: Any + content: + application/json: + schema: + $ref: '#/components/schemas/EvenMoreData' + text/plain: + schema: + type: string + /datamanagement/v1/moreData/{id}: + get: + operationId: findMoreData + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + minimum: 10 + maximum: 200 + responses: + '200': + description: Any + /datamanagement/v1/someData/: + post: + responses: + '200': + description: Any + requestBody: + $ref: '#/components/requestBodies/SomeData' + tags: + - searchCriteria + /datamanagement/v1/moreData/validateMoreData: + post: + responses: + '200': + description: Any + requestBody: + $ref: '#/components/requestBodies/MoreData' +components: + schemas: + SomeData: + x-component: DataManagement + description: Entity definiton of SomeData + type: object + properties: + AnyString: + type: string + maxLength: 100 + minLength: 5 + uniqueItems: true + furtherData: + type: array + items: + $ref: '#/components/schemas/FurtherData' + MoreData: + x-component: DataManagement + description: Entity definiton of Moredata + type: object + properties: + anyNumber: + type: number + format: int64 + maximum: 100 + minimum: 0 + someData: + $ref: '#/components/schemas/SomeData' + allSomeData: + type: array + description: 'All SomeData' + items: + $ref: '#/components/schemas/SomeData' + required: + - saleExample + FurtherData: + x-component: AnotherComponent + type: object + properties: + parent: + $ref: '#/components/schemas/SomeData' + valid: + type: boolean + someList: + type: array + items: + type: string + EvenMoreData: + x-component: AnotherComponent + description: Entity definiton of more data + type: object + properties: + id: + type: integer + format: int64 + uniqueItems: true + requestBodies: + SomeData: + content: + application/json: + schema: + $ref: '#/components/schemas/SomeData' + required: true + MoreData: + content: + application/json: + schema: + $ref: '#/components/schemas/MoreData' + required: true diff --git a/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml b/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml b/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml new file mode 100644 index 0000000000..7f84fdeef0 --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + com.devonfw.cobigen + devon4jTemplateTest-TestAllTemplatesOpenAPIInput + dev-SNAPSHOT + + + 1.8 + 1.8 + + + + + + com.devonfw.cobigen + cobigen-maven-plugin + ${pluginVersion} + + + generate + package + + generate + + + + + ${templatesProject} + + OpenAPI.yaml + + + + + true + + + + com.devonfw.cobigen + tempeng-freemarker + ${pluginVersion} + + + com.devonfw.cobigen + javaplugin + ${pluginVersion} + + + com.devonfw.cobigen + htmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + tsplugin + ${pluginVersion} + + + com.devonfw.cobigen + jsonplugin + ${pluginVersion} + + + com.devonfw.cobigen + openapiplugin + ${pluginVersion} + + + com.devonfw.cobigen + xmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + textmerger + ${pluginVersion} + + + + + + + diff --git a/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/utils/pom.xml b/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/utils/pom.xml new file mode 100644 index 0000000000..9a33c5c4f2 --- /dev/null +++ b/cobigen-templates/crud-openapi-angular-service-based-app/src/test/resources/utils/pom.xml @@ -0,0 +1,100 @@ + + + 4.0.0 + com.devonfw.cobigen.templates + crud-openapi-angular-service-based-app + 2021.12.007-SNAPSHOT + Crud OpenApi Angular Service Based App + A Code-based incremental Generator + https://github.com/devonfw/cobigen/templates-parent/templates-devon4j-utils + + + Apache Software License 2.0 + https://raw.githubusercontent.com/devonfw/.github/master/LICENSE + repo + + + + + + javax.ws.rs + javax.ws.rs-api + 2.0 + compile + + + org.springframework.data + spring-data-rest-webmvc + 3.7.10 + compile + + + org.apache.commons + commons-lang3 + 3.12.0 + compile + + + com.fasterxml.jackson.core + jackson-databind + 2.10.0 + compile + + + xerces + xercesImpl + 2.12.2 + compile + + + javax.persistence + javax.persistence-api + 2.2 + compile + + + org.slf4j + slf4j-api + 1.7.30 + compile + + + org.slf4j + jcl-over-slf4j + 1.7.30 + compile + + + org.slf4j + log4j-over-slf4j + 1.7.30 + compile + + + + + + false + + + true + + ossrh + OSSRH Snapshots + https://s01.oss.sonatype.org/content/repositories/snapshots/ + + + + + 1.8 + 1.8 + + + + + + src/main/java + + + \ No newline at end of file diff --git a/cobigen-templates/crud-openapi-ionic-client-app/pom.xml b/cobigen-templates/crud-openapi-ionic-client-app/pom.xml new file mode 100644 index 0000000000..fbfd00fd3f --- /dev/null +++ b/cobigen-templates/crud-openapi-ionic-client-app/pom.xml @@ -0,0 +1,19 @@ + + 4.0.0 + crud-openapi-ionic-client-app + CRUD OpenAPI Ionic Client App template + + + com.devonfw.cobigen.templates + templates-parent + ${revision} + + + + + org.apache.commons + commons-lang3 + + + \ No newline at end of file diff --git a/cobigen-templates/crud-openapi-ionic-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java b/cobigen-templates/crud-openapi-ionic-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java new file mode 100644 index 0000000000..395d46154d --- /dev/null +++ b/cobigen-templates/crud-openapi-ionic-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java @@ -0,0 +1,12 @@ +package com.devonfw.cobigen.templates.devon4j.config.constant; + +/** + * Constants extracted from the maven pom by templating-maven-plugin. + * + * @see "edit template in src/main/java-templates" + */ +public class MavenMetadata { + + /** Local repository path */ + public static final String LOCAL_REPO = "${settings.localRepository}"; +} diff --git a/cobigen-templates/crud-openapi-ionic-client-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java b/cobigen-templates/crud-openapi-ionic-client-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java new file mode 100644 index 0000000000..ced2f5fde2 --- /dev/null +++ b/cobigen-templates/crud-openapi-ionic-client-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java @@ -0,0 +1,464 @@ +package com.devonfw.cobigen.templates.devon4j.utils; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.Map; + +import org.apache.commons.lang3.ClassUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Provides type operations, mainly checks and casts for Java Primitives, to be used in the templates + * + */ +public class JavaUtil { + + /** + * Logger for this class + */ + private static final Logger LOG = LoggerFactory.getLogger(JavaUtil.class); + + /** + * The constructor. + */ + public JavaUtil() { + + // Empty for CobiGen to automatically instantiate it + } + + /** + * Returns the Object version of a Java primitive or the input if the input isn't a java primitive + * + * @param simpleType String + * @return the corresponding object wrapper type simple name of the input if the input is the name of a primitive java + * type. The input itself if not. (e.g. "int" results in "Integer") + * @throws ClassNotFoundException should not occur. + */ + public String boxJavaPrimitives(String simpleType) throws ClassNotFoundException { + + if (equalsJavaPrimitive(simpleType)) { + return ClassUtils.primitiveToWrapper(ClassUtils.getClass(simpleType)).getSimpleName(); + } else { + return simpleType; + } + + } + + /** + * Returns the simple name of the type of a field in the pojoClass. If the type is a java primitive the name of the + * wrapper class is returned + * + * @param pojoClass {@link Class} the class object of the pojo + * @param fieldName {@link String} the name of the field + * @return String. The simple name of the field's type. The simple name of the wrapper class in case of java + * primitives + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public String boxJavaPrimitives(Class pojoClass, String fieldName) throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + + if (equalsJavaPrimitive(pojoClass, fieldName)) { + return ClassUtils.primitiveToWrapper(pojoClass.getDeclaredField(fieldName).getType()).getSimpleName(); + } else { + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + throw new IllegalAccessError("Could not find field " + fieldName + " in class " + pojoClass); + } else { + return field.getType().getSimpleName(); + } + } + } + + /** + * Checks if the given type is a Java primitive + * + * @param simpleType the type to be checked + * @return true iff simpleType is a Java primitive + */ + public boolean equalsJavaPrimitive(String simpleType) { + + try { + return ClassUtils.getClass(simpleType).isPrimitive(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + } + + /** + * Checks if the given type is a Java primitive or wrapper + * + * @param simpleType the type to be checked + * @return true iff simpleType is a Java primitive or wrapper + */ + public boolean equalsJavaPrimitiveOrWrapper(String simpleType) { + + try { + return ClassUtils.isPrimitiveOrWrapper(ClassUtils.getClass(simpleType)); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + } + + /** + * Checks if the type of the field in the pojo's class is a java primitive + * + * @param pojoClass the {@link Class} object of the pojo + * @param fieldName the name of the field to be checked + * @return true iff the field is a java primitive + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean equalsJavaPrimitive(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + return false; + } + + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + return false; + } else { + return field.getType().isPrimitive(); + } + } + + /** + * Checks if the given type is a Java primitive or a Java primitive array + * + * @param simpleType the Type name to be checked + * @return true iff {@link #equalsJavaPrimitive(String)} is true or if simpleType is an array with a primitive + * component + */ + public boolean equalsJavaPrimitiveIncludingArrays(String simpleType) { + + Class klasse; + + try { + klasse = ClassUtils.getClass(simpleType).getComponentType(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + return equalsJavaPrimitive(simpleType) || (klasse != null && klasse.isPrimitive()); + } + + /** + * Checks if the given field in the pojo class is a java primitive or an array of java primitives + * + * @param pojoClass the class object of the pojo + * @param fieldName the name of the field to be checked + * @return true iff {@link #equalsJavaPrimitive(Class, String)} is true or the field is an array of primitives + * @throws NoSuchFieldException indicating something awfully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean equalsJavaPrimitiveIncludingArrays(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + return equalsJavaPrimitive(pojoClass, fieldName) || (pojoClass.getDeclaredField(fieldName).getType().isArray() + && pojoClass.getDeclaredField(fieldName).getType().getComponentType().isPrimitive()); + } + + /** + * Returns a cast statement for a given (java primitive, variable name) pair or nothing if the type isn't a java + * primitive + * + * @param simpleType Java Type + * @param varName Variable name + * @return String either of the form '((Java Primitive Object Type)varName)' if simpleType is a primitive or the empty + * String otherwise + * @throws ClassNotFoundException should not occur + */ + public String castJavaPrimitives(String simpleType, String varName) throws ClassNotFoundException { + + if (equalsJavaPrimitive(simpleType)) { + return String.format("((%1$s)%2$s)", boxJavaPrimitives(simpleType), varName); + } else { + return ""; + } + } + + /** + * Returns a cast statement for a given (java primitive, variable name) pair or nothing if the type isn't a java + * primitive + * + * @param pojoClass the class object of the pojo + * @param fieldName the name of the field to be casted + * @return if fieldName points to a primitive field then a casted statement (e.g. for an int field: + * '((Integer)field)') or an empty String otherwise + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public String castJavaPrimitives(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + if (equalsJavaPrimitive(pojoClass, fieldName)) { + return String.format("((%1$s)%2$s)", boxJavaPrimitives(pojoClass, fieldName), fieldName); + } else { + return ""; + } + } + + /** + * @param pojoClass {@link Class} the class object of the pojo + * @param fieldName {@link String} the name of the field + * @return true if the field is an instance of java.utils.Collections + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean isCollection(Class pojoClass, String fieldName) throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + return false; + } + + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + return false; + } else { + return Collection.class.isAssignableFrom(field.getType()); + } + + } + + /** + * Returns the Ext Type to a given java type + * + * @param simpleType any java type's simple name + * @return corresponding Ext type + */ + public String getExtType(String simpleType) { + + switch (simpleType) { + case "short": + case "Short": + case "int": + case "Integer": + case "long": + case "Long": + return "Integer"; + case "float": + case "Float": + case "double": + case "Double": + return "Number"; + case "boolean": + case "Boolean": + return "Boolean"; + case "char": + case "Character": + case "String": + return "String"; + case "Date": + return "Date"; + default: + return "Field"; + } + } + + /** + * returns the Angular5 type associated with a Java primitive + * + * @param simpleType :{@link String} the type to be parsed + * @return the corresponding Angular type or 'any' otherwise + */ + public String getAngularType(String simpleType) { + + switch (simpleType) { + case "boolean": + return "boolean"; + case "Boolean": + return "boolean"; + case "short": + return "number"; + case "Short": + return "number"; + case "int": + return "number"; + case "Integer": + return "number"; + case "long": + return "number"; + case "Long": + return "number"; + case "float": + return "number"; + case "Float": + return "number"; + case "double": + return "number"; + case "Double": + return "number"; + case "char": + return "string"; + case "Character": + return "string"; + case "String": + return "string"; + case "byte": + return "number"; + default: + return "any"; + } + } + + /** + * returns the class name of the return type of a specific method. + * + * @param pojoClass {@link Class}<?> the class object of the pojo + * @param methodName {@link String} the name of the method + * @return the class name of the return type of the specified method + * @throws SecurityException If no method of the given name can be found + * @throws NoSuchMethodException If no method of the given name can be found + */ + public String getReturnType(Class pojoClass, String methodName) throws NoSuchMethodException, SecurityException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + String s = "-"; + Method method = findMethod(pojoClass, methodName); + if (method != null && !method.getReturnType().equals(Void.TYPE)) { + s = method.getReturnType().toString(); + s = s.substring(s.lastIndexOf('.') + 1, s.length()); + } + return s; + } + + /** + * + * This methods returns the return type of the method in the given pojoClass which are annotated with the parameter + * annotatedClass + * + * @param pojoClass - The class in which to find if it has methods with annotatedClass + * @param annotatedClassName - The annotation which needs to be found + * @return Return type of the method annotated with the given annotation, else "null" + * @throws ClassNotFoundException if the annotated class name could not be found in the class path + */ + @SuppressWarnings("unchecked") + public String getReturnTypeOfMethodAnnotatedWith(Class pojoClass, String annotatedClassName) + throws ClassNotFoundException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + + Method[] methods = pojoClass.getDeclaredMethods(); + for (Method method : methods) { + if (!method.getName().startsWith("get")) { + continue; + } + for (Annotation a : method.getAnnotations()) { + // better if (method.isAnnotationPresent(classObj)) {, but postponed as of different class + // loaders of a.getClass() and pojoClass.getClass() + if (a.getClass().getCanonicalName().equals(annotatedClassName)) { + return method.getReturnType().getSimpleName(); + } + } + } + return "null"; + } + + /** + * returns the HTTP request type corresponding to an annotation type + * + * @param annotations The annotation to get the type name of + * @return the HTTP request type name of the selected annotation + */ + public String getRequestType(Map annotations) { + + if (annotations.containsKey("javax_ws_rs_GET")) { + return "GET"; + } else if (annotations.containsKey("javax_ws_rs_PUT")) { + return "PUT"; + } else if (annotations.containsKey("javax_ws_rs_POST")) { + return "POST"; + } else if (annotations.containsKey("javax_ws_rs_DELETE")) { + return "DELETE"; + } else if (annotations.containsKey("javax_ws_rs_PATCH")) { + return "PATCH"; + } else { + return "-"; + } + } + + /** + * Helper method to find a class's specific method + * + * @param pojoClass {@link Class}<?> the class object of the pojo + * @param methodName The name of the method to be found + * @return The method object of the method to be found, null if it wasn't found + */ + private Method findMethod(Class pojoClass, String methodName) { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + for (Method m : pojoClass.getMethods()) { + if (m.getName().equals(methodName)) { + return m; + } + } + return null; + } + + /** + * Checks whether the class given by the full qualified name is an enum + * + * @param className full qualified class name + * @return true if the class is an enum, false otherwise + */ + public boolean isEnum(String className) { + + try { + return ClassUtils.getClass(className).isEnum(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), className); + return false; + } + } + + /** + * Returns the first enum value of an enum class + * + * @param className full qualified class name + * @return the first enum value name found in order + */ + public String getFirstEnumValue(String className) { + + try { + Class enumClass = ClassUtils.getClass(className); + Field[] declaredFields = enumClass.getDeclaredFields(); + if (declaredFields.length > 0) { + return declaredFields[0].getName(); + } else { + return null; + } + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), className); + return null; + } + } +} diff --git a/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/template-set.xml b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/template-set.xml new file mode 100644 index 0000000000..cbd540239e --- /dev/null +++ b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/template-set.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/cobigen.properties b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/cobigen.properties old mode 100755 new mode 100644 similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/cobigen.properties rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/cobigen.properties diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/app-routing.module.ts.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/app-routing.module.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/app-routing.module.ts.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/app-routing.module.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/app.component.ts.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/app.component.ts.ftl old mode 100755 new mode 100644 similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/app.component.ts.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/app.component.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/app.module.ts.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/app.module.ts.ftl old mode 100755 new mode 100644 similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/app.module.ts.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/app.module.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.html.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.html.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.html.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.html.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.scss.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.scss.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.scss.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.scss.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.ts.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.ts.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/pages/${variables.etoName#lower_case}-detail/${variables.etoName#lower_case}-detail.page.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.html.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.html.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.html.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.html.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.scss.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.scss.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.scss.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.scss.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.ts.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.ts.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/pages/${variables.etoName#lower_case}-list/${variables.etoName#lower_case}-list.page.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/services/${variables.etoName#lower_case}-rest.service.ts.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/services/${variables.etoName#lower_case}-rest.service.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/services/${variables.etoName#lower_case}-rest.service.ts.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/services/${variables.etoName#lower_case}-rest.service.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/services/interfaces/${variables.etoName#lower_case}-search-criteria.ts.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/services/interfaces/${variables.etoName#lower_case}-search-criteria.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/services/interfaces/${variables.etoName#lower_case}-search-criteria.ts.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/services/interfaces/${variables.etoName#lower_case}-search-criteria.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/services/interfaces/${variables.etoName#lower_case}.ts.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/services/interfaces/${variables.etoName#lower_case}.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/services/interfaces/${variables.etoName#lower_case}.ts.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/services/interfaces/${variables.etoName#lower_case}.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/services/interfaces/pageable.ts.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/services/interfaces/pageable.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/services/interfaces/pageable.ts.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/services/interfaces/pageable.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/services/interfaces/paginated-list-to.ts.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/services/interfaces/paginated-list-to.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/services/interfaces/paginated-list-to.ts.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/services/interfaces/paginated-list-to.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/services/interfaces/sort.ts.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/services/interfaces/sort.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/services/interfaces/sort.ts.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/services/interfaces/sort.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/services/shared/business-operator.service.ts.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/services/shared/business-operator.service.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/app/services/shared/business-operator.service.ts.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/app/services/shared/business-operator.service.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/assets/i18n/en.json.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/assets/i18n/en.json.ftl old mode 100755 new mode 100644 similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/assets/i18n/en.json.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/assets/i18n/en.json.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/assets/i18n/es.json.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/assets/i18n/es.json.ftl old mode 100755 new mode 100644 similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/assets/i18n/es.json.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/assets/i18n/es.json.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/assets/i18n/it.json.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/assets/i18n/it.json.ftl old mode 100755 new mode 100644 similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/assets/i18n/it.json.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/assets/i18n/it.json.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/environments/environment.android.ts.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/environments/environment.android.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/environments/environment.android.ts.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/environments/environment.android.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/environments/environment.prod.ts.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/environments/environment.prod.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/environments/environment.prod.ts.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/environments/environment.prod.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/environments/environment.ts.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/environments/environment.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/environments/environment.ts.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/environments/environment.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/theme/variables.scss.ftl b/cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/theme/variables.scss.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_ionic_client_app/templates/src/theme/variables.scss.ftl rename to cobigen-templates/crud-openapi-ionic-client-app/src/main/resources/templates/src/theme/variables.scss.ftl diff --git a/cobigen-templates/crud-openapi-ionic-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenapiIonicClientAppTest.java b/cobigen-templates/crud-openapi-ionic-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenapiIonicClientAppTest.java new file mode 100644 index 0000000000..32051623e8 --- /dev/null +++ b/cobigen-templates/crud-openapi-ionic-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenapiIonicClientAppTest.java @@ -0,0 +1,100 @@ +package com.devonfw.cobigen.templates.devon4j.test.templates; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.apache.commons.io.FileUtils; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.devonfw.cobigen.api.constants.ConfigurationConstants; +import com.devonfw.cobigen.maven.test.AbstractMavenTest; +import com.devonfw.cobigen.templates.devon4j.config.constant.MavenMetadata; + +/** + * Smoke tests of all templates. + */ +public class CrudOpenapiIonicClientAppTest extends AbstractMavenTest { + + /** Root of all test resources of this test suite */ + public static final String TEST_RESOURCES_ROOT = "src/test/resources/testdata/templatetest/"; + + /** Temporary files rule to create temporary folders */ + @ClassRule + public static TemporaryFolder tempFolder = new TemporaryFolder(); + + /** The templates development folder */ + protected static Path templatesProject; + + /** The templates development folder */ + protected static Path templatesProjectTemporary; + + /** + * Creates a copy of the templates project in the temp directory + * + * @throws URISyntaxException if the path could not be created properly + * @throws IOException if accessing a directory or file fails + */ + @BeforeClass + public static void setupDevTemplates() throws URISyntaxException, IOException { + + templatesProject = new File( + CrudOpenapiIonicClientAppTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile() + .getParentFile().toPath(); + + Path utilsPom = new File( + CrudOpenapiIonicClientAppTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile() + .getParentFile().toPath().resolve("src/test/resources/utils/pom.xml"); + + // create a temporary directory cobigen-templates/template-sets/adapted containing the template sets + Path tempFolderPath = tempFolder.getRoot().toPath(); + Path cobigenTemplatePath = tempFolderPath.resolve("cobigen-templates"); + if (!Files.exists(cobigenTemplatePath)) { + Files.createDirectory(cobigenTemplatePath); + + templatesProjectTemporary = cobigenTemplatePath.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER); + Path templateSetsAdaptedFolder = templatesProjectTemporary.resolve(ConfigurationConstants.ADAPTED_FOLDER); + Files.createDirectory(templatesProjectTemporary); + Files.createDirectory(templateSetsAdaptedFolder); + + Path templateSetPath = templateSetsAdaptedFolder.resolve("template-set"); + FileUtils.copyDirectory(templatesProject.toFile(), templateSetPath.toFile()); + + if (Files.isDirectory(templateSetPath)) { + + // Replace the pom.xml in the template sets. Needed so that the project in the temp directory is build + // properly + if (Files.exists(templateSetPath.resolve("pom.xml"))) { + try { + Files.delete(templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error deleting file " + templateSetPath.resolve("pom.xml"), e); + } + try { + Files.copy(utilsPom, templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error copying file " + utilsPom, e); + } + } + } + } + } + + /** + * Test successful generation of all templates based on an ETO + * + * @throws Exception test fails + */ + @Test + public void testAllTemplatesGeneration_OpenApiInput() throws Exception { + + File testProject = new File(TEST_RESOURCES_ROOT + "TestAllTemplatesOpenApiInput/"); + runMavenInvoker(testProject, templatesProjectTemporary.toFile(), MavenMetadata.LOCAL_REPO); + } + +} diff --git a/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/application.properties b/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/application.properties new file mode 100644 index 0000000000..cf2c614efb --- /dev/null +++ b/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/application.properties @@ -0,0 +1,2 @@ +server.port=8080 +server.context-path=/ \ No newline at end of file diff --git a/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/logback.xml b/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml b/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml new file mode 100644 index 0000000000..14b9ec10cf --- /dev/null +++ b/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml @@ -0,0 +1,131 @@ +openapi: 3.0.0 +servers: + - url: 'https://localhost:8081/server/services/rest' +info: + title: Devon Example + description: Example of a API definition + version: 1.0.0 + x-rootpackage: com.devonfw.demo +paths: + /datamanagement/v1/someData/{id}: + get: + operationId: findSomeData + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + minimum: 0 + maximum: 50 + responses: + '200': + description: Any + content: + application/json: + schema: + $ref: '#/components/schemas/EvenMoreData' + text/plain: + schema: + type: string + /datamanagement/v1/moreData/{id}: + get: + operationId: findMoreData + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + minimum: 10 + maximum: 200 + responses: + '200': + description: Any + /datamanagement/v1/someData/: + post: + responses: + '200': + description: Any + requestBody: + $ref: '#/components/requestBodies/SomeData' + tags: + - searchCriteria + /datamanagement/v1/moreData/validateMoreData: + post: + responses: + '200': + description: Any + requestBody: + $ref: '#/components/requestBodies/MoreData' +components: + schemas: + SomeData: + x-component: DataManagement + description: Entity definiton of SomeData + type: object + properties: + AnyString: + type: string + maxLength: 100 + minLength: 5 + uniqueItems: true + furtherData: + type: array + items: + $ref: '#/components/schemas/FurtherData' + MoreData: + x-component: DataManagement + description: Entity definiton of Moredata + type: object + properties: + anyNumber: + type: number + format: int64 + maximum: 100 + minimum: 0 + someData: + $ref: '#/components/schemas/SomeData' + allSomeData: + type: array + description: 'All SomeData' + items: + $ref: '#/components/schemas/SomeData' + required: + - saleExample + FurtherData: + x-component: AnotherComponent + type: object + properties: + parent: + $ref: '#/components/schemas/SomeData' + valid: + type: boolean + someList: + type: array + items: + type: string + EvenMoreData: + x-component: AnotherComponent + description: Entity definiton of more data + type: object + properties: + id: + type: integer + format: int64 + uniqueItems: true + requestBodies: + SomeData: + content: + application/json: + schema: + $ref: '#/components/schemas/SomeData' + required: true + MoreData: + content: + application/json: + schema: + $ref: '#/components/schemas/MoreData' + required: true diff --git a/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml b/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml b/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml new file mode 100644 index 0000000000..7f84fdeef0 --- /dev/null +++ b/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + com.devonfw.cobigen + devon4jTemplateTest-TestAllTemplatesOpenAPIInput + dev-SNAPSHOT + + + 1.8 + 1.8 + + + + + + com.devonfw.cobigen + cobigen-maven-plugin + ${pluginVersion} + + + generate + package + + generate + + + + + ${templatesProject} + + OpenAPI.yaml + + + + + true + + + + com.devonfw.cobigen + tempeng-freemarker + ${pluginVersion} + + + com.devonfw.cobigen + javaplugin + ${pluginVersion} + + + com.devonfw.cobigen + htmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + tsplugin + ${pluginVersion} + + + com.devonfw.cobigen + jsonplugin + ${pluginVersion} + + + com.devonfw.cobigen + openapiplugin + ${pluginVersion} + + + com.devonfw.cobigen + xmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + textmerger + ${pluginVersion} + + + + + + + diff --git a/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/utils/pom.xml b/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/utils/pom.xml new file mode 100644 index 0000000000..9e540cd237 --- /dev/null +++ b/cobigen-templates/crud-openapi-ionic-client-app/src/test/resources/utils/pom.xml @@ -0,0 +1,100 @@ + + + 4.0.0 + com.devonfw.cobigen.templates + crud-openapi-ionic-client-app + 2021.12.007-SNAPSHOT + Crud Openapi Ionic Client App + A Code-based incremental Generator + https://github.com/devonfw/cobigen/templates-parent/templates-devon4j-utils + + + Apache Software License 2.0 + https://raw.githubusercontent.com/devonfw/.github/master/LICENSE + repo + + + + + + javax.ws.rs + javax.ws.rs-api + 2.0 + compile + + + org.springframework.data + spring-data-rest-webmvc + 3.7.10 + compile + + + org.apache.commons + commons-lang3 + 3.12.0 + compile + + + com.fasterxml.jackson.core + jackson-databind + 2.10.0 + compile + + + xerces + xercesImpl + 2.12.2 + compile + + + javax.persistence + javax.persistence-api + 2.2 + compile + + + org.slf4j + slf4j-api + 1.7.30 + compile + + + org.slf4j + jcl-over-slf4j + 1.7.30 + compile + + + org.slf4j + log4j-over-slf4j + 1.7.30 + compile + + + + + + false + + + true + + ossrh + OSSRH Snapshots + https://s01.oss.sonatype.org/content/repositories/snapshots/ + + + + + 1.8 + 1.8 + + + + + + src/main/java + + + \ No newline at end of file diff --git a/cobigen-templates/crud-openapi-java-server-app/pom.xml b/cobigen-templates/crud-openapi-java-server-app/pom.xml new file mode 100644 index 0000000000..9d845790e1 --- /dev/null +++ b/cobigen-templates/crud-openapi-java-server-app/pom.xml @@ -0,0 +1,19 @@ + + 4.0.0 + crud-openapi-java-server-app + CRUD OpenAPI Java Server App template + + + com.devonfw.cobigen.templates + templates-parent + ${revision} + + + + + org.apache.commons + commons-lang3 + + + \ No newline at end of file diff --git a/cobigen-templates/crud-openapi-java-server-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java b/cobigen-templates/crud-openapi-java-server-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java new file mode 100644 index 0000000000..395d46154d --- /dev/null +++ b/cobigen-templates/crud-openapi-java-server-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java @@ -0,0 +1,12 @@ +package com.devonfw.cobigen.templates.devon4j.config.constant; + +/** + * Constants extracted from the maven pom by templating-maven-plugin. + * + * @see "edit template in src/main/java-templates" + */ +public class MavenMetadata { + + /** Local repository path */ + public static final String LOCAL_REPO = "${settings.localRepository}"; +} diff --git a/cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/constants/Field.java b/cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/constants/Field.java new file mode 100644 index 0000000000..5376daaea9 --- /dev/null +++ b/cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/constants/Field.java @@ -0,0 +1,48 @@ +package com.devonfw.cobigen.templates.devon4j.constants; + +/** + * Contains the used keys for the pojo field mapping + */ +public enum Field { + + /** + * Name of the field + */ + NAME("name"), + /** + * Type of the field + */ + TYPE("type"), + /** + * Canonical Type of the field + */ + CANONICAL_TYPE("canonicalType"), + /** + * The Javadoc of the field + */ + JAVA_DOC("javaDoc"), + /** + * Annotations + */ + ANNOTATIONS("annotations"); + + /** + * key value + */ + private String value; + + /** + * @param value of the key + */ + Field(String value) { + + this.value = value; + } + + @Override + public String toString() { + + return this.value; + } + +} diff --git a/cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/DevonfwUtil.java b/cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/DevonfwUtil.java new file mode 100644 index 0000000000..4de413b930 --- /dev/null +++ b/cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/DevonfwUtil.java @@ -0,0 +1,449 @@ +package com.devonfw.cobigen.templates.devon4j.utils; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.w3c.dom.Attr; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import com.devonfw.cobigen.templates.devon4j.constants.Field; + +/** + * A class for shared devon4j specific functions in the templates + * + */ +@SuppressWarnings("restriction") +public class DevonfwUtil { + + /** + * Check whether the given 'canonicalType' is a devon4j Entity, which is declared in the given 'component' + * + * @param canonicalType the type name + * @param component the component name + * @return true iff the canonicalType is a devon Entity + */ + public boolean isEntityInComponent(String canonicalType, String component) { + + return canonicalType.matches(String.format(".+%1$s\\.dataaccess\\.api\\.[A-Za-z0-9]+Entity(<.*)?", component)); + } + + /** + * Check whether the given 'canonicalType' is declared in the given 'component' + * + * @param canonicalType the type name + * @param component the component name + * @return true iff the canonicalType is inside the given component + */ + public boolean isTypeInComponent(String canonicalType, String component) { + + return canonicalType.matches(String.format("%1$s.[A-Za-z0-9]+(<.*)?", component)); + } + + /** + * Determines the ID getter for a given 'field' dependent on whether the getter should access the ID via an object + * reference or a direct ID getter + * + * @param field the field + * @param byObjectReference boolean + * @param component the devon4j component name + * @return 'get' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)} + '()' with + * capitalize=true + */ + public String resolveIdGetter(Map field, boolean byObjectReference, String component) { + + // If field comes from an UML file + if (field.getClass().toGenericString().contains("freemarker.ext.beans.HashAdapter")) { + return resolveIdGetter(field, byObjectReference, component); + } + return "get" + resolveIdVariableNameOrSetterGetterSuffix(field, byObjectReference, true, component) + "()"; + } + + /** + * Determines the ID getter for a given 'field' dependent on whether the getter should access the ID via an object + * reference or a direct ID getter + * + * This method is used when the field parameter comes from an UML file. The name and type of the attributes must be + * pre-processed for later inserting them inside the HashMap. + * + * @param field the field + * @param byObjectReference boolean + * @param component the devon4j component name + * @return 'get' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)} + '()' with + * capitalize=true + */ + public String resolveIdGetter(Node field, boolean byObjectReference, String component) { + + HashMap nodeHash = new HashMap<>(); + + // Putting the name of the attribute to the hash + nodeHash.put(Field.NAME.toString(), field.getAttributes().getNamedItem("name")); + + // Putting the type of the attribute to the hash + NodeList childs = field.getChildNodes(); + for (int i = 0; i < childs.getLength(); i++) { + // Retrieve "type" tag + if (childs.item(i).getNodeName().equals("type")) { + NamedNodeMap attrs = childs.item(i).getAttributes(); + for (int j = 0; j < attrs.getLength(); j++) { + Attr attribute = (Attr) attrs.item(j); + // Try to find the attribute that contains the type + if (attribute.getName().equals("xmi:idref")) { + nodeHash.put(Field.TYPE.toString(), attribute.getName().replace("EAJava_", "")); + } + } + } + } + return "get" + resolveIdVariableNameOrSetterGetterSuffix(nodeHash, byObjectReference, true, component) + "()"; + + } + + /** + * Determines the ID getter for a given 'field' dependent on whether the getter should access the ID via an object + * reference or a direct ID getter + * + * @param pojoClass the class object of the pojo + * @param fieldMap the field mapping + * @param byObjectReference boolean + * @param component the devon4j component name + * @return 'get' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)} + '()' with + * capitalize=true + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdGetter(Class pojoClass, Map fieldMap, boolean byObjectReference, + String component) throws NoSuchFieldException, SecurityException { + + return "get" + resolveIdVariableNameOrSetterGetterSuffix(pojoClass, fieldMap, byObjectReference, true, component) + + "()"; + } + + /** + * same as {@link #resolveIdGetter(Map, boolean, String)} but with byObjectReference=false and component="" + * + * @param field the field + * @return 'get' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map,boolean,boolean,String)} + '()' with + * capitalize=true + */ + public String resolveIdGetter(Map field) { + + return this.resolveIdGetter(field, false, ""); + } + + /** + * same as {@link #resolveIdGetter(Class,Map,boolean,String)} but with byObjectReference=false and component="" + * + * @param pojoClass the class object of the pojo + * @param fieldMap the field mapping + * @return 'get' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map,boolean,boolean,String)} + '()' with + * capitalize=true + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdGetter(Class pojoClass, Map fieldMap) + throws NoSuchFieldException, SecurityException { + + return resolveIdGetter(pojoClass, fieldMap, false, ""); + } + + /** + * Determines the ID setter for a given 'field' dependent on whether the setter should access the ID via an object + * reference or a direct ID setter. In contrast to resolveIdGetter, this function does not generate the function + * parenthesis to enable parameter declaration. + * + * @param field the field + * @param byObjectReference boolean + * @param component the devon4j component name + * @return 'set' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)} with + * capitalize=true + */ + public String resolveIdSetter(Map field, boolean byObjectReference, String component) { + + return "set" + resolveIdVariableNameOrSetterGetterSuffix(field, byObjectReference, true, component); + } + + /** + * same as {@link #resolveIdSetter(Map, boolean, String)} but with byObjectReference=false and component="" + * + * @param field the field + * @return 'set' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)} with + * capitalize=true + */ + public String resolveIdSetter(Map field) { + + return this.resolveIdSetter(field, false, ""); + } + + /** + * Determines the ID setter for a given 'field' dependent on whether the setter should access the ID via an object + * reference or a direct ID setter. In contrast to resolveIdGetter, this function does not generate the function + * parenthesis to enable parameter declaration. + * + * @param pojoClass the class object of the pojo + * @param fieldMap the field mapping + * @param byObjectReference boolean + * @param component the devon4j component name + * @return 'set'+ {@link #resolveIdVariableNameOrSetterGetterSuffix(Map,boolean,boolean,String)} with capitalize=true + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdSetter(Class pojoClass, Map fieldMap, boolean byObjectReference, + String component) throws NoSuchFieldException, SecurityException { + + return "set" + resolveIdVariableNameOrSetterGetterSuffix(pojoClass, fieldMap, byObjectReference, true, component); + } + + /** + * same as {@link #resolveIdSetter(Class,Map,boolean,String)} but with byObjectReference=false and component="" + * + * @param pojoClass the class object of the pojo + * @param fieldMap the field mapping + * @return 'set' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map,boolean,boolean,String)} with capitalize=true + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdSetter(Class pojoClass, Map fieldMap) + throws NoSuchFieldException, SecurityException { + + return resolveIdSetter(pojoClass, fieldMap, false, ""); + } + + /** + * Determines the variable name for the id value of the 'field' + * + * @param field the field + * @return {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)}) with + * byObjectReference=false, capitalize=false and component="" + */ + public String resolveIdVariableName(Map field) { + + // the component is passed down as an empty string since byObjectReference is false and therefore the + // component is + // never touched + return resolveIdVariableNameOrSetterGetterSuffix(field, false, false, ""); + } + + /** + * Determines the variable name for the id value of the specified field in the pojo + * + * @param pojoClass the class object of the pojo + * @param fieldMap the field mapping + * @return {@link #resolveIdVariableNameOrSetterGetterSuffix(Class, Map, boolean, boolean, String)}) with + * byObjectReference=false, capitalize=false and component="" + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdVariableName(Class pojoClass, Map fieldMap) + throws NoSuchFieldException, SecurityException { + + // the component is passed down as an empty string since byObjectReference is false and therefore the + // component is + // never touched + return resolveIdVariableNameOrSetterGetterSuffix(pojoClass, fieldMap, false, false, ""); + } + + /** + * Determines the ID setter/getter suffix for a given 'field' dependent on whether the setter/getter should access the + * ID via an object reference or a direct ID setter/getter + * + * @param field the field + * @param byObjectReference boolean + * @param capitalize if the field name should be capitalized + * @param component the devon4j component. Only needed if $byObjectReference is true + * @return idVariable name or getter/setter suffix + */ + public String resolveIdVariableNameOrSetterGetterSuffix(Map field, boolean byObjectReference, + boolean capitalize, String component) { + + String fieldName = (String) field.get(Field.NAME.toString()); + if (capitalize) { + fieldName = fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1); + } + String suffix = ""; + + String fieldType = (String) field.get(Field.TYPE.toString()); + String fieldCType = (String) field.get(Field.CANONICAL_TYPE.toString()); + if (fieldType.contains("Entity")) { + if (fieldCType.startsWith("java.util.List") || fieldCType.startsWith("java.util.Set")) { + suffix = "Ids"; + if (fieldName.endsWith("s")) { + // Assume trailing 's' as indicator for a plural + fieldName = fieldName.substring(0, fieldName.length() - 1); + } + } else { + suffix = "Id"; + } + if (byObjectReference && isTypeInComponent(fieldCType, component)) { + // direct references for Entities in same component, so get id of the object reference + suffix = "().getId"; + } + } + + return fieldName + suffix; + + } + + /** + * Determines the ID setter/getter suffix for a given 'field' dependent on whether the setter/getter should access the + * ID via an object reference or a direct ID setter/getter + * + * @param pojoClass the {@link Class} object of the pojo + * @param fieldMap the field mapping + * @param byObjectReference boolean + * @param capitalize if the field name should be capitalized + * @param component the devon4j component. Only needed if byObjectReference is true + * @return idVariable name or getter/setter suffix + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdVariableNameOrSetterGetterSuffix(Class pojoClass, Map fieldMap, + boolean byObjectReference, boolean capitalize, String component) throws NoSuchFieldException, SecurityException { + + String resultName = (String) fieldMap.get(Field.NAME.toString()); + if (capitalize) { + resultName = resultName.substring(0, 1).toUpperCase() + resultName.substring(1); + } + String suffix = ""; + String fieldType = (String) fieldMap.get(Field.TYPE.toString()); + String fieldName = (String) fieldMap.get(Field.NAME.toString()); + if (fieldType.contains("Entity")) { + if (Collection.class.isAssignableFrom(pojoClass.getDeclaredField(fieldName).getType())) { + suffix = "Ids"; + if (resultName.endsWith("s")) { + // Assume trailing 's' as indicator for a plural + resultName = resultName.substring(0, resultName.length() - 1); + } + } else { + suffix = "Id"; + } + if (byObjectReference + && isEntityInComponent(pojoClass.getDeclaredField(fieldName).getType().getName(), component)) { + // direct references for Entities in same component, so get id of the object reference + suffix = "().getId"; + } + } + + return resultName + suffix; + + } + + /** + * Returns the argument type of the list or set from a field. If the string contains "Entity" it will remove that + * part. For example, if we have a List <SampleEntity> it will return "Sample" + * + * @param field the field + * @param pojoClass the object class of the Entity that contains the field + * @return fieldType argument of the list + * @throws SecurityException if field type could not accessed + * @throws NoSuchFieldException if field could not be found + */ + public String getListArgumentType(Map field, Class pojoClass) + throws NoSuchFieldException, SecurityException { + + JavaUtil javaUtil = new JavaUtil(); + + String fieldType = (String) field.get(Field.TYPE.toString()); + String fieldName = (String) field.get(Field.NAME.toString()); + + if (fieldType.contains("Entity")) { + if (javaUtil.isCollection(pojoClass, fieldName)) { + + fieldType = fieldType.replace("Entity", ""); + // Regex: Extracts the argument type of the list 'List' => type + String regex = "(?<=\\<).+?(?=\\>)"; + Pattern pattern = Pattern.compile(regex); + Matcher regexMatcher = pattern.matcher(fieldType); + + if (regexMatcher.find()) { + fieldType = regexMatcher.group(0); + } + } + } + return fieldType; + + } + + /** + * Converts all occurrences of devon4j Entity types in the given 'field' simple type (possibly generic) to Longs + * + * @param field the field + * @return the field type as String. If field type contains 'Entity' the result is Long + */ + public String getSimpleEntityTypeAsLongReference(Map field) { + + String fieldType = (String) field.get(Field.TYPE.toString()); + if (fieldType.endsWith("Entity")) { + fieldType = fieldType.replaceAll("[^<>]+Entity", "Long"); + } + return fieldType; + } + + /** + * If the string last character is an 's', then it gets removed + * + * @param targetClassName string to remove plural + * @return string without 's' + */ + public String removePlural(String targetClassName) { + + if (targetClassName.charAt(targetClassName.length() - 1) == 's') { + targetClassName = targetClassName.substring(0, targetClassName.length() - 1); + } + return targetClassName; + } + + /** + * Checks whether the operation with the given ID corresponds to any standard CRUD method name. + * + * @param operationId operation ID interpreted as method name + * @param entityName entity name to check standard CRUD methods for + * @return true if the operation ID maps any standard CRUD method name, false otherwise + */ + public boolean isCrudOperation(String operationId, String entityName) { + + if (operationId == null) { + return false; + } + String opIdLowerCase = operationId.toLowerCase(); + String entityNameLowerCase = entityName.toLowerCase(); + if (opIdLowerCase.contains(entityNameLowerCase)) { + return opIdLowerCase.equals("find" + entityNameLowerCase) + || opIdLowerCase.equals("find" + entityNameLowerCase + "Etos") + || opIdLowerCase.equals("delete" + entityNameLowerCase) || opIdLowerCase.equals("save" + entityNameLowerCase); + } else { + return false; + } + } + + /** + * Converts the given media type to the spring Java enum value + * + * @param mediaType to be converted + * @return the spring enum value representing the given media type + */ + public String getSpringMediaType(String mediaType) { + + switch (mediaType) { + case "application/xml": + return "APPLICATION_XML_VALUE"; + case "application / x-www-form-urlencoded": + return "APPLICATION_FORM_URLENCODED_VALUE"; + case "multipart/form-data": + return "MULTIPART_FORM_DATA_VALUE"; + case "text/plain": + return "TEXT_PLAIN_VALUE"; + case "text/html": + return "TEXT_HTML_VALUE"; + case "application/pdf": + return "APPLICATION_PDF_VALUE"; + case "image/png": + return "IMAGE_PNG_VALUE"; + default: + return "APPLICATION_JSON_VALUE"; + } + } +} \ No newline at end of file diff --git a/cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java b/cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java new file mode 100644 index 0000000000..ced2f5fde2 --- /dev/null +++ b/cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java @@ -0,0 +1,464 @@ +package com.devonfw.cobigen.templates.devon4j.utils; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.Map; + +import org.apache.commons.lang3.ClassUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Provides type operations, mainly checks and casts for Java Primitives, to be used in the templates + * + */ +public class JavaUtil { + + /** + * Logger for this class + */ + private static final Logger LOG = LoggerFactory.getLogger(JavaUtil.class); + + /** + * The constructor. + */ + public JavaUtil() { + + // Empty for CobiGen to automatically instantiate it + } + + /** + * Returns the Object version of a Java primitive or the input if the input isn't a java primitive + * + * @param simpleType String + * @return the corresponding object wrapper type simple name of the input if the input is the name of a primitive java + * type. The input itself if not. (e.g. "int" results in "Integer") + * @throws ClassNotFoundException should not occur. + */ + public String boxJavaPrimitives(String simpleType) throws ClassNotFoundException { + + if (equalsJavaPrimitive(simpleType)) { + return ClassUtils.primitiveToWrapper(ClassUtils.getClass(simpleType)).getSimpleName(); + } else { + return simpleType; + } + + } + + /** + * Returns the simple name of the type of a field in the pojoClass. If the type is a java primitive the name of the + * wrapper class is returned + * + * @param pojoClass {@link Class} the class object of the pojo + * @param fieldName {@link String} the name of the field + * @return String. The simple name of the field's type. The simple name of the wrapper class in case of java + * primitives + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public String boxJavaPrimitives(Class pojoClass, String fieldName) throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + + if (equalsJavaPrimitive(pojoClass, fieldName)) { + return ClassUtils.primitiveToWrapper(pojoClass.getDeclaredField(fieldName).getType()).getSimpleName(); + } else { + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + throw new IllegalAccessError("Could not find field " + fieldName + " in class " + pojoClass); + } else { + return field.getType().getSimpleName(); + } + } + } + + /** + * Checks if the given type is a Java primitive + * + * @param simpleType the type to be checked + * @return true iff simpleType is a Java primitive + */ + public boolean equalsJavaPrimitive(String simpleType) { + + try { + return ClassUtils.getClass(simpleType).isPrimitive(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + } + + /** + * Checks if the given type is a Java primitive or wrapper + * + * @param simpleType the type to be checked + * @return true iff simpleType is a Java primitive or wrapper + */ + public boolean equalsJavaPrimitiveOrWrapper(String simpleType) { + + try { + return ClassUtils.isPrimitiveOrWrapper(ClassUtils.getClass(simpleType)); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + } + + /** + * Checks if the type of the field in the pojo's class is a java primitive + * + * @param pojoClass the {@link Class} object of the pojo + * @param fieldName the name of the field to be checked + * @return true iff the field is a java primitive + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean equalsJavaPrimitive(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + return false; + } + + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + return false; + } else { + return field.getType().isPrimitive(); + } + } + + /** + * Checks if the given type is a Java primitive or a Java primitive array + * + * @param simpleType the Type name to be checked + * @return true iff {@link #equalsJavaPrimitive(String)} is true or if simpleType is an array with a primitive + * component + */ + public boolean equalsJavaPrimitiveIncludingArrays(String simpleType) { + + Class klasse; + + try { + klasse = ClassUtils.getClass(simpleType).getComponentType(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + return equalsJavaPrimitive(simpleType) || (klasse != null && klasse.isPrimitive()); + } + + /** + * Checks if the given field in the pojo class is a java primitive or an array of java primitives + * + * @param pojoClass the class object of the pojo + * @param fieldName the name of the field to be checked + * @return true iff {@link #equalsJavaPrimitive(Class, String)} is true or the field is an array of primitives + * @throws NoSuchFieldException indicating something awfully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean equalsJavaPrimitiveIncludingArrays(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + return equalsJavaPrimitive(pojoClass, fieldName) || (pojoClass.getDeclaredField(fieldName).getType().isArray() + && pojoClass.getDeclaredField(fieldName).getType().getComponentType().isPrimitive()); + } + + /** + * Returns a cast statement for a given (java primitive, variable name) pair or nothing if the type isn't a java + * primitive + * + * @param simpleType Java Type + * @param varName Variable name + * @return String either of the form '((Java Primitive Object Type)varName)' if simpleType is a primitive or the empty + * String otherwise + * @throws ClassNotFoundException should not occur + */ + public String castJavaPrimitives(String simpleType, String varName) throws ClassNotFoundException { + + if (equalsJavaPrimitive(simpleType)) { + return String.format("((%1$s)%2$s)", boxJavaPrimitives(simpleType), varName); + } else { + return ""; + } + } + + /** + * Returns a cast statement for a given (java primitive, variable name) pair or nothing if the type isn't a java + * primitive + * + * @param pojoClass the class object of the pojo + * @param fieldName the name of the field to be casted + * @return if fieldName points to a primitive field then a casted statement (e.g. for an int field: + * '((Integer)field)') or an empty String otherwise + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public String castJavaPrimitives(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + if (equalsJavaPrimitive(pojoClass, fieldName)) { + return String.format("((%1$s)%2$s)", boxJavaPrimitives(pojoClass, fieldName), fieldName); + } else { + return ""; + } + } + + /** + * @param pojoClass {@link Class} the class object of the pojo + * @param fieldName {@link String} the name of the field + * @return true if the field is an instance of java.utils.Collections + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean isCollection(Class pojoClass, String fieldName) throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + return false; + } + + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + return false; + } else { + return Collection.class.isAssignableFrom(field.getType()); + } + + } + + /** + * Returns the Ext Type to a given java type + * + * @param simpleType any java type's simple name + * @return corresponding Ext type + */ + public String getExtType(String simpleType) { + + switch (simpleType) { + case "short": + case "Short": + case "int": + case "Integer": + case "long": + case "Long": + return "Integer"; + case "float": + case "Float": + case "double": + case "Double": + return "Number"; + case "boolean": + case "Boolean": + return "Boolean"; + case "char": + case "Character": + case "String": + return "String"; + case "Date": + return "Date"; + default: + return "Field"; + } + } + + /** + * returns the Angular5 type associated with a Java primitive + * + * @param simpleType :{@link String} the type to be parsed + * @return the corresponding Angular type or 'any' otherwise + */ + public String getAngularType(String simpleType) { + + switch (simpleType) { + case "boolean": + return "boolean"; + case "Boolean": + return "boolean"; + case "short": + return "number"; + case "Short": + return "number"; + case "int": + return "number"; + case "Integer": + return "number"; + case "long": + return "number"; + case "Long": + return "number"; + case "float": + return "number"; + case "Float": + return "number"; + case "double": + return "number"; + case "Double": + return "number"; + case "char": + return "string"; + case "Character": + return "string"; + case "String": + return "string"; + case "byte": + return "number"; + default: + return "any"; + } + } + + /** + * returns the class name of the return type of a specific method. + * + * @param pojoClass {@link Class}<?> the class object of the pojo + * @param methodName {@link String} the name of the method + * @return the class name of the return type of the specified method + * @throws SecurityException If no method of the given name can be found + * @throws NoSuchMethodException If no method of the given name can be found + */ + public String getReturnType(Class pojoClass, String methodName) throws NoSuchMethodException, SecurityException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + String s = "-"; + Method method = findMethod(pojoClass, methodName); + if (method != null && !method.getReturnType().equals(Void.TYPE)) { + s = method.getReturnType().toString(); + s = s.substring(s.lastIndexOf('.') + 1, s.length()); + } + return s; + } + + /** + * + * This methods returns the return type of the method in the given pojoClass which are annotated with the parameter + * annotatedClass + * + * @param pojoClass - The class in which to find if it has methods with annotatedClass + * @param annotatedClassName - The annotation which needs to be found + * @return Return type of the method annotated with the given annotation, else "null" + * @throws ClassNotFoundException if the annotated class name could not be found in the class path + */ + @SuppressWarnings("unchecked") + public String getReturnTypeOfMethodAnnotatedWith(Class pojoClass, String annotatedClassName) + throws ClassNotFoundException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + + Method[] methods = pojoClass.getDeclaredMethods(); + for (Method method : methods) { + if (!method.getName().startsWith("get")) { + continue; + } + for (Annotation a : method.getAnnotations()) { + // better if (method.isAnnotationPresent(classObj)) {, but postponed as of different class + // loaders of a.getClass() and pojoClass.getClass() + if (a.getClass().getCanonicalName().equals(annotatedClassName)) { + return method.getReturnType().getSimpleName(); + } + } + } + return "null"; + } + + /** + * returns the HTTP request type corresponding to an annotation type + * + * @param annotations The annotation to get the type name of + * @return the HTTP request type name of the selected annotation + */ + public String getRequestType(Map annotations) { + + if (annotations.containsKey("javax_ws_rs_GET")) { + return "GET"; + } else if (annotations.containsKey("javax_ws_rs_PUT")) { + return "PUT"; + } else if (annotations.containsKey("javax_ws_rs_POST")) { + return "POST"; + } else if (annotations.containsKey("javax_ws_rs_DELETE")) { + return "DELETE"; + } else if (annotations.containsKey("javax_ws_rs_PATCH")) { + return "PATCH"; + } else { + return "-"; + } + } + + /** + * Helper method to find a class's specific method + * + * @param pojoClass {@link Class}<?> the class object of the pojo + * @param methodName The name of the method to be found + * @return The method object of the method to be found, null if it wasn't found + */ + private Method findMethod(Class pojoClass, String methodName) { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + for (Method m : pojoClass.getMethods()) { + if (m.getName().equals(methodName)) { + return m; + } + } + return null; + } + + /** + * Checks whether the class given by the full qualified name is an enum + * + * @param className full qualified class name + * @return true if the class is an enum, false otherwise + */ + public boolean isEnum(String className) { + + try { + return ClassUtils.getClass(className).isEnum(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), className); + return false; + } + } + + /** + * Returns the first enum value of an enum class + * + * @param className full qualified class name + * @return the first enum value name found in order + */ + public String getFirstEnumValue(String className) { + + try { + Class enumClass = ClassUtils.getClass(className); + Field[] declaredFields = enumClass.getDeclaredFields(); + if (declaredFields.length > 0) { + return declaredFields[0].getName(); + } else { + return null; + } + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), className); + return null; + } + } +} diff --git a/cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/OpenApiUtil.java b/cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/OpenApiUtil.java new file mode 100644 index 0000000000..a93288f45a --- /dev/null +++ b/cobigen-templates/crud-openapi-java-server-app/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/OpenApiUtil.java @@ -0,0 +1,255 @@ +package com.devonfw.cobigen.templates.devon4j.utils; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.time.Instant; +import java.time.LocalDate; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; + +/** Utils on OpenAPI template model */ +public class OpenApiUtil { + + /** + * Prints javax validation constraints from an OpenAPI model + * + * @param constraints OpenAPI model constraints + * @return the list of supported annotations in Java syntax + */ + public String printJavaConstraints(Map constraints) { + + String consts = ""; + if (constraints.get("maximum") != null) { + consts = consts + "@Max(" + constraints.get("maximum") + ")"; + } + if (constraints.get("minimum") != null) { + consts = consts + "@Min(" + constraints.get("minimum") + ")"; + } + if (constraints.get("maxLength") != null) { + consts = consts + "@Size(max=" + constraints.get("maxLength"); + if (constraints.get("minLength") != null) { + consts = consts + ", min=" + constraints.get("minLength"); + } + consts = consts + ")"; + } else { + if (constraints.get("minLength") != null) { + consts = consts + "@Size(min=" + constraints.get("minLength"); + if (constraints.get("maxLength") != null) { + consts = consts + ", max=" + constraints.get("maxLength"); + } + consts = consts + ")"; + } + } + return consts; + } + + /** + * Prints the return type of a response based on the OpenAPI model + * + * @param response the OpenAPI model of a response + * @return simple type of the response return type in Java syntax + */ + public String printJavaServiceResponseReturnType(Map response) { + + String returnType = toJavaType(response, false); + if ((boolean) response.get("isVoid")) { + return "void"; + } + if ((boolean) response.get("isArray")) { + if ((boolean) response.get("isEntity")) { + if (returnType.contains("Entity")) { + return "List<" + returnType + ">"; + } else { + return "List<" + returnType + "Entity>"; + } + } else { + return "List<" + returnType + ">"; + } + } else if ((boolean) response.get("isPaginated")) { + if ((boolean) response.get("isEntity")) { + if (returnType.contains("Entity")) { + return "Page<" + returnType + ">"; + } else { + return "Page<" + returnType + "Entity>"; + } + } else { + return "Page<" + returnType + ">"; + } + } else { + return returnType; + } + } + + /** + * Returns the Java type corresponding to the OpenAPI type definition. If the type could not be matched, Object will + * be returned. + * + * @param parameter OpenAPI model of a parameter + * @param simpleType if a Java simple type should be returned if possible + * @return the Java type + */ + public String toJavaType(Map parameter, boolean simpleType) { + + String typeConverted = null; + String format = (String) parameter.get("format"); + String type = (String) parameter.get("type"); + boolean isCollection = false; + if (parameter.get("isCollection") != null) { + isCollection = (boolean) parameter.get("isCollection"); + } + + boolean isEntity = (boolean) parameter.get("isEntity"); + + if (type != null) { + switch (type.toLowerCase()) { + case "integer": + if (format != null) { + switch (format) { + case "int32": + typeConverted = simpleType ? "int" : "Integer"; + break; + case "int64": + typeConverted = simpleType ? "long" : "Long"; + break; + default: + typeConverted = BigInteger.class.getSimpleName(); + break; + } + } else { + typeConverted = BigInteger.class.getSimpleName(); + } + break; + case "number": + if (format != null) { + switch (format) { + case "float": + typeConverted = simpleType ? "float" : "Float"; + break; + case "double": + typeConverted = simpleType ? "double" : "Double"; + break; + default: + typeConverted = BigDecimal.class.getSimpleName(); + break; + } + } else { + typeConverted = BigDecimal.class.getSimpleName(); + } + break; + case "string": + if (format != null) { + switch (format) { + case "date": + typeConverted = LocalDate.class.getSimpleName(); + break; + case "date-time": + typeConverted = Instant.class.getSimpleName(); + break; + case "binary": + typeConverted = simpleType ? "float" : "Float"; + break; + case "email": + case "password": + typeConverted = String.class.getSimpleName(); + break; + default: + typeConverted = "String"; + break; + } + } else { + typeConverted = "String"; + } + break; + case "boolean": + typeConverted = simpleType ? "boolean" : "Boolean"; + break; + default: + typeConverted = "void"; + break; + } + } else { + typeConverted = "void"; + } + + if (isCollection) { + if (isEntity) { + return "List<" + parameter.get("type") + ">"; + } else { + return "List<" + typeConverted + ">"; + } + } else if (isEntity) { + return (String) parameter.get("type"); + } + return typeConverted; + } + + /** + * Returns the TypeScript type corresponding to the OpenAPI type definition. If the type could not be matched, the + * same value will be returned. + * + * @param parameter OpenAPI model of a parameter + * @return the Java type + */ + // getOaspTypeFromOpenAPI + public String toTypeScriptType(Map parameter) { + + String typeConverted = null; + String type = (String) parameter.get("type"); + boolean isCollection = false; + if (parameter.get("isCollection") != null) { + isCollection = (boolean) parameter.get("isCollection"); + } + + boolean isEntity = (boolean) parameter.get("isEntity"); + + if (type != null) { + switch (type.toLowerCase()) { + case "integer": + typeConverted = "number"; + break; + default: + typeConverted = type; + break; + } + } else { + typeConverted = "undefined"; + } + + if (isCollection) { + if (isEntity) { + return parameter.get("type") + "[]"; + } else { + return typeConverted + "[]"; + } + } else if (isEntity) { + return (String) parameter.get("type"); + } + return typeConverted; + } + + /** + * Prints the service operation name based on the operationId or generates one based on the servicePath while printing + * a comment how to get better service names. + * + * @param operation operation Model of the OpenAPI model + * @param servicePath service path of the + * @return the service method name + */ + public String printServiceOperationName(Map operation, String servicePath) { + + String operationId = (String) operation.get("operationId"); + if (StringUtils.isEmpty(operationId)) { + String[] split = servicePath.split("/"); + String lastSegment; + if (!split[split.length - 1].isEmpty()) { + lastSegment = split[split.length - 1]; + } else { + lastSegment = split[split.length - 2]; + } + return ((String) operation.get("type")) + lastSegment; + } else { + return operationId; + } + } +} diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/functions.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/functions.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/functions.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/functions.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/makros.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/makros.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/makros.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/makros.ftl diff --git a/cobigen-templates/crud-openapi-java-server-app/src/main/resources/template-set.xml b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/template-set.xml new file mode 100644 index 0000000000..e91923bf07 --- /dev/null +++ b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/template-set.xml @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/common/api/${variables.entityName}.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/common/api/${variables.entityName}.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/common/api/${variables.entityName}.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/common/api/${variables.entityName}.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/common/api/cobigen.properties b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/common/api/cobigen.properties similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/common/api/cobigen.properties rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/common/api/cobigen.properties diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/dataaccess/api/${variables.entityName}Entity.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/dataaccess/api/${variables.entityName}Entity.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/dataaccess/api/${variables.entityName}Entity.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/dataaccess/api/${variables.entityName}Entity.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/dataaccess/api/repo/${variables.entityName}Repository.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/dataaccess/api/repo/${variables.entityName}Repository.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/dataaccess/api/repo/${variables.entityName}Repository.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/dataaccess/api/repo/${variables.entityName}Repository.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/${variables.component#cap_first}.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/${variables.component#cap_first}.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/${variables.component#cap_first}.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/${variables.component#cap_first}.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/${variables.component#cap_first}Ctos.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/${variables.component#cap_first}Ctos.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/${variables.component#cap_first}Ctos.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/${variables.component#cap_first}Ctos.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/cobigen.properties b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/cobigen.properties similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/cobigen.properties rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/cobigen.properties diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/to/${variables.entityName}Cto.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/to/${variables.entityName}Cto.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/to/${variables.entityName}Cto.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/to/${variables.entityName}Cto.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/to/${variables.entityName}Eto.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/to/${variables.entityName}Eto.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/to/${variables.entityName}Eto.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/to/${variables.entityName}Eto.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/to/${variables.entityName}SearchCriteriaTo.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/to/${variables.entityName}SearchCriteriaTo.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/to/${variables.entityName}SearchCriteriaTo.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/to/${variables.entityName}SearchCriteriaTo.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/usecase/UcFind${variables.entityName}.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/usecase/UcFind${variables.entityName}.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/usecase/UcFind${variables.entityName}.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/usecase/UcFind${variables.entityName}.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/usecase/UcFind${variables.entityName}Ctos.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/usecase/UcFind${variables.entityName}Ctos.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/usecase/UcFind${variables.entityName}Ctos.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/usecase/UcFind${variables.entityName}Ctos.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/usecase/UcManage${variables.entityName}.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/usecase/UcManage${variables.entityName}.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/usecase/UcManage${variables.entityName}.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/api/usecase/UcManage${variables.entityName}.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/base/usecase/Abstract${variables.entityName}Uc.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/base/usecase/Abstract${variables.entityName}Uc.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/base/usecase/Abstract${variables.entityName}Uc.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/base/usecase/Abstract${variables.entityName}Uc.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/${variables.component#cap_first}Impl.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/${variables.component#cap_first}Impl.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/${variables.component#cap_first}Impl.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/${variables.component#cap_first}Impl.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/${variables.component#cap_first}ImplCtos.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/${variables.component#cap_first}ImplCtos.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/${variables.component#cap_first}ImplCtos.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/${variables.component#cap_first}ImplCtos.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/usecase/UcFind${variables.entityName}Impl.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/usecase/UcFind${variables.entityName}Impl.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/usecase/UcFind${variables.entityName}Impl.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/usecase/UcFind${variables.entityName}Impl.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/usecase/UcFind${variables.entityName}ImplCtos.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/usecase/UcFind${variables.entityName}ImplCtos.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/usecase/UcFind${variables.entityName}ImplCtos.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/usecase/UcFind${variables.entityName}ImplCtos.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/usecase/UcManage${variables.entityName}Impl.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/usecase/UcManage${variables.entityName}Impl.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/usecase/UcManage${variables.entityName}Impl.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/logic/impl/usecase/UcManage${variables.entityName}Impl.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/api/cobigen.properties b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/api/cobigen.properties similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/api/cobigen.properties rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/api/cobigen.properties diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/api/rest/${variables.component#cap_first}RestService.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/api/rest/${variables.component#cap_first}RestService.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/api/rest/${variables.component#cap_first}RestService.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/api/rest/${variables.component#cap_first}RestService.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/api/rest/${variables.component#cap_first}RestServiceCtos.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/api/rest/${variables.component#cap_first}RestServiceCtos.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/api/rest/${variables.component#cap_first}RestServiceCtos.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/api/rest/${variables.component#cap_first}RestServiceCtos.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/impl/rest/${variables.component#cap_first}RestServiceImpl.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/impl/rest/${variables.component#cap_first}RestServiceImpl.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/impl/rest/${variables.component#cap_first}RestServiceImpl.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/impl/rest/${variables.component#cap_first}RestServiceImpl.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/impl/rest/${variables.component#cap_first}RestServiceImplCtos.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/impl/rest/${variables.component#cap_first}RestServiceImplCtos.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/impl/rest/${variables.component#cap_first}RestServiceImplCtos.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/${variables.component#lower_case}/service/impl/rest/${variables.component#cap_first}RestServiceImplCtos.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/common/api/ApplicationEntity.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/api/ApplicationEntity.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/common/api/ApplicationEntity.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/api/ApplicationEntity.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/common/api/to/AbstractSearchCriteriaTo.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/api/to/AbstractSearchCriteriaTo.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/common/api/to/AbstractSearchCriteriaTo.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/api/to/AbstractSearchCriteriaTo.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/common/api/to/cobigen.properties b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/api/to/cobigen.properties similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/common/api/to/cobigen.properties rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/api/to/cobigen.properties diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/common/base/AbstractBeanMapperSupport.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/base/AbstractBeanMapperSupport.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/common/base/AbstractBeanMapperSupport.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/common/base/AbstractBeanMapperSupport.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/dataaccess/api/ApplicationPersistenceEntity.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/dataaccess/api/ApplicationPersistenceEntity.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/dataaccess/api/ApplicationPersistenceEntity.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/dataaccess/api/ApplicationPersistenceEntity.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/logic/base/AbstractComponentFacade.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/logic/base/AbstractComponentFacade.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/logic/base/AbstractComponentFacade.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/logic/base/AbstractComponentFacade.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/logic/base/AbstractLogic.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/logic/base/AbstractLogic.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/logic/base/AbstractLogic.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/logic/base/AbstractLogic.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/logic/base/AbstractUc.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/logic/base/AbstractUc.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/logic/base/AbstractUc.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/logic/base/AbstractUc.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/service/impl/config/ServiceConfig.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/service/impl/config/ServiceConfig.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/service/impl/config/ServiceConfig.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/service/impl/config/ServiceConfig.java.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/service/impl/config/WebApplicationContextLocator.java.ftl b/cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/service/impl/config/WebApplicationContextLocator.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_java_server_app/templates/java/${variables.rootPackage}/general/service/impl/config/WebApplicationContextLocator.java.ftl rename to cobigen-templates/crud-openapi-java-server-app/src/main/resources/templates/java/${variables.rootPackage}/general/service/impl/config/WebApplicationContextLocator.java.ftl diff --git a/cobigen-templates/crud-openapi-java-server-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenApiJavaServerAppGenerationTest.java b/cobigen-templates/crud-openapi-java-server-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenApiJavaServerAppGenerationTest.java new file mode 100644 index 0000000000..635086e78c --- /dev/null +++ b/cobigen-templates/crud-openapi-java-server-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenApiJavaServerAppGenerationTest.java @@ -0,0 +1,99 @@ +package com.devonfw.cobigen.templates.devon4j.test.templates; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.apache.commons.io.FileUtils; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.devonfw.cobigen.api.constants.ConfigurationConstants; +import com.devonfw.cobigen.maven.test.AbstractMavenTest; +import com.devonfw.cobigen.templates.devon4j.config.constant.MavenMetadata; + +/** + * Smoke tests of all templates. + */ +public class CrudOpenApiJavaServerAppGenerationTest extends AbstractMavenTest { + + /** Root of all test resources of this test suite */ + public static final String TEST_RESOURCES_ROOT = "src/test/resources/testdata/templatetest/"; + + /** Temporary files rule to create temporary folders */ + @ClassRule + public static TemporaryFolder tempFolder = new TemporaryFolder(); + + /** The templates development folder */ + protected static Path templatesProject; + + /** The templates development folder */ + protected static Path templatesProjectTemporary; + + /** + * Creates a copy of the templates project in the temp directory + * + * @throws URISyntaxException if the path could not be created properly + * @throws IOException if accessing a directory or file fails + */ + @BeforeClass + public static void setupDevTemplates() throws URISyntaxException, IOException { + + templatesProject = new File( + CrudOpenApiJavaServerAppGenerationTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile() + .getParentFile().toPath(); + + Path utilsPom = new File(CrudOpenApiJavaServerAppGenerationTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()) + .getParentFile().getParentFile().toPath().resolve("src/test/resources/utils/pom.xml"); + + // create a temporary directory cobigen-templates/template-sets/adapted containing the template sets + Path tempFolderPath = tempFolder.getRoot().toPath(); + Path cobigenTemplatePath = tempFolderPath.resolve("cobigen-templates"); + if (!Files.exists(cobigenTemplatePath)) { + Files.createDirectory(cobigenTemplatePath); + + templatesProjectTemporary = cobigenTemplatePath.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER); + Path templateSetsAdaptedFolder = templatesProjectTemporary.resolve(ConfigurationConstants.ADAPTED_FOLDER); + Files.createDirectory(templatesProjectTemporary); + Files.createDirectory(templateSetsAdaptedFolder); + + Path templateSetPath = templateSetsAdaptedFolder.resolve("template-set"); + FileUtils.copyDirectory(templatesProject.toFile(), templateSetPath.toFile()); + + if (Files.isDirectory(templateSetPath)) { + + // Replace the pom.xml in the template sets. Needed so that the project in the temp directory is build + // properly + if (Files.exists(templateSetPath.resolve("pom.xml"))) { + try { + Files.delete(templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error deleting file " + templateSetPath.resolve("pom.xml"), e); + } + try { + Files.copy(utilsPom, templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error copying file " + utilsPom, e); + } + } + } + } + } + + /** + * Test successful generation of all templates based on an ETO + * + * @throws Exception test fails + */ + @Test + public void testAllTemplatesGeneration_OpenApiInput() throws Exception { + + File testProject = new File(TEST_RESOURCES_ROOT + "TestAllTemplatesOpenApiInput/"); + runMavenInvoker(testProject, templatesProjectTemporary.toFile(), MavenMetadata.LOCAL_REPO); + } + +} diff --git a/cobigen-templates/crud-openapi-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml b/cobigen-templates/crud-openapi-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml new file mode 100644 index 0000000000..14b9ec10cf --- /dev/null +++ b/cobigen-templates/crud-openapi-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml @@ -0,0 +1,131 @@ +openapi: 3.0.0 +servers: + - url: 'https://localhost:8081/server/services/rest' +info: + title: Devon Example + description: Example of a API definition + version: 1.0.0 + x-rootpackage: com.devonfw.demo +paths: + /datamanagement/v1/someData/{id}: + get: + operationId: findSomeData + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + minimum: 0 + maximum: 50 + responses: + '200': + description: Any + content: + application/json: + schema: + $ref: '#/components/schemas/EvenMoreData' + text/plain: + schema: + type: string + /datamanagement/v1/moreData/{id}: + get: + operationId: findMoreData + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + minimum: 10 + maximum: 200 + responses: + '200': + description: Any + /datamanagement/v1/someData/: + post: + responses: + '200': + description: Any + requestBody: + $ref: '#/components/requestBodies/SomeData' + tags: + - searchCriteria + /datamanagement/v1/moreData/validateMoreData: + post: + responses: + '200': + description: Any + requestBody: + $ref: '#/components/requestBodies/MoreData' +components: + schemas: + SomeData: + x-component: DataManagement + description: Entity definiton of SomeData + type: object + properties: + AnyString: + type: string + maxLength: 100 + minLength: 5 + uniqueItems: true + furtherData: + type: array + items: + $ref: '#/components/schemas/FurtherData' + MoreData: + x-component: DataManagement + description: Entity definiton of Moredata + type: object + properties: + anyNumber: + type: number + format: int64 + maximum: 100 + minimum: 0 + someData: + $ref: '#/components/schemas/SomeData' + allSomeData: + type: array + description: 'All SomeData' + items: + $ref: '#/components/schemas/SomeData' + required: + - saleExample + FurtherData: + x-component: AnotherComponent + type: object + properties: + parent: + $ref: '#/components/schemas/SomeData' + valid: + type: boolean + someList: + type: array + items: + type: string + EvenMoreData: + x-component: AnotherComponent + description: Entity definiton of more data + type: object + properties: + id: + type: integer + format: int64 + uniqueItems: true + requestBodies: + SomeData: + content: + application/json: + schema: + $ref: '#/components/schemas/SomeData' + required: true + MoreData: + content: + application/json: + schema: + $ref: '#/components/schemas/MoreData' + required: true diff --git a/cobigen-templates/crud-openapi-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml b/cobigen-templates/crud-openapi-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/crud-openapi-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/crud-openapi-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml b/cobigen-templates/crud-openapi-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml new file mode 100644 index 0000000000..7f84fdeef0 --- /dev/null +++ b/cobigen-templates/crud-openapi-java-server-app/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + com.devonfw.cobigen + devon4jTemplateTest-TestAllTemplatesOpenAPIInput + dev-SNAPSHOT + + + 1.8 + 1.8 + + + + + + com.devonfw.cobigen + cobigen-maven-plugin + ${pluginVersion} + + + generate + package + + generate + + + + + ${templatesProject} + + OpenAPI.yaml + + + + + true + + + + com.devonfw.cobigen + tempeng-freemarker + ${pluginVersion} + + + com.devonfw.cobigen + javaplugin + ${pluginVersion} + + + com.devonfw.cobigen + htmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + tsplugin + ${pluginVersion} + + + com.devonfw.cobigen + jsonplugin + ${pluginVersion} + + + com.devonfw.cobigen + openapiplugin + ${pluginVersion} + + + com.devonfw.cobigen + xmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + textmerger + ${pluginVersion} + + + + + + + diff --git a/cobigen-templates/crud-openapi-java-server-app/src/test/resources/utils/pom.xml b/cobigen-templates/crud-openapi-java-server-app/src/test/resources/utils/pom.xml new file mode 100644 index 0000000000..95c84448de --- /dev/null +++ b/cobigen-templates/crud-openapi-java-server-app/src/test/resources/utils/pom.xml @@ -0,0 +1,99 @@ + + + 4.0.0 + com.devonfw.cobigen.templates + crud-openapi-java-server-app + 2021.12.007-SNAPSHOT + CRUD OpenApi Java Server App + A Code-based incremental Generator + + + Apache Software License 2.0 + https://raw.githubusercontent.com/devonfw/.github/master/LICENSE + repo + + + + + + javax.ws.rs + javax.ws.rs-api + 2.0 + compile + + + org.springframework.data + spring-data-rest-webmvc + 3.7.10 + compile + + + org.apache.commons + commons-lang3 + 3.12.0 + compile + + + com.fasterxml.jackson.core + jackson-databind + 2.10.0 + compile + + + xerces + xercesImpl + 2.12.2 + compile + + + javax.persistence + javax.persistence-api + 2.2 + compile + + + org.slf4j + slf4j-api + 1.7.30 + compile + + + org.slf4j + jcl-over-slf4j + 1.7.30 + compile + + + org.slf4j + log4j-over-slf4j + 1.7.30 + compile + + + + + + false + + + true + + ossrh + OSSRH Snapshots + https://s01.oss.sonatype.org/content/repositories/snapshots/ + + + + + 1.8 + 1.8 + + + + + + src/main/java + + + \ No newline at end of file diff --git a/cobigen-templates/crud-openapi-net/pom.xml b/cobigen-templates/crud-openapi-net/pom.xml new file mode 100644 index 0000000000..ddd28d9c64 --- /dev/null +++ b/cobigen-templates/crud-openapi-net/pom.xml @@ -0,0 +1,19 @@ + + 4.0.0 + crud-openapi-net + CRUD OpenAPI Net template + + + com.devonfw.cobigen.templates + templates-parent + ${revision} + + + + + org.apache.commons + commons-lang3 + + + \ No newline at end of file diff --git a/cobigen-templates/crud-openapi-net/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java b/cobigen-templates/crud-openapi-net/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java new file mode 100644 index 0000000000..395d46154d --- /dev/null +++ b/cobigen-templates/crud-openapi-net/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java @@ -0,0 +1,12 @@ +package com.devonfw.cobigen.templates.devon4j.config.constant; + +/** + * Constants extracted from the maven pom by templating-maven-plugin. + * + * @see "edit template in src/main/java-templates" + */ +public class MavenMetadata { + + /** Local repository path */ + public static final String LOCAL_REPO = "${settings.localRepository}"; +} diff --git a/cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/constants/Field.java b/cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/constants/Field.java new file mode 100644 index 0000000000..5376daaea9 --- /dev/null +++ b/cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/constants/Field.java @@ -0,0 +1,48 @@ +package com.devonfw.cobigen.templates.devon4j.constants; + +/** + * Contains the used keys for the pojo field mapping + */ +public enum Field { + + /** + * Name of the field + */ + NAME("name"), + /** + * Type of the field + */ + TYPE("type"), + /** + * Canonical Type of the field + */ + CANONICAL_TYPE("canonicalType"), + /** + * The Javadoc of the field + */ + JAVA_DOC("javaDoc"), + /** + * Annotations + */ + ANNOTATIONS("annotations"); + + /** + * key value + */ + private String value; + + /** + * @param value of the key + */ + Field(String value) { + + this.value = value; + } + + @Override + public String toString() { + + return this.value; + } + +} diff --git a/cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/DevonfwUtil.java b/cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/DevonfwUtil.java new file mode 100644 index 0000000000..4de413b930 --- /dev/null +++ b/cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/DevonfwUtil.java @@ -0,0 +1,449 @@ +package com.devonfw.cobigen.templates.devon4j.utils; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.w3c.dom.Attr; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import com.devonfw.cobigen.templates.devon4j.constants.Field; + +/** + * A class for shared devon4j specific functions in the templates + * + */ +@SuppressWarnings("restriction") +public class DevonfwUtil { + + /** + * Check whether the given 'canonicalType' is a devon4j Entity, which is declared in the given 'component' + * + * @param canonicalType the type name + * @param component the component name + * @return true iff the canonicalType is a devon Entity + */ + public boolean isEntityInComponent(String canonicalType, String component) { + + return canonicalType.matches(String.format(".+%1$s\\.dataaccess\\.api\\.[A-Za-z0-9]+Entity(<.*)?", component)); + } + + /** + * Check whether the given 'canonicalType' is declared in the given 'component' + * + * @param canonicalType the type name + * @param component the component name + * @return true iff the canonicalType is inside the given component + */ + public boolean isTypeInComponent(String canonicalType, String component) { + + return canonicalType.matches(String.format("%1$s.[A-Za-z0-9]+(<.*)?", component)); + } + + /** + * Determines the ID getter for a given 'field' dependent on whether the getter should access the ID via an object + * reference or a direct ID getter + * + * @param field the field + * @param byObjectReference boolean + * @param component the devon4j component name + * @return 'get' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)} + '()' with + * capitalize=true + */ + public String resolveIdGetter(Map field, boolean byObjectReference, String component) { + + // If field comes from an UML file + if (field.getClass().toGenericString().contains("freemarker.ext.beans.HashAdapter")) { + return resolveIdGetter(field, byObjectReference, component); + } + return "get" + resolveIdVariableNameOrSetterGetterSuffix(field, byObjectReference, true, component) + "()"; + } + + /** + * Determines the ID getter for a given 'field' dependent on whether the getter should access the ID via an object + * reference or a direct ID getter + * + * This method is used when the field parameter comes from an UML file. The name and type of the attributes must be + * pre-processed for later inserting them inside the HashMap. + * + * @param field the field + * @param byObjectReference boolean + * @param component the devon4j component name + * @return 'get' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)} + '()' with + * capitalize=true + */ + public String resolveIdGetter(Node field, boolean byObjectReference, String component) { + + HashMap nodeHash = new HashMap<>(); + + // Putting the name of the attribute to the hash + nodeHash.put(Field.NAME.toString(), field.getAttributes().getNamedItem("name")); + + // Putting the type of the attribute to the hash + NodeList childs = field.getChildNodes(); + for (int i = 0; i < childs.getLength(); i++) { + // Retrieve "type" tag + if (childs.item(i).getNodeName().equals("type")) { + NamedNodeMap attrs = childs.item(i).getAttributes(); + for (int j = 0; j < attrs.getLength(); j++) { + Attr attribute = (Attr) attrs.item(j); + // Try to find the attribute that contains the type + if (attribute.getName().equals("xmi:idref")) { + nodeHash.put(Field.TYPE.toString(), attribute.getName().replace("EAJava_", "")); + } + } + } + } + return "get" + resolveIdVariableNameOrSetterGetterSuffix(nodeHash, byObjectReference, true, component) + "()"; + + } + + /** + * Determines the ID getter for a given 'field' dependent on whether the getter should access the ID via an object + * reference or a direct ID getter + * + * @param pojoClass the class object of the pojo + * @param fieldMap the field mapping + * @param byObjectReference boolean + * @param component the devon4j component name + * @return 'get' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)} + '()' with + * capitalize=true + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdGetter(Class pojoClass, Map fieldMap, boolean byObjectReference, + String component) throws NoSuchFieldException, SecurityException { + + return "get" + resolveIdVariableNameOrSetterGetterSuffix(pojoClass, fieldMap, byObjectReference, true, component) + + "()"; + } + + /** + * same as {@link #resolveIdGetter(Map, boolean, String)} but with byObjectReference=false and component="" + * + * @param field the field + * @return 'get' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map,boolean,boolean,String)} + '()' with + * capitalize=true + */ + public String resolveIdGetter(Map field) { + + return this.resolveIdGetter(field, false, ""); + } + + /** + * same as {@link #resolveIdGetter(Class,Map,boolean,String)} but with byObjectReference=false and component="" + * + * @param pojoClass the class object of the pojo + * @param fieldMap the field mapping + * @return 'get' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map,boolean,boolean,String)} + '()' with + * capitalize=true + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdGetter(Class pojoClass, Map fieldMap) + throws NoSuchFieldException, SecurityException { + + return resolveIdGetter(pojoClass, fieldMap, false, ""); + } + + /** + * Determines the ID setter for a given 'field' dependent on whether the setter should access the ID via an object + * reference or a direct ID setter. In contrast to resolveIdGetter, this function does not generate the function + * parenthesis to enable parameter declaration. + * + * @param field the field + * @param byObjectReference boolean + * @param component the devon4j component name + * @return 'set' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)} with + * capitalize=true + */ + public String resolveIdSetter(Map field, boolean byObjectReference, String component) { + + return "set" + resolveIdVariableNameOrSetterGetterSuffix(field, byObjectReference, true, component); + } + + /** + * same as {@link #resolveIdSetter(Map, boolean, String)} but with byObjectReference=false and component="" + * + * @param field the field + * @return 'set' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)} with + * capitalize=true + */ + public String resolveIdSetter(Map field) { + + return this.resolveIdSetter(field, false, ""); + } + + /** + * Determines the ID setter for a given 'field' dependent on whether the setter should access the ID via an object + * reference or a direct ID setter. In contrast to resolveIdGetter, this function does not generate the function + * parenthesis to enable parameter declaration. + * + * @param pojoClass the class object of the pojo + * @param fieldMap the field mapping + * @param byObjectReference boolean + * @param component the devon4j component name + * @return 'set'+ {@link #resolveIdVariableNameOrSetterGetterSuffix(Map,boolean,boolean,String)} with capitalize=true + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdSetter(Class pojoClass, Map fieldMap, boolean byObjectReference, + String component) throws NoSuchFieldException, SecurityException { + + return "set" + resolveIdVariableNameOrSetterGetterSuffix(pojoClass, fieldMap, byObjectReference, true, component); + } + + /** + * same as {@link #resolveIdSetter(Class,Map,boolean,String)} but with byObjectReference=false and component="" + * + * @param pojoClass the class object of the pojo + * @param fieldMap the field mapping + * @return 'set' + {@link #resolveIdVariableNameOrSetterGetterSuffix(Map,boolean,boolean,String)} with capitalize=true + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdSetter(Class pojoClass, Map fieldMap) + throws NoSuchFieldException, SecurityException { + + return resolveIdSetter(pojoClass, fieldMap, false, ""); + } + + /** + * Determines the variable name for the id value of the 'field' + * + * @param field the field + * @return {@link #resolveIdVariableNameOrSetterGetterSuffix(Map, boolean, boolean, String)}) with + * byObjectReference=false, capitalize=false and component="" + */ + public String resolveIdVariableName(Map field) { + + // the component is passed down as an empty string since byObjectReference is false and therefore the + // component is + // never touched + return resolveIdVariableNameOrSetterGetterSuffix(field, false, false, ""); + } + + /** + * Determines the variable name for the id value of the specified field in the pojo + * + * @param pojoClass the class object of the pojo + * @param fieldMap the field mapping + * @return {@link #resolveIdVariableNameOrSetterGetterSuffix(Class, Map, boolean, boolean, String)}) with + * byObjectReference=false, capitalize=false and component="" + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdVariableName(Class pojoClass, Map fieldMap) + throws NoSuchFieldException, SecurityException { + + // the component is passed down as an empty string since byObjectReference is false and therefore the + // component is + // never touched + return resolveIdVariableNameOrSetterGetterSuffix(pojoClass, fieldMap, false, false, ""); + } + + /** + * Determines the ID setter/getter suffix for a given 'field' dependent on whether the setter/getter should access the + * ID via an object reference or a direct ID setter/getter + * + * @param field the field + * @param byObjectReference boolean + * @param capitalize if the field name should be capitalized + * @param component the devon4j component. Only needed if $byObjectReference is true + * @return idVariable name or getter/setter suffix + */ + public String resolveIdVariableNameOrSetterGetterSuffix(Map field, boolean byObjectReference, + boolean capitalize, String component) { + + String fieldName = (String) field.get(Field.NAME.toString()); + if (capitalize) { + fieldName = fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1); + } + String suffix = ""; + + String fieldType = (String) field.get(Field.TYPE.toString()); + String fieldCType = (String) field.get(Field.CANONICAL_TYPE.toString()); + if (fieldType.contains("Entity")) { + if (fieldCType.startsWith("java.util.List") || fieldCType.startsWith("java.util.Set")) { + suffix = "Ids"; + if (fieldName.endsWith("s")) { + // Assume trailing 's' as indicator for a plural + fieldName = fieldName.substring(0, fieldName.length() - 1); + } + } else { + suffix = "Id"; + } + if (byObjectReference && isTypeInComponent(fieldCType, component)) { + // direct references for Entities in same component, so get id of the object reference + suffix = "().getId"; + } + } + + return fieldName + suffix; + + } + + /** + * Determines the ID setter/getter suffix for a given 'field' dependent on whether the setter/getter should access the + * ID via an object reference or a direct ID setter/getter + * + * @param pojoClass the {@link Class} object of the pojo + * @param fieldMap the field mapping + * @param byObjectReference boolean + * @param capitalize if the field name should be capitalized + * @param component the devon4j component. Only needed if byObjectReference is true + * @return idVariable name or getter/setter suffix + * @throws NoSuchFieldException indicating a severe problem in the used model + * @throws SecurityException if the field cannot be accessed for any reason + */ + public String resolveIdVariableNameOrSetterGetterSuffix(Class pojoClass, Map fieldMap, + boolean byObjectReference, boolean capitalize, String component) throws NoSuchFieldException, SecurityException { + + String resultName = (String) fieldMap.get(Field.NAME.toString()); + if (capitalize) { + resultName = resultName.substring(0, 1).toUpperCase() + resultName.substring(1); + } + String suffix = ""; + String fieldType = (String) fieldMap.get(Field.TYPE.toString()); + String fieldName = (String) fieldMap.get(Field.NAME.toString()); + if (fieldType.contains("Entity")) { + if (Collection.class.isAssignableFrom(pojoClass.getDeclaredField(fieldName).getType())) { + suffix = "Ids"; + if (resultName.endsWith("s")) { + // Assume trailing 's' as indicator for a plural + resultName = resultName.substring(0, resultName.length() - 1); + } + } else { + suffix = "Id"; + } + if (byObjectReference + && isEntityInComponent(pojoClass.getDeclaredField(fieldName).getType().getName(), component)) { + // direct references for Entities in same component, so get id of the object reference + suffix = "().getId"; + } + } + + return resultName + suffix; + + } + + /** + * Returns the argument type of the list or set from a field. If the string contains "Entity" it will remove that + * part. For example, if we have a List <SampleEntity> it will return "Sample" + * + * @param field the field + * @param pojoClass the object class of the Entity that contains the field + * @return fieldType argument of the list + * @throws SecurityException if field type could not accessed + * @throws NoSuchFieldException if field could not be found + */ + public String getListArgumentType(Map field, Class pojoClass) + throws NoSuchFieldException, SecurityException { + + JavaUtil javaUtil = new JavaUtil(); + + String fieldType = (String) field.get(Field.TYPE.toString()); + String fieldName = (String) field.get(Field.NAME.toString()); + + if (fieldType.contains("Entity")) { + if (javaUtil.isCollection(pojoClass, fieldName)) { + + fieldType = fieldType.replace("Entity", ""); + // Regex: Extracts the argument type of the list 'List' => type + String regex = "(?<=\\<).+?(?=\\>)"; + Pattern pattern = Pattern.compile(regex); + Matcher regexMatcher = pattern.matcher(fieldType); + + if (regexMatcher.find()) { + fieldType = regexMatcher.group(0); + } + } + } + return fieldType; + + } + + /** + * Converts all occurrences of devon4j Entity types in the given 'field' simple type (possibly generic) to Longs + * + * @param field the field + * @return the field type as String. If field type contains 'Entity' the result is Long + */ + public String getSimpleEntityTypeAsLongReference(Map field) { + + String fieldType = (String) field.get(Field.TYPE.toString()); + if (fieldType.endsWith("Entity")) { + fieldType = fieldType.replaceAll("[^<>]+Entity", "Long"); + } + return fieldType; + } + + /** + * If the string last character is an 's', then it gets removed + * + * @param targetClassName string to remove plural + * @return string without 's' + */ + public String removePlural(String targetClassName) { + + if (targetClassName.charAt(targetClassName.length() - 1) == 's') { + targetClassName = targetClassName.substring(0, targetClassName.length() - 1); + } + return targetClassName; + } + + /** + * Checks whether the operation with the given ID corresponds to any standard CRUD method name. + * + * @param operationId operation ID interpreted as method name + * @param entityName entity name to check standard CRUD methods for + * @return true if the operation ID maps any standard CRUD method name, false otherwise + */ + public boolean isCrudOperation(String operationId, String entityName) { + + if (operationId == null) { + return false; + } + String opIdLowerCase = operationId.toLowerCase(); + String entityNameLowerCase = entityName.toLowerCase(); + if (opIdLowerCase.contains(entityNameLowerCase)) { + return opIdLowerCase.equals("find" + entityNameLowerCase) + || opIdLowerCase.equals("find" + entityNameLowerCase + "Etos") + || opIdLowerCase.equals("delete" + entityNameLowerCase) || opIdLowerCase.equals("save" + entityNameLowerCase); + } else { + return false; + } + } + + /** + * Converts the given media type to the spring Java enum value + * + * @param mediaType to be converted + * @return the spring enum value representing the given media type + */ + public String getSpringMediaType(String mediaType) { + + switch (mediaType) { + case "application/xml": + return "APPLICATION_XML_VALUE"; + case "application / x-www-form-urlencoded": + return "APPLICATION_FORM_URLENCODED_VALUE"; + case "multipart/form-data": + return "MULTIPART_FORM_DATA_VALUE"; + case "text/plain": + return "TEXT_PLAIN_VALUE"; + case "text/html": + return "TEXT_HTML_VALUE"; + case "application/pdf": + return "APPLICATION_PDF_VALUE"; + case "image/png": + return "IMAGE_PNG_VALUE"; + default: + return "APPLICATION_JSON_VALUE"; + } + } +} \ No newline at end of file diff --git a/cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java b/cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java new file mode 100644 index 0000000000..ced2f5fde2 --- /dev/null +++ b/cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java @@ -0,0 +1,464 @@ +package com.devonfw.cobigen.templates.devon4j.utils; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.Map; + +import org.apache.commons.lang3.ClassUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Provides type operations, mainly checks and casts for Java Primitives, to be used in the templates + * + */ +public class JavaUtil { + + /** + * Logger for this class + */ + private static final Logger LOG = LoggerFactory.getLogger(JavaUtil.class); + + /** + * The constructor. + */ + public JavaUtil() { + + // Empty for CobiGen to automatically instantiate it + } + + /** + * Returns the Object version of a Java primitive or the input if the input isn't a java primitive + * + * @param simpleType String + * @return the corresponding object wrapper type simple name of the input if the input is the name of a primitive java + * type. The input itself if not. (e.g. "int" results in "Integer") + * @throws ClassNotFoundException should not occur. + */ + public String boxJavaPrimitives(String simpleType) throws ClassNotFoundException { + + if (equalsJavaPrimitive(simpleType)) { + return ClassUtils.primitiveToWrapper(ClassUtils.getClass(simpleType)).getSimpleName(); + } else { + return simpleType; + } + + } + + /** + * Returns the simple name of the type of a field in the pojoClass. If the type is a java primitive the name of the + * wrapper class is returned + * + * @param pojoClass {@link Class} the class object of the pojo + * @param fieldName {@link String} the name of the field + * @return String. The simple name of the field's type. The simple name of the wrapper class in case of java + * primitives + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public String boxJavaPrimitives(Class pojoClass, String fieldName) throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + + if (equalsJavaPrimitive(pojoClass, fieldName)) { + return ClassUtils.primitiveToWrapper(pojoClass.getDeclaredField(fieldName).getType()).getSimpleName(); + } else { + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + throw new IllegalAccessError("Could not find field " + fieldName + " in class " + pojoClass); + } else { + return field.getType().getSimpleName(); + } + } + } + + /** + * Checks if the given type is a Java primitive + * + * @param simpleType the type to be checked + * @return true iff simpleType is a Java primitive + */ + public boolean equalsJavaPrimitive(String simpleType) { + + try { + return ClassUtils.getClass(simpleType).isPrimitive(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + } + + /** + * Checks if the given type is a Java primitive or wrapper + * + * @param simpleType the type to be checked + * @return true iff simpleType is a Java primitive or wrapper + */ + public boolean equalsJavaPrimitiveOrWrapper(String simpleType) { + + try { + return ClassUtils.isPrimitiveOrWrapper(ClassUtils.getClass(simpleType)); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + } + + /** + * Checks if the type of the field in the pojo's class is a java primitive + * + * @param pojoClass the {@link Class} object of the pojo + * @param fieldName the name of the field to be checked + * @return true iff the field is a java primitive + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean equalsJavaPrimitive(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + return false; + } + + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + return false; + } else { + return field.getType().isPrimitive(); + } + } + + /** + * Checks if the given type is a Java primitive or a Java primitive array + * + * @param simpleType the Type name to be checked + * @return true iff {@link #equalsJavaPrimitive(String)} is true or if simpleType is an array with a primitive + * component + */ + public boolean equalsJavaPrimitiveIncludingArrays(String simpleType) { + + Class klasse; + + try { + klasse = ClassUtils.getClass(simpleType).getComponentType(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), simpleType); + return false; + } + return equalsJavaPrimitive(simpleType) || (klasse != null && klasse.isPrimitive()); + } + + /** + * Checks if the given field in the pojo class is a java primitive or an array of java primitives + * + * @param pojoClass the class object of the pojo + * @param fieldName the name of the field to be checked + * @return true iff {@link #equalsJavaPrimitive(Class, String)} is true or the field is an array of primitives + * @throws NoSuchFieldException indicating something awfully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean equalsJavaPrimitiveIncludingArrays(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + return equalsJavaPrimitive(pojoClass, fieldName) || (pojoClass.getDeclaredField(fieldName).getType().isArray() + && pojoClass.getDeclaredField(fieldName).getType().getComponentType().isPrimitive()); + } + + /** + * Returns a cast statement for a given (java primitive, variable name) pair or nothing if the type isn't a java + * primitive + * + * @param simpleType Java Type + * @param varName Variable name + * @return String either of the form '((Java Primitive Object Type)varName)' if simpleType is a primitive or the empty + * String otherwise + * @throws ClassNotFoundException should not occur + */ + public String castJavaPrimitives(String simpleType, String varName) throws ClassNotFoundException { + + if (equalsJavaPrimitive(simpleType)) { + return String.format("((%1$s)%2$s)", boxJavaPrimitives(simpleType), varName); + } else { + return ""; + } + } + + /** + * Returns a cast statement for a given (java primitive, variable name) pair or nothing if the type isn't a java + * primitive + * + * @param pojoClass the class object of the pojo + * @param fieldName the name of the field to be casted + * @return if fieldName points to a primitive field then a casted statement (e.g. for an int field: + * '((Integer)field)') or an empty String otherwise + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public String castJavaPrimitives(Class pojoClass, String fieldName) + throws NoSuchFieldException, SecurityException { + + if (equalsJavaPrimitive(pojoClass, fieldName)) { + return String.format("((%1$s)%2$s)", boxJavaPrimitives(pojoClass, fieldName), fieldName); + } else { + return ""; + } + } + + /** + * @param pojoClass {@link Class} the class object of the pojo + * @param fieldName {@link String} the name of the field + * @return true if the field is an instance of java.utils.Collections + * @throws NoSuchFieldException indicating something awefully wrong in the used model + * @throws SecurityException if the field cannot be accessed. + */ + public boolean isCollection(Class pojoClass, String fieldName) throws NoSuchFieldException, SecurityException { + + if (pojoClass == null) { + return false; + } + + Field field = pojoClass.getDeclaredField(fieldName); + if (field == null) { + field = pojoClass.getField(fieldName); + } + if (field == null) { + return false; + } else { + return Collection.class.isAssignableFrom(field.getType()); + } + + } + + /** + * Returns the Ext Type to a given java type + * + * @param simpleType any java type's simple name + * @return corresponding Ext type + */ + public String getExtType(String simpleType) { + + switch (simpleType) { + case "short": + case "Short": + case "int": + case "Integer": + case "long": + case "Long": + return "Integer"; + case "float": + case "Float": + case "double": + case "Double": + return "Number"; + case "boolean": + case "Boolean": + return "Boolean"; + case "char": + case "Character": + case "String": + return "String"; + case "Date": + return "Date"; + default: + return "Field"; + } + } + + /** + * returns the Angular5 type associated with a Java primitive + * + * @param simpleType :{@link String} the type to be parsed + * @return the corresponding Angular type or 'any' otherwise + */ + public String getAngularType(String simpleType) { + + switch (simpleType) { + case "boolean": + return "boolean"; + case "Boolean": + return "boolean"; + case "short": + return "number"; + case "Short": + return "number"; + case "int": + return "number"; + case "Integer": + return "number"; + case "long": + return "number"; + case "Long": + return "number"; + case "float": + return "number"; + case "Float": + return "number"; + case "double": + return "number"; + case "Double": + return "number"; + case "char": + return "string"; + case "Character": + return "string"; + case "String": + return "string"; + case "byte": + return "number"; + default: + return "any"; + } + } + + /** + * returns the class name of the return type of a specific method. + * + * @param pojoClass {@link Class}<?> the class object of the pojo + * @param methodName {@link String} the name of the method + * @return the class name of the return type of the specified method + * @throws SecurityException If no method of the given name can be found + * @throws NoSuchMethodException If no method of the given name can be found + */ + public String getReturnType(Class pojoClass, String methodName) throws NoSuchMethodException, SecurityException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + String s = "-"; + Method method = findMethod(pojoClass, methodName); + if (method != null && !method.getReturnType().equals(Void.TYPE)) { + s = method.getReturnType().toString(); + s = s.substring(s.lastIndexOf('.') + 1, s.length()); + } + return s; + } + + /** + * + * This methods returns the return type of the method in the given pojoClass which are annotated with the parameter + * annotatedClass + * + * @param pojoClass - The class in which to find if it has methods with annotatedClass + * @param annotatedClassName - The annotation which needs to be found + * @return Return type of the method annotated with the given annotation, else "null" + * @throws ClassNotFoundException if the annotated class name could not be found in the class path + */ + @SuppressWarnings("unchecked") + public String getReturnTypeOfMethodAnnotatedWith(Class pojoClass, String annotatedClassName) + throws ClassNotFoundException { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + + Method[] methods = pojoClass.getDeclaredMethods(); + for (Method method : methods) { + if (!method.getName().startsWith("get")) { + continue; + } + for (Annotation a : method.getAnnotations()) { + // better if (method.isAnnotationPresent(classObj)) {, but postponed as of different class + // loaders of a.getClass() and pojoClass.getClass() + if (a.getClass().getCanonicalName().equals(annotatedClassName)) { + return method.getReturnType().getSimpleName(); + } + } + } + return "null"; + } + + /** + * returns the HTTP request type corresponding to an annotation type + * + * @param annotations The annotation to get the type name of + * @return the HTTP request type name of the selected annotation + */ + public String getRequestType(Map annotations) { + + if (annotations.containsKey("javax_ws_rs_GET")) { + return "GET"; + } else if (annotations.containsKey("javax_ws_rs_PUT")) { + return "PUT"; + } else if (annotations.containsKey("javax_ws_rs_POST")) { + return "POST"; + } else if (annotations.containsKey("javax_ws_rs_DELETE")) { + return "DELETE"; + } else if (annotations.containsKey("javax_ws_rs_PATCH")) { + return "PATCH"; + } else { + return "-"; + } + } + + /** + * Helper method to find a class's specific method + * + * @param pojoClass {@link Class}<?> the class object of the pojo + * @param methodName The name of the method to be found + * @return The method object of the method to be found, null if it wasn't found + */ + private Method findMethod(Class pojoClass, String methodName) { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + for (Method m : pojoClass.getMethods()) { + if (m.getName().equals(methodName)) { + return m; + } + } + return null; + } + + /** + * Checks whether the class given by the full qualified name is an enum + * + * @param className full qualified class name + * @return true if the class is an enum, false otherwise + */ + public boolean isEnum(String className) { + + try { + return ClassUtils.getClass(className).isEnum(); + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), className); + return false; + } + } + + /** + * Returns the first enum value of an enum class + * + * @param className full qualified class name + * @return the first enum value name found in order + */ + public String getFirstEnumValue(String className) { + + try { + Class enumClass = ClassUtils.getClass(className); + Field[] declaredFields = enumClass.getDeclaredFields(); + if (declaredFields.length > 0) { + return declaredFields[0].getName(); + } else { + return null; + } + } catch (ClassNotFoundException e) { + LOG.warn("{}: Could not find {}", e.getMessage(), className); + return null; + } + } +} diff --git a/cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/OpenApiUtil.java b/cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/OpenApiUtil.java new file mode 100644 index 0000000000..a93288f45a --- /dev/null +++ b/cobigen-templates/crud-openapi-net/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/OpenApiUtil.java @@ -0,0 +1,255 @@ +package com.devonfw.cobigen.templates.devon4j.utils; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.time.Instant; +import java.time.LocalDate; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; + +/** Utils on OpenAPI template model */ +public class OpenApiUtil { + + /** + * Prints javax validation constraints from an OpenAPI model + * + * @param constraints OpenAPI model constraints + * @return the list of supported annotations in Java syntax + */ + public String printJavaConstraints(Map constraints) { + + String consts = ""; + if (constraints.get("maximum") != null) { + consts = consts + "@Max(" + constraints.get("maximum") + ")"; + } + if (constraints.get("minimum") != null) { + consts = consts + "@Min(" + constraints.get("minimum") + ")"; + } + if (constraints.get("maxLength") != null) { + consts = consts + "@Size(max=" + constraints.get("maxLength"); + if (constraints.get("minLength") != null) { + consts = consts + ", min=" + constraints.get("minLength"); + } + consts = consts + ")"; + } else { + if (constraints.get("minLength") != null) { + consts = consts + "@Size(min=" + constraints.get("minLength"); + if (constraints.get("maxLength") != null) { + consts = consts + ", max=" + constraints.get("maxLength"); + } + consts = consts + ")"; + } + } + return consts; + } + + /** + * Prints the return type of a response based on the OpenAPI model + * + * @param response the OpenAPI model of a response + * @return simple type of the response return type in Java syntax + */ + public String printJavaServiceResponseReturnType(Map response) { + + String returnType = toJavaType(response, false); + if ((boolean) response.get("isVoid")) { + return "void"; + } + if ((boolean) response.get("isArray")) { + if ((boolean) response.get("isEntity")) { + if (returnType.contains("Entity")) { + return "List<" + returnType + ">"; + } else { + return "List<" + returnType + "Entity>"; + } + } else { + return "List<" + returnType + ">"; + } + } else if ((boolean) response.get("isPaginated")) { + if ((boolean) response.get("isEntity")) { + if (returnType.contains("Entity")) { + return "Page<" + returnType + ">"; + } else { + return "Page<" + returnType + "Entity>"; + } + } else { + return "Page<" + returnType + ">"; + } + } else { + return returnType; + } + } + + /** + * Returns the Java type corresponding to the OpenAPI type definition. If the type could not be matched, Object will + * be returned. + * + * @param parameter OpenAPI model of a parameter + * @param simpleType if a Java simple type should be returned if possible + * @return the Java type + */ + public String toJavaType(Map parameter, boolean simpleType) { + + String typeConverted = null; + String format = (String) parameter.get("format"); + String type = (String) parameter.get("type"); + boolean isCollection = false; + if (parameter.get("isCollection") != null) { + isCollection = (boolean) parameter.get("isCollection"); + } + + boolean isEntity = (boolean) parameter.get("isEntity"); + + if (type != null) { + switch (type.toLowerCase()) { + case "integer": + if (format != null) { + switch (format) { + case "int32": + typeConverted = simpleType ? "int" : "Integer"; + break; + case "int64": + typeConverted = simpleType ? "long" : "Long"; + break; + default: + typeConverted = BigInteger.class.getSimpleName(); + break; + } + } else { + typeConverted = BigInteger.class.getSimpleName(); + } + break; + case "number": + if (format != null) { + switch (format) { + case "float": + typeConverted = simpleType ? "float" : "Float"; + break; + case "double": + typeConverted = simpleType ? "double" : "Double"; + break; + default: + typeConverted = BigDecimal.class.getSimpleName(); + break; + } + } else { + typeConverted = BigDecimal.class.getSimpleName(); + } + break; + case "string": + if (format != null) { + switch (format) { + case "date": + typeConverted = LocalDate.class.getSimpleName(); + break; + case "date-time": + typeConverted = Instant.class.getSimpleName(); + break; + case "binary": + typeConverted = simpleType ? "float" : "Float"; + break; + case "email": + case "password": + typeConverted = String.class.getSimpleName(); + break; + default: + typeConverted = "String"; + break; + } + } else { + typeConverted = "String"; + } + break; + case "boolean": + typeConverted = simpleType ? "boolean" : "Boolean"; + break; + default: + typeConverted = "void"; + break; + } + } else { + typeConverted = "void"; + } + + if (isCollection) { + if (isEntity) { + return "List<" + parameter.get("type") + ">"; + } else { + return "List<" + typeConverted + ">"; + } + } else if (isEntity) { + return (String) parameter.get("type"); + } + return typeConverted; + } + + /** + * Returns the TypeScript type corresponding to the OpenAPI type definition. If the type could not be matched, the + * same value will be returned. + * + * @param parameter OpenAPI model of a parameter + * @return the Java type + */ + // getOaspTypeFromOpenAPI + public String toTypeScriptType(Map parameter) { + + String typeConverted = null; + String type = (String) parameter.get("type"); + boolean isCollection = false; + if (parameter.get("isCollection") != null) { + isCollection = (boolean) parameter.get("isCollection"); + } + + boolean isEntity = (boolean) parameter.get("isEntity"); + + if (type != null) { + switch (type.toLowerCase()) { + case "integer": + typeConverted = "number"; + break; + default: + typeConverted = type; + break; + } + } else { + typeConverted = "undefined"; + } + + if (isCollection) { + if (isEntity) { + return parameter.get("type") + "[]"; + } else { + return typeConverted + "[]"; + } + } else if (isEntity) { + return (String) parameter.get("type"); + } + return typeConverted; + } + + /** + * Prints the service operation name based on the operationId or generates one based on the servicePath while printing + * a comment how to get better service names. + * + * @param operation operation Model of the OpenAPI model + * @param servicePath service path of the + * @return the service method name + */ + public String printServiceOperationName(Map operation, String servicePath) { + + String operationId = (String) operation.get("operationId"); + if (StringUtils.isEmpty(operationId)) { + String[] split = servicePath.split("/"); + String lastSegment; + if (!split[split.length - 1].isEmpty()) { + lastSegment = split[split.length - 1]; + } else { + lastSegment = split[split.length - 2]; + } + return ((String) operation.get("type")) + lastSegment; + } else { + return operationId; + } + } +} diff --git a/cobigen-templates/crud-openapi-net/src/main/resources/template-set.xml b/cobigen-templates/crud-openapi-net/src/main/resources/template-set.xml new file mode 100644 index 0000000000..f4f7d91fac --- /dev/null +++ b/cobigen-templates/crud-openapi-net/src/main/resources/template-set.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.Application.WebAPI/Startup.cs b/cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.Application.WebAPI/Startup.cs similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.Application.WebAPI/Startup.cs rename to cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.Application.WebAPI/Startup.cs diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.Application.WebAPI/appsettings.Development.json b/cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.Application.WebAPI/appsettings.Development.json similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.Application.WebAPI/appsettings.Development.json rename to cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.Application.WebAPI/appsettings.Development.json diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Controller/${variables.component#cap_first}Controller.cs.ftl b/cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Controller/${variables.component#cap_first}Controller.cs.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Controller/${variables.component#cap_first}Controller.cs.ftl rename to cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Controller/${variables.component#cap_first}Controller.cs.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Converter/${variables.component#cap_first}Converter.cs.ftl b/cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Converter/${variables.component#cap_first}Converter.cs.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Converter/${variables.component#cap_first}Converter.cs.ftl rename to cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Converter/${variables.component#cap_first}Converter.cs.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Dto/${variables.entityName#replace('Dto', '')#cap_first}Dto.cs.ftl b/cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Dto/${variables.entityName#replace('Dto', '')#cap_first}Dto.cs.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Dto/${variables.entityName#replace('Dto', '')#cap_first}Dto.cs.ftl rename to cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Dto/${variables.entityName#replace('Dto', '')#cap_first}Dto.cs.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Dto/${variables.entityName#replace('Dto', '')#cap_first}ResponseDto.cs.ftl b/cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Dto/${variables.entityName#replace('Dto', '')#cap_first}ResponseDto.cs.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Dto/${variables.entityName#replace('Dto', '')#cap_first}ResponseDto.cs.ftl rename to cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Dto/${variables.entityName#replace('Dto', '')#cap_first}ResponseDto.cs.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Exceptions/${variables.entityName#cap_first}NotCreatedException.cs.ftl b/cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Exceptions/${variables.entityName#cap_first}NotCreatedException.cs.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Exceptions/${variables.entityName#cap_first}NotCreatedException.cs.ftl rename to cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Exceptions/${variables.entityName#cap_first}NotCreatedException.cs.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Exceptions/${variables.entityName#cap_first}NotDeletedException.cs.ftl b/cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Exceptions/${variables.entityName#cap_first}NotDeletedException.cs.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Exceptions/${variables.entityName#cap_first}NotDeletedException.cs.ftl rename to cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Exceptions/${variables.entityName#cap_first}NotDeletedException.cs.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Exceptions/${variables.entityName#cap_first}NotFoundException.cs.ftl b/cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Exceptions/${variables.entityName#cap_first}NotFoundException.cs.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Exceptions/${variables.entityName#cap_first}NotFoundException.cs.ftl rename to cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Exceptions/${variables.entityName#cap_first}NotFoundException.cs.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Service/${variables.component#cap_first}Service.cs.ftl b/cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Service/${variables.component#cap_first}Service.cs.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Service/${variables.component#cap_first}Service.cs.ftl rename to cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Service/${variables.component#cap_first}Service.cs.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Service/I${variables.component#cap_first}Service.cs.ftl b/cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Service/I${variables.component#cap_first}Service.cs.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Service/I${variables.component#cap_first}Service.cs.ftl rename to cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Business/${variables.component#cap_first}Management/Service/I${variables.component#cap_first}Service.cs.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Data/Repositories/${variables.entityName#cap_first}Repository.cs.ftl b/cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Data/Repositories/${variables.entityName#cap_first}Repository.cs.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Data/Repositories/${variables.entityName#cap_first}Repository.cs.ftl rename to cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Data/Repositories/${variables.entityName#cap_first}Repository.cs.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Domain/Database/CobigenContext.cs b/cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Domain/Database/CobigenContext.cs similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Domain/Database/CobigenContext.cs rename to cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Domain/Database/CobigenContext.cs diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Domain/Entities/${variables.entityName#cap_first}.cs.ftl b/cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Domain/Entities/${variables.entityName#cap_first}.cs.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Domain/Entities/${variables.entityName#cap_first}.cs.ftl rename to cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Domain/Entities/${variables.entityName#cap_first}.cs.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Domain/RepositoryInterfaces/I${variables.entityName#cap_first}Repository.cs.ftl b/cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Domain/RepositoryInterfaces/I${variables.entityName#cap_first}Repository.cs.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_openapi_net/templates/Devon4Net.WebAPI.Implementation/Domain/RepositoryInterfaces/I${variables.entityName#cap_first}Repository.cs.ftl rename to cobigen-templates/crud-openapi-net/src/main/resources/templates/Devon4Net.WebAPI.Implementation/Domain/RepositoryInterfaces/I${variables.entityName#cap_first}Repository.cs.ftl diff --git a/cobigen-templates/crud-openapi-net/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenApiNetGenerationTest.java b/cobigen-templates/crud-openapi-net/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenApiNetGenerationTest.java new file mode 100644 index 0000000000..c3031d0e9e --- /dev/null +++ b/cobigen-templates/crud-openapi-net/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudOpenApiNetGenerationTest.java @@ -0,0 +1,100 @@ +package com.devonfw.cobigen.templates.devon4j.test.templates; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.apache.commons.io.FileUtils; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.devonfw.cobigen.api.constants.ConfigurationConstants; +import com.devonfw.cobigen.templates.devon4j.config.constant.MavenMetadata; +import com.devonfw.cobigen.maven.test.AbstractMavenTest; + +/** + * Smoke tests of all templates. + */ +public class CrudOpenApiNetGenerationTest extends AbstractMavenTest { + + /** Root of all test resources of this test suite */ + public static final String TEST_RESOURCES_ROOT = "src/test/resources/testdata/templatetest/"; + + /** Temporary files rule to create temporary folders */ + @ClassRule + public static TemporaryFolder tempFolder = new TemporaryFolder(); + + /** The templates development folder */ + protected static Path templatesProject; + + /** The templates development folder */ + protected static Path templatesProjectTemporary; + + /** + * Creates a copy of the templates project in the temp directory + * + * @throws URISyntaxException if the path could not be created properly + * @throws IOException if accessing a directory or file fails + */ + @BeforeClass + public static void setupDevTemplates() throws URISyntaxException, IOException { + + templatesProject = new File( + CrudOpenApiNetGenerationTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile() + .getParentFile().toPath(); + + Path utilsPom = new File( + CrudOpenApiNetGenerationTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile() + .getParentFile().toPath().resolve("src/test/resources/utils/pom.xml"); + + // create a temporary directory cobigen-templates/template-sets/adapted containing the template sets + Path tempFolderPath = tempFolder.getRoot().toPath(); + Path cobigenTemplatePath = tempFolderPath.resolve("cobigen-templates"); + if (!Files.exists(cobigenTemplatePath)) { + Files.createDirectory(cobigenTemplatePath); + + templatesProjectTemporary = cobigenTemplatePath.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER); + Path templateSetsAdaptedFolder = templatesProjectTemporary.resolve(ConfigurationConstants.ADAPTED_FOLDER); + Files.createDirectory(templatesProjectTemporary); + Files.createDirectory(templateSetsAdaptedFolder); + + Path templateSetPath = templateSetsAdaptedFolder.resolve("template-set"); + FileUtils.copyDirectory(templatesProject.toFile(), templateSetPath.toFile()); + + if (Files.isDirectory(templateSetPath)) { + + // Replace the pom.xml in the template sets. Needed so that the project in the temp directory is build + // properly + if (Files.exists(templateSetPath.resolve("pom.xml"))) { + try { + Files.delete(templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error deleting file " + templateSetPath.resolve("pom.xml"), e); + } + try { + Files.copy(utilsPom, templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error copying file " + utilsPom, e); + } + } + } + } + } + + /** + * Test successful generation of all templates based on an ETO + * + * @throws Exception test fails + */ + @Test + public void testAllTemplatesGeneration_OpenApiInput() throws Exception { + + File testProject = new File(TEST_RESOURCES_ROOT + "TestAllTemplatesOpenApiInput/"); + runMavenInvoker(testProject, templatesProjectTemporary.toFile(), MavenMetadata.LOCAL_REPO); + } + +} diff --git a/cobigen-templates/crud-openapi-net/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml b/cobigen-templates/crud-openapi-net/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml new file mode 100644 index 0000000000..14b9ec10cf --- /dev/null +++ b/cobigen-templates/crud-openapi-net/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml @@ -0,0 +1,131 @@ +openapi: 3.0.0 +servers: + - url: 'https://localhost:8081/server/services/rest' +info: + title: Devon Example + description: Example of a API definition + version: 1.0.0 + x-rootpackage: com.devonfw.demo +paths: + /datamanagement/v1/someData/{id}: + get: + operationId: findSomeData + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + minimum: 0 + maximum: 50 + responses: + '200': + description: Any + content: + application/json: + schema: + $ref: '#/components/schemas/EvenMoreData' + text/plain: + schema: + type: string + /datamanagement/v1/moreData/{id}: + get: + operationId: findMoreData + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + minimum: 10 + maximum: 200 + responses: + '200': + description: Any + /datamanagement/v1/someData/: + post: + responses: + '200': + description: Any + requestBody: + $ref: '#/components/requestBodies/SomeData' + tags: + - searchCriteria + /datamanagement/v1/moreData/validateMoreData: + post: + responses: + '200': + description: Any + requestBody: + $ref: '#/components/requestBodies/MoreData' +components: + schemas: + SomeData: + x-component: DataManagement + description: Entity definiton of SomeData + type: object + properties: + AnyString: + type: string + maxLength: 100 + minLength: 5 + uniqueItems: true + furtherData: + type: array + items: + $ref: '#/components/schemas/FurtherData' + MoreData: + x-component: DataManagement + description: Entity definiton of Moredata + type: object + properties: + anyNumber: + type: number + format: int64 + maximum: 100 + minimum: 0 + someData: + $ref: '#/components/schemas/SomeData' + allSomeData: + type: array + description: 'All SomeData' + items: + $ref: '#/components/schemas/SomeData' + required: + - saleExample + FurtherData: + x-component: AnotherComponent + type: object + properties: + parent: + $ref: '#/components/schemas/SomeData' + valid: + type: boolean + someList: + type: array + items: + type: string + EvenMoreData: + x-component: AnotherComponent + description: Entity definiton of more data + type: object + properties: + id: + type: integer + format: int64 + uniqueItems: true + requestBodies: + SomeData: + content: + application/json: + schema: + $ref: '#/components/schemas/SomeData' + required: true + MoreData: + content: + application/json: + schema: + $ref: '#/components/schemas/MoreData' + required: true diff --git a/cobigen-templates/crud-openapi-net/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml b/cobigen-templates/crud-openapi-net/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/crud-openapi-net/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/crud-openapi-net/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml b/cobigen-templates/crud-openapi-net/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml new file mode 100644 index 0000000000..7f84fdeef0 --- /dev/null +++ b/cobigen-templates/crud-openapi-net/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + com.devonfw.cobigen + devon4jTemplateTest-TestAllTemplatesOpenAPIInput + dev-SNAPSHOT + + + 1.8 + 1.8 + + + + + + com.devonfw.cobigen + cobigen-maven-plugin + ${pluginVersion} + + + generate + package + + generate + + + + + ${templatesProject} + + OpenAPI.yaml + + + + + true + + + + com.devonfw.cobigen + tempeng-freemarker + ${pluginVersion} + + + com.devonfw.cobigen + javaplugin + ${pluginVersion} + + + com.devonfw.cobigen + htmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + tsplugin + ${pluginVersion} + + + com.devonfw.cobigen + jsonplugin + ${pluginVersion} + + + com.devonfw.cobigen + openapiplugin + ${pluginVersion} + + + com.devonfw.cobigen + xmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + textmerger + ${pluginVersion} + + + + + + + diff --git a/cobigen-templates/crud-openapi-net/src/test/resources/utils/pom.xml b/cobigen-templates/crud-openapi-net/src/test/resources/utils/pom.xml new file mode 100644 index 0000000000..4336fbf1a7 --- /dev/null +++ b/cobigen-templates/crud-openapi-net/src/test/resources/utils/pom.xml @@ -0,0 +1,99 @@ + + + 4.0.0 + com.devonfw.cobigen.templates + crud-openapi-net + 2021.12.007-SNAPSHOT + CRUD OpenApi Net + A Code-based incremental Generator + + + Apache Software License 2.0 + https://raw.githubusercontent.com/devonfw/.github/master/LICENSE + repo + + + + + + javax.ws.rs + javax.ws.rs-api + 2.0 + compile + + + org.springframework.data + spring-data-rest-webmvc + 3.7.10 + compile + + + org.apache.commons + commons-lang3 + 3.12.0 + compile + + + com.fasterxml.jackson.core + jackson-databind + 2.10.0 + compile + + + xerces + xercesImpl + 2.12.2 + compile + + + javax.persistence + javax.persistence-api + 2.2 + compile + + + org.slf4j + slf4j-api + 1.7.30 + compile + + + org.slf4j + jcl-over-slf4j + 1.7.30 + compile + + + org.slf4j + log4j-over-slf4j + 1.7.30 + compile + + + + + + false + + + true + + ossrh + OSSRH Snapshots + https://s01.oss.sonatype.org/content/repositories/snapshots/ + + + + + 1.8 + 1.8 + + + + + + src/main/java + + + \ No newline at end of file diff --git a/cobigen-templates/crud-typescript-angular-client-app/pom.xml b/cobigen-templates/crud-typescript-angular-client-app/pom.xml new file mode 100644 index 0000000000..602944faf3 --- /dev/null +++ b/cobigen-templates/crud-typescript-angular-client-app/pom.xml @@ -0,0 +1,13 @@ + + 4.0.0 + crud-typescript-angular-client-app + CRUD TypeScript Angular Client App template + + + com.devonfw.cobigen.templates + templates-parent + ${revision} + + + \ No newline at end of file diff --git a/cobigen-templates/crud-typescript-angular-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java b/cobigen-templates/crud-typescript-angular-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java new file mode 100644 index 0000000000..395d46154d --- /dev/null +++ b/cobigen-templates/crud-typescript-angular-client-app/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java @@ -0,0 +1,12 @@ +package com.devonfw.cobigen.templates.devon4j.config.constant; + +/** + * Constants extracted from the maven pom by templating-maven-plugin. + * + * @see "edit template in src/main/java-templates" + */ +public class MavenMetadata { + + /** Local repository path */ + public static final String LOCAL_REPO = "${settings.localRepository}"; +} diff --git a/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/template-set.xml b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/template-set.xml new file mode 100644 index 0000000000..e5a9b786f5 --- /dev/null +++ b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/template-set.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/cobigen.properties b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/cobigen.properties similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/cobigen.properties rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/cobigen.properties diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.html.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.html.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.html.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.html.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.scss b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.scss similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.scss rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.scss diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.spec.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.spec.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.spec.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.spec.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-alert/${variables.entityName#lower_case}-alert.component.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-dialog/${variables.entityName#lower_case}-dialog.component.html.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-dialog/${variables.entityName#lower_case}-dialog.component.html.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-dialog/${variables.entityName#lower_case}-dialog.component.html.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-dialog/${variables.entityName#lower_case}-dialog.component.html.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-dialog/${variables.entityName#lower_case}-dialog.component.spec.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-dialog/${variables.entityName#lower_case}-dialog.component.spec.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-dialog/${variables.entityName#lower_case}-dialog.component.spec.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-dialog/${variables.entityName#lower_case}-dialog.component.spec.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-dialog/${variables.entityName#lower_case}-dialog.component.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-dialog/${variables.entityName#lower_case}-dialog.component.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-dialog/${variables.entityName#lower_case}-dialog.component.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-dialog/${variables.entityName#lower_case}-dialog.component.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.html.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.html.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.html.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.html.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.scss b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.scss similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.scss rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.scss diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.spec.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.spec.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.spec.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.spec.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}-grid/${variables.entityName#lower_case}-grid.component.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}.module.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}.module.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}.module.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/${variables.entityName#lower_case}.module.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/services/${variables.entityName#lower_case}.service.spec.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/services/${variables.entityName#lower_case}.service.spec.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/services/${variables.entityName#lower_case}.service.spec.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/services/${variables.entityName#lower_case}.service.spec.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/services/${variables.entityName#lower_case}.service.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/services/${variables.entityName#lower_case}.service.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/${variables.entityName#lower_case}/services/${variables.entityName#lower_case}.service.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/${variables.entityName#lower_case}/services/${variables.entityName#lower_case}.service.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/app-routing.module.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/app-routing.module.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/app-routing.module.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/app-routing.module.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/app.module.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/app.module.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/app.module.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/app.module.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/core/interfaces/sort.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/core/interfaces/sort.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/core/interfaces/sort.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/core/interfaces/sort.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/core/security/login.service.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/core/security/login.service.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/core/security/login.service.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/core/security/login.service.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/core/shared/business-operations.service.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/core/shared/business-operations.service.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/core/shared/business-operations.service.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/core/shared/business-operations.service.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/home/home.component.html.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/home/home.component.html.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/home/home.component.html.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/home/home.component.html.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/model/${variables.entityName#lower_case}.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/model/${variables.entityName#lower_case}.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/model/${variables.entityName#lower_case}.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/model/${variables.entityName#lower_case}.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/model/model.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/model/model.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/app/model/model.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/app/model/model.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/assets/i18n/en.json.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/assets/i18n/en.json.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/assets/i18n/en.json.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/assets/i18n/en.json.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/assets/i18n/es.json.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/assets/i18n/es.json.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/assets/i18n/es.json.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/assets/i18n/es.json.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/environments/environment.prod.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/environments/environment.prod.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/environments/environment.prod.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/environments/environment.prod.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/environments/environment.ts.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/environments/environment.ts.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/templates/src/environments/environment.ts.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/templates/src/environments/environment.ts.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/variables.ftl b/cobigen-templates/crud-typescript-angular-client-app/src/main/resources/variables.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/crud_typescript_angular_client_app/variables.ftl rename to cobigen-templates/crud-typescript-angular-client-app/src/main/resources/variables.ftl diff --git a/cobigen-templates/crud-typescript-angular-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudTypescriptAngularClientAppTest.java b/cobigen-templates/crud-typescript-angular-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudTypescriptAngularClientAppTest.java new file mode 100644 index 0000000000..bc2cc3ae0c --- /dev/null +++ b/cobigen-templates/crud-typescript-angular-client-app/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/CrudTypescriptAngularClientAppTest.java @@ -0,0 +1,100 @@ +package com.devonfw.cobigen.templates.devon4j.test.templates; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.apache.commons.io.FileUtils; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.devonfw.cobigen.api.constants.ConfigurationConstants; +import com.devonfw.cobigen.maven.test.AbstractMavenTest; +import com.devonfw.cobigen.templates.devon4j.config.constant.MavenMetadata; + +/** + * Smoke tests of all templates. + */ +public class CrudTypescriptAngularClientAppTest extends AbstractMavenTest { + + /** Root of all test resources of this test suite */ + public static final String TEST_RESOURCES_ROOT = "src/test/resources/testdata/templatetest/"; + + /** Temporary files rule to create temporary folders */ + @ClassRule + public static TemporaryFolder tempFolder = new TemporaryFolder(); + + /** The templates development folder */ + protected static Path templatesProject; + + /** The templates development folder */ + protected static Path templatesProjectTemporary; + + /** + * Creates a copy of the templates project in the temp directory + * + * @throws URISyntaxException if the path could not be created properly + * @throws IOException if accessing a directory or file fails + */ + @BeforeClass + public static void setupDevTemplates() throws URISyntaxException, IOException { + + templatesProject = new File( + CrudTypescriptAngularClientAppTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()) + .getParentFile().getParentFile().toPath(); + + Path utilsPom = new File( + CrudTypescriptAngularClientAppTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()) + .getParentFile().getParentFile().toPath().resolve("src/test/resources/utils/pom.xml"); + + // create a temporary directory cobigen-templates/template-sets/adapted containing the template sets + Path tempFolderPath = tempFolder.getRoot().toPath(); + Path cobigenTemplatePath = tempFolderPath.resolve("cobigen-templates"); + if (!Files.exists(cobigenTemplatePath)) { + Files.createDirectory(cobigenTemplatePath); + + templatesProjectTemporary = cobigenTemplatePath.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER); + Path templateSetsAdaptedFolder = templatesProjectTemporary.resolve(ConfigurationConstants.ADAPTED_FOLDER); + Files.createDirectory(templatesProjectTemporary); + Files.createDirectory(templateSetsAdaptedFolder); + + Path templateSetPath = templateSetsAdaptedFolder.resolve("template-set"); + FileUtils.copyDirectory(templatesProject.toFile(), templateSetPath.toFile()); + + if (Files.isDirectory(templateSetPath)) { + + // Replace the pom.xml in the template sets. Needed so that the project in the temp directory is build + // properly + if (Files.exists(templateSetPath.resolve("pom.xml"))) { + try { + Files.delete(templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error deleting file " + templateSetPath.resolve("pom.xml"), e); + } + try { + Files.copy(utilsPom, templateSetPath.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error copying file " + utilsPom, e); + } + } + } + } + } + + /** + * Test successful generation of all templates based on a TypeScript entity + * + * @throws Exception test fails + */ + @Test + public void testAllTemplatesGeneration_TypescriptEntityInput() throws Exception { + + File testProject = new File(TEST_RESOURCES_ROOT + "TestAllTemplatesEntityInput/"); + runMavenInvoker(testProject, templatesProjectTemporary.toFile(), MavenMetadata.LOCAL_REPO); + } + +} diff --git a/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/application.properties b/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/application.properties new file mode 100644 index 0000000000..cf2c614efb --- /dev/null +++ b/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/application.properties @@ -0,0 +1,2 @@ +server.port=8080 +server.context-path=/ \ No newline at end of file diff --git a/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/logback.xml b/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/baseFile.entity.ts b/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/baseFile.entity.ts new file mode 100644 index 0000000000..d8f3f6f8b2 --- /dev/null +++ b/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/baseFile.entity.ts @@ -0,0 +1,22 @@ +import { a } from 'b'; +import { c } from 'd'; +export { e } from 'f'; + + /** + * Should format correctly this line + * Api Documentation + * + * OpenAPI spec version: 1.0 + */ +class a { + + aProperty: number = 2; + + aMethod(){ + + } +} + +export interface a { + private b: number; +} \ No newline at end of file diff --git a/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml b/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml b/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml new file mode 100644 index 0000000000..3e3cbe8ba5 --- /dev/null +++ b/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml @@ -0,0 +1,58 @@ + + 4.0.0 + com.devonfw.cobigen + devon4jTemplateTest-TestAllTemplatesEntityInput + dev-SNAPSHOT + + + 1.8 + 1.8 + + + + + + com.devonfw.cobigen + cobigen-maven-plugin + ${pluginVersion} + + + generate + package + + generate + + + + + ${templatesProject} + + baseFile.entity.ts + + + + + true + + + + com.devonfw.cobigen + tempeng-freemarker + ${pluginVersion} + + + com.devonfw.cobigen + tsplugin + ${pluginVersion} + + + com.devonfw.cobigen + jsonplugin + ${pluginVersion} + + + + + + diff --git a/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java b/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java new file mode 100644 index 0000000000..e2d76c7c9f --- /dev/null +++ b/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java @@ -0,0 +1,25 @@ +package io.github.devonfw.cobigen.generator.dataaccess.api; + +public class InputEntity { + + private String input; + + private int complexity; + + public String getInput() { + return input; + } + + public void setInput(String input) { + this.input = input; + } + + public int getComplexity() { + return complexity; + } + + public void setComplexity(int complexity) { + this.complexity = complexity; + } + +} diff --git a/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/utils/pom.xml b/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/utils/pom.xml new file mode 100644 index 0000000000..c692753c92 --- /dev/null +++ b/cobigen-templates/crud-typescript-angular-client-app/src/test/resources/utils/pom.xml @@ -0,0 +1,100 @@ + + + 4.0.0 + com.devonfw.cobigen.templates + crud-typescript-angular-client-app + 2021.12.007-SNAPSHOT + Crud Typescript Angular Client App + A Code-based incremental Generator + https://github.com/devonfw/cobigen/templates-parent/templates-devon4j-utils + + + Apache Software License 2.0 + https://raw.githubusercontent.com/devonfw/.github/master/LICENSE + repo + + + + + + javax.ws.rs + javax.ws.rs-api + 2.0 + compile + + + org.springframework.data + spring-data-rest-webmvc + 3.7.10 + compile + + + org.apache.commons + commons-lang3 + 3.12.0 + compile + + + com.fasterxml.jackson.core + jackson-databind + 2.10.0 + compile + + + xerces + xercesImpl + 2.12.2 + compile + + + javax.persistence + javax.persistence-api + 2.2 + compile + + + org.slf4j + slf4j-api + 1.7.30 + compile + + + org.slf4j + jcl-over-slf4j + 1.7.30 + compile + + + org.slf4j + log4j-over-slf4j + 1.7.30 + compile + + + + + + false + + + true + + ossrh + OSSRH Snapshots + https://s01.oss.sonatype.org/content/repositories/snapshots/ + + + + + 1.8 + 1.8 + + + + + + src/main/java + + + \ No newline at end of file diff --git a/cobigen-templates/kafka-documentation/pom.xml b/cobigen-templates/kafka-documentation/pom.xml new file mode 100644 index 0000000000..fc496c637a --- /dev/null +++ b/cobigen-templates/kafka-documentation/pom.xml @@ -0,0 +1,24 @@ + + 4.0.0 + kafka-documentation + Kafka Documentation template + + + com.devonfw.cobigen.templates + templates-parent + ${revision} + + + + + javax.ws.rs + javax.ws.rs-api + 2.0 + + + com.fasterxml.jackson.core + jackson-databind + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/JavaDocumentationUtil.java b/cobigen-templates/kafka-documentation/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/JavaDocumentationUtil.java similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/JavaDocumentationUtil.java rename to cobigen-templates/kafka-documentation/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/JavaDocumentationUtil.java diff --git a/cobigen-templates/kafka-documentation/src/main/resources/template-set.xml b/cobigen-templates/kafka-documentation/src/main/resources/template-set.xml new file mode 100644 index 0000000000..b97ddec904 --- /dev/null +++ b/cobigen-templates/kafka-documentation/src/main/resources/template-set.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/templates/kafka_documentation/templates/docs/${variables.component}To.adoc.ftl b/cobigen-templates/kafka-documentation/src/main/resources/templates/docs/${variables.component}To.adoc.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/kafka_documentation/templates/docs/${variables.component}To.adoc.ftl rename to cobigen-templates/kafka-documentation/src/main/resources/templates/docs/${variables.component}To.adoc.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/kafka_documentation/templates/docs/Documentation.adoc.ftl b/cobigen-templates/kafka-documentation/src/main/resources/templates/docs/Documentation.adoc.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/kafka_documentation/templates/docs/Documentation.adoc.ftl rename to cobigen-templates/kafka-documentation/src/main/resources/templates/docs/Documentation.adoc.ftl diff --git a/cobigen-templates/named-queries/pom.xml b/cobigen-templates/named-queries/pom.xml new file mode 100644 index 0000000000..49f83e48a7 --- /dev/null +++ b/cobigen-templates/named-queries/pom.xml @@ -0,0 +1,13 @@ + + 4.0.0 + named-queries + Named Queries template + + + com.devonfw.cobigen.templates + templates-parent + ${revision} + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/templates/named_queries/NamedQueries.java.ftl b/cobigen-templates/named-queries/src/main/resources/NamedQueries.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/named_queries/NamedQueries.java.ftl rename to cobigen-templates/named-queries/src/main/resources/NamedQueries.java.ftl diff --git a/cobigen-templates/named-queries/src/main/resources/template-set.xml b/cobigen-templates/named-queries/src/main/resources/template-set.xml new file mode 100644 index 0000000000..8b71406890 --- /dev/null +++ b/cobigen-templates/named-queries/src/main/resources/template-set.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-templates/openapi-documentation/pom.xml b/cobigen-templates/openapi-documentation/pom.xml new file mode 100644 index 0000000000..d7d8746738 --- /dev/null +++ b/cobigen-templates/openapi-documentation/pom.xml @@ -0,0 +1,13 @@ + + 4.0.0 + openapi-documentation + OpenAPI Documentation template + + + com.devonfw.cobigen.templates + templates-parent + ${revision} + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/DocumentationUtil.java b/cobigen-templates/openapi-documentation/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/DocumentationUtil.java similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/DocumentationUtil.java rename to cobigen-templates/openapi-documentation/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/DocumentationUtil.java diff --git a/cobigen-templates/templates-devon4j/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/OpenApiDocumentationUtil.java b/cobigen-templates/openapi-documentation/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/OpenApiDocumentationUtil.java similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/OpenApiDocumentationUtil.java rename to cobigen-templates/openapi-documentation/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/OpenApiDocumentationUtil.java diff --git a/cobigen-templates/templates-devon4j/src/main/templates/openapi_documentation/functions.ftl b/cobigen-templates/openapi-documentation/src/main/resources/functions.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/openapi_documentation/functions.ftl rename to cobigen-templates/openapi-documentation/src/main/resources/functions.ftl diff --git a/cobigen-templates/openapi-documentation/src/main/resources/template-set.xml b/cobigen-templates/openapi-documentation/src/main/resources/template-set.xml new file mode 100644 index 0000000000..460011a9d0 --- /dev/null +++ b/cobigen-templates/openapi-documentation/src/main/resources/template-set.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/templates/openapi_documentation/templates/docs/${variables.component}Doc.adoc.ftl b/cobigen-templates/openapi-documentation/src/main/resources/templates/docs/${variables.component}Doc.adoc.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/openapi_documentation/templates/docs/${variables.component}Doc.adoc.ftl rename to cobigen-templates/openapi-documentation/src/main/resources/templates/docs/${variables.component}Doc.adoc.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/openapi_documentation/templates/docs/Documentation.adoc.ftl b/cobigen-templates/openapi-documentation/src/main/resources/templates/docs/Documentation.adoc.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/openapi_documentation/templates/docs/Documentation.adoc.ftl rename to cobigen-templates/openapi-documentation/src/main/resources/templates/docs/Documentation.adoc.ftl diff --git a/cobigen-templates/pom.xml b/cobigen-templates/pom.xml index 48cf2f9652..09f7db4f18 100644 --- a/cobigen-templates/pom.xml +++ b/cobigen-templates/pom.xml @@ -1,7 +1,8 @@ +xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 + com.devonfw.cobigen.templates templates-parent CobiGen - Templates Parent pom @@ -10,10 +11,36 @@ com.devonfw.cobigen master-parent ${revision} + ../pom.xml + + false + 1.8 + 1.8 + + - templates-devon4j + templates-devon4j-utils + templates-devon4j-tests + crud-angular-client-app + crud-ionic-client-app + crud-java-ea-uml + crud-java-server-app + crud-java-server-app-complex + crud-ngrx-client-app + crud-openapi-angular-client-app + crud-openapi-angular-service-based-app + crud-openapi-ionic-client-app + crud-openapi-java-server-app + crud-openapi-net + crud-typescript-angular-client-app + kafka-documentation + named-queries + openapi-documentation + rest-documentation + security-permissions + testdata-builder @@ -26,16 +53,22 @@ - - - src/main/templates - src/main/templates - - - src/main/resources - - + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + ${skip.deployment} + + org.apache.maven.plugins maven-resources-plugin @@ -67,6 +100,13 @@ org.apache.maven.plugins maven-antrun-plugin + + + ant-contrib + ant-contrib + 20020829 + + prepare-package @@ -76,7 +116,29 @@ Integrate flattened POM manually - + + + + + + + + + + + + + + + + + + + + </project> + + + @@ -84,4 +146,44 @@ - + + + + + attach-artifacts + + + src/main/resources/template-set.xml + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.3.0 + + + attach-artifacts + package + + attach-artifact + + + + + src\main\resources\template-set.xml + xml + template-set + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-templates/pom_patch.xml b/cobigen-templates/pom_patch.xml new file mode 100644 index 0000000000..1dc364a9cb --- /dev/null +++ b/cobigen-templates/pom_patch.xml @@ -0,0 +1,4 @@ + + {maven.compiler.source} + {maven.compiler.source} + diff --git a/cobigen-templates/rest-documentation/pom.xml b/cobigen-templates/rest-documentation/pom.xml new file mode 100644 index 0000000000..6d2c790050 --- /dev/null +++ b/cobigen-templates/rest-documentation/pom.xml @@ -0,0 +1,24 @@ + + 4.0.0 + rest-documentation + REST Documentation template + + + com.devonfw.cobigen.templates + templates-parent + ${revision} + + + + + javax.ws.rs + javax.ws.rs-api + 2.0 + + + com.fasterxml.jackson.core + jackson-databind + + + \ No newline at end of file diff --git a/cobigen-templates/rest-documentation/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/JavaDocumentationUtil.java b/cobigen-templates/rest-documentation/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/JavaDocumentationUtil.java new file mode 100644 index 0000000000..8832368645 --- /dev/null +++ b/cobigen-templates/rest-documentation/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/documentation/JavaDocumentationUtil.java @@ -0,0 +1,346 @@ +package com.devonfw.cobigen.templates.devon4j.utils.documentation; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.annotation.Annotation; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +/** + * + */ +public class JavaDocumentationUtil { + + /** Full qualified name of spring RequestMapping annotation */ + private final String requestMapping = "org_springframework_web_bind_annotation_RequestMapping"; + + /** Full qualified name of javax Path annotation */ + private final String javaxPath = "javax_ws_rs_Path"; + + /** + * Creates a list of parameters of a specific method as an asciidoc string, including its name, type, description, + * constraints + * + * @param pojoClass {@link Class}<?> the class object of the pojo + * @param methodName {@link String} the name of the method to get the parameter info of + * @param javaDoc the javadoc of the method, taken from the javaplugin model + * @return A list of the parameters info in asciidoc code + * @throws Exception When errors occur in invoking an annotations method + */ + public String getParams(Class pojoClass, String methodName, Map javaDoc) throws Exception { + + String result = ""; + Method m = findMethod(pojoClass, methodName); + if (m.getParameterCount() < 1) { + return "!-!-!-!-"; + } + if (m.getParameterCount() == 1) { + if (!m.getParameters()[0].getType().isPrimitive()) { + return "!-!-!-!-"; + } + } + for (Parameter param : m.getParameters()) { + // Add the name of the parameter as path or query parameter + boolean isPath = param.isAnnotationPresent(javax.ws.rs.PathParam.class); + boolean isQuery = param.isAnnotationPresent(javax.ws.rs.QueryParam.class); + if (isPath || isQuery) { + result += "!"; + if (isPath) { + result += "{" + param.getAnnotation(javax.ws.rs.PathParam.class).value() + "}" + System.lineSeparator(); + } else if (isQuery) { + result += "?" + param.getAnnotation(javax.ws.rs.QueryParam.class).value() + System.lineSeparator(); + } + + // Add the type + String type = param.getType().getSimpleName(); + result += "!" + type + System.lineSeparator(); + + // Add the constraints + result += "!"; + int counter = 0; + for (Annotation anno : param.getAnnotations()) { + String annoName = anno.annotationType().getName(); + Pattern p = Pattern.compile("javax\\.validation\\.constraints\\.([^\\.]*)"); + Matcher match = p.matcher(annoName); + if (match.find()) { + counter++; + String shortName = annoName.substring(annoName.lastIndexOf('.') + 1); + Object value; + Method method; + try { + method = anno.getClass().getMethod("value"); + value = method.invoke(anno); + result += shortName + " = " + value + " +" + System.lineSeparator(); + } catch (NoSuchMethodException e) { + result += shortName + " +" + System.lineSeparator(); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException + | SecurityException e) { + throw new Exception(e.getMessage()); + } + } + } + if (counter == 0) { + result += "-" + System.lineSeparator(); + } + + // Add Javadoc + Map params = (Map) javaDoc.get("params"); + result += "!" + getJavaDocWithoutLink(params.get(param.getName())) + " +" + System.lineSeparator(); + } + } + return result; + } + + /** + * returns the javadoc of an element, stripped of any links to other sources + * + * @param doc the javadoc to be changed + * @return the input string stripped of all links + */ + public String getJavaDocWithoutLink(String doc) { + + Pattern p = Pattern.compile("(\\{@link ([^\\}]*)\\})"); + Matcher m = p.matcher(doc); + while (m.find()) { + doc = doc.replace(m.group(1), m.group(2)); + } + return doc; + } + + /** + * Create a response in JSON format, iterating through non-primitive types to get their data as well + * + * @param pojoClass The input class + * @param methodName The name of the operation to get the response of + * @return A JSON representation of the response object + * @throws Exception When Jackson fails + */ + public String getJSONResponseBody(Class pojoClass, String methodName) throws Exception { + + Class responseType = findMethod(pojoClass, methodName).getReturnType(); + if (hasBody(pojoClass, methodName, true)) { + return getJSON(responseType); + } + return "-"; + } + + /** + * Create a request in JSON format, iterating through non-primitive types to get their data as well + * + * @param pojoClass The input class + * @param methodName The name of the operation to get the request of + * @return A JSON representation of the request object + * @throws Exception When Jackson fails + */ + public String getJSONRequestBody(Class pojoClass, String methodName) throws Exception { + + Method m = findMethod(pojoClass, methodName); + if (hasBody(pojoClass, methodName, false)) { + Parameter param = m.getParameters()[0]; + Class requestType = param.getType(); + return getJSON(requestType); + } + return "-"; + } + + /** + * Using Jackson, creates a JSON string for Asciidoc + * + * @param clazz The class to create the JSON string of + * @return A JSON representation of the given class + * @throws Exception When Jackson fails + */ + public String getJSON(Class clazz) throws Exception { + + ObjectMapper mapper = new ObjectMapper(); + mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); + mapper.enable(SerializationFeature.INDENT_OUTPUT); + try { + Object obj = clazz.newInstance(); + return "...." + System.lineSeparator() + mapper.writeValueAsString(obj) + System.lineSeparator() + "...."; + } catch (InstantiationException | IllegalAccessException | JsonProcessingException e) { + throw new Exception(e.getMessage()); + } + } + + /** + * Checks if a request/response has a body + * + * @param pojoClass {@link Class}<?> the class object of the pojo + * @param methodName The name of the operation to be checked + * @param isResponse true if the response of the operation should be checked, false if the request should be checked + * @return true if the response/request has a body, false if not + * @throws SecurityException If no method of the given name can be found + */ + public boolean hasBody(Class pojoClass, String methodName, boolean isResponse) throws SecurityException { + + Method m = findMethod(pojoClass, methodName); + if (isResponse) { + Class returnType = m.getReturnType(); + if (!returnType.isPrimitive() && !returnType.equals(Void.TYPE)) { + return true; + } + } else { + int nr = 0; + int position = 0; + for (Parameter param : m.getParameters()) { + if (!param.isAnnotationPresent(javax.ws.rs.PathParam.class) + && !param.isAnnotationPresent(javax.ws.rs.QueryParam.class)) { + nr++; + position = Integer.parseInt(param.getName().replace("arg", "")); + } + } + if (nr == 1) { + Parameter param = m.getParameters()[position]; + Class requestType = param.getType(); + if (!requestType.isPrimitive() && !requestType.equals(Void.TYPE) + && !param.isAnnotationPresent(javax.ws.rs.PathParam.class) + && !param.isAnnotationPresent(javax.ws.rs.QueryParam.class)) { + return true; + } + } + } + return false; + } + + /** + * returns the HTTP request type corresponding to an annotation type + * + * @param annotations The annotation to get the type name of + * @return the HTTP request type name of the selected annotation + */ + public String getRequestType(Map annotations) { + + String type = ""; + if (annotations.containsKey(this.requestMapping)) { + Map method = (Map) annotations.get(this.requestMapping); + String rm = (String) method.get("method"); + type = rm.toLowerCase(); + } + if (annotations.containsKey("javax_ws_rs_GET") || type.equals("requestmethod.get")) { + return "GET"; + } else if (annotations.containsKey("javax_ws_rs_PUT") || type.equals("requestmethod.put")) { + return "PUT"; + } else if (annotations.containsKey("javax_ws_rs_POST") || type.equals("requestmethod.post")) { + return "POST"; + } else if (annotations.containsKey("javax_ws_rs_DELETE") || type.equals("requestmethod.delete")) { + return "DELETE"; + } else if (annotations.containsKey("javax_ws_rs_PATCH") || type.equals("requestmethod.patch")) { + return "PATCH"; + } else { + return "-"; + } + } + + /** + * Gets the path of an operation + * + * @param pojoAnnotations the annotation map of the given pojo + * @param method The method to get the operation path of + * @return The path of an operation + * @throws IOException If no application_properties file is found + */ + public String getOperationPath(Map pojoAnnotations, Map method) throws IOException { + + String path = getPath(pojoAnnotations); + Map pathAnno = new HashMap<>(); + if (pojoAnnotations.containsKey(this.javaxPath)) { + pathAnno = (Map) pojoAnnotations.get(this.javaxPath); + } else if (pojoAnnotations.containsKey(this.requestMapping)) { + pathAnno = (Map) pojoAnnotations.get(this.requestMapping); + } + if (pathAnno.containsKey("value")) { + String toAdd = (String) pathAnno.get("value"); + if (toAdd.startsWith("/") && path.endsWith("/")) { + path += toAdd.substring(1); + } + } + return path; + } + + /** + * Gets the path of a component + * + * @param pojoAnnotations the annotation map of the given pojo + * @return The communal path of a component + * @throws IOException If no application_properties file is found + */ + public String getPath(Map pojoAnnotations) throws IOException { + + String path = extractRootPath(); + Map pathAnno = new HashMap<>(); + if (pojoAnnotations.containsKey(this.javaxPath)) { + pathAnno = (Map) pojoAnnotations.get(this.javaxPath); + } else if (pojoAnnotations.containsKey(this.requestMapping)) { + pathAnno = (Map) pojoAnnotations.get(this.requestMapping); + } + if (pathAnno.containsKey("value")) { + String toAdd = (String) pathAnno.get("value"); + if (toAdd.startsWith("/") && path.endsWith(":")) { + path += toAdd.substring(1); + } + } + return path; + } + + /** + * Checks the class path for an application.properties file and extracts the port and path from it + * + * @return The root path of the application + * @throws IOException If no application.properties file could be found + */ + private String extractRootPath() throws IOException { + + Class clazz = this.getClass(); + String t = ""; + StringBuilder sb = new StringBuilder("http://localhost:"); + try (InputStream in = clazz.getClassLoader().getResourceAsStream("application.properties")) { + if (in != null) { + try (InputStreamReader reader = new InputStreamReader(in); BufferedReader br = new BufferedReader(reader)) { + while ((t = br.readLine()) != null) { + if (t.matches("server\\.port=(\\d{0,5})") || t.matches("server\\.context-path=([^\\s]*)")) { + sb.append(t.substring(t.indexOf('=') + 1)); + } + } + return sb.toString(); + } + } else { + return ""; + } + } + } + + /** + * Helper method to find a class's specific method + * + * @param pojoClass {@link Class}<?> the class object of the pojo + * @param methodName The name of the method to be found + * @return The method object of the method to be found, null if it wasn't found + */ + private Method findMethod(Class pojoClass, String methodName) { + + if (pojoClass == null) { + throw new IllegalAccessError( + "Class object is null. Cannot generate template as it might obviously depend on reflection."); + } + for (Method m : pojoClass.getMethods()) { + if (m.getName().equals(methodName)) { + return m; + } + } + return null; + } +} diff --git a/cobigen-templates/rest-documentation/src/main/resources/template-set.xml b/cobigen-templates/rest-documentation/src/main/resources/template-set.xml new file mode 100644 index 0000000000..650bd46afc --- /dev/null +++ b/cobigen-templates/rest-documentation/src/main/resources/template-set.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/templates/rest_documentation/templates/docs/${variables.component}RESTInterfaces.adoc.ftl b/cobigen-templates/rest-documentation/src/main/resources/templates/docs/${variables.component}RESTInterfaces.adoc.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/rest_documentation/templates/docs/${variables.component}RESTInterfaces.adoc.ftl rename to cobigen-templates/rest-documentation/src/main/resources/templates/docs/${variables.component}RESTInterfaces.adoc.ftl diff --git a/cobigen-templates/templates-devon4j/src/main/templates/rest_documentation/templates/docs/Documentation.adoc.ftl b/cobigen-templates/rest-documentation/src/main/resources/templates/docs/Documentation.adoc.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/rest_documentation/templates/docs/Documentation.adoc.ftl rename to cobigen-templates/rest-documentation/src/main/resources/templates/docs/Documentation.adoc.ftl diff --git a/cobigen-templates/security-permissions/pom.xml b/cobigen-templates/security-permissions/pom.xml new file mode 100644 index 0000000000..f9e305af34 --- /dev/null +++ b/cobigen-templates/security-permissions/pom.xml @@ -0,0 +1,13 @@ + + 4.0.0 + security-permissions + Security permissions template + + + com.devonfw.cobigen.templates + templates-parent + ${revision} + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/templates/security_permissions/PermissionConstants.java.ftl b/cobigen-templates/security-permissions/src/main/resources/PermissionConstants.java.ftl similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/templates/security_permissions/PermissionConstants.java.ftl rename to cobigen-templates/security-permissions/src/main/resources/PermissionConstants.java.ftl diff --git a/cobigen-templates/security-permissions/src/main/resources/template-set.xml b/cobigen-templates/security-permissions/src/main/resources/template-set.xml new file mode 100644 index 0000000000..ca925563ef --- /dev/null +++ b/cobigen-templates/security-permissions/src/main/resources/template-set.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/logback.xml b/cobigen-templates/templates-devon4j-tests/logback.xml similarity index 100% rename from cobigen-templates/templates-devon4j/logback.xml rename to cobigen-templates/templates-devon4j-tests/logback.xml diff --git a/cobigen-templates/templates-devon4j-tests/pom.xml b/cobigen-templates/templates-devon4j-tests/pom.xml new file mode 100644 index 0000000000..1eec2470e9 --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/pom.xml @@ -0,0 +1,57 @@ + + + 4.0.0 + templates-devon4j-tests + CobiGen - devon4j Templates Tests + + + com.devonfw.cobigen.templates + templates-parent + ${revision} + + + + false + 1.8 + 1.8 + + + + + javax.ws.rs + javax.ws.rs-api + 2.0 + + + org.springframework.data + spring-data-rest-webmvc + 3.7.10 + + + org.apache.commons + commons-lang3 + + + com.fasterxml.jackson.core + jackson-databind + + + xerces + xercesImpl + 2.12.2 + + + javax.persistence + javax.persistence-api + 2.2 + + + org.assertj + assertj-core + 3.10.0 + test + + + + diff --git a/cobigen-templates/templates-devon4j-tests/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java b/cobigen-templates/templates-devon4j-tests/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java new file mode 100644 index 0000000000..395d46154d --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/main/java-templates/com/devonfw/cobigen/templates/devon4j/config/constant/MavenMetadata.java @@ -0,0 +1,12 @@ +package com.devonfw.cobigen.templates.devon4j.config.constant; + +/** + * Constants extracted from the maven pom by templating-maven-plugin. + * + * @see "edit template in src/main/java-templates" + */ +public class MavenMetadata { + + /** Local repository path */ + public static final String LOCAL_REPO = "${settings.localRepository}"; +} diff --git a/cobigen-templates/templates-devon4j/src/main/resources/META-INF/LICENSE.txt b/cobigen-templates/templates-devon4j-tests/src/main/resources/META-INF/LICENSE.txt similarity index 100% rename from cobigen-templates/templates-devon4j/src/main/resources/META-INF/LICENSE.txt rename to cobigen-templates/templates-devon4j-tests/src/main/resources/META-INF/LICENSE.txt diff --git a/cobigen-templates/templates-devon4j/src/main/templates/named_queries/context.xml b/cobigen-templates/templates-devon4j-tests/src/main/templates/named_queries/context.xml similarity index 54% rename from cobigen-templates/templates-devon4j/src/main/templates/named_queries/context.xml rename to cobigen-templates/templates-devon4j-tests/src/main/templates/named_queries/context.xml index a3365447d6..e0aa1ee404 100644 --- a/cobigen-templates/templates-devon4j/src/main/templates/named_queries/context.xml +++ b/cobigen-templates/templates-devon4j-tests/src/main/templates/named_queries/context.xml @@ -1,8 +1,11 @@ - + - + - + + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j/src/main/templates/security_permissions/context.xml b/cobigen-templates/templates-devon4j-tests/src/main/templates/security_permissions/context.xml similarity index 59% rename from cobigen-templates/templates-devon4j/src/main/templates/security_permissions/context.xml rename to cobigen-templates/templates-devon4j-tests/src/main/templates/security_permissions/context.xml index def83023b0..930ad79991 100644 --- a/cobigen-templates/templates-devon4j/src/main/templates/security_permissions/context.xml +++ b/cobigen-templates/templates-devon4j-tests/src/main/templates/security_permissions/context.xml @@ -1,8 +1,11 @@ - + - + - + + + + \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j-tests/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/TemplatesGenerationTest.java b/cobigen-templates/templates-devon4j-tests/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/TemplatesGenerationTest.java new file mode 100644 index 0000000000..cc868fd0ce --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/test/java/com/devonfw/cobigen/templates/devon4j/test/templates/TemplatesGenerationTest.java @@ -0,0 +1,181 @@ +package com.devonfw.cobigen.templates.devon4j.test.templates; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +import org.apache.commons.io.FileUtils; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.devonfw.cobigen.api.constants.ConfigurationConstants; +import com.devonfw.cobigen.maven.test.AbstractMavenTest; +import com.devonfw.cobigen.templates.devon4j.config.constant.MavenMetadata; + +/** + * Smoke tests of all templates. + */ +@Ignore +public class TemplatesGenerationTest extends AbstractMavenTest { + + /** Root of all test resources of this test suite */ + public static final String TEST_RESOURCES_ROOT = "src/test/resources/testdata/templatetest/"; + + /** Temporary files rule to create temporary folders */ + @ClassRule + public static TemporaryFolder tempFolder = new TemporaryFolder(); + + /** The templates development folder */ + protected static Path templatesProject; + + /** The templates development folder */ + protected static Path templatesProjectTemporary; + + /** + * Creates a copy of the templates project in the temp directory + * + * @throws URISyntaxException if the path could not be created properly + * @throws IOException if accessing a directory or file fails + */ + @BeforeClass + public static void setupDevTemplates() throws URISyntaxException, IOException { + + templatesProject = new File( + TemplatesGenerationTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile() + .getParentFile().getParentFile().toPath(); + + Path utilsPom = new File(TemplatesGenerationTest.class.getProtectionDomain().getCodeSource().getLocation().toURI()) + .getParentFile().getParentFile().toPath().resolve("src/test/resources/utils/pom.xml"); + + // create a temporary directory cobigen-templates/template-sets/adapted containing the template sets + Path tempFolderPath = tempFolder.getRoot().toPath(); + Path cobigenTemplatePath = tempFolderPath.resolve("cobigen-templates"); + if (!Files.exists(cobigenTemplatePath)) { + Files.createDirectory(cobigenTemplatePath); + + templatesProjectTemporary = cobigenTemplatePath.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER); + Path templateSetsAdaptedFolder = templatesProjectTemporary.resolve(ConfigurationConstants.ADAPTED_FOLDER); + Files.createDirectory(templatesProjectTemporary); + Files.createDirectory(templateSetsAdaptedFolder); + + FileUtils.copyDirectory(templatesProject.toFile(), templateSetsAdaptedFolder.toFile()); + + List devTemplateSets = new ArrayList<>(); + try (Stream files = Files.list(templateSetsAdaptedFolder)) { + files.forEach(path -> { + devTemplateSets.add(path); + }); + } + + for (Path path : devTemplateSets) { + if (Files.isDirectory(path)) { + Path resourcesFolder = path.resolve("src/main/resources"); + Path templatesFolder = path.resolve(ConfigurationConstants.TEMPLATE_RESOURCE_FOLDER); + if (Files.exists(resourcesFolder) && !Files.exists(templatesFolder)) { + try { + Files.move(resourcesFolder, templatesFolder); + } catch (IOException e) { + throw new IOException("Error moving directory " + resourcesFolder, e); + } + } + + // Replace the pom.xml in the template sets. Needed so that the project in the temp directory is build + // properly + if (Files.exists(path.resolve("pom.xml"))) { + try { + Files.delete(path.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error deleting file " + path.resolve("pom.xml"), e); + } + try { + Files.copy(utilsPom, path.resolve("pom.xml")); + } catch (IOException e) { + throw new IOException("Error copying file " + utilsPom, e); + } + } + } + } + } + } + + /** + * Test successful generation of all templates based on an entity + * + * @throws Exception test fails + */ + @Test + public void testAllTemplatesGeneration_EntityInput() throws Exception { + + File testProject = new File(TEST_RESOURCES_ROOT + "TestAllTemplatesEntityInput/"); + runMavenInvoker(testProject, templatesProjectTemporary.toFile(), MavenMetadata.LOCAL_REPO); + } + + /** + * Test successful generation of all templates based on an ETO + * + * @throws Exception test fails + */ + @Test + public void testAllTemplatesGeneration_EtoInput() throws Exception { + + File testProject = new File(TEST_RESOURCES_ROOT + "TestAllTemplatesEtoInput/"); + runMavenInvoker(testProject, templatesProjectTemporary.toFile(), MavenMetadata.LOCAL_REPO); + } + + /** + * Test successful generation of all templates based on an ETO + * + * @throws Exception test fails + */ + @Test + public void testAllTemplatesGeneration_OpenApiInput() throws Exception { + + File testProject = new File(TEST_RESOURCES_ROOT + "TestAllTemplatesOpenApiInput/"); + runMavenInvoker(testProject, templatesProjectTemporary.toFile(), MavenMetadata.LOCAL_REPO); + } + + /** + * Test successful generation of all templates based on a RestService + * + * @throws Exception test fails + */ + @Test + public void testAllTemplatesGeneration_RestServiceInput() throws Exception { + + File testProject = new File(TEST_RESOURCES_ROOT + "TestAllTemplatesRestServiceInput/"); + runMavenInvoker(testProject, templatesProjectTemporary.toFile(), MavenMetadata.LOCAL_REPO); + } + + /** + * Test successful generation of all templates based on a TO + * + * @throws Exception test fails + */ + @Test + public void testAllTemplatesGeneration_ToInput() throws Exception { + + File testProject = new File(TEST_RESOURCES_ROOT + "TestAllTemplatesToInput/"); + runMavenInvoker(testProject, templatesProjectTemporary.toFile(), MavenMetadata.LOCAL_REPO); + } + + /** + * Test successful generation of all templates based on a + * + * @throws Exception test fails + */ + @Test + public void testAllTemplatesGeneration_XML() throws Exception { + + File testProject = new File(TEST_RESOURCES_ROOT + "TestAllTemplatesXMLInput/"); + runMavenInvoker(testProject, templatesProjectTemporary.toFile(), MavenMetadata.LOCAL_REPO); + } + +} diff --git a/cobigen-templates/templates-devon4j-tests/src/test/resources/application.properties b/cobigen-templates/templates-devon4j-tests/src/test/resources/application.properties new file mode 100644 index 0000000000..cf2c614efb --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/test/resources/application.properties @@ -0,0 +1,2 @@ +server.port=8080 +server.context-path=/ \ No newline at end of file diff --git a/cobigen-templates/templates-devon4j-tests/src/test/resources/logback.xml b/cobigen-templates/templates-devon4j-tests/src/test/resources/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/test/resources/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml new file mode 100644 index 0000000000..530ec2a8c0 --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/pom.xml @@ -0,0 +1,68 @@ + + 4.0.0 + com.devonfw.cobigen + devon4jTemplateTest-TestAllTemplatesEntityInput + dev-SNAPSHOT + + + 1.8 + 1.8 + + + + + + com.devonfw.cobigen + cobigen-maven-plugin + ${pluginVersion} + + + generate + package + + generate + + + + + ${templatesProject} + + src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java + + + + + true + + + + com.devonfw.cobigen + tempeng-freemarker + ${pluginVersion} + + + com.devonfw.cobigen + javaplugin + ${pluginVersion} + + + com.devonfw.cobigen + xmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + openapiplugin + ${pluginVersion} + + + com.devonfw.cobigen + tsplugin + ${pluginVersion} + + + + + + diff --git a/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java new file mode 100644 index 0000000000..e2d76c7c9f --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEntityInput/src/main/java/io/github/devonfw/cobigen/generator/dataaccess/api/InputEntity.java @@ -0,0 +1,25 @@ +package io.github.devonfw.cobigen.generator.dataaccess.api; + +public class InputEntity { + + private String input; + + private int complexity; + + public String getInput() { + return input; + } + + public void setInput(String input) { + this.input = input; + } + + public int getComplexity() { + return complexity; + } + + public void setComplexity(int complexity) { + this.complexity = complexity; + } + +} diff --git a/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/logback.xml b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/pom.xml b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/pom.xml new file mode 100644 index 0000000000..68371aa12b --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/pom.xml @@ -0,0 +1,79 @@ + + 4.0.0 + com.devonfw.cobigen + devon4jTemplateTest-TestAllTemplatesEtoInput + dev-SNAPSHOT + + + 1.8 + 1.8 + + + + + + com.devonfw.cobigen + cobigen-maven-plugin + ${pluginVersion} + + + generate + package + + generate + + + + + ${templatesProject} + + src/main/java/io/github/devonfw/cobigen/generator/logic/api/to/InputEto.java + + + + + true + + + + com.devonfw.cobigen + tempeng-freemarker + ${pluginVersion} + + + com.devonfw.cobigen + javaplugin + ${pluginVersion} + + + com.devonfw.cobigen + xmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + htmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + tsplugin + ${pluginVersion} + + + com.devonfw.cobigen + jsonplugin + ${pluginVersion} + + + com.devonfw.cobigen + openapiplugin + ${pluginVersion} + + + + + + + diff --git a/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/src/main/java/io/github/devonfw/cobigen/generator/logic/api/to/InputEto.java b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/src/main/java/io/github/devonfw/cobigen/generator/logic/api/to/InputEto.java new file mode 100644 index 0000000000..21ad4eeba9 --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesEtoInput/src/main/java/io/github/devonfw/cobigen/generator/logic/api/to/InputEto.java @@ -0,0 +1,25 @@ +package io.github.devonfw.cobigen.generator.logic.api.to; + +public class InputEto { + + private String input; + + private int complexity; + + public String getInput() { + return input; + } + + public void setInput(String input) { + this.input = input; + } + + public int getComplexity() { + return complexity; + } + + public void setComplexity(int complexity) { + this.complexity = complexity; + } + +} diff --git a/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml new file mode 100644 index 0000000000..14b9ec10cf --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/OpenAPI.yaml @@ -0,0 +1,131 @@ +openapi: 3.0.0 +servers: + - url: 'https://localhost:8081/server/services/rest' +info: + title: Devon Example + description: Example of a API definition + version: 1.0.0 + x-rootpackage: com.devonfw.demo +paths: + /datamanagement/v1/someData/{id}: + get: + operationId: findSomeData + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + minimum: 0 + maximum: 50 + responses: + '200': + description: Any + content: + application/json: + schema: + $ref: '#/components/schemas/EvenMoreData' + text/plain: + schema: + type: string + /datamanagement/v1/moreData/{id}: + get: + operationId: findMoreData + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + minimum: 10 + maximum: 200 + responses: + '200': + description: Any + /datamanagement/v1/someData/: + post: + responses: + '200': + description: Any + requestBody: + $ref: '#/components/requestBodies/SomeData' + tags: + - searchCriteria + /datamanagement/v1/moreData/validateMoreData: + post: + responses: + '200': + description: Any + requestBody: + $ref: '#/components/requestBodies/MoreData' +components: + schemas: + SomeData: + x-component: DataManagement + description: Entity definiton of SomeData + type: object + properties: + AnyString: + type: string + maxLength: 100 + minLength: 5 + uniqueItems: true + furtherData: + type: array + items: + $ref: '#/components/schemas/FurtherData' + MoreData: + x-component: DataManagement + description: Entity definiton of Moredata + type: object + properties: + anyNumber: + type: number + format: int64 + maximum: 100 + minimum: 0 + someData: + $ref: '#/components/schemas/SomeData' + allSomeData: + type: array + description: 'All SomeData' + items: + $ref: '#/components/schemas/SomeData' + required: + - saleExample + FurtherData: + x-component: AnotherComponent + type: object + properties: + parent: + $ref: '#/components/schemas/SomeData' + valid: + type: boolean + someList: + type: array + items: + type: string + EvenMoreData: + x-component: AnotherComponent + description: Entity definiton of more data + type: object + properties: + id: + type: integer + format: int64 + uniqueItems: true + requestBodies: + SomeData: + content: + application/json: + schema: + $ref: '#/components/schemas/SomeData' + required: true + MoreData: + content: + application/json: + schema: + $ref: '#/components/schemas/MoreData' + required: true diff --git a/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml new file mode 100644 index 0000000000..5f29165f75 --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml new file mode 100644 index 0000000000..7f84fdeef0 --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesOpenApiInput/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + com.devonfw.cobigen + devon4jTemplateTest-TestAllTemplatesOpenAPIInput + dev-SNAPSHOT + + + 1.8 + 1.8 + + + + + + com.devonfw.cobigen + cobigen-maven-plugin + ${pluginVersion} + + + generate + package + + generate + + + + + ${templatesProject} + + OpenAPI.yaml + + + + + true + + + + com.devonfw.cobigen + tempeng-freemarker + ${pluginVersion} + + + com.devonfw.cobigen + javaplugin + ${pluginVersion} + + + com.devonfw.cobigen + htmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + tsplugin + ${pluginVersion} + + + com.devonfw.cobigen + jsonplugin + ${pluginVersion} + + + com.devonfw.cobigen + openapiplugin + ${pluginVersion} + + + com.devonfw.cobigen + xmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + textmerger + ${pluginVersion} + + + + + + + diff --git a/cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/logback.xml b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/logback.xml similarity index 100% rename from cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/logback.xml rename to cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/logback.xml diff --git a/cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/pom.xml b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/pom.xml similarity index 98% rename from cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/pom.xml rename to cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/pom.xml index 72b7a5d2a6..0e1900e9dd 100644 --- a/cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/pom.xml +++ b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/pom.xml @@ -19,7 +19,7 @@ org.springframework.data spring-data-rest-webmvc - 3.0.9.RELEASE + 3.7.10 diff --git a/cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputNoAnnotationsRestService.java b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputNoAnnotationsRestService.java similarity index 100% rename from cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputNoAnnotationsRestService.java rename to cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputNoAnnotationsRestService.java diff --git a/cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/JavaxAnnotationsInputRestService.java b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/JavaxAnnotationsInputRestService.java similarity index 100% rename from cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/JavaxAnnotationsInputRestService.java rename to cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/JavaxAnnotationsInputRestService.java diff --git a/cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/SpringAnnotationsInputRestService.java b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/SpringAnnotationsInputRestService.java similarity index 100% rename from cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/SpringAnnotationsInputRestService.java rename to cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesRestServiceInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/SpringAnnotationsInputRestService.java diff --git a/cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/logback.xml b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/logback.xml similarity index 100% rename from cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/logback.xml rename to cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/logback.xml diff --git a/cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/pom.xml b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/pom.xml similarity index 100% rename from cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/pom.xml rename to cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/pom.xml diff --git a/cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputNoAnnotationsTo.java b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputNoAnnotationsTo.java similarity index 100% rename from cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputNoAnnotationsTo.java rename to cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputNoAnnotationsTo.java diff --git a/cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputTo.java b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputTo.java similarity index 100% rename from cobigen-templates/templates-devon4j/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputTo.java rename to cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesToInput/src/main/java/io/github/devonfw/cobigen/generator/service/api/rest/InputTo.java diff --git a/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/logback.xml b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/logback.xml new file mode 100644 index 0000000000..29e5047b5f --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/logback.xml @@ -0,0 +1,14 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] [C:%X{correlationId}] - %-5level - %logger{36} - %msg%n + + + + + + + + diff --git a/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/pom.xml b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/pom.xml new file mode 100644 index 0000000000..57252bf691 --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/pom.xml @@ -0,0 +1,73 @@ + + 4.0.0 + com.devonfw + devon4jTemplateTest-TestAllTemplatesXMLInput + dev-SNAPSHOT + + + 1.8 + 1.8 + + + + + + com.devonfw.cobigen + cobigen-maven-plugin + ${pluginVersion} + + + generate + package + + generate + + + + + ${templatesProject} + + src/main/xml/io/github/devonfw/cobigen/generator/dataaccess/api/Input.xml + + + + + true + + + + com.devonfw.cobigen + tempeng-freemarker + ${pluginVersion} + + + com.devonfw.cobigen + javaplugin + ${pluginVersion} + + + com.devonfw.cobigen + xmlplugin + ${pluginVersion} + + + com.devonfw.cobigen + openapiplugin + ${pluginVersion} + + + com.devonfw.cobigen + textmerger + ${pluginVersion} + + + com.devonfw.cobigen + tsplugin + ${pluginVersion} + + + + + + diff --git a/cobigen-templates/templates-devon4j/src/test/resources/testinput/XMI-UML.xml b/cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/src/main/xml/io/github/devonfw/cobigen/generator/dataaccess/api/Input.xml similarity index 100% rename from cobigen-templates/templates-devon4j/src/test/resources/testinput/XMI-UML.xml rename to cobigen-templates/templates-devon4j-tests/src/test/resources/testdata/templatetest/TestAllTemplatesXMLInput/src/main/xml/io/github/devonfw/cobigen/generator/dataaccess/api/Input.xml diff --git a/cobigen-templates/templates-devon4j/src/test/resources/testinput/InputEntity.java b/cobigen-templates/templates-devon4j-tests/src/test/resources/testinput/InputEntity.java similarity index 100% rename from cobigen-templates/templates-devon4j/src/test/resources/testinput/InputEntity.java rename to cobigen-templates/templates-devon4j-tests/src/test/resources/testinput/InputEntity.java diff --git a/cobigen-templates/templates-devon4j-tests/src/test/resources/testinput/XMI-UML.xml b/cobigen-templates/templates-devon4j-tests/src/test/resources/testinput/XMI-UML.xml new file mode 100644 index 0000000000..4073f5c5eb --- /dev/null +++ b/cobigen-templates/templates-devon4j-tests/src/test/resources/testinput/XMI-UML.xml @@ -0,0 +1,391 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +