Skip to content

Commit 68d9c5a

Browse files
Merge pull request #45 from dynamiatools/5.4.x
UX, DX and performance improvements
2 parents 32d4516 + acd5054 commit 68d9c5a

File tree

30 files changed

+694
-82
lines changed

30 files changed

+694
-82
lines changed

actions/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
<parent>
2424
<groupId>tools.dynamia</groupId>
2525
<artifactId>tools.dynamia.parent</artifactId>
26-
<version>5.4.12</version>
26+
<version>5.4.13</version>
2727
</parent>
2828

2929
<artifactId>tools.dynamia.actions</artifactId>
30-
<version>5.4.12</version>
30+
<version>5.4.13</version>
3131
<name>DynamiaTools - Actions</name>
3232
<url>https://dynamia.tools/docs/actions</url>
3333

@@ -65,12 +65,12 @@
6565
<dependency>
6666
<groupId>tools.dynamia</groupId>
6767
<artifactId>tools.dynamia.integration</artifactId>
68-
<version>5.4.12</version>
68+
<version>5.4.13</version>
6969
</dependency>
7070
<dependency>
7171
<groupId>tools.dynamia</groupId>
7272
<artifactId>tools.dynamia.commons</artifactId>
73-
<version>5.4.12</version>
73+
<version>5.4.13</version>
7474
</dependency>
7575

7676
</dependencies>

app/pom.xml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
<parent>
2424
<groupId>tools.dynamia</groupId>
2525
<artifactId>tools.dynamia.parent</artifactId>
26-
<version>5.4.12</version>
26+
<version>5.4.13</version>
2727
</parent>
2828

2929
<artifactId>tools.dynamia.app</artifactId>
30-
<version>5.4.12</version>
30+
<version>5.4.13</version>
3131
<name>DynamiaTools - App</name>
3232
<url>https://dynamia.tools/docs/app</url>
3333

@@ -74,58 +74,58 @@
7474
<dependency>
7575
<groupId>tools.dynamia</groupId>
7676
<artifactId>tools.dynamia.actions</artifactId>
77-
<version>5.4.12</version>
77+
<version>5.4.13</version>
7878
</dependency>
7979
<dependency>
8080
<groupId>tools.dynamia</groupId>
8181
<artifactId>tools.dynamia.commons</artifactId>
82-
<version>5.4.12</version>
82+
<version>5.4.13</version>
8383
</dependency>
8484
<dependency>
8585
<groupId>tools.dynamia</groupId>
8686
<artifactId>tools.dynamia.crud</artifactId>
87-
<version>5.4.12</version>
87+
<version>5.4.13</version>
8888
</dependency>
8989
<dependency>
9090
<groupId>tools.dynamia</groupId>
9191
<artifactId>tools.dynamia.domain</artifactId>
92-
<version>5.4.12</version>
92+
<version>5.4.13</version>
9393
</dependency>
9494
<dependency>
9595
<groupId>tools.dynamia</groupId>
9696
<artifactId>tools.dynamia.integration</artifactId>
97-
<version>5.4.12</version>
97+
<version>5.4.13</version>
9898
</dependency>
9999
<dependency>
100100
<groupId>tools.dynamia</groupId>
101101
<artifactId>tools.dynamia.io</artifactId>
102-
<version>5.4.12</version>
102+
<version>5.4.13</version>
103103
</dependency>
104104
<dependency>
105105
<groupId>tools.dynamia</groupId>
106106
<artifactId>tools.dynamia.navigation</artifactId>
107-
<version>5.4.12</version>
107+
<version>5.4.13</version>
108108
</dependency>
109109
<dependency>
110110
<groupId>tools.dynamia</groupId>
111111
<artifactId>tools.dynamia.reports</artifactId>
112-
<version>5.4.12</version>
112+
<version>5.4.13</version>
113113
</dependency>
114114
<dependency>
115115
<groupId>tools.dynamia</groupId>
116116
<artifactId>tools.dynamia.templates</artifactId>
117-
<version>5.4.12</version>
117+
<version>5.4.13</version>
118118
</dependency>
119119

120120
<dependency>
121121
<groupId>tools.dynamia</groupId>
122122
<artifactId>tools.dynamia.viewers</artifactId>
123-
<version>5.4.12</version>
123+
<version>5.4.13</version>
124124
</dependency>
125125
<dependency>
126126
<groupId>tools.dynamia</groupId>
127127
<artifactId>tools.dynamia.web</artifactId>
128-
<version>5.4.12</version>
128+
<version>5.4.13</version>
129129
</dependency>
130130
<dependency>
131131
<groupId>org.springframework.data</groupId>
@@ -208,7 +208,7 @@
208208
<dependency>
209209
<groupId>tools.dynamia</groupId>
210210
<artifactId>tools.dynamia.domain.jpa</artifactId>
211-
<version>5.4.12</version>
211+
<version>5.4.13</version>
212212
<scope>test</scope>
213213
</dependency>
214214
<dependency>

commons/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<parent>
2626
<groupId>tools.dynamia</groupId>
2727
<artifactId>tools.dynamia.parent</artifactId>
28-
<version>5.4.12</version>
28+
<version>5.4.13</version>
2929
</parent>
3030
<name>DynamiaTools - Commons</name>
3131
<url>https://dynamia.tools/docs/common</url>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package tools.dynamia.commons;
2+
3+
import java.lang.annotation.*;
4+
5+
/**
6+
* Represents one or more semantic aliases for a class or field.
7+
* Aliases can be used for DTO generation, external mapping,
8+
* multi-locale naming, versioning, or backward compatibility.
9+
*/
10+
@Retention(RetentionPolicy.RUNTIME)
11+
@Target({ElementType.TYPE, ElementType.FIELD})
12+
@Repeatable(AliasSet.class)
13+
public @interface Alias {
14+
15+
/**
16+
* Primary alias values for the resource.
17+
* Multiple values are allowed because different contexts
18+
* may treat them as "main names".
19+
*/
20+
String[] value();
21+
22+
23+
/**
24+
* Intended usage or semantic scope of the alias.
25+
* Examples: "dto", "external", "legacy", "csv", "graphql", "pos", "erp"
26+
*/
27+
String scope() default "default";
28+
29+
/**
30+
* Locale for this alias, following BCP 47 style.
31+
* Examples: "en_US", "es_CO", "pt_BR"
32+
*/
33+
String locale() default "";
34+
35+
/**
36+
* Version of the alias, useful for API evolution.
37+
* Example: "v1", "v2".
38+
*/
39+
String version() default "";
40+
41+
/**
42+
* Priority ordering for conflict resolution.
43+
* Higher values override lower ones.
44+
*/
45+
int priority() default 0;
46+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package tools.dynamia.commons;
2+
3+
import tools.dynamia.commons.reflect.PropertyInfo;
4+
5+
/**
6+
* Maps properties between two beans based on their aliases.
7+
*/
8+
public class AliasBeanMapper {
9+
10+
/**
11+
* Maps properties from the source object to the target object
12+
* based on matching aliases within the specified scope.
13+
*
14+
* @param source the source object to map from
15+
* @param target the target object to map to
16+
* @param scope the scope to consider when resolving aliases
17+
*/
18+
public static void map(Object source, Object target, String scope) {
19+
var sourceProps = PropertyInfo.getProperties(source.getClass());
20+
var targetProps = PropertyInfo.getProperties(target.getClass());
21+
22+
for (var sourceProp : sourceProps) {
23+
String sourceAlias = resolvePropertyAlias(source.getClass(), sourceProp.getName(), scope);
24+
if (sourceAlias != null) {
25+
for (var targetProp : targetProps) {
26+
String targetAlias = resolvePropertyAlias(target.getClass(), targetProp.getName(), scope);
27+
if (sourceAlias.equals(targetAlias) && sourceProp.getType().equals(targetProp.getType())) {
28+
Object value = sourceProp.getValue(source);
29+
targetProp.setValue(target, value);
30+
break;
31+
}
32+
}
33+
}
34+
}
35+
}
36+
37+
/**
38+
* Resolves the alias for a property of a given type within a specified scope.
39+
*
40+
* @param type the class containing the property
41+
* @param propertyName the name of the property
42+
* @param scope the scope to consider when resolving the alias
43+
* @return the resolved alias or the original property name if no alias is found
44+
*/
45+
private static String resolvePropertyAlias(Class<?> type, String propertyName, String scope) {
46+
try {
47+
var field = type.getDeclaredField(propertyName);
48+
return AliasResolver.resolve(field, scope, null);
49+
} catch (NoSuchFieldException e) {
50+
return propertyName;
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)