Compare commits
3 Commits
e824feb8a2
...
84a968a426
Author | SHA1 | Date | |
---|---|---|---|
84a968a426 | |||
581c936bec | |||
a6204032b5 |
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>kangaroo-and-rabbit</groupId>
|
||||
<artifactId>archidata</artifactId>
|
||||
<version>0.25.1-SNAPSHOT</version>
|
||||
<version>0.25.3-SNAPSHOT</version>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>gitea</id>
|
||||
|
@ -449,7 +449,7 @@ public class AnnotationTools {
|
||||
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
if (AnnotationTools.getFieldNameRaw(field).equals(name)) {
|
||||
if (field.getName().equals(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -223,16 +223,35 @@ public class DBAccessSQL extends DBAccess {
|
||||
return out;
|
||||
}
|
||||
|
||||
public byte[][] splitIntoGroupsOf12Bytes(final byte[] input) {
|
||||
final int inputLength = input.length;
|
||||
final int numOfGroups = (inputLength + 11) / 12; // Calculate the number of groups needed
|
||||
final byte[][] groups = new byte[numOfGroups][12];
|
||||
|
||||
for (int i = 0; i < numOfGroups; i++) {
|
||||
final int startIndex = i * 12;
|
||||
final int endIndex = Math.min(startIndex + 12, inputLength);
|
||||
groups[i] = Arrays.copyOfRange(input, startIndex, endIndex);
|
||||
}
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
public List<ObjectId> getListOfRawOIDs(final ResultSet rs, final int iii) throws SQLException, DataAccessException {
|
||||
final byte[] trackString = rs.getBytes(iii);
|
||||
if (rs.wasNull()) {
|
||||
return null;
|
||||
}
|
||||
final byte[][] elements = splitIntoGroupsOf16Bytes(trackString);
|
||||
final byte[][] elements = splitIntoGroupsOf12Bytes(trackString);
|
||||
final List<ObjectId> out = new ArrayList<>();
|
||||
for (final byte[] elem : elements) {
|
||||
try {
|
||||
final ObjectId tmp = new ObjectId(elem);
|
||||
out.add(tmp);
|
||||
} catch (final IllegalArgumentException ex) {
|
||||
ex.printStackTrace();
|
||||
LOGGER.error("Fail to parse the OID element: {}", elem);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@ -1276,7 +1295,7 @@ public class DBAccessSQL extends DBAccess {
|
||||
) throws Exception {
|
||||
final boolean readAllfields = QueryOptions.readAllColomn(options);
|
||||
final String tableName = AnnotationTools.getTableName(clazz, options);
|
||||
final String primaryKey = AnnotationTools.getPrimaryKeyField(clazz).getName();
|
||||
final String primaryKey = AnnotationTools.getFieldNameRaw(AnnotationTools.getPrimaryKeyField(clazz));
|
||||
boolean firstField = true;
|
||||
|
||||
for (final Field elem : clazz.getFields()) {
|
||||
|
@ -231,6 +231,7 @@ public class AddOnOneToMany implements DataAccessAddOn {
|
||||
final CountInOut count,
|
||||
final QueryOptions options,
|
||||
final List<LazyGetter> lazyCall) throws Exception {
|
||||
try {
|
||||
if (field.getType() != List.class) {
|
||||
LOGGER.error("Can not OneToMany with other than List Model: {}", field.getType().getCanonicalName());
|
||||
return;
|
||||
@ -258,32 +259,33 @@ public class AddOnOneToMany implements DataAccessAddOn {
|
||||
return;
|
||||
}
|
||||
if (objectClass == decorators.targetEntity()) {
|
||||
final String destinationField = decorators.mappedBy();
|
||||
final Field typeDestination = AnnotationTools.getFieldNamed(objectClass, destinationField);
|
||||
final Class<?> destinationClass = typeDestination.getType();
|
||||
|
||||
Long parentIdTmp = null;
|
||||
UUID parendUuidTmp = null;
|
||||
ObjectId parendOidTmp = null;
|
||||
try {
|
||||
if (destinationClass == String.class) {
|
||||
final String modelData = rs.getString(count.value);
|
||||
parentIdTmp = Long.valueOf(modelData);
|
||||
count.inc();
|
||||
} catch (final NumberFormatException ex) {
|
||||
try {
|
||||
} else if (destinationClass == UUID.class) {
|
||||
final List<UUID> idList = ioDb.getListOfRawUUIDs(rs, count.value);
|
||||
parendUuidTmp = idList.get(0);
|
||||
count.inc();
|
||||
} catch (final NumberFormatException ex2) {
|
||||
// TODO : How to manage ObjectId ==> I am not sure it works well...
|
||||
} else if (destinationClass == ObjectId.class) {
|
||||
final List<ObjectId> idList = ioDb.getListOfRawOIDs(rs, count.value);
|
||||
parendOidTmp = idList.get(0);
|
||||
count.inc();
|
||||
}
|
||||
}
|
||||
final Long parentId = parentIdTmp;
|
||||
final UUID parendUuid = parendUuidTmp;
|
||||
final ObjectId parendOid = parendOidTmp;
|
||||
final String mappingKey = decorators.mappedBy();
|
||||
// We get the parent ID ... ==> need to request the list of elements
|
||||
if (objectClass == Long.class) {
|
||||
LOGGER.error("Need to retreive all primary key of all elements");
|
||||
LOGGER.error("Need to retreive all primary key of all elements.");
|
||||
//field.set(data, idList);
|
||||
return;
|
||||
} else if (objectClass == UUID.class) {
|
||||
@ -335,6 +337,10 @@ public class AddOnOneToMany implements DataAccessAddOn {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
ex.printStackTrace();
|
||||
LOGGER.error("Fail to parse remote {}", ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
0.25.1-dev
|
||||
0.25.3-dev
|
||||
|
Loading…
x
Reference in New Issue
Block a user