Skip to content

Commit

Permalink
feature: mappingfields can now assign structure type from xls
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-hig committed Oct 11, 2022
1 parent 8d1d2c2 commit 137d30e
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,24 @@ public void addMetadataToStructure(MappingField mappingField, String cellContent
addMetadata(structure, mappingField, cellContent);
}

public void createStructure(String strucType) throws TypeNotAllowedForParentException {
structure = digitalDocument.createDocStruct(prefs.getDocStrctTypeByName(strucType));
public void createStructure(String structType) throws TypeNotAllowedForParentException {
structure = digitalDocument.createDocStruct(prefs.getDocStrctTypeByName(structType));
}

public void createStructureWithMetaData(Row row, List<MappingField> mappingFields, Set<Path> imageFiles, String nodeId)
throws TypeNotAllowedForParentException, TypeNotAllowedAsChildException, IOException, InterruptedException, SwapException, DAOException {
createStructure(importSet.getStructureType());
// look if structureType is defined in table
MappingField mFieldStructureType =
mappingFields.stream().filter(mappingField -> "structureType".equals(mappingField.getType())).findFirst().orElse(null);
String structureType = importSet.getStructureType();
if (mFieldStructureType != null) {
String cellContentType = XlsReader.getCellContent(row, mFieldStructureType);
if (StringUtils.isNotEmpty(cellContentType)) {
structureType = cellContentType;
}
}
createStructure(structureType);

for (MappingField mappingField : mappingFields) {

String cellContent = XlsReader.getCellContent(row, mappingField);
Expand Down Expand Up @@ -227,7 +238,7 @@ private Person createPerson(String cellContent, MappingField mappingField) throw
* @throws MetadataTypeNotAllowedException
* @throws TypeNotAllowedAsChildException
*/
public void addMetadata(DocStruct ds, MappingField mappingField, String cellContent)
private void addMetadata(DocStruct ds, MappingField mappingField, String cellContent)
throws MetadataTypeNotAllowedException, TypeNotAllowedAsChildException {
switch (mappingField.getType()) {
case "personWithGnd":
Expand Down Expand Up @@ -282,13 +293,16 @@ public void addMetadata(DocStruct ds, MappingField mappingField, String cellCont
case "FileName":
//do nothhing
break;
case "structureType":
//do nothing
break;
default:
plugin.updateLogAndProcess(process.getId(), "the specified type: " + mappingField.getType() + " is not supported", 3);
return;
}
}

public void addMediaFile(MappingField mappingField, String cellContent, Set<Path> imageFiles) throws IOException, SwapException, DAOException {
private void addMediaFile(MappingField mappingField, String cellContent, Set<Path> imageFiles) throws IOException, SwapException, DAOException {
StorageProviderInterface storageProvider = StorageProvider.getInstance();
String[] imageFileNames = cellContent.split(mappingField.getSeparator());
for (String imageFileName : imageFileNames) {
Expand Down

0 comments on commit 137d30e

Please sign in to comment.