Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

860 sql files generation #1570

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
cb9e16d
#860 template structure and sql util class
quantumfate Aug 12, 2022
c01b3f2
Refactored Util classes, implemented sql util functions
quantumfate Aug 12, 2022
d560494
removed .classpath from tracking
quantumfate Aug 18, 2022
e0f1759
Helper function mapJavaToSqlType(String canonicalTypeName) implemented
quantumfate Aug 18, 2022
feaca19
Added a function that allows to retrieve annotations
quantumfate Aug 18, 2022
49fa75e
Added a new dependency for SQL specific annotations, almost finished …
quantumfate Aug 18, 2022
609680b
Implemented Varchar, Not Null and Auto Increment annotation
quantumfate Aug 19, 2022
0fc0c2a
Functions for non collections
quantumfate Aug 30, 2022
13df6ad
Implemented Foreign Key Functions and template
quantumfate Sep 21, 2022
9c3cc26
Improved javadoc, implemented mappedby aspect into foreignkey method,…
quantumfate Sep 23, 2022
d6678f4
Implemented getSImpleSQLtype and Primary key methods
quantumfate Sep 23, 2022
d4d3027
Added a default parameter to getForeignKeyData and fixed bug in getFo…
quantumfate Sep 26, 2022
5b05bd6
getForeignKeyStatement and template - added Test class for SQL Util
quantumfate Sep 26, 2022
2acc7a1
Testclass for SQL
quantumfate Sep 26, 2022
a6b1613
Added test classes
quantumfate Sep 27, 2022
97b1c8b
Added test cases and refined getsimplesql statement
quantumfate Oct 7, 2022
90ec972
More tests
quantumfate Oct 7, 2022
4379a54
Implemented utility tests and refined methods
quantumfate Oct 10, 2022
6c70fe1
Primary key method refined and tests implemented
quantumfate Oct 14, 2022
ae8c287
Primary key tests
quantumfate Oct 14, 2022
cb31316
Foreign Key methods
quantumfate Oct 14, 2022
8046981
implemented isFieldEntity
quantumfate Oct 25, 2022
8fcf90e
Merge branch 'master' of github.com:devonfw/cobigen into 860_SQL_file…
quantumfate Oct 28, 2022
08327c6
comments nad pulled upstream master
quantumfate Oct 28, 2022
03dc464
- Added JavaPlugin dependency to template project for testing purposes
Lur1an Nov 7, 2022
dcd7f0a
Finished blueprint for template
Lur1an Nov 7, 2022
7baaebd
Implemented most functionality for template generation. Tests are lac…
Lur1an Nov 8, 2022
59e2da5
Simplified usage of AbstractJavaTemplateTest.
Lur1an Nov 8, 2022
87c7afd
Merge branch 'master' into 860_SQL_files_generation
Lur1an Nov 8, 2022
8e7a6e0
Fixes to Nullable and Unique constraint parsing for @Column and @Join…
Lur1an Nov 8, 2022
8ab95ab
Fixed logic error pertaining @OneToMany and @ManyToOne annotations
Lur1an Nov 9, 2022
b480ef0
#860 Added first tests for sql generation
Zylesto Nov 9, 2022
5008c4e
#860 added more tests, fixed bugs
Zylesto Nov 10, 2022
c7e1879
Implemented parsing of @JoinTable annotation into a separate inline S…
Lur1an Nov 9, 2022
568760b
- Removed some unneccessary Blob/Clob logic
Lur1an Nov 10, 2022
1da70f4
Adressing change-request:
Lur1an Nov 15, 2022
68d01a8
Removed unneccessary comments and added javadoc to test
Lur1an Nov 17, 2022
91e996e
added jdoc to getValue() method in SQLUtil
Lur1an Nov 17, 2022
a4b065f
Adressed change requests
Lur1an Nov 17, 2022
dbe627d
Deleted CommonUtil.java and restored JavaUtil to previous state.
Lur1an Nov 18, 2022
ab2c22b
Merge branch 'master' into 860_SQL_files_generation
jan-vcapgemini Dec 6, 2022
32b5707
Merge branch 'master' into 860_SQL_files_generation
jan-vcapgemini Dec 6, 2022
01ff76f
Merge branch 'master' into 860_SQL_files_generation
Jan 5, 2023
ee312fb
Merge branch 'master' into 860_SQL_files_generation
mdukhan Jan 6, 2023
8cd58da
Merge branch 'master' into 860_SQL_files_generation
mdukhan Jan 9, 2023
ddc8b7e
no message
quantumfate Feb 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cobigen-eclipse/cobigen-eclipse-test/.classpath
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/awaitility.jar" sourcepath="C:/Users/mbrunnli/.m2/repository/org/awaitility/awaitility/4.1.1/awaitility-4.1.1-sources.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hamcrest.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/main/java/">
Expand Down Expand Up @@ -32,5 +30,7 @@
<classpathentry exported="true" kind="lib" path="lib/system-lambda.jar"/>
<classpathentry exported="true" kind="lib" path="lib/xmlunit.jar"/>
<classpathentry exported="true" kind="lib" path="lib/zt-exec.jar"/>
<classpathentry exported="true" kind="lib" path="lib/awaitility.jar" sourcepath="C:/Users/mbrunnli/.m2/repository/org/awaitility/awaitility/4.1.1/awaitility-4.1.1-sources.jar"/>
jan-vcapgemini marked this conversation as resolved.
Show resolved Hide resolved
<classpathentry exported="true" kind="lib" path="lib/hamcrest.jar"/>
<classpathentry kind="output" path="eclipse-target/classes"/>
</classpath>
13 changes: 13 additions & 0 deletions cobigen-templates/sql-openapi-app/context.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<contextConfiguration xmlns="http://capgemini.com/devonfw/cobigen/ContextConfiguration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="3.0">
<trigger id="sql_openapi_app" type="openapi">

</trigger>
<tags>
<tag name="OpenAPI"></tag>
<tag name="SQL"></tag>
<tag name="App"></tag>
</tags>
</contextConfiguration>
jan-vcapgemini marked this conversation as resolved.
Show resolved Hide resolved
Empty file.
1 change: 1 addition & 0 deletions cobigen-templates/templates-devon4j/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.classpath
Lur1an marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions cobigen-templates/templates-devon4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
<version>3.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>3.0.2</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.devonfw.cobigen.templates.devon4j.utils;

import java.lang.reflect.Field;
import java.util.Collection;

import org.apache.commons.lang3.ClassUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* This class provides utility for all objects that inherit from it
*
*/
public class CommonUtil {

/**
* The constructor.
*/
public CommonUtil() {

// Empty for CobiGen to automatically instantiate it
}

/**
* Logger for this class
*/
protected static final Logger LOG = LoggerFactory.getLogger(JavaUtil.class);

/**
* Checks whether the class given by the full qualified name is an enum
*
* @param className full qualified class name
* @return <code>true</code> if the class is an enum, <code>false</code> 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;
}
}

/**
* @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
Lur1an marked this conversation as resolved.
Show resolved Hide resolved
* @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());
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,15 @@
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);
public class JavaUtil extends CommonUtil {

/**
* The constructor.
Expand All @@ -31,7 +23,7 @@ public JavaUtil() {

/**
* 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")
Expand Down Expand Up @@ -215,31 +207,6 @@ public String castJavaPrimitives(Class<?> pojoClass, String fieldName)
}
}

/**
* @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
Lur1an marked this conversation as resolved.
Show resolved Hide resolved
*
Expand Down Expand Up @@ -424,22 +391,6 @@ private Method findMethod(Class<?> pojoClass, String methodName) {
return null;
Zylesto marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Checks whether the class given by the full qualified name is an enum
*
* @param className full qualified class name
* @return <code>true</code> if the class is an enum, <code>false</code> 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
*
Expand Down
Loading