Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions klass-api/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<name>Klass API</name>
<description>API for uthenting av kodeverk</description>
<artifactId>klass-api</artifactId>
Expand All @@ -10,15 +10,15 @@
<parent>
<groupId>no.ssb.klass</groupId>
<artifactId>klass-root</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9</version>
<!-- <relativePath>../</relativePath>-->
</parent>

<properties>
<snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
</properties>


<dependencies>
<!--KLASS-->
<dependency>
Expand All @@ -31,7 +31,7 @@
<artifactId>klass-solr</artifactId>
<version>${project.parent.version}</version>
</dependency>

<!--Spring-->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -67,7 +67,7 @@
<scope>provided</scope>
</dependency>


<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
Expand All @@ -90,7 +90,7 @@
<artifactId>javax.el</artifactId>
<version>3.0.0</version>
</dependency>

<!--TEST SCOPE-->
<dependency>
<groupId>no.ssb.klass</groupId>
Expand Down Expand Up @@ -247,5 +247,5 @@
</plugin>
</plugins>
</build>

</project>
2 changes: 1 addition & 1 deletion klass-forvaltning/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>no.ssb.klass</groupId>
<artifactId>klass-root</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9</version>
<relativePath>../</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ klass.search.maxDescriptionLength=300

# Logging properties
logging.file=${klass.env.logging.path}/klass.log
logging.level.no.ssb.klass=DEBUG

spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
Expand Down
10 changes: 5 additions & 5 deletions klass-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>no.ssb.klass</groupId>
<artifactId>klass-root</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9</version>
</parent>

<properties>
Expand Down Expand Up @@ -221,7 +221,7 @@
<version>${rest-assured-version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<profiles>
Expand Down Expand Up @@ -294,7 +294,7 @@
</plugins>
</build>
</profile>


</profiles>

Expand Down Expand Up @@ -329,7 +329,7 @@
</execution>
</executions>
</plugin>

</plugins>
<pluginManagement>
<plugins>
Expand All @@ -351,7 +351,7 @@
<arguments>-Pdocumentation -Dmaven.javadoc.skip=true</arguments>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import no.ssb.klass.core.util.DateRange;
import no.ssb.klass.core.util.TimeUtil;
import no.ssb.klass.core.util.Translatable;
import org.springframework.transaction.annotation.Transactional;

@Entity
@Table(indexes = { @Index(columnList = "source_id", name = "ct_source_idx"),
Expand All @@ -40,7 +41,7 @@ public class CorrespondenceTable extends BaseEntity implements ClassificationEnt
@ManyToOne(optional = false, fetch = FetchType.LAZY)
private final ClassificationVersion target;
private final int targetLevelNumber;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "correspondenceTable")
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "correspondenceTable", fetch = FetchType.EAGER)
private final List<CorrespondenceMap> correspondenceMaps;
@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "correspondencetable_changelog", joinColumns = @JoinColumn(name = "correspondencetable_id"), inverseJoinColumns = @JoinColumn(name = "changelog_id"))
Expand Down Expand Up @@ -159,6 +160,7 @@ private Optional<Level> getLevel(ClassificationVersion version, int levelNumber)
return Optional.of(version.getLevel(levelNumber));
}

@Transactional
public List<CorrespondenceMap> getCorrespondenceMaps() {
return correspondenceMaps.stream().sorted().collect(toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import no.ssb.klass.core.util.TimeUtil;
import no.ssb.klass.core.util.Translatable;
import org.hibernate.Hibernate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand All @@ -58,6 +60,7 @@
@Transactional(readOnly = true)
public class ClassificationServiceImpl implements ClassificationService {

private static final Logger log = LoggerFactory.getLogger(ClassificationServiceImpl.class);
private final ClassificationFamilyRepository classificationFamilyRepository;
private final ClassificationSeriesRepository classificationRepository;
private final ClassificationVersionRepository classificationVersionRepository;
Expand Down Expand Up @@ -450,7 +453,15 @@ public void deleteNotIndexVersion(User user, ClassificationVersion version) thro
public void deleteNotIndexCorrespondenceTable(User user, CorrespondenceTable correspondenceTable)
throws KlassMessageException {
checkAllowedToDelete(user, correspondenceTable);
log.info("Soft deleting correspondence table {} {}", correspondenceTable.getNameInPrimaryLanguage(), correspondenceTable.getId());
correspondenceTable.setDeleted();
// Delete all the correspondence maps to avoid future constraint violations
List<CorrespondenceMap> maps = correspondenceTable.getCorrespondenceMaps();

log.info("Hard deleting {} child correspondence maps", maps.size());
maps.forEach(map -> correspondenceMapRepository.delete(map.getId()));
// This just updates the object in memory, has no effect on persistence
correspondenceTable.removeAllCorrespondenceMaps();
saveNotIndexCorrespondenceTable(correspondenceTable);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,27 @@ public void findCorrespondenceTablesBetweenHandlesTargetFirst() {
assertEquals(1, result.size());
}

@Test
public void deleteCorrespondenceTable() throws KlassMessageException {
// given
ClassificationVersion source = createClassificationVersion();
CorrespondenceTable correspondenceTable = TestUtil.createCorrespondenceTable(source,
createClassificationVersion());

correspondenceTable.addCorrespondenceMap(new CorrespondenceMap(TestUtil.createClassificationItem("code1", "Code 1"), TestUtil.createClassificationItem("code2", "Code 2")));
correspondenceTable.addCorrespondenceMap(new CorrespondenceMap(TestUtil.createClassificationItem("code3", "Code 3"), TestUtil.createClassificationItem("code4", "Code 4")));
correspondenceTable.unpublish(Language.getDefault());
when(correspondenceTableRepositoryMock.save(correspondenceTable)).thenReturn(correspondenceTable);

// when
subject.deleteNotIndexCorrespondenceTable(TestUtil.createUser(), correspondenceTable);

// then
assertTrue(correspondenceTable.isDeleted());
verify(correspondenceMapRepositoryMock, times(2)).delete(anyLong());
assertEquals(0, correspondenceTable.getCorrespondenceMaps().size());
}

private ClassificationVersion createClassificationVersion() {
ClassificationVersion version = TestUtil.createClassificationVersion(TestUtil.anyDateRange());
ClassificationSeries classification = TestUtil.createClassification("name");
Expand Down
8 changes: 4 additions & 4 deletions klass-solr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>no.ssb.klass</groupId>
<artifactId>klass-root</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9</version>
</parent>

<dependencies>
Expand Down Expand Up @@ -74,7 +74,7 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>

<testResources>
Expand All @@ -85,7 +85,7 @@
</excludes>
</testResource>
</testResources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -120,4 +120,4 @@
</plugins>
</build>

</project>
</project>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>no.ssb.klass</groupId>
<artifactId>klass-root</artifactId>
<version>2.1.8-SNAPSHOT</version>
<version>2.1.9</version>
<packaging>pom</packaging>

<parent>
Expand Down