-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conversion: Make template autoselection overridable and add HE
- Loading branch information
1 parent
f512200
commit efd7db9
Showing
6 changed files
with
115 additions
and
20 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
14 changes: 14 additions & 0 deletions
14
src/main/java/at/ac/tuwien/damap/conversion/TemplateSelectorService.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,14 @@ | ||
package at.ac.tuwien.damap.conversion; | ||
|
||
import at.ac.tuwien.damap.enums.ETemplateType; | ||
import at.ac.tuwien.damap.rest.dmp.domain.DmpDO; | ||
import at.ac.tuwien.damap.rest.dmp.domain.IdentifierDO; | ||
|
||
public interface TemplateSelectorService { | ||
|
||
ETemplateType selectTemplate(DmpDO dmpDO); | ||
|
||
boolean isHorizonEuropeTemplate(IdentifierDO identifierDO); | ||
|
||
boolean isFWFTemplate(IdentifierDO identifierDO); | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/at/ac/tuwien/damap/conversion/TemplateSelectorServiceImpl.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,43 @@ | ||
package at.ac.tuwien.damap.conversion; | ||
|
||
import at.ac.tuwien.damap.enums.EFunderIds; | ||
import at.ac.tuwien.damap.enums.EIdentifierType; | ||
import at.ac.tuwien.damap.enums.ETemplateType; | ||
import at.ac.tuwien.damap.rest.dmp.domain.DmpDO; | ||
import at.ac.tuwien.damap.rest.dmp.domain.IdentifierDO; | ||
import io.quarkus.arc.DefaultBean; | ||
import lombok.extern.jbosslog.JBossLog; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
@ApplicationScoped | ||
@DefaultBean | ||
@JBossLog | ||
public class TemplateSelectorServiceImpl implements TemplateSelectorService{ | ||
@Override | ||
public ETemplateType selectTemplate(DmpDO dmpDO) { | ||
if (dmpDO.getProject() != null && dmpDO.getProject().getFunding() != null) { | ||
IdentifierDO funderIdentifier = dmpDO.getProject().getFunding().getFunderId(); | ||
if (funderIdentifier != null && EIdentifierType.getFunderIdentifierTypeList().contains(funderIdentifier.getType())) { | ||
if (isHorizonEuropeTemplate(funderIdentifier)) { | ||
return ETemplateType.HORIZON_EUROPE; | ||
} | ||
if (isFWFTemplate(funderIdentifier)) { | ||
return ETemplateType.FWF; | ||
} | ||
} | ||
} | ||
// default export science europe template | ||
return ETemplateType.SCIENCE_EUROPE; | ||
} | ||
|
||
@Override | ||
public boolean isHorizonEuropeTemplate(IdentifierDO identifierDO) { | ||
return (EFunderIds.getEUFunderIds().contains(identifierDO.getIdentifier())); | ||
} | ||
|
||
@Override | ||
public boolean isFWFTemplate(IdentifierDO identifierDO) { | ||
return (EFunderIds.getFWFFunderIds().contains(identifierDO.getIdentifier())); | ||
} | ||
} |
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,42 @@ | ||
package at.ac.tuwien.damap.enums; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public enum EFunderIds { | ||
|
||
EU_FUNDREF_ID("501100000780"), | ||
EU_ROR_ID("https://ror.org/032s10s29"), | ||
EU_ISNI_ID("0000 0004 6090 9785"), | ||
|
||
FWF_FUNDREF_ID("501100002428"), | ||
FWF_ROR_ID("https://ror.org/013tf3c58"), | ||
FWF_ISNI_ID("0000 0001 1091 8438"); | ||
|
||
|
||
private final String funderId; | ||
|
||
private static final List<String> EUFunderIds = new ArrayList<>(); | ||
private static final List<String> FWFFunderIds = new ArrayList<>(); | ||
|
||
static { | ||
EUFunderIds.add(EU_FUNDREF_ID.funderId); | ||
EUFunderIds.add(EU_ROR_ID.funderId); | ||
EUFunderIds.add(EU_ISNI_ID.funderId); | ||
|
||
FWFFunderIds.add(FWF_FUNDREF_ID.funderId); | ||
FWFFunderIds.add(FWF_ROR_ID.funderId); | ||
FWFFunderIds.add(FWF_ISNI_ID.funderId); | ||
} | ||
|
||
EFunderIds(String funderId) { | ||
this.funderId = funderId; | ||
} | ||
|
||
public static List<String> getEUFunderIds() {return EUFunderIds;} | ||
public static List<String> getFWFFunderIds() {return FWFFunderIds;} | ||
@Override | ||
public String toString() { | ||
return funderId; | ||
} | ||
} |
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