Commit ae45bc18 authored by Matija Obreza's avatar Matija Obreza
Browse files

`Descriptor` updated with publisher

- API endpoint to delete a descriptor
- Descriptor#publisher added
parent 01420582
......@@ -60,6 +60,12 @@ public class ControlledVocabulary extends UuidModel implements Publishable, AclA
@Column()
private boolean published;
/**
* Trait title in English.
*/
@Column(nullable = true, length = 200)
private String publisher;
/**
* Trait title in English.
*/
......@@ -125,6 +131,24 @@ public class ControlledVocabulary extends UuidModel implements Publishable, AclA
public void setPublished(final boolean published) {
this.published = published;
}
/**
* Gets the publisher.
*
* @return the publisher
*/
public String getPublisher() {
return publisher;
}
/**
* Sets the publisher.
*
* @param publisher the new publisher
*/
public void setPublisher(String publisher) {
this.publisher = publisher;
}
/**
* Gets the version tag.
......@@ -235,4 +259,5 @@ public class ControlledVocabulary extends UuidModel implements Publishable, AclA
this.terms = terms;
}
}
......@@ -33,20 +33,20 @@ public interface DescriptorService {
/**
* Creates the descriptor.
*
* @param input the input
* @param descriptor the descriptor
* @return the descriptor
*/
@PreAuthorize("isAuthenticated()")
Descriptor createDescriptor(Descriptor input);
Descriptor createDescriptor(Descriptor descriptor);
/**
* Update descriptor.
*
* @param input updatable descriptor
* @param descriptor updatable descriptor
* @return updated descriptor
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#input, 'WRITE')")
Descriptor updateDescriptor(Descriptor input);
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#descriptor, 'WRITE')")
Descriptor updateDescriptor(Descriptor descriptor);
/**
* copy descriptor.
......@@ -100,6 +100,7 @@ public interface DescriptorService {
* @param descriptor descriptor
* @return removed Descriptor
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#descriptor, 'delete')")
Descriptor removeDescriptor(Descriptor descriptor);
/**
......
......@@ -107,6 +107,7 @@ public class VocabularyServiceImpl implements VocabularyService {
vocabulary.setDescription(input.getDescription());
vocabulary.setPublished(input.isPublished());
vocabulary.setPublisher(input.getPublisher());
vocabulary.setTitle(input.getTitle());
vocabulary.setTermUrlPrefix(input.getTermUrlPrefix());
vocabulary.setUrl(input.getUrl());
......
......@@ -182,10 +182,12 @@ public class ControlledVocabularyTest extends CatalogServiceTest {
vocab1.setUuid(uuid);
vocab1.setVersion(result.getVersion());
vocab1.setTitle(VOCABULARY_TITLE_2);
vocab1.setPublisher("PUBLISHER");
result = vocabularyService.updateVocabulary(vocab1);
assertThat(result.getUuid(), is(uuid));
assertThat(result.getTitle(), is(VOCABULARY_TITLE_2));
assertThat(result.getDescription(), is(nullValue()));
assertThat(result.getPublisher(), is(vocab1.getPublisher()));
result.setTitle(VOCABULARY_TITLE_1);
result.setDescription(VOCABULARY_DESC_1);
......
......@@ -27,6 +27,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -85,6 +86,18 @@ public class DescriptorController {
return descriptorService.upsertDescriptors(source);
}
/**
* Delete descriptor.
*
* @param uuid the uuid
* @param version the version
* @return the descriptor
*/
@DeleteMapping(value = "/{UUID},{version}")
public Descriptor deleteDescriptor(@PathVariable("UUID") final UUID uuid, @PathVariable("version") final int version) {
return descriptorService.removeDescriptor(descriptorService.getDescriptor(uuid, version));
}
/**
* Loads descriptor by uuid and version and tries to publish it.
*
......
......@@ -3115,3 +3115,15 @@ databaseChangeLog:
type: BIT(1)
defaultValueBoolean: false
tableName: descriptor
- changeSet:
id: 1516386605000-1
author: mobreza
comment: Add publisher to Controlled Vocabulary
changes:
- addColumn:
columns:
- column:
name: publisher
type: VARCHAR(200)
tableName: controlled_vocabulary
Supports Markdown
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