Skip to content

Commit

Permalink
Merge pull request #2554 from dbmdz/sql-migration-fixes
Browse files Browse the repository at this point in the history
Sql migration fixes
  • Loading branch information
datazuul authored Aug 8, 2023
2 parents 38f29ff + 92e5998 commit a131574
Show file tree
Hide file tree
Showing 67 changed files with 343 additions and 198 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Add Lobid-Clients for missing Lobid objects
- Add persistence support for new field `Headword.labelNormalized`
- Add sorting to Buckets and Bucket objects handling in `HeadwordRepositoryImpl`

- Add action links to object's view and edit under topic

### Changed

- WEMI parts: Manifestations, Works
Expand Down Expand Up @@ -64,6 +65,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
by `"und"`
- `getByValue` method in `PredicateRepositoryImpl`
- Comment not supported sorting throwing warning every time in `EntityToEntityRelationRepositoryImpl`
- Fix saveUrlAlias (one question mark placeholder in sql more than given params)
- Fix sql migrations 14.10.00, 14.04.00, 9.02.02
- Fix data language handling in admin webapp
- Fix visibility of long text in collection view
- Fix website label rendering

### Removed

Expand Down
2 changes: 1 addition & 1 deletion dc-cudami-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>de.digitalcollections.cudami</groupId>
<artifactId>dc-cudami</artifactId>
<version>7.0.0-RC1</version>
<version>7.0.0-RC2</version>
</parent>

<name>DigitalCollections: cudami Management Webapp</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,32 @@
import de.digitalcollections.cudami.admin.business.i18n.LanguageService;
import de.digitalcollections.cudami.admin.controller.AbstractUniqueObjectController;
import de.digitalcollections.cudami.admin.controller.ParameterHelper;
import de.digitalcollections.cudami.client.CudamiClient;
import de.digitalcollections.cudami.client.identifiable.CudamiIdentifiablesClient;
import de.digitalcollections.model.exception.TechnicalException;
import de.digitalcollections.model.identifiable.Identifiable;
import de.digitalcollections.model.identifiable.IdentifiableObjectType;
import de.digitalcollections.model.identifiable.entity.HeadwordEntry;
import de.digitalcollections.model.list.paging.PageRequest;
import de.digitalcollections.model.list.paging.PageResponse;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.ui.Model;
import org.springframework.util.CollectionUtils;

public class AbstractIdentifiablesController<
I extends Identifiable, C extends CudamiIdentifiablesClient<I>>
extends AbstractUniqueObjectController<I> {

protected AbstractIdentifiablesController(C service, LanguageService languageService) {
private final CudamiClient cudamiClient;

protected AbstractIdentifiablesController(
C service, CudamiClient cudamiClient, LanguageService languageService) {
super(service, languageService);
this.cudamiClient = cudamiClient;
}

protected List<Locale> getExistingLanguagesFromIdentifiable(Identifiable identifiable) {
Expand Down Expand Up @@ -99,4 +107,75 @@ protected PageResponse<I> search(String searchField, String searchTerm, PageRequ
}
}
}

public String doForward(Identifiable identifiable, Model model) throws TechnicalException {
final String uuid = identifiable.getUuid().toString();
IdentifiableObjectType identifiableObjectType = identifiable.getIdentifiableObjectType();
switch (identifiableObjectType) {
case ARTICLE:
return "forward:/articles/" + uuid;
// List<SubtopicImpl> subtopics =
// subtopicService.getSubtopicsOfEntity(entity.getUuid());
// if (!subtopics.isEmpty()) {
// Subtopic subtopic = subtopics.get(0);
// return "forward:/knowledge/node/" + subtopic.getUuid().toString();
// }

case COLLECTION:
return "forward:/collections/" + uuid;
case CORPORATE_BODY:
return "forward:/corporatebodies/" + uuid;
case DIGITAL_OBJECT:
return "forward:/digitalobjects/" + uuid;
case GEO_LOCATION:
return "forward:/geolocations/" + uuid;
// GeoLocation geoLocation = geoLocationsService.findOne(entity.getUuid());
// GeoLocationType geoLocationType = geoLocation.getGeoLocationType();
// switch (geoLocationType) {
// case CANYON:
// return "forward:/geo/canyons/" + uuid;
// case CAVE:
// return "forward:/geo/caves/" + uuid;
// case CONTINENT:
// return "forward:/geo/continents/" + uuid;
// case COUNTRY:
// return "forward:/geo/countries/" + uuid;
// case CREEK:
// return "forward:/geo/creeks/" + uuid;
// case HUMAN_SETTLEMENT:
// return "forward:/geo/human_settlements/" + uuid;
// case LAKE:
// return "forward:/geo/lakes/" + uuid;
// case MOUNTAIN:
// return "forward:/geo/mountains/" + uuid;
// case OCEAN:
// return "forward:/geo/oceans/" + uuid;
// case RIVER:
// return "forward:/geo/rivers/" + uuid;
// case SEA:
// return "forward:/geo/seas/" + uuid;
// case STILL_WATERS:
// return "forward:/geo/still_waters/" + uuid;
// case VALLEY:
// return "forward:/geo/valleys/" + uuid;
// }
case HEADWORD_ENTRY:
HeadwordEntry headwordEntry =
cudamiClient.forHeadwordEntries().getByUuid(identifiable.getUuid());
UUID headwordUuid = headwordEntry.getHeadword().getUuid();
return "redirect:/headwords/" + headwordUuid;
case ITEM:
return "forward:/items/" + uuid;
case MANIFESTATION:
return "forward:/manifestations/" + uuid;
case PERSON:
return "forward:/persons/" + uuid;
case TOPIC:
return "forward:/topics/" + uuid;
case WORK:
return "forward:/works/" + uuid;
default:
throw new TechnicalException("Unhandled object type " + identifiableObjectType);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
import de.digitalcollections.cudami.admin.business.i18n.LanguageService;
import de.digitalcollections.cudami.client.CudamiClient;
import de.digitalcollections.cudami.client.identifiable.CudamiIdentifiablesClient;
import de.digitalcollections.cudami.client.identifiable.entity.CudamiHeadwordEntriesClient;
import de.digitalcollections.model.exception.ResourceNotFoundException;
import de.digitalcollections.model.exception.TechnicalException;
import de.digitalcollections.model.identifiable.Identifiable;
import de.digitalcollections.model.identifiable.IdentifiableObjectType;
import de.digitalcollections.model.identifiable.entity.HeadwordEntry;
import de.digitalcollections.model.list.paging.PageRequest;
import de.digitalcollections.model.list.paging.PageResponse;
import de.digitalcollections.model.list.sorting.Order;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.codec.binary.Base64;
Expand All @@ -29,82 +25,8 @@
public class IdentifiableController
extends AbstractIdentifiablesController<Identifiable, CudamiIdentifiablesClient<Identifiable>> {

CudamiHeadwordEntriesClient headwordEntriesService;

public IdentifiableController(CudamiClient client, LanguageService languageService) {
super(client.forIdentifiables(), languageService);
this.headwordEntriesService = client.forHeadwordEntries();
}

public String doForward(Identifiable identifiable, Model model) throws TechnicalException {
final String uuid = identifiable.getUuid().toString();
IdentifiableObjectType identifiableObjectType = identifiable.getIdentifiableObjectType();
switch (identifiableObjectType) {
case ARTICLE:
return "forward:/articles/" + uuid;
// List<SubtopicImpl> subtopics =
// subtopicService.getSubtopicsOfEntity(entity.getUuid());
// if (!subtopics.isEmpty()) {
// Subtopic subtopic = subtopics.get(0);
// return "forward:/knowledge/node/" + subtopic.getUuid().toString();
// }

case COLLECTION:
return "forward:/collections/" + uuid;
case CORPORATE_BODY:
return "forward:/corporatebodies/" + uuid;
case DIGITAL_OBJECT:
return "forward:/digitalobjects/" + uuid;
case GEO_LOCATION:
return "forward:/geolocations/" + uuid;
// GeoLocation geoLocation = geoLocationsService.findOne(entity.getUuid());
// GeoLocationType geoLocationType = geoLocation.getGeoLocationType();
// switch (geoLocationType) {
// case CANYON:
// return "forward:/geo/canyons/" + uuid;
// case CAVE:
// return "forward:/geo/caves/" + uuid;
// case CONTINENT:
// return "forward:/geo/continents/" + uuid;
// case COUNTRY:
// return "forward:/geo/countries/" + uuid;
// case CREEK:
// return "forward:/geo/creeks/" + uuid;
// case HUMAN_SETTLEMENT:
// return "forward:/geo/human_settlements/" + uuid;
// case LAKE:
// return "forward:/geo/lakes/" + uuid;
// case MOUNTAIN:
// return "forward:/geo/mountains/" + uuid;
// case OCEAN:
// return "forward:/geo/oceans/" + uuid;
// case RIVER:
// return "forward:/geo/rivers/" + uuid;
// case SEA:
// return "forward:/geo/seas/" + uuid;
// case STILL_WATERS:
// return "forward:/geo/still_waters/" + uuid;
// case VALLEY:
// return "forward:/geo/valleys/" + uuid;
// }
case HEADWORD_ENTRY:
HeadwordEntry headwordEntry = headwordEntriesService.getByUuid(identifiable.getUuid());
UUID headwordUuid = headwordEntry.getHeadword().getUuid();
return "redirect:/headwords/" + headwordUuid;
case ITEM:
return "forward:/items/" + uuid;
case MANIFESTATION:
return "forward:/manifestations/" + uuid;
case PERSON:
return "forward:/persons/" + uuid;
case TOPIC:
return "forward:/topics/" + uuid;
case WORK:
return "forward:/works/" + uuid;
default:
throw new TechnicalException(
"Unhandled object type " + identifiable.getIdentifiableObjectType());
}
super(client.forIdentifiables(), client, languageService);
}

@GetMapping(value = "/identifiables")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.digitalcollections.cudami.admin.business.i18n.LanguageService;
import de.digitalcollections.cudami.admin.controller.identifiable.AbstractIdentifiablesController;
import de.digitalcollections.cudami.client.CudamiClient;
import de.digitalcollections.cudami.client.identifiable.entity.CudamiEntitiesClient;
import de.digitalcollections.model.exception.TechnicalException;
import de.digitalcollections.model.identifiable.entity.Entity;
Expand All @@ -12,8 +13,9 @@
public class AbstractEntitiesController<E extends Entity, C extends CudamiEntitiesClient<E>>
extends AbstractIdentifiablesController<E, C> {

protected AbstractEntitiesController(C service, LanguageService languageService) {
super(service, languageService);
protected AbstractEntitiesController(
C service, CudamiClient cudamiClient, LanguageService languageService) {
super(service, cudamiClient, languageService);
}

protected PageResponse<E> search(String searchField, String searchTerm, PageRequest pageRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ArticlesAPIController
private static final Logger LOGGER = LoggerFactory.getLogger(ArticlesAPIController.class);

public ArticlesAPIController(CudamiClient client, LanguageService languageService) {
super(client.forArticles(), languageService);
super(client.forArticles(), client, languageService);
}

@GetMapping("/api/articles/new")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ArticlesController extends AbstractEntitiesController<Article, Cuda
private static final Logger LOGGER = LoggerFactory.getLogger(ArticlesController.class);

public ArticlesController(CudamiClient client, LanguageService languageService) {
super(client.forArticles(), languageService);
super(client.forArticles(), client, languageService);
}

@GetMapping("/articles/new")
Expand Down Expand Up @@ -86,7 +86,7 @@ public String view(
model.addAttribute("article", article);

List<Locale> existingLanguages = getExistingLanguagesFromIdentifiable(article);
String dataLanguage = getDataLanguage(targetDataLanguage, languageService);
String dataLanguage = getDataLanguage(targetDataLanguage, existingLanguages, languageService);
model
.addAttribute("existingLanguages", existingLanguages)
.addAttribute("dataLanguage", dataLanguage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class CollectionsAPIController
private static final Logger LOGGER = LoggerFactory.getLogger(CollectionsAPIController.class);

public CollectionsAPIController(CudamiClient client, LanguageService languageService) {
super(client.forCollections(), languageService);
super(client.forCollections(), client, languageService);
}

@PostMapping("/api/collections/{uuid:" + ParameterHelper.UUID_PATTERN + "}/digitalobjects")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class CollectionsController
private static final Logger LOGGER = LoggerFactory.getLogger(CollectionsController.class);

public CollectionsController(CudamiClient client, LanguageService languageService) {
super(client.forCollections(), languageService);
super(client.forCollections(), client, languageService);
}

@GetMapping("/collections/new")
Expand Down Expand Up @@ -98,17 +98,19 @@ public String view(
}
model.addAttribute("collection", collection);

List<Locale> existingLanguages = getExistingLanguagesFromIdentifiables(List.of(collection));
String dataLanguage = getDataLanguage(targetDataLanguage, languageService);
List<Locale> existingLanguages = getExistingLanguagesFromIdentifiable(collection);
String dataLanguage = getDataLanguage(targetDataLanguage, existingLanguages, languageService);
model
.addAttribute("existingLanguages", existingLanguages)
.addAttribute("dataLanguage", dataLanguage);

List<Locale> existingSubcollectionsLanguages =
getExistingLanguagesFromIdentifiables(collection.getChildren());
String dataLanguageSubcollections =
getDataLanguage(targetDataLanguage, existingSubcollectionsLanguages, languageService);
model
.addAttribute("existingSubcollectionsLanguages", existingSubcollectionsLanguages)
.addAttribute("dataLanguageSubcollections", getDataLanguage(null, languageService));
.addAttribute("dataLanguageSubcollections", dataLanguageSubcollections);

List<Collection> parents = ((CudamiCollectionsClient) service).getParents(uuid);
model.addAttribute("parents", parents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class DigitalObjectsAPIController
private static final Logger LOGGER = LoggerFactory.getLogger(DigitalObjectsAPIController.class);

public DigitalObjectsAPIController(CudamiClient client, LanguageService languageService) {
super(client.forDigitalObjects(), languageService);
super(client.forDigitalObjects(), client, languageService);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class DigitalObjectsController
extends AbstractEntitiesController<DigitalObject, CudamiDigitalObjectsClient> {

public DigitalObjectsController(CudamiClient client, LanguageService languageService) {
super(client.forDigitalObjects(), languageService);
super(client.forDigitalObjects(), client, languageService);
}

@GetMapping("/digitalobjects")
Expand Down Expand Up @@ -55,7 +55,7 @@ public String view(
model.addAttribute("digitalObject", digitalObject);

List<Locale> existingLanguages = getExistingLanguagesFromIdentifiable(digitalObject);
String dataLanguage = getDataLanguage(targetDataLanguage, languageService);
String dataLanguage = getDataLanguage(targetDataLanguage, existingLanguages, languageService);
model
.addAttribute("existingLanguages", existingLanguages)
.addAttribute("dataLanguage", dataLanguage);
Expand All @@ -64,27 +64,34 @@ public String view(

List<Locale> existingCollectionsLanguages =
((CudamiDigitalObjectsClient) service).getLanguagesOfCollections(uuid);
String dataLanguageCollections =
getDataLanguage(targetDataLanguage, existingCollectionsLanguages, languageService);
model
.addAttribute(
"existingCollectionsLanguages",
languageService.sortLanguages(displayLocale, existingCollectionsLanguages))
.addAttribute("dataLanguageCollections", getDataLanguage(null, languageService));
.addAttribute("dataLanguageCollections", dataLanguageCollections);

List<Locale> existingProjectsLanguages =
((CudamiDigitalObjectsClient) service).getLanguagesOfProjects(uuid);
String dataLanguageProjects =
getDataLanguage(targetDataLanguage, existingProjectsLanguages, languageService);
model
.addAttribute(
"existingProjectsLanguages",
languageService.sortLanguages(displayLocale, existingProjectsLanguages))
.addAttribute("dataLanguageProjects", getDataLanguage(null, languageService));
.addAttribute("dataLanguageProjects", dataLanguageProjects);

List<Locale> existingContainedDigitalObjectsLanguages =
((CudamiDigitalObjectsClient) service).getLanguagesOfContainedDigitalObjects(uuid);
String dataLanguageDigitalObjects =
getDataLanguage(
targetDataLanguage, existingContainedDigitalObjectsLanguages, languageService);
model
.addAttribute(
"existingDigitalObjectsLanguages",
languageService.sortLanguages(displayLocale, existingContainedDigitalObjectsLanguages))
.addAttribute("dataLanguageDigitalObjects", getDataLanguage(null, languageService));
.addAttribute("dataLanguageDigitalObjects", dataLanguageDigitalObjects);

return "digitalobjects/view";
}
Expand Down
Loading

0 comments on commit a131574

Please sign in to comment.