Skip to content

Commit

Permalink
#252 Partial changes to some legacy UUIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
unaibrrgn committed Apr 16, 2024
1 parent 41ce0d2 commit 8827caa
Showing 1 changed file with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import eu.europa.ec.re3gistry2.model.RegLocalization;
import eu.europa.ec.re3gistry2.model.uuidhandlers.RegFieldmappingUuidHelper;
import eu.europa.ec.re3gistry2.model.uuidhandlers.RegItemUuidHelper;
import eu.europa.ec.re3gistry2.model.uuidhandlers.RegItemclassUuidHelper;
import eu.europa.ec.re3gistry2.model.uuidhandlers.RegItemhistoryUuidHelper;
import eu.europa.ec.re3gistry2.model.uuidhandlers.RegLocalizationUuidHelper;
import java.text.MessageFormat;
Expand Down Expand Up @@ -468,22 +469,29 @@ private RegItem getRegItemFromItem(Item item) throws Exception {
RegItemclassManager regItemclassManager = new RegItemclassManager(entityManagerRe3gistry2);

RegItemclass regItemclass = regItemclassManager.getByLocalid(item.getItemclass().getUriname());


String legacyuuid = null;
String uuid = null;
String localid = item.getUriname();
// try {
// if (collection == null) {
// uuid = RegItemUuidHelper.getUuid(localid, null, regItemclass);
// } else {
// uuid = RegItemUuidHelper.getUuid(localid, regItemManager.getByLocalidAndRegItemClass(collection.getUriname(), regItemclassManager.getByLocalid(collection.getItemclass().getUriname())), regItemclass);
// }
// } catch (Exception ex) {
// uuid = RegItemUuidHelper.getUuid(localid, null, regItemclass);
// }
uuid = item.getUuid();

regItem = regItemManager.get(uuid);
try {
if (collection == null) {
uuid = RegItemUuidHelper.getUuid(localid, null, regItemclass);
} else {
uuid = RegItemUuidHelper.getUuid(localid, regItemManager.getByLocalidAndRegItemClass(collection.getUriname(), regItemclassManager.getByLocalid(collection.getItemclass().getUriname())), regItemclass);
}
} catch (Exception ex) {
uuid = RegItemUuidHelper.getUuid(localid, null, regItemclass);
}

legacyuuid = item.getUuid();
if(legacyuuid.length() != 32){
regItem = regItemManager.get(legacyuuid);
regItem.setUuid(uuid);
regItemManager.update(regItem);
}else{
regItem = regItemManager.get(uuid);
}

} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
throw new Exception(ex.getMessage());
Expand Down Expand Up @@ -556,17 +564,22 @@ private Item getCollectionFromItem(Item item) {

private RegItemclass addRegItemClassByItemclass(Itemclass itemclass, int procedureorder, RegItemclasstype regItemclasstypeItem, boolean commit) throws Exception {
RegItemclass regItemclass = new RegItemclass();

RegItemclassManager regItemclassManager = new RegItemclassManager(entityManagerRe3gistry2);
regItemclass.setUuid(UuidHelper.createUuid(itemclass.getUriname(), RegItemclass.class));
regItemclass.setUuid(itemclass.getUuid());
regItemclass.setLocalid(itemclass.getUriname());


if(regItemclass.getUuid().length() != 32){
regItemclass.setUuid(RegItemclassUuidHelper.getUuid(regItemclass.getLocalid(), regItemclass.getRegItemclassParent().getLocalid(), regItemclass.getRegItemclasstype()));
regItemclassManager.update(regItemclass);
}


if (itemclass.getParent() != null) {
RegItemclassManager regItemclassManager = new RegItemclassManager(entityManagerRe3gistry2);
RegItemclass regItemclassParent = regItemclassManager.getByLocalid(itemclass.getParent().getUriname());
regItemclass.setRegItemclassParent(regItemclassParent);
} else {
RegItemclassManager regItemclassManager = new RegItemclassManager(entityManagerRe3gistry2);
RegItemclass parent = regItemclassManager.getByLocalid(itemclass.getRegister().getUriname());
regItemclass.setRegItemclassParent(parent);
}
Expand Down

0 comments on commit 8827caa

Please sign in to comment.