Commit db53d595 authored by Matija Obreza's avatar Matija Obreza

Merge Catalog continued

- Updated JPA table and column names
- Annotated Catalog services with "catalog*" name
- Vocabulary source beans with name "*VocabularySource"
- Registered keys missing in application.properties
parent ec10963d
......@@ -38,8 +38,8 @@ import java.util.Set;
* @author Matija Obreza
*/
@Entity
@Cacheable
@Table(name = "partner")
@Cacheable
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "uuid")
@Document(indexName = "catalog")
public class Partner extends UuidModel implements SelfCleaning, AclAwareModel {
......@@ -74,17 +74,17 @@ public class Partner extends UuidModel implements SelfCleaning, AclAwareModel {
/// partner-associated web links
@ElementCollection
@CollectionTable(name = "partnerUrl", joinColumns = @JoinColumn(name = "partnerId"))
@CollectionTable(name = "partner_url", joinColumns = @JoinColumn(name = "partnerId"))
private Set<URL> urls;
/// FAO WIEWS codes associated with this partner
@ElementCollection
@CollectionTable(name = "partnerWiews", joinColumns = @JoinColumn(name = "partnerId"))
@CollectionTable(name = "partner_wiews", joinColumns = @JoinColumn(name = "partnerId"))
@Column(name = "wiews")
private Set<String> wiewsCodes;
@ElementCollection
@CollectionTable(name = "PartnerCountry", joinColumns = @JoinColumn(name = "partnerId"), uniqueConstraints = { @UniqueConstraint(columnNames = { "partnerId", "code" }) })
@CollectionTable(name = "partner_country", joinColumns = @JoinColumn(name = "partnerId"), uniqueConstraints = { @UniqueConstraint(columnNames = { "partnerId", "code" }) })
@Column(name = "code", length = 3, nullable = false)
private Set<String> countryCodes;
......
......@@ -26,8 +26,12 @@ import java.util.Objects;
* @author Maxym Borodenko
*/
@Entity
@Table(name = "short_filter"
// TODO Manually create an index on json field! (length limited)
// , indexes = { @Index(name="UK_1my8xep8hi5fv42o3ivu0t41o", columnList =
// "json") }
)
@Cacheable
@Table(indexes = { @Index(name="UK_1my8xep8hi5fv42o3ivu0t41o", columnList = "json") })
public class ShortFilter implements Serializable, EntityId {
/** The Constant serialVersionUID. */
......@@ -52,12 +56,13 @@ public class ShortFilter implements Serializable, EntityId {
/**
* Default constructor.
*/
public ShortFilter() {}
public ShortFilter() {
}
/**
* Instantiates a new ShortFilter.
*
* @param code the short name
* @param code the short name
* @param json the json filters
*/
public ShortFilter(final String code, final String json) {
......@@ -108,11 +113,12 @@ public class ShortFilter implements Serializable, EntityId {
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (!(o instanceof ShortFilter)) return false;
if (this == o)
return true;
if (!(o instanceof ShortFilter))
return false;
final ShortFilter that = (ShortFilter) o;
return Objects.equals(id, that.id) && Objects.equals(code, that.code)
&& Objects.equals(json, that.json);
return Objects.equals(id, that.id) && Objects.equals(code, that.code) && Objects.equals(json, that.json);
}
@Override
......
......@@ -45,6 +45,7 @@ import java.util.Set;
* @author Maxim Borodenko
*/
@Entity
@Table(name="dataset")
@Cacheable
@Audited
@Document(indexName = "catalog")
......@@ -69,7 +70,7 @@ public class Dataset extends UuidModel implements Publishable, SelfCleaning, Pub
/** The accession identifiers. */
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "datasetAccessions", joinColumns = @JoinColumn(name = "datasetId"),
@CollectionTable(name = "dataset_accessions", joinColumns = @JoinColumn(name = "datasetId"),
// index
indexes = { @Index(columnList = "datasetId, instCode, acceNumb"), @Index(columnList = "datasetId, genus") })
@Field(type=FieldType.Object)
......@@ -78,7 +79,7 @@ public class Dataset extends UuidModel implements Publishable, SelfCleaning, Pub
/** The descriptors. */
@ManyToMany(fetch = FetchType.LAZY, cascade = {})
@JoinTable(name = "datasetDescriptor", joinColumns = @JoinColumn(name = "datasetId", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "descriptorId", referencedColumnName = "id"))
@JoinTable(name = "dataset_descriptor", joinColumns = @JoinColumn(name = "datasetId", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "descriptorId", referencedColumnName = "id"))
@OrderColumn(name = "position")
@JsonView({ JsonViews.Public.class })
private List<Descriptor> descriptors;
......@@ -86,7 +87,7 @@ public class Dataset extends UuidModel implements Publishable, SelfCleaning, Pub
/** The repository files. */
@PublishValidation
@OneToMany(fetch = FetchType.LAZY, cascade = {})
@JoinTable(name = "datasetRepositoryfile", joinColumns = @JoinColumn(name = "datasetId", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "repositoryfileId", referencedColumnName = "id"))
@JoinTable(name = "dataset_repositoryfile", joinColumns = @JoinColumn(name = "datasetId", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "repositoryfileId", referencedColumnName = "id"))
@OrderColumn(name = "position")
@Field(type=FieldType.Object)
@JsonView({ JsonViews.Public.class })
......@@ -118,7 +119,7 @@ public class Dataset extends UuidModel implements Publishable, SelfCleaning, Pub
/** The crops. */
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "datasetCrops", joinColumns = @JoinColumn(name = "datasetId"),
@CollectionTable(name = "dataset_crops", joinColumns = @JoinColumn(name = "datasetId"),
// index
indexes = { @Index(columnList = "datasetId, crop") })
@Column(name = "crop", nullable = false, length = 20)
......
......@@ -29,6 +29,7 @@ import java.util.Map;
* @author Andrey Lugovskoy.
*/
@Entity
@Table(name="dataset_creator")
public class DatasetCreator extends UuidModel implements PublishValidationInterface {
/**
......
......@@ -29,6 +29,7 @@ import java.util.Map;
* @author Andrey Lugovskoy.
*/
@Entity
@Table(name="dataset_location")
public class DatasetLocation extends UuidModel implements PublishValidationInterface {
/**
......
......@@ -22,6 +22,8 @@ import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import java.util.List;
/**
......@@ -31,6 +33,7 @@ import java.util.List;
*
*/
@Entity
@Table(name="dataset_version")
public class DatasetVersions extends UuidModel {
/** The Constant serialVersionUID. */
......
......@@ -135,8 +135,13 @@ public class Descriptor extends UuidModel implements SelfCleaning, Publishable,
/** Allow only integers, no decimal numbers. */
private Boolean integerOnly;
/** Data constraints, min and max allowed numeric values. */
private Double minValue, maxValue;
/** Data constraints: minimum allowed numeric values. */
@Column(name = "min_value")
private Double minValue;
/** Data constraints: maximum allowed numeric values. */
@Column(name = "max_value")
private Double maxValue;
/** The uom. */
@Column(name = "uom", length = 20)
......@@ -164,7 +169,7 @@ public class Descriptor extends UuidModel implements SelfCleaning, Publishable,
* Vocabulary terms specific to this descriptor (99% of the cases).
*/
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH }, orphanRemoval = true)
@JoinTable(name = "DescriptorTerm", joinColumns = @JoinColumn(name = "descriptorId"),
@JoinTable(name = "descriptor_term", joinColumns = @JoinColumn(name = "descriptorId"),
// other side
inverseJoinColumns = @JoinColumn(name = "termId", unique = true),
// unique constraints
......
......@@ -40,6 +40,7 @@ import java.util.Map;
* @author Andrey Lugovskoy
*/
@Entity
@Table(name="descriptorlist")
@Audited
@Cacheable
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "uuid")
......@@ -87,7 +88,7 @@ public class DescriptorList extends UuidModel implements Publishable, SelfCleani
/** The descriptors. */
@ManyToMany(cascade = { CascadeType.REFRESH }, fetch = FetchType.LAZY)
@JoinTable(name = "descriptorListDescriptor", joinColumns = @JoinColumn(name = "descriptorListId", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "descriptorId", referencedColumnName = "id"))
@JoinTable(name = "descriptorlist_descriptor", joinColumns = @JoinColumn(name = "descriptorListId", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "descriptorId", referencedColumnName = "id"))
@OrderColumn(name = "position")
@JsonView({ JsonViews.Public.class })
@JsonIgnoreProperties(value = { "descriptorLists", "datasets", "owner", "vocabulary", "terms" })
......@@ -111,7 +112,7 @@ public class DescriptorList extends UuidModel implements Publishable, SelfCleani
/** Extra information associated with the descriptor list */
@JsonView({ JsonViews.Update.class, JsonViews.Public.class })
@ElementCollection(fetch = FetchType.EAGER)
@JoinTable(name = "DescriptorListExtra", joinColumns = { @JoinColumn(name = "descriptorListId") })
@JoinTable(name = "descriptorlist_extra", joinColumns = { @JoinColumn(name = "descriptorListId") })
@MapKeyColumn(name = "extra", length = 25)
@MapKeyEnumerated(EnumType.STRING)
@Column(name = "v")
......
......@@ -40,6 +40,7 @@ import java.util.List;
* @author Matija Obreza
*/
@Entity
@Table(name = "vocabulary")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "uuid")
@Document(indexName = "catalog")
public class ControlledVocabulary extends UuidModel implements Publishable, SelfCleaning, AclAwareModel {
......@@ -82,7 +83,7 @@ public class ControlledVocabulary extends UuidModel implements Publishable, Self
/** The terms. */
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH }, orphanRemoval = true)
@JoinTable(name = "ControlledVocabularyTerm", joinColumns = @JoinColumn(name = "vocabularyId"),
@JoinTable(name = "vocabulary_term", joinColumns = @JoinColumn(name = "vocabularyId"),
// other side
inverseJoinColumns = @JoinColumn(name = "termId", unique = true),
// unique constraints
......
......@@ -43,7 +43,7 @@ import java.text.MessageFormat;
* @author Matija Obreza
*/
@Entity
@Table(name = "Term")
@Table(name = "term")
@Document(indexName = "catalog")
public class VocabularyTerm extends BasicModel implements SelfCleaning {
......@@ -64,7 +64,7 @@ public class VocabularyTerm extends BasicModel implements SelfCleaning {
* Link back to Descriptor
*/
@ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.REFRESH })
@JoinTable(name = "DescriptorTerm", joinColumns = @JoinColumn(name = "termId"),
@JoinTable(name = "descriptor_term", joinColumns = @JoinColumn(name = "termId"),
// other side
inverseJoinColumns = @JoinColumn(name = "descriptorId"))
@JsonView({ JsonViews.Indexed.class, JsonViews.Minimal.class })
......@@ -77,7 +77,7 @@ public class VocabularyTerm extends BasicModel implements SelfCleaning {
* Link back to Descriptor
*/
@ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.REFRESH })
@JoinTable(name = "ControlledVocabularyTerm", joinColumns = @JoinColumn(name = "termId"),
@JoinTable(name = "vocabulary_term", joinColumns = @JoinColumn(name = "termId"),
// other side
inverseJoinColumns = @JoinColumn(name = "vocabularyId"))
@JsonView({ JsonViews.Indexed.class, JsonViews.Minimal.class })
......
......@@ -43,7 +43,7 @@ import java.util.stream.Collectors;
* @author Andrey Lugovskoy
* @author Matija Obreza
*/
@RestController
@RestController("catalogDatasetController")
@RequestMapping(DatasetController.API_BASE)
@PreAuthorize("isAuthenticated()")
public class DatasetController {
......
......@@ -39,7 +39,7 @@ import java.util.UUID;
*
* @author Maxym Borodenko
*/
@RestController
@RestController("catalogDescriptorController")
@RequestMapping(DescriptorController.API_BASE)
@PreAuthorize("isAuthenticated()")
public class DescriptorController {
......
......@@ -15,28 +15,23 @@
*/
package org.genesys.catalog.server.controller.api.v0;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.commons.io.FileUtils;
import org.genesys.catalog.service.MetadataService;
import org.genesys.catalog.service.FileMetadataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* The Class MetadataController.
* The Class FileMetadataController.
*
* @author Maxym Borodenko
*/
@RestController
@RequestMapping(MetadataController.API_BASE)
@RequestMapping(FileMetadataController.API_BASE)
@PreAuthorize("isAuthenticated()")
public class MetadataController {
public class FileMetadataController {
/**
* The Constant API_BASE.
......@@ -46,13 +41,13 @@ public class MetadataController {
/**
* The Constant LOG.
*/
private static final Logger LOG = LoggerFactory.getLogger(MetadataController.class);
private static final Logger LOG = LoggerFactory.getLogger(FileMetadataController.class);
private static final String APPLICATION_OXML_SHEET = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
private static final String APPLICATION_MS_EXCEL = "application/vnd.ms-excel";
@Autowired
private MetadataService metadataService;
private FileMetadataService fileMetadataService;
/**
* Metadata.
......@@ -87,7 +82,7 @@ public class MetadataController {
// final File tempFile = File.createTempFile("metadata", ".xlsx");
// try {
// FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile);
// return metadataService.getExcelMetadata(tempFile);
// return fileMetadataService.getExcelMetadata(tempFile);
// } finally {
// FileUtils.deleteQuietly(tempFile);
// }
......
......@@ -21,11 +21,11 @@ import java.io.File;
import java.io.IOException;
/**
* The Class MetadataService.
* The Class FileMetadataService.
*
* @author Maxym Borodenko
*/
public interface MetadataService {
public interface FileMetadataService {
/**
* generate JSON with Excel metadata.
......
......@@ -65,7 +65,7 @@ import com.querydsl.core.BooleanBuilder;
/**
* The Class DatasetServiceImpl.
*/
@Service
@Service("catalogDatasetService")
@Transactional(readOnly = true)
public class DatasetServiceImpl implements DatasetService {
......
......@@ -56,11 +56,10 @@ import org.springframework.transaction.annotation.Transactional;
import com.querydsl.core.BooleanBuilder;
/**
* The Class DescriptorServiceImpl.
*/
@Service
@Service("catalogDescriptorService")
@Transactional(readOnly = true)
public class DescriptorServiceImpl implements DescriptorService {
......
......@@ -22,7 +22,7 @@ import java.util.Iterator;
import java.util.List;
import org.apache.poi.ss.usermodel.Cell;
import org.genesys.catalog.service.MetadataService;
import org.genesys.catalog.service.FileMetadataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
......@@ -31,17 +31,17 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
/**
* The Class MetadataServiceImpl.
* The Class FileMetadataServiceImpl.
*
* @author Maxym Borodenko
*/
@Service
public class MetadataServiceImpl implements MetadataService {
public class FileMetadataServiceImpl implements FileMetadataService {
/**
* The Constant LOG.
*/
private static final Logger LOG = LoggerFactory.getLogger(MetadataServiceImpl.class);
private static final Logger LOG = LoggerFactory.getLogger(FileMetadataServiceImpl.class);
/**
* The Constant ROWS_TO_READ.
......
......@@ -40,7 +40,7 @@ import java.util.stream.Collectors;
* @author Matija Obreza
* @author Maxym Borodenko
*/
@Component
@Component("davrosVocabularySource")
public class DavrosCountrySource {
public static final String DAVROS_ISO3166_URL = "http://www.davros.org/misc/iso3166.txt";
......
......@@ -38,7 +38,7 @@ import java.util.stream.Collectors;
*
* @author Maxym Borodenko
*/
@Component
@Component("genonamesVocabularySource")
public class GeonamesISOLanguageSource {
public static final String GEONAMES_ISO639_URL = "http://download.geonames.org/export/dump/iso-languagecodes.txt";
......
......@@ -40,7 +40,7 @@ import java.util.zip.ZipInputStream;
*
* @author Maxym Borodenko
*/
@Component
@Component("wiewsVocabularySource")
public class WiewsVocabularySource {
public static final String WIEWS_EXPORT_URL = "http://www.fao.org/wiews-archive/export_c.zip";
public static final String[] WIEWS_EXPORT_C_HEADERS = { "INSTCODE", "ACRONYM", "ECPACRONYM", "FULL_NAME", "TYPE", "GENEBANK_LONG_TERM_COLLECTIONS", "BOTANICAL_GARDEN",
......
......@@ -51,7 +51,7 @@ import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import org.springframework.web.util.UriUtils;
@Controller
@Controller("adminRepositoryController")
@RequestMapping(RepositoryController.CONTROLLER_PATH)
@PreAuthorize("hasRole('ADMINISTRATOR')")
public class RepositoryController extends BaseController {
......
......@@ -45,7 +45,7 @@ import liquibase.integration.spring.SpringLiquibase;
@EnableJpaRepositories(basePackages = { "org.genesys.blocks.persistence", "org.genesys.blocks.security.persistence", "org.genesys.blocks.oauth.persistence",
"org.genesys.blocks.auditlog.persistence", "org.genesys2.server.persistence.domain", "org.genesys2.server.persistence.acl",
"org.genesys.filerepository.persistence" }, entityManagerFactoryRef = "entityManagerFactory", transactionManagerRef = "transactionManager", repositoryImplementationPostfix = "CustomImpl")
"org.genesys.filerepository.persistence", "org.genesys.catalog.persistence" }, entityManagerFactoryRef = "entityManagerFactory", transactionManagerRef = "transactionManager", repositoryImplementationPostfix = "CustomImpl")
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
@EnableTransactionManagement
@Configuration
......
......@@ -182,6 +182,7 @@ transifex.content.template=<html xmlns="http://www.w3.org/1999/xhtml">\
# File repository
file.repository.dir=${data.dir}/repository
file.repository.datasets.folder=/datasets
# File repository S3 parameter values
s3.accessKey=
......@@ -202,3 +203,9 @@ itpgrfa.glis.basepath=https://glistest.planttreaty.org
itpgrfa.glis.username=
itpgrfa.glis.password=
itpgrfa.glis.ratelimit=20
# Catalogy thingies
partner.primary.uuid=39d3022b-dfca-45d8-98f1-3eeaa6c3e605
default.jwt.signingKey=genesys-signing-key-changeme
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