-
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.
Merge pull request #29 from aodn/ranking-by-completeness
Ranking by completeness
- Loading branch information
Showing
4 changed files
with
127 additions
and
19 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
7 changes: 7 additions & 0 deletions
7
src/main/java/au/org/aodn/esindexer/service/RankingService.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,7 @@ | ||
package au.org.aodn.esindexer.service; | ||
|
||
import au.org.aodn.esindexer.model.StacCollectionModel; | ||
|
||
public interface RankingService { | ||
public Integer evaluateCompleteness(StacCollectionModel stacCollectionModel); | ||
} |
87 changes: 87 additions & 0 deletions
87
src/main/java/au/org/aodn/esindexer/service/RankingServiceImpl.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,87 @@ | ||
package au.org.aodn.esindexer.service; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.stereotype.Service; | ||
|
||
import au.org.aodn.esindexer.model.StacCollectionModel; | ||
|
||
@Service | ||
public class RankingServiceImpl implements RankingService { | ||
|
||
protected static Logger logger = LoggerFactory.getLogger(RankingServiceImpl.class); | ||
|
||
public Integer evaluateCompleteness(StacCollectionModel stacCollectionModel) { | ||
Integer total = 0; | ||
|
||
/* | ||
* The implementation of this method can be adjusted | ||
* Current scoring system is (well, I made it up! feel free to change it) | ||
* 1. 15 points for title | ||
* 2. 15 points for description | ||
* 3. 10 points for extent geometry | ||
* 4. 10 points for extent temporal | ||
* 5a. 10 points for links with just 1-2 link | ||
* * 5b. 15 points for links with 3-5 links | ||
* * 5c. 20 points for links more than 5 links | ||
* 6a. 10 points for themes with just 1-2 themes | ||
* * 6b. 15 points for themes with 3-5 themes | ||
* * 6c. 20 points for themes more than 5 themes | ||
* 7. 10 points for contacts | ||
* Total: 100 points | ||
* */ | ||
|
||
if (stacCollectionModel.getTitle() != null) { | ||
logger.debug("Title found"); | ||
total += 15; | ||
} | ||
|
||
if (stacCollectionModel.getDescription() != null) { | ||
logger.debug("Description found"); | ||
total += 15; | ||
} | ||
|
||
if (stacCollectionModel.getExtent().getBbox() != null) { | ||
logger.debug("Extent found"); | ||
total += 10; | ||
} | ||
|
||
if (stacCollectionModel.getExtent().getTemporal() != null) { | ||
logger.debug("Temporal found"); | ||
total += 10; | ||
} | ||
|
||
if (stacCollectionModel.getLinks() != null) { | ||
if (stacCollectionModel.getLinks().size() <= 2) { | ||
logger.debug("Links found with size: " + stacCollectionModel.getLinks().size()); | ||
total += 10; | ||
} else if (stacCollectionModel.getLinks().size() <= 5) { | ||
logger.debug("Links found with size: " + stacCollectionModel.getLinks().size()); | ||
total += 15; | ||
} else { | ||
logger.debug("Links found with size: " + stacCollectionModel.getLinks().size()); | ||
total += 20; | ||
} | ||
} | ||
|
||
if (stacCollectionModel.getThemes() != null) { | ||
if (stacCollectionModel.getThemes().size() <= 2) { | ||
logger.debug("Themes found with size: " + stacCollectionModel.getThemes().size()); | ||
total += 10; | ||
} else if (stacCollectionModel.getThemes().size() <= 5) { | ||
logger.debug("Themes found with size: " + stacCollectionModel.getThemes().size()); | ||
total += 15; | ||
} else { | ||
logger.debug("Themes found with size: " + stacCollectionModel.getThemes().size()); | ||
total += 20; | ||
} | ||
} | ||
|
||
if (stacCollectionModel.getContacts() != null) { | ||
logger.debug("Contacts found"); | ||
total += 10; | ||
} | ||
|
||
return total; | ||
} | ||
} |
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