Skip to content

Commit

Permalink
Move filename mapping back to export
Browse files Browse the repository at this point in the history
  • Loading branch information
wwelling committed Aug 1, 2023
1 parent 189e6f1 commit 607f9a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 45 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@

import edu.tamu.scholars.middleware.discovery.model.AbstractIndexDocument;
import edu.tamu.scholars.middleware.discovery.model.Individual;
import edu.tamu.scholars.middleware.discovery.model.helper.IndividualHelper;
import edu.tamu.scholars.middleware.discovery.model.Organization;
import edu.tamu.scholars.middleware.discovery.model.Person;
import edu.tamu.scholars.middleware.discovery.model.helper.ContentMapper;

public class FilenameUtility {

private final static String UNDERSCORE = "_";
private final static String NAME = "name";
private final static String LAST_NAME = "lastName";
private final static String FIRST_NAME = "firstName";

private FilenameUtility() {

Expand All @@ -27,7 +32,24 @@ public static String normalizeExportFilename(AbstractIndexDocument refDoc) {
}

public static String normalizeExportFilename(Individual individual) {
return localizeWhileUnderscoreReplaceSpaceWithUnderscore(IndividualHelper.as(individual).getLabel());
ContentMapper cm = ContentMapper.from(individual);
StringBuilder label = new StringBuilder();

String clazz = individual.getClazz();

if (clazz.equals(Organization.class.getSimpleName())) {
label.append(cm.getValue(NAME))
.append(UNDERSCORE);
} else if (clazz.equals(Person.class.getSimpleName())) {
label.append(cm.getValue(LAST_NAME))
.append(UNDERSCORE)
.append(cm.getValue(FIRST_NAME))
.append(UNDERSCORE);
}

return localizeWhileUnderscoreReplaceSpaceWithUnderscore(label
.append(individual.getId())
.toString());
}

private static String localizeWhileUnderscoreReplaceSpaceWithUnderscore(String value) {
Expand Down

0 comments on commit 607f9a6

Please sign in to comment.