26 lines
1.1 KiB
Java
26 lines
1.1 KiB
Java
package eu.eudat.file.transformer.service.descriptiontemplatesearcher;
|
|
|
|
import eu.eudat.commonmodels.models.descriptiotemplate.*;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
@Component
|
|
public class TemplateFieldSearcherServiceImpl implements TemplateFieldSearcherService {
|
|
|
|
@Override
|
|
public List<FieldModel> searchFieldsById(DescriptionTemplateModel template, String value) {
|
|
if (template == null || template.getDefinition() == null) return new ArrayList<>();
|
|
return template.getDefinition().getFieldById(value);
|
|
}
|
|
|
|
@Override
|
|
public List<FieldModel> searchFieldsBySemantics(DescriptionTemplateModel template, String value) {
|
|
if (template == null || template.getDefinition() == null) return new ArrayList<>();
|
|
List<FieldModel> fieldModels = template.getDefinition().getAllField();
|
|
if (fieldModels == null) return new ArrayList<>();
|
|
return fieldModels.stream().filter(x-> x.getSchematics() != null && x.getSchematics().contains(value)).toList();
|
|
}
|
|
}
|