Commit bbb6c9e9 authored by Maxym Borodenko's avatar Maxym Borodenko Committed by Matija Obreza

Subset and Dataset accession lists

- Rename methods and API paths
- improvement of listAccessions method
- use subList
- Renamed {UUID} param
parent b440b739
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
*/ */
package org.genesys.catalog.model.dataset; package org.genesys.catalog.model.dataset;
import javax.persistence.*;
import java.util.List;
import java.util.Set;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonView; import com.fasterxml.jackson.annotation.JsonView;
import org.genesys.blocks.auditlog.annotations.Audited; import org.genesys.blocks.auditlog.annotations.Audited;
...@@ -36,10 +40,6 @@ import org.springframework.data.elasticsearch.annotations.Document; ...@@ -36,10 +40,6 @@ import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.FieldType;
import javax.persistence.*;
import java.util.List;
import java.util.Set;
/** /**
* {@link Dataset} captures the metadata information as a snapshot. Multiple * {@link Dataset} captures the metadata information as a snapshot. Multiple
* versions of the versions may exist. * versions of the versions may exist.
...@@ -78,7 +78,7 @@ public class Dataset extends UuidModel implements Publishable, SelfCleaning, Pub ...@@ -78,7 +78,7 @@ public class Dataset extends UuidModel implements Publishable, SelfCleaning, Pub
// index // index
indexes = { @Index(columnList = "datasetId, instCode, acceNumb"), @Index(columnList = "datasetId, genus") }) indexes = { @Index(columnList = "datasetId, instCode, acceNumb"), @Index(columnList = "datasetId, genus") })
@Field(type = FieldType.Object) @Field(type = FieldType.Object)
@JsonView({ JsonViews.Minimal.class }) @JsonIgnore
private Set<AccessionRef> accessionRefs; private Set<AccessionRef> accessionRefs;
/** The descriptors. */ /** The descriptors. */
......
...@@ -117,6 +117,15 @@ public interface DatasetService { ...@@ -117,6 +117,15 @@ public interface DatasetService {
*/ */
Dataset loadDataset(UUID uuid, int version); Dataset loadDataset(UUID uuid, int version);
/**
* Load AccessionRef list by Dataset
*
* @param uuid uuid of Dataset
* @param page Pageable
* @return PageImpl of AccessionRef
*/
Page<AccessionRef> listAccessions(UUID uuid, Pageable page);
/** /**
* List published datasets by accession. * List published datasets by accession.
* *
......
...@@ -25,6 +25,7 @@ import java.nio.file.Paths; ...@@ -25,6 +25,7 @@ import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
...@@ -166,10 +167,6 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -166,10 +167,6 @@ public class DatasetServiceImpl implements DatasetService {
dataset.setLocations(new ArrayList<>()); dataset.setLocations(new ArrayList<>());
dataset.setCrops(source.getCrops()); dataset.setCrops(source.getCrops());
if (source.getAccessionRefs() != null && !source.getAccessionRefs().isEmpty()) {
dataset.setAccessionRefs(lookupMatchingAccessions(source.getAccessionRefs()));
}
copyDescriptors(dataset, source.getDescriptors()); copyDescriptors(dataset, source.getDescriptors());
dataset = datasetRepository.save(dataset); dataset = datasetRepository.save(dataset);
...@@ -229,7 +226,9 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -229,7 +226,9 @@ public class DatasetServiceImpl implements DatasetService {
public Dataset updateAccessionRefs(Dataset dataset, final Set<AccessionRef> accessionRefs) { public Dataset updateAccessionRefs(Dataset dataset, final Set<AccessionRef> accessionRefs) {
LOG.info("Update AccessionIdentifiers. Input dataset: {}, input accessionRefs {}", dataset, accessionRefs); LOG.info("Update AccessionIdentifiers. Input dataset: {}, input accessionRefs {}", dataset, accessionRefs);
dataset = loadDataset(dataset); dataset = loadDataset(dataset);
if (dataset.getAccessionRefs() != null && !dataset.getAccessionRefs().isEmpty()) {
dataset.getAccessionRefs().clear(); dataset.getAccessionRefs().clear();
}
dataset.setAccessionRefs(lookupMatchingAccessions(accessionRefs)); dataset.setAccessionRefs(lookupMatchingAccessions(accessionRefs));
return lazyLoad(datasetRepository.save(dataset)); return lazyLoad(datasetRepository.save(dataset));
} }
...@@ -379,6 +378,24 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -379,6 +378,24 @@ public class DatasetServiceImpl implements DatasetService {
return lazyLoad(dataset); return lazyLoad(dataset);
} }
/**
* {@inheritDoc}
*/
@Override
public Page<AccessionRef> listAccessions(final UUID uuid, final Pageable page) {
final Dataset dataset = datasetRepository.findByUuid(uuid);
if (dataset == null) {
throw new NotFoundElement("Dataset not found by UUID=" + uuid.toString());
}
final Set<AccessionRef> accessionRefs = dataset.getAccessionRefs();
if (accessionRefs != null && !accessionRefs.isEmpty()) {
int fromIndex = Math.multiplyExact(page.getPageNumber(), page.getPageSize());
int toIndex = Math.min(fromIndex + page.getPageSize(), accessionRefs.size());
return new PageImpl<>(new ArrayList<AccessionRef>(accessionRefs).subList(fromIndex, toIndex), page, accessionRefs.size());
}
return new PageImpl<>(Collections.emptyList(), page, 0);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
...@@ -463,9 +480,6 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -463,9 +480,6 @@ public class DatasetServiceImpl implements DatasetService {
throw new NotFoundElement("No such dataset"); throw new NotFoundElement("No such dataset");
} }
if (dataset.getAccessionRefs() != null) {
dataset.getAccessionRefs().size();
}
if (dataset.getDescriptors() != null) { if (dataset.getDescriptors() != null) {
dataset.getDescriptors().size(); dataset.getDescriptors().size();
} }
......
...@@ -218,6 +218,20 @@ public class DatasetController extends ApiBaseController { ...@@ -218,6 +218,20 @@ public class DatasetController extends ApiBaseController {
return new FilteredPage<>(filterInfo.filterCode, filterInfo.filter, datasetService.listDatasets(filterInfo.filter, page.toPageRequest(100, Sort.Direction.ASC, "id"))); return new FilteredPage<>(filterInfo.filterCode, filterInfo.filter, datasetService.listDatasets(filterInfo.filter, page.toPageRequest(100, Sort.Direction.ASC, "id")));
} }
/**
* Load AccessionRef list by Dataset
*
* @param uuid uuid of Dataset
* @param page Pageable
* @return the page
* @throws NotFoundElement
*/
@JsonView({ JsonViews.Minimal.class })
@GetMapping(value = "/accessions/{uuid}", produces = { MediaType.APPLICATION_JSON_VALUE })
public Page<AccessionRef> listAccessions(@PathVariable("uuid") final UUID uuid, final Pagination page) throws NotFoundElement {
return datasetService.listAccessions(datasetService.loadDataset(uuid), page.toPageRequest(100));
}
/** /**
* Removes the descriptors. * Removes the descriptors.
* *
......
...@@ -20,18 +20,22 @@ import java.io.IOException; ...@@ -20,18 +20,22 @@ import java.io.IOException;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import com.fasterxml.jackson.annotation.JsonView;
import org.genesys.blocks.model.JsonViews;
import org.genesys.catalog.service.ShortFilterService; import org.genesys.catalog.service.ShortFilterService;
import org.genesys.catalog.service.ShortFilterService.FilterInfo; import org.genesys.catalog.service.ShortFilterService.FilterInfo;
import org.genesys2.server.api.ApiBaseController; import org.genesys2.server.api.ApiBaseController;
import org.genesys2.server.api.FilteredPage; import org.genesys2.server.api.FilteredPage;
import org.genesys2.server.api.Pagination; import org.genesys2.server.api.Pagination;
import org.genesys2.server.exception.NotFoundElement; import org.genesys2.server.exception.NotFoundElement;
import org.genesys2.server.model.genesys.AccessionRef;
import org.genesys2.server.model.impl.FaoInstitute; import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.model.impl.Subset; import org.genesys2.server.model.impl.Subset;
import org.genesys2.server.service.InstituteService; import org.genesys2.server.service.InstituteService;
import org.genesys2.server.service.SubsetService; import org.genesys2.server.service.SubsetService;
import org.genesys2.server.service.filter.SubsetFilter; import org.genesys2.server.service.filter.SubsetFilter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
...@@ -161,6 +165,20 @@ public class SubsetController { ...@@ -161,6 +165,20 @@ public class SubsetController {
return new FilteredPage<>(filterInfo.filterCode, filterInfo.filter, subsetService.listSubsetsForCurrentUser(filterInfo.filter, page.toPageRequest(100, Sort.Direction.DESC, "lastModifiedDate"))); return new FilteredPage<>(filterInfo.filterCode, filterInfo.filter, subsetService.listSubsetsForCurrentUser(filterInfo.filter, page.toPageRequest(100, Sort.Direction.DESC, "lastModifiedDate")));
} }
/**
* Load AccessionRef list by Subset
*
* @param uuid uuid of Subset
* @param page Pageable
* @return the page
* @throws NotFoundElement
*/
@JsonView({ JsonViews.Public.class })
@GetMapping(value = "/accessions/{uuid}", produces = { MediaType.APPLICATION_JSON_VALUE })
public Page<AccessionRef> listAccessions(@PathVariable("uuid") final UUID uuid, final Pagination page) throws NotFoundElement {
return subsetService.listAccessions(subsetService.get(uuid), page.toPageRequest(100));
}
/** /**
* Remove accessions form subset. * Remove accessions form subset.
* *
......
...@@ -47,6 +47,7 @@ import org.hibernate.annotations.Type; ...@@ -47,6 +47,7 @@ import org.hibernate.annotations.Type;
import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.FieldType;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonView; import com.fasterxml.jackson.annotation.JsonView;
/** /**
...@@ -94,7 +95,7 @@ public class Subset extends UuidModel implements AclAwareModel, SelfCleaning { ...@@ -94,7 +95,7 @@ public class Subset extends UuidModel implements AclAwareModel, SelfCleaning {
// index // index
indexes = { @Index(columnList = "subsetId, instCode, acceNumb"), @Index(columnList = "subsetId, genus") }) indexes = { @Index(columnList = "subsetId, instCode, acceNumb"), @Index(columnList = "subsetId, genus") })
@Field(type = FieldType.Object) @Field(type = FieldType.Object)
@JsonView({ JsonViews.Public.class }) @JsonIgnore
private Set<AccessionRef> accessionRefs; private Set<AccessionRef> accessionRefs;
/** The accession count. */ /** The accession count. */
......
...@@ -23,6 +23,7 @@ import java.util.UUID; ...@@ -23,6 +23,7 @@ import java.util.UUID;
import org.genesys2.server.exception.NotFoundElement; import org.genesys2.server.exception.NotFoundElement;
import org.genesys2.server.model.genesys.Accession; import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AccessionRef;
import org.genesys2.server.model.impl.FaoInstitute; import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.model.impl.Subset; import org.genesys2.server.model.impl.Subset;
import org.genesys2.server.model.impl.SubsetCreator; import org.genesys2.server.model.impl.SubsetCreator;
...@@ -44,6 +45,15 @@ public interface SubsetService { ...@@ -44,6 +45,15 @@ public interface SubsetService {
*/ */
Page<Subset> list(SubsetFilter filter, Pageable page); Page<Subset> list(SubsetFilter filter, Pageable page);
/**
* Load AccessionRef list by Subset
*
* @param uuid uuid of Subset
* @param page Pageable
* @return PageImpl of AccessionRef
*/
Page<AccessionRef> listAccessions(UUID uuid, Pageable page);
/** /**
* Count published subsets. * Count published subsets.
* *
......
...@@ -20,6 +20,7 @@ import static org.genesys2.server.model.impl.QSubsetCreator.subsetCreator; ...@@ -20,6 +20,7 @@ import static org.genesys2.server.model.impl.QSubsetCreator.subsetCreator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -105,6 +106,21 @@ public class SubsetServiceImpl implements SubsetService { ...@@ -105,6 +106,21 @@ public class SubsetServiceImpl implements SubsetService {
return subsetRepository.findAll(published, page); return subsetRepository.findAll(published, page);
} }
@Override
public Page<AccessionRef> listAccessions(final UUID uuid, final Pageable page) {
final Subset subset = subsetRepository.getByUuid(uuid);
if (subset == null) {
throw new NotFoundElement("Subset not found by UUID=" + uuid.toString());
}
final Set<AccessionRef> accessionRefs = subset.getAccessionRefs();
if (accessionRefs != null && !accessionRefs.isEmpty()) {
int fromIndex = Math.multiplyExact(page.getPageNumber(), page.getPageSize());
int toIndex = Math.min(fromIndex + page.getPageSize(), accessionRefs.size());
return new PageImpl<>(new ArrayList<AccessionRef>(accessionRefs).subList(fromIndex, toIndex), page, accessionRefs.size());
}
return new PageImpl<>(Collections.emptyList(), page, 0);
}
@Override @Override
public long countSubsets(SubsetFilter filter) { public long countSubsets(SubsetFilter filter) {
return subsetRepository.count(filter.buildQuery()); return subsetRepository.count(filter.buildQuery());
...@@ -138,7 +154,6 @@ public class SubsetServiceImpl implements SubsetService { ...@@ -138,7 +154,6 @@ public class SubsetServiceImpl implements SubsetService {
} }
final Subset subset = new Subset(); final Subset subset = new Subset();
copyValues(subset, source); copyValues(subset, source);
copyAccessions(subset, source.getAccessionRefs());
subset.setState(PublishState.DRAFT); subset.setState(PublishState.DRAFT);
return deepLoad(subsetRepository.save(subset)); return deepLoad(subsetRepository.save(subset));
} }
...@@ -204,8 +219,6 @@ public class SubsetServiceImpl implements SubsetService { ...@@ -204,8 +219,6 @@ public class SubsetServiceImpl implements SubsetService {
subset.getInstitute().getId(); subset.getInstitute().getId();
if (subset.getCrops() != null) if (subset.getCrops() != null)
subset.getCrops().size(); subset.getCrops().size();
if (subset.getAccessionRefs() != null)
subset.getAccessionRefs().size();
if (subset.getCreators() != null) if (subset.getCreators() != null)
subset.getCreators().size(); subset.getCreators().size();
...@@ -260,9 +273,6 @@ public class SubsetServiceImpl implements SubsetService { ...@@ -260,9 +273,6 @@ public class SubsetServiceImpl implements SubsetService {
public Subset update(final Subset source) { public Subset update(final Subset source) {
LOG.info("Update Subset."); LOG.info("Update Subset.");
final Subset subset = loadSubset(source); final Subset subset = loadSubset(source);
subset.getAccessionRefs().clear();
copyAccessions(subset, source.getAccessionRefs());
copyValues(subset, source); copyValues(subset, source);
return deepLoad(subsetRepository.save(subset)); return deepLoad(subsetRepository.save(subset));
......
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
*/ */
package org.genesys.test.catalog.services; package org.genesys.test.catalog.services;
import java.util.List;
import java.util.Set;
import org.genesys.catalog.model.Partner; import org.genesys.catalog.model.Partner;
import org.genesys.catalog.model.dataset.Dataset; import org.genesys.catalog.model.dataset.Dataset;
import org.genesys.catalog.model.dataset.DatasetCreator; import org.genesys.catalog.model.dataset.DatasetCreator;
...@@ -26,25 +23,14 @@ import org.genesys.catalog.persistence.dataset.DatasetRepository; ...@@ -26,25 +23,14 @@ import org.genesys.catalog.persistence.dataset.DatasetRepository;
import org.genesys.catalog.persistence.dataset.DatasetVersionsRepository; import org.genesys.catalog.persistence.dataset.DatasetVersionsRepository;
import org.genesys.catalog.service.DatasetService; import org.genesys.catalog.service.DatasetService;
import org.genesys.filerepository.persistence.RepositoryFilePersistence; import org.genesys.filerepository.persistence.RepositoryFilePersistence;
import org.genesys2.server.api.model.AccessionHeaderJson;
import org.genesys2.server.model.PublishState; import org.genesys2.server.model.PublishState;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AccessionRef; import org.genesys2.server.model.genesys.AccessionRef;
import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.persistence.AccessionRepository; import org.genesys2.server.persistence.AccessionRepository;
import org.genesys2.server.persistence.FaoInstituteRepository; import org.genesys2.server.persistence.FaoInstituteRepository;
import org.genesys2.server.service.InstituteService;
import org.genesys2.server.service.worker.AccessionUploader;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
public abstract class AbstractDatasetServiceTest extends CatalogServiceTest { public abstract class AbstractDatasetServiceTest extends CatalogServiceTest {
protected static final String TEST_INSTCODE = "XYZ001"; protected static final String TEST_INSTCODE = "XYZ001";
...@@ -73,10 +59,6 @@ public abstract class AbstractDatasetServiceTest extends CatalogServiceTest { ...@@ -73,10 +59,6 @@ public abstract class AbstractDatasetServiceTest extends CatalogServiceTest {
protected AccessionRepository accessionRepository; protected AccessionRepository accessionRepository;
@Autowired @Autowired
protected FaoInstituteRepository instituteRepository; protected FaoInstituteRepository instituteRepository;
@Autowired
private InstituteService instituteService;
@Autowired
private AccessionUploader accessionUploader;
public AbstractDatasetServiceTest() { public AbstractDatasetServiceTest() {
super(); super();
...@@ -95,22 +77,16 @@ public abstract class AbstractDatasetServiceTest extends CatalogServiceTest { ...@@ -95,22 +77,16 @@ public abstract class AbstractDatasetServiceTest extends CatalogServiceTest {
datasetVersionsRepository.deleteAll(); datasetVersionsRepository.deleteAll();
descriptorRepository.deleteAll(); descriptorRepository.deleteAll();
repositoryFilePersistence.deleteAll(); repositoryFilePersistence.deleteAll();
accessionRepository.deleteAll();
instituteRepository.deleteAll();
super.cleanup(); super.cleanup();
} }
protected Dataset buildAndSaveDataset(final String datasetTitle, final String datasetDescription, final Partner partner, final PublishState state) { protected Dataset buildAndSaveDataset(final String datasetTitle, final String datasetDescription, final Partner partner, final PublishState state) {
return datasetService.createDataset(buildDataset(datasetTitle, datasetDescription, partner, state));
final Set<AccessionRef> accessionRefs = Sets.newHashSet(new AccessionRef("InstCode", "TestAccNum", "TestGen", null));
return datasetService.createDataset(buildDataset(datasetTitle, datasetDescription, partner, accessionRefs, state));
} }
protected Dataset buildDataset(final String datasetTitle, final String datasetDescription, final Partner partner, final Set<AccessionRef> accessionRefs, final PublishState state) { protected Dataset buildDataset(final String datasetTitle, final String datasetDescription, final Partner partner, final PublishState state) {
final Dataset input = new Dataset(); final Dataset input = new Dataset();
input.setTitle(datasetTitle); input.setTitle(datasetTitle);
input.setAccessionRefs(accessionRefs);
input.setDescription(datasetDescription); input.setDescription(datasetDescription);
input.setOwner(partner); input.setOwner(partner);
input.setState(state); input.setState(state);
...@@ -140,47 +116,4 @@ public abstract class AbstractDatasetServiceTest extends CatalogServiceTest { ...@@ -140,47 +116,4 @@ public abstract class AbstractDatasetServiceTest extends CatalogServiceTest {
return new AccessionRef(instCode, acceNumb, genus, doi); return new AccessionRef(instCode, acceNumb, genus, doi);
} }
protected Accession upsertAccession(final String instCode, final String acceNumb, final String genus) {
FaoInstitute institute = instituteService.getInstitute(instCode);
if (institute == null) {
institute = new FaoInstitute();
institute.setCode(instCode);
institute.setFullName("Test institute " + instCode);
instituteService.update(Lists.newArrayList(institute));
institute = instituteService.getInstitute(instCode);
}
ObjectMapper objectMapper = new ObjectMapper();
ArrayNode updates = objectMapper.createArrayNode();
ObjectNode accession = updates.addObject();
accession.put("instituteCode", instCode);
accession.put("accessionNumber", acceNumb);
ObjectNode taxa = accession.putObject("taxonomy");
taxa.put("genus", genus);
accessionUploader.upsertAccessions(institute, updates);
return accessionRepository.findOne(institute, null, acceNumb, genus);
}
protected void deleteAccession(final String instCode, final String acceNumb, final String genus) {
FaoInstitute institute = instituteService.getInstitute(instCode);
if (institute == null) {
institute = new FaoInstitute();
institute.setCode(instCode);
institute.setFullName("Test institute " + instCode);
instituteService.update(Lists.newArrayList(institute));
institute = instituteService.getInstitute(instCode);
}
AccessionHeaderJson ah=new AccessionHeaderJson();
ah.instCode=instCode;
ah.acceNumb=acceNumb;
ah.genus=genus;
List<AccessionHeaderJson> identifiers=Lists.newArrayList(ah);
accessionUploader.deleteAccessions(institute, identifiers);
assert(accessionRepository.findOne(institute, null, acceNumb, genus) == null);
}
} }
\ No newline at end of file
...@@ -17,6 +17,7 @@ package org.genesys.test.catalog.services; ...@@ -17,6 +17,7 @@ package org.genesys.test.catalog.services;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.genesys.catalog.model.Partner; import org.genesys.catalog.model.Partner;
...@@ -35,9 +36,20 @@ import org.genesys.catalog.service.PartnerService; ...@@ -35,9 +36,20 @@ import org.genesys.catalog.service.PartnerService;
import org.genesys.catalog.service.ShortFilterService; import org.genesys.catalog.service.ShortFilterService;
import org.genesys.catalog.service.VocabularyService; import org.genesys.catalog.service.VocabularyService;
import org.genesys.test.base.AbstractServiceTest; import org.genesys.test.base.AbstractServiceTest;
import org.genesys2.server.api.model.AccessionHeaderJson;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.persistence.AccessionRepository;
import org.genesys2.server.persistence.FaoInstituteRepository;
import org.genesys2.server.service.InstituteService;
import org.genesys2.server.service.worker.AccessionUploader;
import org.junit.After; import org.junit.After;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
/** /**
...@@ -97,6 +109,18 @@ public abstract class CatalogServiceTest extends AbstractServiceTest { ...@@ -97,6 +109,18 @@ public abstract class CatalogServiceTest extends AbstractServiceTest {
@Autowired @Autowired
protected ShortFilterRepository shortFilterRepository; protected ShortFilterRepository shortFilterRepository;
@Autowired
private InstituteService instituteService;
@Autowired
private AccessionUploader accessionUploader;
@Autowired
protected AccessionRepository accessionRepository;
@Autowired
protected FaoInstituteRepository instituteRepository;
protected Partner partner; protected Partner partner;
protected Partner partner2; protected Partner partner2;
...@@ -106,6 +130,9 @@ public abstract class CatalogServiceTest extends AbstractServiceTest { ...@@ -106,6 +130,9 @@ public abstract class CatalogServiceTest extends AbstractServiceTest {
partnerRepository.deleteAll();