Skip to content
Snippets Groups Projects
Commit 99151125 authored by Alexander Mühlbauer's avatar Alexander Mühlbauer
Browse files

Project -> Release v0.6.0

parents 358554be a65e541f
No related branches found
Tags v0.6.0
1 merge request!4With caching
Pipeline #
......@@ -14,7 +14,22 @@ server-master:
only:
- master
- stable
server-v3.1.0:
stage: test
script:
- git clone https://git.gesis.org/stardat/stardat-ddiflatdb.git
- cd ./stardat-ddiflatdb
- git checkout tags/v3.1.0 -b v3.1.0
- mvn package -q -DskipTests=true
- java -jar target/stardat-ddiflatdb.war --logging.level.org.gesis.stardat.ddiflatdb=ERROR &
- cd ..
- sleep 20
- mvn test -q
only:
- master
- stable
server-v3.0.1:
stage: test
script:
......@@ -29,7 +44,7 @@ server-v3.0.1:
only:
- master
- stable
server-v2.1.0:
stage: test
script:
......
......@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gesis.stardat</groupId>
<artifactId>stardat-ddiflatdb-rest</artifactId>
<version>0.5.0</version>
<version>0.6.0</version>
<properties>
<java.version>1.8</java.version>
......
......@@ -12,21 +12,32 @@
see also [GESIS Maven Repository UI](https://maven.gesis.org) (only internal access to the UI):
```xml
<dependency>
<groupId>org.gesis.stardat</groupId>
<artifactId>stardat-ddiflatdb-rest</artifactId>
<version>0.5.0</version>
<groupId>org.gesis.stardat</groupId>
<artifactId>stardat-ddiflatdb-rest</artifactId>
<version>0.6.0</version>
</dependency>
```
# Client-Server Compatibility Matrix
| client \ server | v3.1.0 | v3.0.1 | v2.1.0 |
|-----------------|:-------------------------------:|:-------------------------------:|:---------------------------:|
| v0.5.0 | :star: :white_check_mark:| :white_check_mark: | :white_check_mark: |
| v0.4.0 | :white_check_mark: | :star: :white_check_mark: | |
| v0.3.1 | :white_check_mark: | :white_check_mark: | |
| client \ server | v3.2.0 | v3.1.0 | v3.0.1 | v2.1.0 |
|-----------------|:-------------------------------:|:-------------------------------:|:-------------------------------:|:---------------------------:|
| v0.6.0 | :star::white_check_mark:| :white_check_mark:| :white_check_mark: | :white_check_mark: |
| v0.5.0 | :white_check_mark: | :star: :white_check_mark:| :white_check_mark: | :white_check_mark: |
| v0.4.0 | :negative_squared_cross_mark: ^1) | :white_check_mark: | :star: :white_check_mark: | |
| v0.3.1 | :negative_squared_cross_mark: ^1) | :white_check_mark: | :white_check_mark: | |
##### Always keep in mind
* Solid testing does not prove correctness, it shows the presence of errors.
##### Legend
* :star: Client-Server-combination is recommended
* :white_check_mark: Client is compatible to server
* :negative_squared_cross_mark: Client is not compatible to server
##### 1) Well-formed xml is required on servers > v3.1.0
* With earlier client and server versions it was possible to persist not well-formed content. If you persist well-formed xml, backward compatibility is not broken.
* Remove possible usage of not well-formed content xml. Well-formed xml is a very strong pre-condition of flatdb.
* Writing (!) clients < v0.5.0 can not be used with servers > v3.1.0.
* For more information, see also https://git.gesis.org/stardat/stardat-ddiflatdb/issues/84.
......@@ -628,4 +628,38 @@ public class RestClient
throw new RuntimeException( ex );
}
}
/**
* Deletes an existing document by fileName
*
* @param fileName
* <i>must</i> not be null.
* @param userName
* <i>must</i> not be null.<br>
* @param comment
* <i>should</i> not be null.
*
* @return count of deleted documents
*
* @since stardat-ddiflatdb-rest v0.6.0 and stardat-ddiflatdb(-server) v3.2.0
*/
public Long deleteDocumentByFileName( String fileName, String userName, String comment )
{
Assert.notNull( fileName, "fileName is null" );
Assert.notNull( userName, "userName is null" );
try
{
StringBuilder uriBuilder = new StringBuilder();
uriBuilder.append( getUri() );
uriBuilder.append( "/documents" );
uriBuilder.append( "?fileName=" + fileName );
HttpEntity<Long> entity = new HttpEntity<Long>( buildHttpHeaders( userName, comment ) );
return restTemplate.exchange( uriBuilder.toString(), HttpMethod.DELETE, entity, Long.class ).getBody();
}
catch (HttpClientErrorException ex)
{
throw new RuntimeException( ex );
}
}
}
......@@ -178,6 +178,27 @@ public class RestClientTest
Assert.assertNotNull( ddiStore );
Assert.assertTrue( ddiStore.getContent().contains( "zwischen 1958 und 1979" ) );
}
@Test
public void updateElement()
{
String documentIdentifier = "gesis_ZA0021";
String elementTypeName = "ddiinstance.studyunit.othermaterial";
String elementIdentifier = "ZA0021_OthMat19";
DDIStore ddiStore = restClient.getElement( documentIdentifier, elementTypeName, elementIdentifier );
Assert.assertNotNull( ddiStore );
Assert.assertEquals( documentIdentifier, ddiStore.getStudy() );
Assert.assertEquals( elementIdentifier, ddiStore.getElementId() );
Assert.assertEquals( elementTypeName, ddiStore.getType() );
Assert.assertTrue( ddiStore.getContent().contains( "Besucher" ) );
ddiStore.setContent( ddiStore.getContent().replace( "Besucher", "Kunden" ) );
ddiStore = restClient.saveElement( ddiStore, "Alex", "change" );
Assert.assertNotNull( ddiStore );
Assert.assertTrue( ddiStore.getContent().contains( "Kunden" ) );
}
@Test
public void importAndExportAndDeleteDocument() throws IOException
......@@ -213,6 +234,33 @@ public class RestClientTest
Assert.assertEquals( Long.valueOf( 0 ), count );
}
@Test
public void deleteDocumentByFileName() throws IOException
{
Assume.assumeTrue( serverIsAtLeastOfVersion( Version.valueOf( "3.2.0" ) ) );
File file = new File( "src/test/resources/ddi-xml/ZA4611_AC10-dataseteditor-ddi-v31.xml" );
String content = new String( Files.readAllBytes( file.toPath() ), StandardCharsets.UTF_8 );
Document document = new Document();
document.setSplitConfigurationName( "dataseteditor-ddi31" );
document.setContent( content );
document.setFileName( file.getName() );
// import document
Document importedDocument = restClient.importDocument( document, "Alex", "Import dataset" );
Assert.assertEquals( document.getFileName(), importedDocument.getFileName() );
Assert.assertEquals( document.getSplitConfigurationName(), importedDocument.getSplitConfigurationName() );
// delete document by fileName
Long count = restClient.deleteDocumentByFileName( file.getName(), "Peter", "Delete dataset by fileName" );
Assert.assertEquals( Long.valueOf( 1 ), count );
// delete document by fileName twice
count = restClient.deleteDocumentByFileName( file.getName(), "Peter", "Delete dataset by fileName twice" );
Assert.assertEquals( Long.valueOf( 0 ), count );
}
@Test
public void getElementsByDocumentIdentifierAndElementTypeName()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment