CCM NG:
- Additional entities for the n:m relations between CcmObject and Category - JPA Converter for URI properties git-svn-id: https://svn.libreccm.org/ccm/jpa@3365 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
4e89a8a1a0
commit
c0fe9ee411
203
ccm-core/pom.xml
203
ccm-core/pom.xml
|
|
@ -59,7 +59,208 @@
|
|||
<artifactId>hamcrest-library</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>ccm-core</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<optimize>true</optimize>
|
||||
<debug>true</debug>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.18.1</version>
|
||||
<configuration>
|
||||
<groups>de.jpdigital.research.accessibilitystudy.tests.UnitTest</groups>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.7.4.201502262128</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-prepare-agent</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>default-report</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>default-check</id>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<rule>
|
||||
<element>BUNDLE</element>
|
||||
<limits>
|
||||
<limit>
|
||||
<counter>COMPLEXITY</counter>
|
||||
<value>COVEREDRATIO</value>
|
||||
<minimum>0.60</minimum>
|
||||
</limit>
|
||||
</limits>
|
||||
</rule>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>de.jpdigital</groupId>
|
||||
<artifactId>hibernate4-ddl-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<dialects>
|
||||
<param>h2</param>
|
||||
<param>mysql5_innodb</param>
|
||||
<param>postgresql9</param>
|
||||
</dialects>
|
||||
<packages>
|
||||
<param>de.jpdigital.webpagebuilder2.data</param>
|
||||
</packages>
|
||||
<useEnvers>true</useEnvers>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>gen-ddl</goal>
|
||||
</goals>
|
||||
<phase>process-classes</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.2</version>
|
||||
<configuration>
|
||||
<detectLinks>true</detectLinks>
|
||||
<detectJavaApiLinks>true</detectJavaApiLinks>
|
||||
<links>
|
||||
<link>http://docs.oracle.com/javase/7/docs/api/</link>
|
||||
<link>http://docs.oracle.com/javaee/7/api/</link>
|
||||
<link>http://docs.jboss.org/hibernate/orm/4.3/javadocs/</link>
|
||||
</links>
|
||||
<show>private</show>
|
||||
<docfilessubdirs>true</docfilessubdirs>
|
||||
<charset>UTF-8</charset>
|
||||
<encoding>UTF-8</encoding>
|
||||
<docencoding>UTF-8</docencoding>
|
||||
<breakiterator>true</breakiterator>
|
||||
<version>true</version>
|
||||
<author>true</author>
|
||||
<keywords>true</keywords>
|
||||
<failOnError>false</failOnError>
|
||||
<doclet>org.jboss.apiviz.APIviz</doclet>
|
||||
<docletArtifact>
|
||||
<groupId>org.jboss.apiviz</groupId>
|
||||
<artifactId>apiviz</artifactId>
|
||||
<version>1.3.2.GA</version>
|
||||
</docletArtifact>
|
||||
<useStandardDocletOptions>true</useStandardDocletOptions>
|
||||
<additionalparam>
|
||||
-sourceclasspath ${project.build.outputDirectory}
|
||||
</additionalparam>
|
||||
<!--<additionalparam>-Xdoclint:none</additionalparam>-->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jxr-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-report-plugin</artifactId>
|
||||
<version>2.18.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.7.4.201502262128</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>findbugs-maven-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-pmd-plugin</artifactId>
|
||||
<version>3.4</version>
|
||||
<configuration>
|
||||
<linkXref>true</linkXref>
|
||||
<sourceEncoding>utf-8</sourceEncoding>
|
||||
<targetJdk>1.7</targetJdk>
|
||||
<rulesets>
|
||||
<ruleset>/rulesets/java/basic.xml</ruleset>
|
||||
<ruleset>/rulesets/java/braces.xml</ruleset>
|
||||
<ruleset>/rulesets/java/clone.xml</ruleset>
|
||||
<ruleset>/rulesets/java/codesize.xml</ruleset>
|
||||
<ruleset>/rulesets/java/design.xml</ruleset>
|
||||
<ruleset>/rulesets/java/empty.xml</ruleset>
|
||||
<ruleset>/rulesets/java/finalizers.xml</ruleset>
|
||||
<ruleset>/rulesets/java/imports.xml</ruleset>
|
||||
<ruleset>/rulesets/java/javabeans.xml</ruleset>
|
||||
<ruleset>/rulesets/java/junit.xml</ruleset>
|
||||
<ruleset>/rulesets/java/naming.xml</ruleset>
|
||||
<ruleset>/rulesets/java/optimizations.xml</ruleset>
|
||||
<ruleset>/rulesets/java/strictexception.xml</ruleset>
|
||||
<ruleset>/rulesets/java/strings.xml</ruleset>
|
||||
<ruleset>/rulesets/java/sunsecure.xml</ruleset>
|
||||
<ruleset>/rulesets/java/typeresolution.xml</ruleset>
|
||||
<ruleset>/rulesets/java/unnecessary.xml</ruleset>
|
||||
<ruleset>/rulesets/java/unusedcode.xml</ruleset>
|
||||
</rulesets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>javancss-maven-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>2.8</version>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<!--<report>dependencies</report>
|
||||
<report>project-team</report>
|
||||
<report>mailing-list</report>
|
||||
<report>cim</report>
|
||||
<report>issue-tracking</report>-->
|
||||
<report>license</report>
|
||||
<!--<report>scm</report>-->
|
||||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (C) 2015 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.libreccm.categorization;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import org.libreccm.core.CcmObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "categorizations")
|
||||
public class Categorization implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 201504301320L;
|
||||
|
||||
@Id
|
||||
@Column(name = "categorization_id")
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long categorizationId;
|
||||
|
||||
@ManyToOne
|
||||
private Category category;
|
||||
|
||||
@ManyToOne
|
||||
private CcmObject categorizedObject;
|
||||
|
||||
@Column(name = "category_order")
|
||||
private long categoryOrder;
|
||||
|
||||
@Column(name = "object_order")
|
||||
private long objectOrder;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -21,9 +21,16 @@ package org.libreccm.categorization;
|
|||
import org.libreccm.core.CcmObject;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.Table;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -35,4 +42,43 @@ public class Category extends CcmObject implements Serializable {
|
|||
|
||||
private static final long serialVersionUID = -7250208963391878547L;
|
||||
|
||||
@Column(name = "unique_id", nullable = false)
|
||||
private String uniqueId;
|
||||
|
||||
@Column(name = "name", nullable = false)
|
||||
private String name;
|
||||
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "category_titles",
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "object_id")}
|
||||
))
|
||||
private LocalizedString title;
|
||||
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "category_descriptions",
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "object_id")}
|
||||
))
|
||||
private LocalizedString description;
|
||||
|
||||
@Column(name = "enabled")
|
||||
private boolean enabled;
|
||||
|
||||
@Column(name = "visible")
|
||||
private boolean visible;
|
||||
|
||||
@Column(name = "abstract_category")
|
||||
private boolean abstractCategory;
|
||||
|
||||
|
||||
private List<CcmObject> owners;
|
||||
private List<CcmObject> objects;
|
||||
private List<Category> subCategories;
|
||||
private Category parentCategory;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class Domain extends CcmObject implements Serializable {
|
|||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "category_titles",
|
||||
joinTable = @JoinTable(name = "domain_titles",
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "object_id")}))
|
||||
private LocalizedString title;
|
||||
|
|
@ -64,7 +64,7 @@ public class Domain extends CcmObject implements Serializable {
|
|||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "category_descriptions",
|
||||
joinTable = @JoinTable(name = "domain_descriptions",
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "object_id")}))
|
||||
private LocalizedString description;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,181 @@
|
|||
/*
|
||||
* Copyright (C) 2015 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.libreccm.categorization;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import org.libreccm.core.CcmObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "domain_ownerships;")
|
||||
public class DomainOwnership implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 201504301305L;
|
||||
|
||||
@Id
|
||||
@Column(name = "ownership_id")
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long ownershipId;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
private CcmObject owner;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
private Domain domain;
|
||||
|
||||
@Column(name = "context")
|
||||
private String context;
|
||||
|
||||
@Column(name = "owner_order")
|
||||
private long ownerOrder;
|
||||
|
||||
@Column(name = "domain_order")
|
||||
private long domainOrder;
|
||||
|
||||
public long getOwnershipId() {
|
||||
return ownershipId;
|
||||
}
|
||||
|
||||
public void setOwnershipId(final long ownershipId) {
|
||||
this.ownershipId = ownershipId;
|
||||
}
|
||||
|
||||
public CcmObject getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
protected void setOwner(final CcmObject owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Domain getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
protected void setDomain(final Domain domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public String getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public void setContext(final String context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public long getDomainOrder() {
|
||||
return domainOrder;
|
||||
}
|
||||
|
||||
public void setDomainOrder(final long domainOrder) {
|
||||
this.domainOrder = domainOrder;
|
||||
}
|
||||
|
||||
public long getOwnerOrder() {
|
||||
return ownerOrder;
|
||||
}
|
||||
|
||||
public void setOwnerOrder(final long ownerOrder) {
|
||||
this.ownerOrder = ownerOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 59 * hash + (int) (ownershipId ^ (ownershipId >>> 32));
|
||||
hash = 59 * hash + Objects.hashCode(owner);
|
||||
hash = 59 * hash + Objects.hashCode(domain);
|
||||
hash = 59 * hash + Objects.hashCode(context);
|
||||
hash = 59 * hash + (int) (domainOrder ^ (domainOrder >>> 32));
|
||||
hash = 59 * hash + (int) (ownerOrder ^ (ownerOrder >>> 32));
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final DomainOwnership other = (DomainOwnership) obj;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ownershipId != other.getOwnershipId()) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(owner, other.getOwner())) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(domain, other.getDomain())) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(context, other.getContext())) {
|
||||
return false;
|
||||
}
|
||||
if (domainOrder != other.getDomainOrder()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ownerOrder == other.getOwnerOrder();
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object obj) {
|
||||
return obj instanceof DomainOwnership;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toString("");
|
||||
}
|
||||
|
||||
public String toString(final String data) {
|
||||
return String.format("%s{ "
|
||||
+ "ownershipId = %d, "
|
||||
+ "owner = %s, "
|
||||
+ "domain = %s, "
|
||||
+ "context = \"%s\", "
|
||||
+ "domainOrder = %d"
|
||||
+ "ownerOrder = %d"
|
||||
+ "%s }",
|
||||
super.toString(),
|
||||
ownershipId,
|
||||
owner.toString(),
|
||||
domain.toString(),
|
||||
context,
|
||||
domainOrder,
|
||||
ownerOrder,
|
||||
data);
|
||||
}
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ import javax.persistence.Table;
|
|||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter jens@jp-digital.de
|
||||
* @author <a href="jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "ccm_objects")
|
||||
|
|
@ -46,6 +46,7 @@ public class CcmObject implements Serializable {
|
|||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long objectId;
|
||||
|
||||
@Column(name = "display_name")
|
||||
private String displayName;
|
||||
|
||||
//private Map<String, Category> ownedCategories;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Copyright (C) 2015 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.libreccm.jpautils;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
/**
|
||||
* A converter for converting URI properties to String. JPA does not support
|
||||
* URI as type and will store them as LOBs without this converter. The converter
|
||||
* is automatically applied to all URI properties.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Converter(autoApply = true)
|
||||
public class UriConverter implements AttributeConverter<URI, String> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @param attribute {@inheritDoc}
|
||||
* @return {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String convertToDatabaseColumn(final URI attribute) {
|
||||
return attribute.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @param dbData {@inheritDoc}
|
||||
* @return {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URI convertToEntityAttribute(final String dbData) {
|
||||
try {
|
||||
return new URI(dbData);
|
||||
} catch (URISyntaxException ex) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Failed to convert String value '%s' from "
|
||||
+ "database to an URI.",
|
||||
dbData),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue