Skip to content

Commit

Permalink
Merge pull request #403 from ec-jrc/396-database-error
Browse files Browse the repository at this point in the history
#396 Fixed datatable error
  • Loading branch information
unaibrrgn authored Apr 30, 2024
2 parents ca0243e + 5807a8e commit 7b6a39d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
//Getting the master language
RegLanguagecode masterLanguage = regLanguagecodeManager.getMasterLanguage();
request.setAttribute(BaseConstants.KEY_REQUEST_MASTERLANGUAGE, masterLanguage);

RegLanguagecode english = regLanguagecodeManager.getByIso6391code("en");

// Getting the language by parameter (if not available the master language is used)
Expand Down Expand Up @@ -415,7 +415,7 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
j++;

} else if (tmpRegFieldmapping.getRegField().getRegFieldtype().getLocalid().equals(BaseConstants.KEY_FIELD_TYPE_SUCCESSOR)) {

// Get the "successor" reg relation
List<RegRelation> tmpRegRelations = regRelationManager.getAll(tmpRegItem, regRelationpredicateSuccessor);
if (!tmpRegRelations.isEmpty()) {
Expand Down Expand Up @@ -473,12 +473,16 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
RegStatus regStatusProposedItem = regItemproposed.getRegStatus();

//Getting the RegStatus localization
RegStatuslocalization regStatusLocalizationProposedItem;
RegStatuslocalization regStatusLocalizationProposedItem = null;
try {
regStatusLocalizationProposedItem = regStatuslocalizationManager.get(regStatusProposedItem, regLanguagecode);
} catch (NoResultException e) {
regStatusLocalizationProposedItem = regStatuslocalizationManager.get(regStatusProposedItem, masterLanguage);
}

if(regStatusLocalizationProposedItem == null) {
regStatusLocalizationProposedItem = regStatuslocalizationManager.get(regStatusProposedItem, masterLanguage);
}

regItemproposedStatus = " / " + regStatusLocalizationProposedItem.getLabel();

Expand All @@ -490,14 +494,14 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
try {
regStatusLocalization = regStatuslocalizationManager.get(regStatus, regLanguagecode);
} catch (NoResultException e) {
try{
regStatusLocalization = regStatuslocalizationManager.get(regStatus, masterLanguage);
} catch (Exception ex){
try {
regStatusLocalization = regStatuslocalizationManager.get(regStatus, masterLanguage);
} catch (Exception ex) {
regStatusLocalization = regStatuslocalizationManager.get(regStatus, english);
}
}

String statusURI = regStatusgroup.getBaseuri()+ "/" + regStatusgroup.getLocalid() + "/" + regStatus.getLocalid();
String statusURI = regStatusgroup.getBaseuri() + "/" + regStatusgroup.getLocalid() + "/" + regStatus.getLocalid();
outs += "\"<a data-uri=\\\"/" + statusURI + "\\\" href=\\\"" + statusURI + "\\\">" + regStatusLocalization.getLabel() + regItemproposedStatus + "</a>\"";

j++;
Expand Down Expand Up @@ -550,6 +554,9 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
} catch (NoResultException e) {
regLocalizationTmps = regLocalizationManager.getAll(regFieldManager.getTitleRegField(), regRelation.getRegItemObject(), masterLanguage);
}
if (regLocalizationTmps.isEmpty()) {
regLocalizationTmps = regLocalizationManager.getAll(regFieldManager.getTitleRegField(), regRelation.getRegItemObject(), masterLanguage);
}

for (RegLocalization regLocalizationTmp : regLocalizationTmps) {
outs += "\"<a href=\\\"." + WebConstants.PAGE_URINAME_BROWSE + "?" + BaseConstants.KEY_REQUEST_ITEMUUID + "=" + regItemReference.getUuid() + "&" + BaseConstants.KEY_REQUEST_LANGUAGEUUID + "=" + regLanguagecode.getUuid() + "\\\">" + StringEscapeUtils.escapeJson(regLocalizationTmp.getValue()) + "</a>\"";
Expand All @@ -571,7 +578,11 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
} catch (NoResultException e) {
regLocalizationTmps = regLocalizationManager.getAll(regFieldManager.getTitleRegField(), regRelation.getRegItemObject(), masterLanguage);
}


/* if(regLocalizationTmps.isEmpty()){
regLocalizationTmps = regLocalizationManager.getAll(regFieldManager.getTitleRegField(), regRelation.getRegItemObject(), masterLanguage);
} */

if (k != 0) {
outs += ",";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
// }
List<RegItemproposed> containedRegItemsCheck = regItemproposedManager.getAllNew(regItemclasses, regItem, regRelationpredicateCollection, start, length);

if (!containedRegItemsCheck.isEmpty()
// && containedRegItemsCheck.size() != containedRegItems.size()
if (!containedRegItemsCheck.isEmpty() // && containedRegItemsCheck.size() != containedRegItems.size()
) {
containedRegItems = containedRegItemsCheck;
totalCount = regItemproposedManager.countAllNew(regItemclasses, regItem, regRelationpredicateCollection);
Expand Down Expand Up @@ -224,7 +223,7 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
if (i != 0) {
outs += ",";
}
outs += "[\"<a href=\\\"./"+WebConstants.PAGE_URINAME_BROWSE+"?" + BaseConstants.KEY_REQUEST_ITEMUUID + "=" + tmpRegItem.getUuid() + "&" + BaseConstants.KEY_REQUEST_LANGUAGEUUID + "=" + regLanguagecode.getUuid() + "\\\">" + StringEscapeUtils.escapeJson(tmpRegLocalozations.get(0).getValue()) + "</a>\"]";
outs += "[\"<a href=\\\"./" + WebConstants.PAGE_URINAME_BROWSE + "?" + BaseConstants.KEY_REQUEST_ITEMUUID + "=" + tmpRegItem.getUuid() + "&" + BaseConstants.KEY_REQUEST_LANGUAGEUUID + "=" + regLanguagecode.getUuid() + "\\\">" + StringEscapeUtils.escapeJson(tmpRegLocalozations.get(0).getValue()) + "</a>\"]";

// It the contained itemclass is just one
} else {
Expand Down Expand Up @@ -459,7 +458,7 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
regStatusLocalization = regStatuslocalizationManager.get(regStatus, masterLanguage);
}

String statusURI = regStatusgroup.getBaseuri()+ "/" + regStatusgroup.getLocalid() + "/" + regStatus.getLocalid();
String statusURI = regStatusgroup.getBaseuri() + "/" + regStatusgroup.getLocalid() + "/" + regStatus.getLocalid();
outs += "\"<a data-uri=\\\"/" + statusURI + "\\\" href=\\\"" + statusURI + "\\\">" + regStatusLocalization.getLabel() + "</a>\"";

j++;
Expand Down Expand Up @@ -510,7 +509,9 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
} catch (NoResultException e) {
regLocalizationTmps = regLocalizationManager.getAll(regFieldManager.getTitleRegField(), regRelation.getRegItemObject(), masterLanguage);
}

if (regLocalizationTmps.isEmpty()) {
regLocalizationTmps = regLocalizationManager.getAll(regFieldManager.getTitleRegField(), regRelation.getRegItemObject(), masterLanguage);
}
for (RegLocalization regLocalizationTmp : regLocalizationTmps) {
outs += "\"<a href=\\\"./content?" + BaseConstants.KEY_REQUEST_ITEMUUID + "=" + regItemReference.getUuid() + "&" + BaseConstants.KEY_REQUEST_LANGUAGEUUID + "=" + regLanguagecode.getUuid() + "\\\">" + StringEscapeUtils.escapeJson(regLocalizationTmp.getValue()) + "</a>\"";
}
Expand All @@ -528,10 +529,12 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
List<RegLocalization> regLocalizationTmps;
try {
regLocalizationTmps = regLocalizationManager.getAll(regFieldManager.getTitleRegField(), regRelation.getRegItemObject(), regLanguagecode);
} catch (NoResultException e) {
} catch (Exception e) {
regLocalizationTmps = regLocalizationManager.getAll(regFieldManager.getTitleRegField(), regRelation.getRegItemObject(), masterLanguage);
}
if (regLocalizationTmps.isEmpty()) {
regLocalizationTmps = regLocalizationManager.getAll(regFieldManager.getTitleRegField(), regRelation.getRegItemObject(), masterLanguage);
}

if (k != 0) {
outs += ",";
}
Expand Down

0 comments on commit 7b6a39d

Please sign in to comment.