Skip to content

Commit

Permalink
Code improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
IkramMaalej committed Jan 11, 2022
1 parent 9fb80da commit 30d2eea
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -606,16 +606,20 @@ public String getReferringView() {
*/
public boolean canBeAdded(TreeNode treeNode) throws InvalidMetadataValueException {
if (Objects.isNull(treeNode.getParent().getParent())) {
if (Objects.nonNull(processMetadata.getSelectedMetadataTreeNode()) || Objects.isNull(addMetadataDialog.getAddableMetadata())) {
if (Objects.nonNull(processMetadata.getSelectedMetadataTreeNode())
|| Objects.isNull(addMetadataDialog.getAddableMetadata())) {
this.addMetadataDialog.prepareAddableMetadataForStructure();
}
} else if (!Objects.equals(processMetadata.getSelectedMetadataTreeNode(), treeNode.getParent())
|| Objects.isNull(addMetadataDialog.getAddableMetadata())) {
prepareAddableMetadataForGroup(treeNode.getParent());
}
if (Objects.nonNull(addMetadataDialog.getAddableMetadata())) {
return addMetadataDialog.getAddableMetadata().stream()
.map(SelectItem::getValue).collect(Collectors.toList()).contains(((ProcessDetail) treeNode.getData()).getMetadataID());
return addMetadataDialog.getAddableMetadata()
.stream()
.map(SelectItem::getValue)
.collect(Collectors.toList())
.contains(((ProcessDetail) treeNode.getData()).getMetadataID());
}
return false;
}
Expand All @@ -636,9 +640,8 @@ public boolean canBeDeleted(ProcessDetail processDetail) {
public boolean metadataAddableToGroup(TreeNode metadataNode) {
if (metadataNode.getData() instanceof ProcessFieldedMetadata) {
return !(DataEditorService.getAddableMetadataForGroup(getMainProcess().getRuleset(), metadataNode).isEmpty());
} else {
return false;
}
return false;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public String getInput() {
}

@Override
public Collection<Metadata> getMetadata() throws InvalidMetadataValueException {
public Collection<Metadata> getMetadataWithFilledValues() throws InvalidMetadataValueException {
return getMetadata(true);
}

Expand All @@ -87,9 +87,8 @@ public Collection<Metadata> getMetadata(boolean skipEmpty) throws InvalidMetadat
entry.setDomain(DOMAIN_TO_MDSEC.get(settings.getDomain().orElse(Domain.DESCRIPTION)));
entry.setValue(value.isPresent() ? value.get() : "");
return Collections.singletonList(entry);
} else {
return Collections.emptyList();
}
return Collections.emptyList();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public String getLabel() {
return label;
}


/**
* Returns the metadata from this row, as far as it has to be stored in the
* collection obtainable from {@link LogicalDivision#getMetadata()}.
Expand All @@ -108,8 +107,15 @@ public String getLabel() {
* @throws InvalidMetadataValueException
* if the metadata form contains syntactically wrong input
*/
public abstract Collection<Metadata> getMetadata() throws InvalidMetadataValueException;

public abstract Collection<Metadata> getMetadataWithFilledValues() throws InvalidMetadataValueException;

/**
* Returns the metadata from this row.
* @param skipEmpty boolean to filter metadata with empty value or not.
* @return the metadata from this row
* @throws InvalidMetadataValueException
* if the metadata form contains syntactically wrong input
*/
public abstract Collection<Metadata> getMetadata(boolean skipEmpty) throws InvalidMetadataValueException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ public String getInput() {
* if some value is invalid
*/
@Override
public Collection<Metadata> getMetadata() throws InvalidMetadataValueException {
public Collection<Metadata> getMetadataWithFilledValues() throws InvalidMetadataValueException {
return getMetadata(true);
}

Expand Down Expand Up @@ -551,7 +551,7 @@ public void preserve() throws InvalidMetadataValueException, NoSuchMetadataField
if (Objects.nonNull(metsFieldValue)) {
metsFieldValue.getKey().accept(division, metsFieldValue.getValue());
} else {
metadata.addAll(row.getMetadata());
metadata.addAll(row.getMetadataWithFilledValues());
}
}
if (Objects.nonNull(hiddenMetadata)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public boolean metadataAddableToStructureElement() throws InvalidMetadataValueEx
}

/**
* Adds an empty table line with the given type.
* Adds an empty table line with 'addMetadataKeySelectedItem' type.
*/
public void addMetadataEntry() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public List<SelectItem> getItems() {
}

@Override
public Collection<Metadata> getMetadata() throws InvalidMetadataValueException {
public Collection<Metadata> getMetadataWithFilledValues() throws InvalidMetadataValueException {
return getMetadata(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public Collection<Metadata> getMetadata(boolean skipEmpty) {
}

@Override
public Collection<Metadata> getMetadata() {
public Collection<Metadata> getMetadataWithFilledValues() {
return getMetadata(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -859,9 +859,8 @@ public boolean canBeAdded(TreeNode treeNode) {
if (Objects.nonNull(addMetadataDialog.getAddableMetadata())) {
return addMetadataDialog.getAddableMetadata().stream()
.map(SelectItem::getValue).collect(Collectors.toList()).contains(((ProcessDetail) treeNode.getData()).getMetadataID());
} else {
return false;
}
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ public static void addProperties(Process process, Template template, List<Proces
private static void addMetadataProperties(List<ProcessDetail> processDetailList, Process process) {
try {
for (ProcessDetail processDetail : processDetailList) {
Collection<Metadata> processMetadata = processDetail.getMetadata();
Collection<Metadata> processMetadata = processDetail.getMetadataWithFilledValues();
if (!processMetadata.isEmpty() && processMetadata.toArray()[0] instanceof Metadata) {
String metadataValue = ImportService.getProcessDetailValue(processDetail);
Metadata metadata = (Metadata) processMetadata.toArray()[0];
Expand Down
2 changes: 1 addition & 1 deletion Kitodo/src/main/resources/messages/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ messages=Nachrichten
metadata=Metadaten
metadataCorrupt=Die Metadatendatei ist fehlerhaft, bitte informieren Sie ihren Administrator.
metadataDelete=Metadaten l\u00F6schen
metadataDeleteNotAllowed=Metadaten ist in Regelsatz als 'Required' oder "alwaysShowing" konfiguriert
metadataDeleteNotAllowed=Metadatum ist in Regelsatz als 'Required' oder "alwaysShowing" konfiguriert
metadataDoesNotEndWith=endet nicht mit dem Wert
metadataDoesNotStartWith=startet nicht mit dem Wert
metadataDuplicate=Metadaten duplizieren
Expand Down
4 changes: 2 additions & 2 deletions Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css
Original file line number Diff line number Diff line change
Expand Up @@ -1304,11 +1304,11 @@ Import form
}

#editForm\:processFromTemplateTabView\:metadataTable tr.ui-widget-content:not([data-prk='root']) span > .ui-inputfield.hasDatepicker {
width: calc(50% - 4 * var(--default-half-size) - 93px - 39px);
width: calc(50% - 172px);
}

#editForm\:processFromTemplateTabView\:metadataTable tr.ui-widget-content span > .ui-inputfield.hasDatepicker {
width: calc(50% - var(--default-half-size) - 93px - 39px);
width: calc(50% - 140px);
}

#editForm\:processFromTemplateTabView\:metadataTable div.ui-selectmanymenu + span,
Expand Down

0 comments on commit 30d2eea

Please sign in to comment.