BGBM BDI Projects
/
cdmlib.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e80d154
)
factory method and singleton support for TaxonRelationshipFormatter
author
Andreas Müller
<a.mueller@bgbm.org>
Fri, 14 May 2021 11:17:43 +0000
(13:17 +0200)
committer
Andreas Müller
<a.mueller@bgbm.org>
Fri, 14 May 2021 11:17:43 +0000
(13:17 +0200)
cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/taxon/TaxonRelationshipFormatter.java
patch
|
blob
|
history
cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/taxon/TaxonRelationshipFormatterTest.java
patch
|
blob
|
history
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/TaxonRelationshipsDTO.java
patch
|
blob
|
history
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/dto/TaxonRelationshipsDTOTest.java
patch
|
blob
|
history
diff --git
a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/taxon/TaxonRelationshipFormatter.java
b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/taxon/TaxonRelationshipFormatter.java
index 13de1af57c9be3a67cd908aa57c2fffd8f7ac65a..f51722a2d5d19fea0d094673501075139a14aa6e 100644
(file)
--- a/
cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/taxon/TaxonRelationshipFormatter.java
+++ b/
cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/taxon/TaxonRelationshipFormatter.java
@@
-55,6
+55,23
@@
public class TaxonRelationshipFormatter {
private static final String INVERT_SYMBOL = "<-"; //TODO
private static final String UNDEFINED_SYMBOL = "??"; //TODO
private static final String INVERT_SYMBOL = "<-"; //TODO
private static final String UNDEFINED_SYMBOL = "??"; //TODO
+ private static TaxonRelationshipFormatter instance;
+
+ public static TaxonRelationshipFormatter NewInstance(){
+ return new TaxonRelationshipFormatter();
+ }
+
+ public static TaxonRelationshipFormatter INSTANCE(){
+ if (instance == null){
+ instance = NewInstance();
+ }
+ return instance;
+ }
+
+ private TaxonRelationshipFormatter(){
+
+ }
+
public List<TaggedText> getTaggedText(TaxonRelationship taxonRelationship, boolean reverse, List<Language> languages) {
return getTaggedText(taxonRelationship, reverse, languages, false);
}
public List<TaggedText> getTaggedText(TaxonRelationship taxonRelationship, boolean reverse, List<Language> languages) {
return getTaggedText(taxonRelationship, reverse, languages, false);
}
diff --git
a/cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/taxon/TaxonRelationshipFormatterTest.java
b/cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/taxon/TaxonRelationshipFormatterTest.java
index 36a19ad7675427144bc0783ba24b7d99ddfe32e3..07d5ce48211022e29f5ca747f28a0a13f6e1399f 100644
(file)
--- a/
cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/taxon/TaxonRelationshipFormatterTest.java
+++ b/
cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/taxon/TaxonRelationshipFormatterTest.java
@@
-99,7
+99,7
@@
public class TaxonRelationshipFormatterTest extends TermTestBase{
taxonRel = fromTaxon.addTaxonRelation(toTaxon, type, relSec, "123");
reverse = false;
taxonRel = fromTaxon.addTaxonRelation(toTaxon, type, relSec, "123");
reverse = false;
- formatter =
new TaxonRelationshipFormatter
();
+ formatter =
TaxonRelationshipFormatter.INSTANCE
();
languages = null;
}
languages = null;
}
diff --git
a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/TaxonRelationshipsDTO.java
b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/TaxonRelationshipsDTO.java
index a1e34ba00db20913b2af1385fd420a8ccad5e222..ec2f6271f456718127be51482e6021466059c56d 100644
(file)
--- a/
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/TaxonRelationshipsDTO.java
+++ b/
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/TaxonRelationshipsDTO.java
@@
-73,7
+73,7
@@
public class TaxonRelationshipsDTO {
// TODO localize
// termDto.localize(representation_L10n);
}
// TODO localize
// termDto.localize(representation_L10n);
}
- List<TaggedText> tags =
new TaxonRelationshipFormatter
().getTaggedText(
+ List<TaggedText> tags =
TaxonRelationshipFormatter.INSTANCE
().getTaggedText(
relation, direction == Direction.relatedFrom, languages);
this.taggedText = tags;
this.setCache(TaggedCacheHelper.createString(tags));
relation, direction == Direction.relatedFrom, languages);
this.taggedText = tags;
this.setCache(TaggedCacheHelper.createString(tags));
diff --git
a/cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/dto/TaxonRelationshipsDTOTest.java
b/cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/dto/TaxonRelationshipsDTOTest.java
index 7dd8350ec79f89ce15c81c0b7c7fbf7abaefaac1..fb2f3befe0c07fe8f208206a06f4afb0c7751a46 100644
(file)
--- a/
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/dto/TaxonRelationshipsDTOTest.java
+++ b/
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/dto/TaxonRelationshipsDTOTest.java
@@
-92,7
+92,7
@@
public class TaxonRelationshipsDTOTest extends TermTestBase {
taxonRel = fromTaxon.addTaxonRelation(toTaxon, type, relSec, "123");
reverse = false;
taxonRel = fromTaxon.addTaxonRelation(toTaxon, type, relSec, "123");
reverse = false;
- formatter =
new TaxonRelationshipFormatter
();
+ formatter =
TaxonRelationshipFormatter.INSTANCE
();
languages = null;
}
languages = null;
}