-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MODLD-353: Update API to support language (#285)
* MODLD-353: Update API to support language * MODLD-353: fix review remark
- Loading branch information
1 parent
1d8bdaa
commit cb69650
Showing
18 changed files
with
165 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/java/org/folio/linked/data/mapper/dto/monograph/work/sub/LanguageMapperUnit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.folio.linked.data.mapper.dto.monograph.work.sub; | ||
|
||
import static org.apache.commons.lang3.StringUtils.EMPTY; | ||
import static org.folio.ld.dictionary.PredicateDictionary.LANGUAGE; | ||
import static org.folio.ld.dictionary.ResourceTypeDictionary.LANGUAGE_CATEGORY; | ||
import static org.folio.linked.data.util.BibframeUtils.getFirstValue; | ||
|
||
import org.folio.linked.data.domain.dto.Category; | ||
import org.folio.linked.data.domain.dto.CategoryResponse; | ||
import org.folio.linked.data.domain.dto.WorkResponse; | ||
import org.folio.linked.data.mapper.dto.common.CoreMapper; | ||
import org.folio.linked.data.mapper.dto.common.MapperUnit; | ||
import org.folio.linked.data.mapper.dto.monograph.common.CategoryMapperUnit; | ||
import org.folio.linked.data.model.entity.Resource; | ||
import org.folio.linked.data.service.HashService; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@MapperUnit(type = LANGUAGE_CATEGORY, predicate = LANGUAGE, requestDto = Category.class) | ||
public class LanguageMapperUnit extends CategoryMapperUnit { | ||
|
||
private static final String LANGUAGE_LINK_PREFIX = "http://id.loc.gov/vocabulary/languages"; | ||
|
||
public LanguageMapperUnit(CoreMapper coreMapper, HashService hashService) { | ||
super(hashService, coreMapper); | ||
} | ||
|
||
@Override | ||
protected void addToParent(CategoryResponse category, Object parentDto) { | ||
if (parentDto instanceof WorkResponse work) { | ||
work.addLanguageItem(category); | ||
} | ||
} | ||
|
||
@Override | ||
protected String getCategorySetLabel() { | ||
return EMPTY; | ||
} | ||
|
||
@Override | ||
protected String getCategorySetLink() { | ||
return EMPTY; | ||
} | ||
|
||
@Override | ||
public String getLinkPrefix() { | ||
return LANGUAGE_LINK_PREFIX; | ||
} | ||
|
||
@Override | ||
public Resource toEntity(Object dto, Resource parentEntity) { | ||
var languageCategory = (Category) dto; | ||
var resource = new Resource(); | ||
resource.setLabel(getFirstValue(() -> getMarcCodes(languageCategory.getLink()))); | ||
resource.addTypes(LANGUAGE_CATEGORY); | ||
resource.setDoc(getDoc(languageCategory)); | ||
resource.setId(hashService.hash(resource)); | ||
return resource; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.