Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Genesys Backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
15
Issues
15
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Backend
Commits
99ec18fb
Commit
99ec18fb
authored
Nov 10, 2018
by
Matija Obreza
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'vocabularies-update' into 'master'
Vocabularies update See merge request genesys-pgr/genesys-server!281
parents
4d84d753
789d89c4
Changes
50
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
50 changed files
with
437 additions
and
5215 deletions
+437
-5215
src/main/java/org/genesys/catalog/api/v0/ApiInfoController.java
...in/java/org/genesys/catalog/api/v0/ApiInfoController.java
+0
-151
src/main/java/org/genesys/catalog/api/v0/DatasetController.java
...in/java/org/genesys/catalog/api/v0/DatasetController.java
+0
-534
src/main/java/org/genesys/catalog/api/v0/DescriptorController.java
...java/org/genesys/catalog/api/v0/DescriptorController.java
+0
-338
src/main/java/org/genesys/catalog/api/v0/DescriptorListController.java
.../org/genesys/catalog/api/v0/DescriptorListController.java
+0
-288
src/main/java/org/genesys/catalog/api/v0/FileMetadataController.java
...va/org/genesys/catalog/api/v0/FileMetadataController.java
+0
-104
src/main/java/org/genesys/catalog/api/v0/GeoController.java
src/main/java/org/genesys/catalog/api/v0/GeoController.java
+0
-123
src/main/java/org/genesys/catalog/api/v0/LanguagesController.java
.../java/org/genesys/catalog/api/v0/LanguagesController.java
+0
-110
src/main/java/org/genesys/catalog/api/v0/MeController.java
src/main/java/org/genesys/catalog/api/v0/MeController.java
+0
-259
src/main/java/org/genesys/catalog/api/v0/PartnerController.java
...in/java/org/genesys/catalog/api/v0/PartnerController.java
+0
-145
src/main/java/org/genesys/catalog/api/v0/SearchController.java
...ain/java/org/genesys/catalog/api/v0/SearchController.java
+0
-131
src/main/java/org/genesys/catalog/api/v0/VocabularyController.java
...java/org/genesys/catalog/api/v0/VocabularyController.java
+0
-186
src/main/java/org/genesys/catalog/api/v0/WiewsController.java
...main/java/org/genesys/catalog/api/v0/WiewsController.java
+0
-109
src/main/java/org/genesys/catalog/persistence/vocab/ControlledVocabularyRepository.java
...log/persistence/vocab/ControlledVocabularyRepository.java
+3
-3
src/main/java/org/genesys/catalog/service/impl/VocabularyServiceImpl.java
...g/genesys/catalog/service/impl/VocabularyServiceImpl.java
+1
-1
src/main/java/org/genesys/catalog/service/worker/DavrosCountrySource.java
...g/genesys/catalog/service/worker/DavrosCountrySource.java
+0
-220
src/main/java/org/genesys/catalog/service/worker/ISO3166VocabularyUpdater.java
...esys/catalog/service/worker/ISO3166VocabularyUpdater.java
+0
-141
src/main/java/org/genesys/catalog/service/worker/WiewsVocabularySource.java
...genesys/catalog/service/worker/WiewsVocabularySource.java
+0
-307
src/main/java/org/genesys/catalog/service/worker/WiewsVocabularyUpdater.java
...enesys/catalog/service/worker/WiewsVocabularyUpdater.java
+0
-156
src/main/java/org/genesys2/server/api/ApiError.java
src/main/java/org/genesys2/server/api/ApiError.java
+1
-1
src/main/java/org/genesys2/server/api/ApiExceptionHandler.java
...ain/java/org/genesys2/server/api/ApiExceptionHandler.java
+2
-2
src/main/java/org/genesys2/server/api/FilteredPage.java
src/main/java/org/genesys2/server/api/FilteredPage.java
+6
-5
src/main/java/org/genesys2/server/api/v1/AccessionController.java
.../java/org/genesys2/server/api/v1/AccessionController.java
+1
-1
src/main/java/org/genesys2/server/api/v1/CMSController.java
src/main/java/org/genesys2/server/api/v1/CMSController.java
+2
-1
src/main/java/org/genesys2/server/api/v1/DatasetController.java
...in/java/org/genesys2/server/api/v1/DatasetController.java
+1
-1
src/main/java/org/genesys2/server/api/v1/DescriptorController.java
...java/org/genesys2/server/api/v1/DescriptorController.java
+1
-1
src/main/java/org/genesys2/server/api/v1/DescriptorListController.java
.../org/genesys2/server/api/v1/DescriptorListController.java
+1
-1
src/main/java/org/genesys2/server/api/v1/GeoController.java
src/main/java/org/genesys2/server/api/v1/GeoController.java
+8
-52
src/main/java/org/genesys2/server/api/v1/InstituteController.java
.../java/org/genesys2/server/api/v1/InstituteController.java
+1
-1
src/main/java/org/genesys2/server/api/v1/PartnerController.java
...in/java/org/genesys2/server/api/v1/PartnerController.java
+2
-1
src/main/java/org/genesys2/server/api/v1/RequestsController.java
...n/java/org/genesys2/server/api/v1/RequestsController.java
+1
-1
src/main/java/org/genesys2/server/api/v1/SubsetController.java
...ain/java/org/genesys2/server/api/v1/SubsetController.java
+1
-1
src/main/java/org/genesys2/server/api/v1/UserManagementController.java
.../org/genesys2/server/api/v1/UserManagementController.java
+1
-1
src/main/java/org/genesys2/server/api/v1/VocabularyController.java
...java/org/genesys2/server/api/v1/VocabularyController.java
+71
-8
src/main/java/org/genesys2/server/api/v1/WiewsController.java
...main/java/org/genesys2/server/api/v1/WiewsController.java
+4
-27
src/main/java/org/genesys2/server/persistence/CountryRepository.java
...va/org/genesys2/server/persistence/CountryRepository.java
+7
-1
src/main/java/org/genesys2/server/service/GeoService.java
src/main/java/org/genesys2/server/service/GeoService.java
+16
-3
src/main/java/org/genesys2/server/service/InstituteService.java
...in/java/org/genesys2/server/service/InstituteService.java
+5
-0
src/main/java/org/genesys2/server/service/impl/GeoServiceImpl.java
...java/org/genesys2/server/service/impl/GeoServiceImpl.java
+69
-7
src/main/java/org/genesys2/server/service/impl/InstituteServiceImpl.java
...rg/genesys2/server/service/impl/InstituteServiceImpl.java
+70
-0
src/main/java/org/genesys2/spring/config/CommonConfig.java
src/main/java/org/genesys2/spring/config/CommonConfig.java
+1
-1
src/test/java/org/genesys/test/catalog/api/v0/DatasetControllerTest.java
...rg/genesys/test/catalog/api/v0/DatasetControllerTest.java
+0
-355
src/test/java/org/genesys/test/catalog/api/v0/DatasetCreatorControllerTest.java
...sys/test/catalog/api/v0/DatasetCreatorControllerTest.java
+0
-134
src/test/java/org/genesys/test/catalog/api/v0/DescriptorControllerTest.java
...genesys/test/catalog/api/v0/DescriptorControllerTest.java
+0
-352
src/test/java/org/genesys/test/catalog/api/v0/DescriptorListControllerTest.java
...sys/test/catalog/api/v0/DescriptorListControllerTest.java
+0
-382
src/test/java/org/genesys/test/catalog/api/v0/PartnerControllerTest.java
...rg/genesys/test/catalog/api/v0/PartnerControllerTest.java
+0
-323
src/test/java/org/genesys/test/catalog/api/v0/VocabularyControllerTest.java
...genesys/test/catalog/api/v0/VocabularyControllerTest.java
+0
-193
src/test/java/org/genesys/test/catalog/services/AutomaticVocabulariesTest.java
...esys/test/catalog/services/AutomaticVocabulariesTest.java
+39
-43
src/test/java/org/genesys/test/config/ApplicationConfig.java
src/test/java/org/genesys/test/config/ApplicationConfig.java
+1
-1
src/test/java/org/genesys/test/server/api/v1/GeoControllerTest.java
...ava/org/genesys/test/server/api/v1/GeoControllerTest.java
+25
-9
src/test/java/org/genesys/test/server/api/v1/WiewsControllerTest.java
...a/org/genesys/test/server/api/v1/WiewsControllerTest.java
+96
-0
No files found.
src/main/java/org/genesys/catalog/api/v0/ApiInfoController.java
deleted
100644 → 0
View file @
4d84d753
/*
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.genesys.catalog.api.v0
;
import
org.genesys2.server.api.ApiBaseController
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
io.swagger.annotations.Api
;
import
java.net.UnknownHostException
;
/**
* The Class ApiInfoController.
*
* @author Andrey Lugovskoy.
*/
@RestController
@RequestMapping
(
ApiInfoController
.
CONTROLLER_URL
)
@PreAuthorize
(
"isAuthenticated()"
)
@Api
(
tags
=
{
"api-info"
})
public
class
ApiInfoController
implements
InitializingBean
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ApiInfoController
.
class
);
/** The Constant API_BASE. */
public
static
final
String
CONTROLLER_URL
=
ApiBaseController
.
APIv0_BASE
+
"/info"
;
@Value
(
"${build.version}"
)
private
String
version
;
@Value
(
"${build.artifactId}"
)
private
String
artifactId
;
@Value
(
"${build.revision}"
)
private
String
revision
;
private
ApiInfo
apiInfo
;
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
String
hN
;
try
{
hN
=
java
.
net
.
InetAddress
.
getLocalHost
().
getHostName
();
}
catch
(
final
UnknownHostException
e
)
{
LOG
.
error
(
"Error getting Host Name"
);
hN
=
""
;
}
apiInfo
=
new
ApiInfo
(
artifactId
,
version
,
revision
,
hN
);
LOG
.
info
(
"API Info: art="
+
artifactId
+
" ver="
+
version
+
" rev="
+
revision
);
}
/**
* Api info.
*
* @return the api info
*/
@RequestMapping
(
value
=
"/version"
,
method
=
RequestMethod
.
GET
)
public
ApiInfo
apiInfo
()
{
return
apiInfo
;
}
/**
* The Class ApiInfo.
*/
public
static
class
ApiInfo
{
private
final
String
artifactId
;
private
final
String
version
;
private
final
String
revision
;
private
final
String
hostName
;
/**
* Instantiates a new api info.
*
* @param artifactId the artifact id
* @param version the version
* @param revision the revision
* @param hostName the host name
*/
public
ApiInfo
(
final
String
artifactId
,
final
String
version
,
final
String
revision
,
final
String
hostName
)
{
this
.
artifactId
=
artifactId
;
this
.
version
=
version
;
this
.
revision
=
revision
;
this
.
hostName
=
hostName
;
}
/**
* Gets the host name.
*
* @return the host name
*/
public
String
getHostName
()
{
return
hostName
;
}
/**
* Gets the artifact id.
*
* @return the artifactId
*/
public
String
getArtifactId
()
{
return
artifactId
;
}
/**
* Gets the version.
*
* @return the version
*/
public
String
getVersion
()
{
return
version
;
}
/**
* Gets the revision.
*
* @return the revision
*/
public
String
getRevision
()
{
return
revision
;
}
}
}
src/main/java/org/genesys/catalog/api/v0/DatasetController.java
deleted
100644 → 0
View file @
4d84d753
This diff is collapsed.
Click to expand it.
src/main/java/org/genesys/catalog/api/v0/DescriptorController.java
deleted
100644 → 0
View file @
4d84d753
/*
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.genesys.catalog.api.v0
;
import
java.io.EOFException
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.util.List
;
import
java.util.UUID
;
import
org.genesys.blocks.model.JsonViews
;
import
org.genesys.catalog.api.FilteredPage
;
import
org.genesys.catalog.model.dataset.Dataset
;
import
org.genesys.catalog.model.filters.DescriptorFilter
;
import
org.genesys.catalog.model.traits.Descriptor
;
import
org.genesys.catalog.model.traits.DescriptorList
;
import
org.genesys.catalog.service.DescriptorService
;
import
org.genesys.catalog.service.ShortFilterService
;
import
org.genesys2.server.api.ApiBaseController
;
import
org.genesys2.server.exception.InvalidApiUsageException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.dao.DataIntegrityViolationException
;
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
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.fasterxml.jackson.annotation.JsonView
;
import
io.swagger.annotations.Api
;
import
javax.servlet.http.HttpServletResponse
;
/**
* The Class DescriptorController.
*
* @author Maxym Borodenko
* @deprecated Use {@link org.genesys2.server.api.v1.DescriptorController}
*/
@Deprecated
@RestController
(
"catalogDescriptorApi0"
)
@RequestMapping
(
DescriptorController
.
CONTROLLER_URL
)
@PreAuthorize
(
"isAuthenticated()"
)
@Api
(
tags
=
{
"descriptor"
})
public
class
DescriptorController
{
private
Logger
LOG
=
LoggerFactory
.
getLogger
(
DescriptorController
.
class
);
/** The Constant API_BASE. */
public
static
final
String
CONTROLLER_URL
=
ApiBaseController
.
APIv0_BASE
+
"/descriptor"
;
@Autowired
private
DescriptorService
descriptorService
;
/** The short filter service. */
@Autowired
protected
ShortFilterService
shortFilterService
;
/**
* List categories.
*
* @return the category[]
*/
@GetMapping
(
value
=
"/categories"
)
public
Descriptor
.
Category
[]
listCategories
()
{
return
Descriptor
.
Category
.
values
();
}
/**
* My descriptors.
*
* @param page the page
* @param pageSize the page size
* @param direction the direction
* @param sort the sort
* @param filter the descriptor filter
* @return the page
* @throws IOException
*/
@PostMapping
(
value
=
"/list-mine"
)
public
FilteredPage
<
Descriptor
>
myDescriptors
(
@RequestParam
(
name
=
"p"
,
required
=
false
,
defaultValue
=
"0"
)
final
int
page
,
@RequestParam
(
name
=
"l"
,
required
=
false
,
defaultValue
=
"50"
)
final
int
pageSize
,
@RequestParam
(
name
=
"d"
,
required
=
false
,
defaultValue
=
"DESC"
)
final
Sort
.
Direction
direction
,
@RequestParam
(
name
=
"s"
,
required
=
false
,
defaultValue
=
"lastModifiedDate"
)
final
String
[]
sort
,
@RequestParam
(
name
=
"f"
,
required
=
false
)
String
filterCode
,
@RequestBody
(
required
=
false
)
DescriptorFilter
filter
)
throws
IOException
{
if
(
filterCode
!=
null
)
{
filter
=
shortFilterService
.
filterByCode
(
filterCode
,
DescriptorFilter
.
class
);
}
else
{
filterCode
=
shortFilterService
.
getCode
(
filter
);
}
return
new
FilteredPage
<>(
filterCode
,
filter
,
descriptorService
.
listDescriptorsForCurrentUser
(
filter
,
new
PageRequest
(
page
,
Integer
.
min
(
pageSize
,
100
),
direction
,
sort
)));
}
/**
* List descriptors.
*
* @param page the page
* @param pageSize the page size
* @param direction the direction
* @param sort the sort
* @param filter the descriptor filter
* @return the page
* @throws IOException
*/
@PostMapping
(
value
=
"/list"
)
public
FilteredPage
<
Descriptor
>
listDescriptors
(
@RequestParam
(
name
=
"p"
,
required
=
false
,
defaultValue
=
"0"
)
final
int
page
,
@RequestParam
(
name
=
"l"
,
required
=
false
,
defaultValue
=
"50"
)
final
int
pageSize
,
@RequestParam
(
name
=
"d"
,
required
=
false
,
defaultValue
=
"ASC"
)
final
Sort
.
Direction
direction
,
@RequestParam
(
name
=
"s"
,
required
=
false
,
defaultValue
=
"id"
)
final
String
[]
sort
,
@RequestParam
(
name
=
"f"
,
required
=
false
)
String
filterCode
,
@RequestBody
(
required
=
false
)
DescriptorFilter
filter
)
throws
IOException
{
if
(
filterCode
!=
null
)
{
filter
=
shortFilterService
.
filterByCode
(
filterCode
,
DescriptorFilter
.
class
);
}
else
{
filterCode
=
shortFilterService
.
getCode
(
filter
);
}
return
new
FilteredPage
<>(
filterCode
,
filter
,
descriptorService
.
listDescriptors
(
filter
,
new
PageRequest
(
page
,
Integer
.
min
(
pageSize
,
100
),
direction
,
sort
)));
}
/**
* Filter descriptors by filter code.
*
* @param page the page
* @param pageSize the page size
* @param direction the direction
* @param sort the sort
* @param filterCode the filter code
* @return the filtered page
* @throws IOException Signals that an I/O exception has occurred.
* @deprecated Use {@link #listDescriptors(int, int, org.springframework.data.domain.Sort.Direction, String[], DescriptorFilter)}
*/
@PostMapping
(
value
=
"/list/{filterCode}"
)
public
FilteredPage
<
Descriptor
>
listDescriptorsByShort
(
@RequestParam
(
name
=
"p"
,
required
=
false
,
defaultValue
=
"0"
)
final
int
page
,
@RequestParam
(
name
=
"l"
,
required
=
false
,
defaultValue
=
"50"
)
final
int
pageSize
,
@RequestParam
(
name
=
"d"
,
required
=
false
,
defaultValue
=
"ASC"
)
final
Sort
.
Direction
direction
,
@RequestParam
(
name
=
"s"
,
required
=
false
,
defaultValue
=
"id"
)
final
String
[]
sort
,
@PathVariable
(
"filterCode"
)
final
String
filterCode
)
throws
IOException
{
final
DescriptorFilter
filter
=
shortFilterService
.
filterByCode
(
filterCode
,
DescriptorFilter
.
class
);
return
new
FilteredPage
<>(
filterCode
,
filter
,
descriptorService
.
listDescriptors
(
filter
,
new
PageRequest
(
page
,
Integer
.
min
(
pageSize
,
100
),
direction
,
sort
)));
}
/**
* Gets the descriptor.
*
* @param uuid the uuid
* @return the descriptor
*/
@RequestMapping
(
value
=
"/{UUID}"
,
method
=
RequestMethod
.
GET
)
public
Descriptor
getDescriptor
(
@PathVariable
(
"UUID"
)
final
UUID
uuid
)
{
return
descriptorService
.
getDescriptor
(
uuid
);
}
/**
* Get additional information about descriptor that is not provided in the
* {@link #getDescriptor(UUID)} call.
*
* @param uuid descriptor UUID
* @return the other descriptor info
*/
@RequestMapping
(
value
=
"/extra/{UUID}"
,
method
=
RequestMethod
.
GET
)
@SuppressWarnings
(
"unused"
)
@JsonView
(
JsonViews
.
Minimal
.
class
)
public
Object
getOtherDescriptorInfo
(
@PathVariable
(
"UUID"
)
final
UUID
uuid
)
{
final
Descriptor
descriptor
=
descriptorService
.
getDescriptor
(
uuid
);
return
new
Object
()
{
public
List
<
DescriptorList
>
descriptorLists
=
descriptorService
.
getDescriptorLists
(
descriptor
);
public
List
<
Dataset
>
datasets
=
descriptorService
.
getDatasets
(
descriptor
);
};
}
/**
* Creates the descriptor.
*
* @param source the source
* @return the descriptor
*/
@RequestMapping
(
value
=
"/create"
,
method
=
RequestMethod
.
POST
)
@PreAuthorize
(
"isAuthenticated()"
)
public
Descriptor
createDescriptor
(
@RequestBody
final
Descriptor
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.
*
* @param source the source
* @return the descriptor
*/
@RequestMapping
(
value
=
"/update"
,
method
=
RequestMethod
.
POST
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR') or hasPermission(#source, 'write')"
)
public
Descriptor
updateDescriptor
(
@RequestBody
final
Descriptor
source
)
{
return
descriptorService
.
updateDescriptor
(
source
);
}
/**
* Update descriptor.
*
* @param source the source
* @return the list
*/
@RequestMapping
(
value
=
"/upsert"
,
method
=
RequestMethod
.
POST
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
public
List
<
Descriptor
>
updateDescriptors
(
@RequestBody
final
List
<
Descriptor
>
source
)
{
return
descriptorService
.
upsertDescriptors
(
source
);
}
/**
* Make a new version of a descriptor.
*
* @param major make a new major version
* @param source the descriptor to copy
* @return the descriptor
*/
@RequestMapping
(
value
=
"/copy"
,
method
=
RequestMethod
.
POST
)
public
Descriptor
copyDescriptor
(
@RequestParam
(
name
=
"major"
,
defaultValue
=
"true"
,
required
=
false
)
final
boolean
major
,
@RequestBody
final
Descriptor
source
)
{
return
descriptorService
.
nextVersion
(
source
,
major
);
}
/**
* 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
)
{
try
{
return
descriptorService
.
removeDescriptor
(
descriptorService
.
getDescriptor
(
uuid
,
version
));
}
catch
(
DataIntegrityViolationException
e
)
{
throw
new
InvalidApiUsageException
(
"Cannot delete a referenced descriptor"
);
}
}
/**
* Loads descriptor by uuid and version and tries to publish it.
*
* @param uuid descriptor UUID
* @param version record version
* @return published Descriptor (admin-only)
*/
@RequestMapping
(
value
=
"/approve"
,
method
=
RequestMethod
.
POST
)
public
Descriptor
approveDescriptor
(
@RequestParam
(
value
=
"uuid"
,
required
=
true
)
final
UUID
uuid
,
@RequestParam
(
value
=
"version"
,
required
=
true
)
final
int
version
)
{
final
Descriptor
descriptor
=
descriptorService
.
getDescriptor
(
uuid
,
version
);
return
descriptorService
.
approveDescriptor
(
descriptor
);
}
/**
* Loads descriptor by uuid and version and send to review.
*
* @param uuid descriptor UUID
* @param version record version
* @return descriptor in review state
*/
@RequestMapping
(
value
=
"/for-review"
,
method
=
RequestMethod
.
POST
)
public
Descriptor
reviewDescriptor
(
@RequestParam
(
value
=
"uuid"
,
required
=
true
)
final
UUID
uuid
,
@RequestParam
(
value
=
"version"
,
required
=
true
)
final
int
version
)
{
final
Descriptor
descriptor
=
descriptorService
.
getDescriptor
(
uuid
,
version
);
return
descriptorService
.
reviewDescriptor
(
descriptor
);
}
/**
* Loads descriptor by uuid and version and unpublish it.
*
* @param uuid descriptor UUID
* @param version record version
* @return unpublished descriptor
*/
@RequestMapping
(
value
=
"/reject"
,
method
=
RequestMethod
.
POST
)
public
Descriptor
rejectDescriptor
(
@RequestParam
(
value
=
"uuid"
,
required
=
true
)
final
UUID
uuid
,
@RequestParam
(
value
=
"version"
,
required
=
true
)
final
int
version
)
{
final
Descriptor
descriptor
=
descriptorService
.
getDescriptor
(
uuid
,
version
);
return
descriptorService
.
rejectDescriptor
(
descriptor
);
}
@PostMapping
(
value
=
"/export"
,
produces
=
{
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
})
public
void
exportDescriptors
(
@RequestParam
(
name
=
"f"
,
required
=
false
)
String
filterCode
,
@RequestBody
(
required
=
false
)
DescriptorFilter
filter
,
HttpServletResponse
response
)
throws
IOException
{
if
(
filterCode
!=
null
)
{
filter
=
shortFilterService
.
filterByCode
(
filterCode
,
DescriptorFilter
.
class
);
}
else
{
filterCode
=
shortFilterService
.
getCode
(
filter
);
}
response
.
setContentType
(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
);
response
.
addHeader
(
"Content-Disposition"
,
String
.
format
(
"attachment; filename=\"genesys-descriptors-"
+
filterCode
+
".xlsx\""
));
response
.
flushBuffer
();
// Write XLSX to the stream.
final
OutputStream
outputStream
=
response
.
getOutputStream
();
try
{
descriptorService
.
exportDescriptors
(
filter
,
outputStream
);
response
.
flushBuffer
();
}
catch
(
EOFException
e
)
{
LOG
.
warn
(
"Download was aborted"
,
e
);
}
}
}
src/main/java/org/genesys/catalog/api/v0/DescriptorListController.java
deleted
100644 → 0
View file @
4d84d753
/*
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.genesys.catalog.api.v0
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.UUID
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletResponse
;
import
org.genesys.blocks.model.JsonViews
;
import
org.genesys.catalog.api.FilteredPage
;
import
org.genesys.catalog.model.filters.DescriptorListFilter
;
import
org.genesys.catalog.model.traits.Descriptor
;
import
org.genesys.catalog.model.traits.DescriptorList
;
import
org.genesys.catalog.mvc.DescriptorListExporter
;
import
org.genesys.catalog.service.DescriptorListService
;
import
org.genesys.catalog.service.DescriptorService
;
import
org.genesys.catalog.service.ShortFilterService
;
import
org.genesys.catalog.service.ShortFilterService.FilterInfo
;
import
org.genesys2.server.api.ApiBaseController
;
import
org.genesys2.server.api.Pagination
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.transaction.annotation.Transactional
;
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
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.fasterxml.jackson.annotation.JsonView
;
import
io.swagger.annotations.Api
;
/**
* The Class DescriptorListController.
*
* @author Matija Obreza
* @deprecated Use {@link org.genesys2.server.api.v1.DescriptorListController}
*/
@Deprecated
@RestController
(
"catalogDescriptorListApi0"
)
@RequestMapping
(
DescriptorListController
.
CONTROLLER_URL
)
@PreAuthorize
(
"isAuthenticated()"
)
@Api
(
tags
=
{
"descriptor-list"
})
public
class
DescriptorListController
{
/** The Constant API_BASE. */
public
static
final
String
CONTROLLER_URL
=
ApiBaseController
.
APIv0_BASE
+
"/descriptorlist"
;
@Autowired
private
DescriptorService
descriptorService
;
@Autowired
private
DescriptorListService
descriptorListService
;