Commit d4c17f71 authored by Maxym Borodenko's avatar Maxym Borodenko

Merge branch 'ui-313-allow-pasting-descriptors-in-dataset' into 'master'

Functionality for searching matches descriptors

See merge request genesys-pgr/genesys-server!184
parents 27155abc 3b2d9c77
...@@ -195,6 +195,17 @@ public class DescriptorController { ...@@ -195,6 +195,17 @@ public class DescriptorController {
return descriptorService.createDescriptor(source); return descriptorService.createDescriptor(source);
} }
/**
* Search matching descriptor.
*
* @param source the source
* @return matching descriptor
*/
@RequestMapping(value = "/search-matching", method = RequestMethod.POST)
public Descriptor searchMatchingDescriptor(@RequestBody final Descriptor source) {
return descriptorService.searchMatchingDescriptor(source);
}
/** /**
* Update descriptor. * Update descriptor.
* *
......
...@@ -40,6 +40,14 @@ public interface DescriptorService { ...@@ -40,6 +40,14 @@ public interface DescriptorService {
*/ */
Descriptor createDescriptor(Descriptor descriptor); Descriptor createDescriptor(Descriptor descriptor);
/**
* Search matching descriptor.
*
* @param descriptor the descriptor
* @return matching descriptor
*/
Descriptor searchMatchingDescriptor(Descriptor descriptor);
/** /**
* Update descriptor. * Update descriptor.
* *
......
...@@ -24,6 +24,7 @@ import java.util.UUID; ...@@ -24,6 +24,7 @@ import java.util.UUID;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import com.querydsl.core.types.Predicate;
import org.genesys.catalog.exceptions.InvalidApiUsageException; import org.genesys.catalog.exceptions.InvalidApiUsageException;
import org.genesys.catalog.exceptions.NotFoundElement; import org.genesys.catalog.exceptions.NotFoundElement;
import org.genesys.catalog.model.Partner; import org.genesys.catalog.model.Partner;
...@@ -106,6 +107,16 @@ public class DescriptorServiceImpl implements DescriptorService { ...@@ -106,6 +107,16 @@ public class DescriptorServiceImpl implements DescriptorService {
return lazyLoad(descriptorRepository.save(descriptor)); return lazyLoad(descriptorRepository.save(descriptor));
} }
/**
* {@inheritDoc}
*/
@Override
public Descriptor searchMatchingDescriptor(final Descriptor input) {
final Predicate predicate = descriptor.state.in(PublishState.PUBLISHED).and(descriptor.category.in(input.getCategory())).and(descriptor.dataType.in(input.getDataType()))
.and(descriptor.versionTag.eq(input.getVersionTag())).and(descriptor.title.eq(input.getTitle())).and(descriptor.key.eq(input.isKey()));
return lazyLoad(descriptorRepository.findOne(predicate));
}
/** /**
* Persist or update terms in descriptor itself. It updates descriptor's own * Persist or update terms in descriptor itself. It updates descriptor's own
* terms List * terms List
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment