Commit 635b2334 authored by Andrey Lugovskiy's avatar Andrey Lugovskiy Committed by Matija Obreza
Browse files

- added accessionsIdentifier

parent 937d1c30
package org.genesys.catalog.model.dataset;
import org.genesys.blocks.model.AuditedVersionedModel;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import java.io.Serializable;
import java.util.Set;
/**
* @author Andrey Lugovskoy.
*/
@Entity
@Table(name = "accession", uniqueConstraints = {
@UniqueConstraint(name = "UQ_accession_genus_inst", columnNames = { "taxGenus", "instCode", "acceNumb" }),
@UniqueConstraint(name = "UQ_accession_doi", columnNames = { "doi" }) })
public class AccessionIdentifier extends AuditedVersionedModel implements Serializable {
@ManyToMany(mappedBy = "accessionIdentifiers")
private Set<Dataset> datasets;
@Column(name = "doi")
public String doi;
@Column(name = "instCode", length = 10, nullable = false)
public String instCode;
@Column(name = "acceNumb", nullable = false, length = 128)
public String acceNumb;
@Column(name = "taxGenus", nullable = false)
public String genus;
public Set<Dataset> getDatasets() {
return datasets;
}
public void setDatasets(Set<Dataset> datasets) {
this.datasets = datasets;
}
public String getInstCode() {
return instCode;
}
public String getAcceNumb() {
return acceNumb;
}
public void setDoi(String doi) {
this.doi = doi;
}
public void setInstCode(String instCode) {
this.instCode = instCode;
}
public void setAcceNumb(String acceNumb) {
this.acceNumb = acceNumb;
}
public void setGenus(String genus) {
this.genus = genus;
}
public String getDoi() {
return doi;
}
public String getHoldingInstitute() {
return instCode;
}
public String getAccessionNumber() {
return acceNumb;
}
public String getGenus() {
return genus;
}
}
......@@ -16,14 +16,13 @@
package org.genesys.catalog.model.dataset;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.Cacheable;
import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
......@@ -73,10 +72,11 @@ public class Dataset extends UuidEntity implements Publishable, PublishValidatio
private Partner owner;
@PublishValidation
@ElementCollection
@CollectionTable(name = "datasetaccessions", joinColumns = @JoinColumn(name = "datasetId"))
@Column(name = "accessionIdentifer", nullable = false)
private Set<String> accessionIdentifiers;
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable(name = "datasetaccessions", joinColumns = @JoinColumn(name = "datasetId", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "accessionId", referencedColumnName = "id"))
@OrderColumn(name = "position")
private Set<AccessionIdentifier> accessionIdentifiers;
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable(name = "datasetdescriptor", joinColumns = @JoinColumn(name = "datasetId", referencedColumnName = "id"),
......@@ -306,14 +306,14 @@ public class Dataset extends UuidEntity implements Publishable, PublishValidatio
/**
* @return the accessionIdentifiers
*/
public final Set<String> getAccessionIdentifiers() {
public final Set<AccessionIdentifier> getAccessionIdentifiers() {
return accessionIdentifiers;
}
/**
* @param accessionIdentifiers the accessionIdentifiers to set
*/
public final void setAccessionIdentifiers(final Set<String> accessionIdentifiers) {
public final void setAccessionIdentifiers(final Set<AccessionIdentifier> accessionIdentifiers) {
this.accessionIdentifiers = accessionIdentifiers;
}
......
package org.genesys.catalog.persistence.dataset;
import org.genesys.catalog.model.dataset.AccessionIdentifier;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.stereotype.Repository;
/**
* @author Andrey Lugovskoy.
*/
@Repository
public interface AccessionIdentifierRepository extends JpaRepository<AccessionIdentifier, Long>, QueryDslPredicateExecutor<AccessionIdentifier> {
}
......@@ -17,6 +17,7 @@ package org.genesys.catalog.service;
import org.genesys.catalog.exceptions.NotFoundElement;
import org.genesys.catalog.exceptions.PublishValidationException;
import org.genesys.catalog.model.dataset.AccessionIdentifier;
import org.genesys.catalog.model.dataset.Dataset;
import org.genesys.catalog.model.traits.Descriptor;
import org.genesys.catalog.service.filters.DatasetFilter;
......@@ -66,7 +67,7 @@ public interface DatasetService {
* @return updated Dataset in db.
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#input, 'write')")
Dataset updateAccessionIdentifiers(Dataset input, Set<String> accessionIdentifiers);
Dataset updateAccessionIdentifiers(Dataset input, Set<AccessionIdentifier> accessionIdentifiers);
/**
* Method adding new descriptor to Dataset.
......@@ -219,4 +220,13 @@ public interface DatasetService {
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'delete')")
Dataset removeDataset(Dataset dataset);
/**
* add Accessions to Dataset
*
* @param accessionIdentifiers accessionIdentifiers
* @return updated Dataset
*/
@PreAuthorize("isAuthenticated()")
Dataset upsertAccessions(Set<AccessionIdentifier> accessionIdentifiers, UUID datasetUuid) throws NotFoundElement;
}
......@@ -54,7 +54,7 @@ public class DatasetFilter extends AuditedVersionedModelFilter {
and.and(dataset.owner.in(JPAExpressions.selectFrom(QPartner.partner).where(owner.buildQuery())));
}
if (CollectionUtils.isNotEmpty(accessionIdentifiers)) {
and.and(dataset.accessionIdentifiers.any().in(accessionIdentifiers));
// and.and(dataset.accessionIdentifiers.any().in(accessionIdentifiers));
}
if (CollectionUtils.isNotEmpty(language)) {
and.and(dataset.language.in(language));
......
......@@ -17,9 +17,11 @@ package org.genesys.catalog.service.impl;
import org.genesys.catalog.exceptions.NotFoundElement;
import org.genesys.catalog.exceptions.PublishValidationException;
import org.genesys.catalog.model.dataset.AccessionIdentifier;
import org.genesys.catalog.model.dataset.Dataset;
import org.genesys.catalog.model.dataset.DatasetVersions;
import org.genesys.catalog.model.traits.Descriptor;
import org.genesys.catalog.persistence.dataset.AccessionIdentifierRepository;
import org.genesys.catalog.persistence.dataset.DatasetRepository;
import org.genesys.catalog.persistence.dataset.DatasetVersionsRepository;
import org.genesys.catalog.service.DatasetService;
......@@ -73,6 +75,9 @@ public class DatasetServiceImpl implements DatasetService {
@Autowired
private Utils utils;
@Autowired
private AccessionIdentifierRepository accessionIdentifierRepository;
@Value("${file.repository.path}")
public String fileRepositoryPath;
......@@ -96,7 +101,8 @@ public class DatasetServiceImpl implements DatasetService {
dataset.setCreators(new ArrayList<>());
if (source.getAccessionIdentifiers() != null) {
dataset.setAccessionIdentifiers(source.getAccessionIdentifiers());
List<AccessionIdentifier> accessionIdentifier = accessionIdentifierRepository.save(source.getAccessionIdentifiers());
dataset.setAccessionIdentifiers(new HashSet<>(accessionIdentifier));
}
copyDescriptors(dataset, source.getDescriptors());
......@@ -130,12 +136,11 @@ public class DatasetServiceImpl implements DatasetService {
*/
@Override
@Transactional
public Dataset updateAccessionIdentifiers(Dataset source, final Set<String> accessionIdentifiers) {
public Dataset updateAccessionIdentifiers(Dataset source, final Set<AccessionIdentifier> accessionIdentifiers) {
LOG.info("Update AccessionIdentifiers. Input dataset: {}, input accessionIdentifiers {}", source, accessionIdentifiers);
Dataset dataset = loadDataset(source);
dataset.getAccessionIdentifiers().clear();
dataset.setAccessionIdentifiers(accessionIdentifiers);
return fetchLazyCollections(datasetRepository.save(dataset));
}
......@@ -359,6 +364,17 @@ public class DatasetServiceImpl implements DatasetService {
return loadedDataset;
}
/**
* {@inheritDoc}
*/
@Transactional
@Override
public Dataset upsertAccessions(Set<AccessionIdentifier> accessionIdentifiers, UUID datasetUuid) throws NotFoundElement {
Dataset loadedDataset = loadDataset(datasetUuid);
loadedDataset.setAccessionIdentifiers(accessionIdentifiers);
return datasetRepository.save(loadedDataset);
}
private void copyValues(Dataset target, final Dataset source) {
target.setTitle(source.getTitle());
target.setPublished(source.isPublished());
......
package org.genesys.catalog.service;
import com.google.common.collect.Sets;
import org.genesys.catalog.exceptions.NotFoundElement;
import org.genesys.catalog.model.dataset.Dataset;
import org.genesys.catalog.model.dataset.DatasetCreator;
......@@ -38,7 +37,7 @@ public class DatasetCreatorServiceTest extends DatasetServiceTest {
@Test
public void createDatasetCreator() throws Exception {
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
DatasetCreator datasetCreator = buildDatasetCreator("TestFirstName", "TestLastName", "TestEmailName", "0673579007", result);
DatasetCreator datasetCreators = datasetCreatorService.createDatasetCreator(result.getUuid(), datasetCreator);
assertThat(datasetCreators, is(not(nullValue())));
......@@ -48,7 +47,7 @@ public class DatasetCreatorServiceTest extends DatasetServiceTest {
@Test
public void updateDatasetCreator() throws NotFoundElement {
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
DatasetCreator datasetCreator = buildDatasetCreator("TestFirstName", "TestLastName", "TestEmailName", "0673579007", result);
datasetCreator = datasetCreatorService.createDatasetCreator(result.getUuid(), datasetCreator);
datasetCreator.setInstituteAddress("TEST FAX");
......@@ -59,7 +58,7 @@ public class DatasetCreatorServiceTest extends DatasetServiceTest {
@Test
public void removeDatasetCreator() throws Exception {
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
DatasetCreator datasetCreator = buildDatasetCreator("TestFirstName", "TestLastName", "TestEmailName", "0673579007", result);
DatasetCreator creator = datasetCreatorService.createDatasetCreator(result.getUuid(), datasetCreator);
assertThat(creator.getDataset().getUuid().toString(), equalTo(result.getUuid().toString()));
......@@ -69,7 +68,7 @@ public class DatasetCreatorServiceTest extends DatasetServiceTest {
@Test
public void listDatasetCreators() throws Exception {
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
DatasetCreator datasetCreator = buildDatasetCreator("TestFirstName", "TestLastName", "TestEmailName", "0673579007", result);
DatasetCreator creator = datasetCreatorService.createDatasetCreator(result.getUuid(), datasetCreator);
......@@ -84,7 +83,7 @@ public class DatasetCreatorServiceTest extends DatasetServiceTest {
@Test
public void loadDatasetCreators() throws Exception {
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
DatasetCreator datasetCreator = buildDatasetCreator("TestFirstName", "TestLastName", "TestEmailName", "0673579007", result);
datasetCreatorService.createDatasetCreator(result.getUuid(), datasetCreator);
List<DatasetCreator> creator = datasetCreatorService.loadDatasetCreators(result.getUuid());
......@@ -95,7 +94,7 @@ public class DatasetCreatorServiceTest extends DatasetServiceTest {
@Test(expected = NotFoundElement.class)
public void failLoadDatasetCreator() throws NotFoundElement {
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
DatasetCreator datasetCreator = buildDatasetCreator("TestFirstName", "TestLastName", "TestEmailName", "0673579007", result);
datasetCreatorService.createDatasetCreator(result.getUuid(), datasetCreator);
datasetCreator.setUuid(UUID.randomUUID());
......@@ -104,7 +103,7 @@ public class DatasetCreatorServiceTest extends DatasetServiceTest {
@Test(expected = ConcurrencyFailureException.class)
public void failLoadDatasetCreator2() throws NotFoundElement {
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
DatasetCreator datasetCreator = buildDatasetCreator("TestFirstName", "TestLastName", "TestEmailName", "0673579007", result);
datasetCreatorService.createDatasetCreator(result.getUuid(), datasetCreator);
datasetCreator.setVersion(10);
......
......@@ -16,14 +16,15 @@
package org.genesys.catalog.service;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.genesys.catalog.exceptions.NotFoundElement;
import org.genesys.catalog.exceptions.PublishValidationException;
import org.genesys.catalog.model.dataset.AccessionIdentifier;
import org.genesys.catalog.model.dataset.Dataset;
import org.genesys.catalog.model.dataset.DatasetCreator;
import org.genesys.catalog.model.dataset.Location;
import org.genesys.catalog.model.traits.Descriptor;
import org.genesys.catalog.model.traits.Descriptor.DataType;
import org.genesys.catalog.persistence.dataset.AccessionIdentifierRepository;
import org.genesys.catalog.persistence.dataset.DatasetRepository;
import org.genesys.catalog.persistence.dataset.DatasetVersionsRepository;
import org.genesys.catalog.test.CatalogServiceTest;
......@@ -31,7 +32,6 @@ import org.genesys.common.model.Partner;
import org.genesys.filerepository.InvalidRepositoryFileDataException;
import org.genesys.filerepository.InvalidRepositoryPathException;
import org.genesys.filerepository.NoSuchRepositoryFileException;
import org.genesys.filerepository.model.RepositoryFile;
import org.genesys.filerepository.persistence.RepositoryFilePersistence;
import org.junit.Ignore;
import org.junit.Test;
......@@ -51,6 +51,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -81,28 +82,32 @@ public class DatasetServiceTest extends CatalogServiceTest {
@Autowired
protected DatasetCreatorService datasetCreatorService;
@Autowired
protected AccessionIdentifierRepository accessionIdentifierRepository;
@Override
public void cleanup() {
datasetRepository.deleteAll();
datasetVersionsRepository.deleteAll();
descriptorRepository.deleteAll();
repositoryFilePersistence.deleteAll();
accessionIdentifierRepository.deleteAll();
super.cleanup();
}
@Test
public void testCreateDataset() {
Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
assertThat(input, not(nullValue()));
assertThat(input.getId(), not(nullValue()));
assertThat(input.getAccessionIdentifiers(), contains("accession 1"));
assertThat(input.getAccessionIdentifiers().size(), is(1));
assertThat(input.getVersions(), not(nullValue()));
assertThat(input.getVersions().getCurrentVersion(), is(input));
}
@Test(expected = DataRetrievalFailureException.class)
public void testRemoveDataset(){
Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
public void testRemoveDataset() {
Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
Dataset removed = datasetService.removeDataset(input);
assertThat(removed, not(nullValue()));
assertThat(removed, equalTo(input));
......@@ -113,7 +118,7 @@ public class DatasetServiceTest extends CatalogServiceTest {
public void testCreateDatasetForCopyDescriptors() {
final Descriptor savedDescriptor = descriptorService.createDescriptor(createDescriptor(partner, "D1", "1.0", DataType.NUMERIC));
Dataset input2 = buildDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset input2 = buildDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
input2.setDescriptors(new ArrayList<Descriptor>() {{
add(savedDescriptor);
add(savedDescriptor);
......@@ -123,12 +128,21 @@ public class DatasetServiceTest extends CatalogServiceTest {
@Test
public void testUpdateAccessionIdentifiersInDataset() {
Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Set<String> accessionIdentifiers = Sets.newHashSet("accession 1", "accession 2", "accession 3", "accession 4");
Dataset input = buildDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
input = datasetService.createDataset(input);
Set<AccessionIdentifier> accessionIdentifiers = new HashSet<AccessionIdentifier>() {{
AccessionIdentifier accessionIdentifier = new AccessionIdentifier();
accessionIdentifier.setAcceNumb("TestAccNum");
accessionIdentifier.setGenus("TestGen");
accessionIdentifier.setInstCode("InstCode");
add(accessionIdentifier);
}};
input = datasetService.updateAccessionIdentifiers(input, accessionIdentifiers);
assertThat(input, not(nullValue()));
assertThat(input.getAccessionIdentifiers().size(), is(4));
assertThat(input.getAccessionIdentifiers(), containsInAnyOrder("accession 1", "accession 2", "accession 3", "accession 4"));
assertThat(input.getAccessionIdentifiers().size(), is(1));
assertThat(input.getAccessionIdentifiers().iterator().next(), is(accessionIdentifiers.iterator().next()));
}
/**
......@@ -136,7 +150,7 @@ public class DatasetServiceTest extends CatalogServiceTest {
*/
@Test(expected = DataIntegrityViolationException.class)
public void testFailUpdatePublishedDataset() {
Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
input.setPublished(Boolean.TRUE);
input = datasetService.updateDataset(input);
input.setTitle(DATASET_TITLE_2);
......@@ -148,7 +162,7 @@ public class DatasetServiceTest extends CatalogServiceTest {
*/
@Test(expected = InvalidDataAccessApiUsageException.class)
public void testFailUpdateWithoutIdentifiers() {
Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
input.setId(null);
datasetService.updateDataset(input);
}
......@@ -158,34 +172,40 @@ public class DatasetServiceTest extends CatalogServiceTest {
*/
@Test(expected = DataRetrievalFailureException.class)
public void testFailUpdateNonExistent() {
Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
input.setId(-1l);
datasetService.updateDataset(input);
}
@Test(expected = ConcurrencyFailureException.class)
public void testFailUpdateErrorVersion() {
Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
input.setVersion(4);
datasetService.updateDataset(input);
}
@Test
public void testUpdateDataset() {
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset result2 = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
Set<AccessionIdentifier> accessionIdentifiers = new HashSet<AccessionIdentifier>() {{
AccessionIdentifier accessionIdentifier = new AccessionIdentifier();
accessionIdentifier.setAcceNumb("TestAcc1");
accessionIdentifier.setGenus("TestGenn1");
accessionIdentifier.setInstCode("InstCode1");
add(accessionIdentifier);
}};
Dataset result2 = datasetService.createDataset(buildDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, accessionIdentifiers));
assertThat(result.getAccessionIdentifiers(), contains("accession 1"));
assertThat(result.isPublished(), is(false));
result.setTitle(DATASET_TITLE_2);
result.setDescription(DATASET_DESCRIPTION_2);
result.setAccessionIdentifiers(Sets.newHashSet("accession 2", "accession 3"));
Dataset resultUpdated = datasetService.updateDataset(result);
assertThat(resultUpdated.getTitle(), is(DATASET_TITLE_2));
assertThat(resultUpdated.getDescription(), is(DATASET_DESCRIPTION_2));
assertThat(resultUpdated.getAccessionIdentifiers(), contains("accession 1"));
assertThat(resultUpdated.getVersions().getAllVersions(), hasSize(1));
List<Dataset> datasetVersionss = new ArrayList<>();
......@@ -195,7 +215,6 @@ public class DatasetServiceTest extends CatalogServiceTest {
resultUpdated.getVersions().setAllVersions(datasetVersionss);
datasetVersionsRepository.save(resultUpdated.getVersions());
assertThat(resultUpdated.getVersions().getAllVersions(), hasSize(2));
// assertThat(result.getDescriptors(), contains(descriptorOne));
}
@Test
......@@ -203,7 +222,7 @@ public class DatasetServiceTest extends CatalogServiceTest {
Descriptor savedDescriptor = createDescriptor(partner, "D1", "1.0", DataType.NUMERIC);
savedDescriptor = descriptorService.createDescriptor(savedDescriptor);
Dataset savedDataset = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset savedDataset = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
assertThat(savedDataset.getDescriptors(), hasSize(0));
savedDataset = datasetService.addDescriptor(savedDataset, savedDescriptor);
......@@ -220,7 +239,7 @@ public class DatasetServiceTest extends CatalogServiceTest {
Descriptor descriptor2 = createDescriptor(partner, "D2", "1.0", DataType.NUMERIC);
descriptor2 = descriptorService.createDescriptor(descriptor2);
Dataset savedDataset = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset savedDataset = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
savedDataset = datasetService.addDescriptor(savedDataset, descriptor1);
savedDataset = datasetService.addDescriptor(savedDataset, descriptor2);
......@@ -244,7 +263,7 @@ public class DatasetServiceTest extends CatalogServiceTest {
Descriptor descriptor3 = createDescriptor(partner, "D3", "1.1", DataType.TEXT);
descriptor3 = descriptorService.createDescriptor(descriptor3);
Dataset savedDataset = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset savedDataset = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
savedDataset = datasetService.addDescriptor(savedDataset, descriptor1);
savedDataset = datasetService.addDescriptor(savedDataset, descriptor2);
......@@ -268,7 +287,7 @@ public class DatasetServiceTest extends CatalogServiceTest {
Descriptor descriptor3 = createDescriptor(partner, "D3", "1.1", DataType.TEXT);
descriptor3 = descriptorService.createDescriptor(descriptor3);
Dataset savedDataset = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset savedDataset = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
savedDataset = datasetService.updateDescriptors(savedDataset, Lists.newArrayList(descriptor3, descriptor1, descriptor2, descriptor3));
assertThat(savedDataset.getDescriptors(), contains(descriptor3, descriptor1, descriptor2, descriptor3));
......@@ -279,7 +298,7 @@ public class DatasetServiceTest extends CatalogServiceTest {
Descriptor descriptor1 = createDescriptor(partner, "D1", "1.0", DataType.NUMERIC);
descriptor1 = descriptorService.createDescriptor(descriptor1);
Dataset dataset = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset dataset = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
dataset.setDescriptors(Lists.newArrayList(descriptor1));
Dataset savedDataset = datasetService.createDataset(dataset);
......@@ -289,14 +308,14 @@ public class DatasetServiceTest extends CatalogServiceTest {
@Test(expected = NullPointerException.class)
public void testFailOnUpdateDescriptorsWithNullInDataset() {
Dataset dataset = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset dataset = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
assertThat(dataset.getDescriptors(), hasSize(0));
datasetService.addDescriptor(dataset, null);
}
@Test
public void testLoadList() {
Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);
String[] strs = new String[] { "title" };
Pageable pageable = new PageRequest(0, Integer.min(50, 100), Sort.Direction.ASC, strs);
Page page = datasetService.loadList(pageable);
......@@ -306,7 +325,7 @@ public class DatasetServiceTest extends CatalogServiceTest {
@Test
public void testLoadCurrentVersionList() {
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, Sets.newHashSet("accession 1"));
Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner);