parent
7d3475a480
commit
0eea72225e
|
|
@ -91,6 +91,9 @@ public class LocalizedStringType implements UserType {
|
|||
final int index,
|
||||
final SharedSessionContractImplementor session
|
||||
) throws HibernateException, SQLException {
|
||||
if (value == null) {
|
||||
statement.setObject(index, null, Types.OTHER);
|
||||
} else {
|
||||
final JsonObject jsonObject = ((LocalizedString) value).toJson();
|
||||
try (StringWriter strWriter = new StringWriter();
|
||||
JsonWriter jsonWriter = Json.createWriter(strWriter)) {
|
||||
|
|
@ -100,6 +103,7 @@ public class LocalizedStringType implements UserType {
|
|||
throw new HibernateException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object deepCopy(final Object value) throws HibernateException {
|
||||
|
|
|
|||
|
|
@ -40,16 +40,12 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.NamedAttributeNode;
|
||||
import javax.persistence.NamedEntityGraph;
|
||||
import javax.persistence.NamedEntityGraphs;
|
||||
|
|
@ -186,7 +182,7 @@ public class Role implements Serializable, Exportable {
|
|||
@Column(name = "DESCRIPTION")
|
||||
@Type(type = "org.libreccm.l10n.LocalizedStringType")
|
||||
@XmlElement(name = "description", namespace = CORE_XML_NS)
|
||||
private LocalizedString description = new LocalizedString();
|
||||
private LocalizedString description;
|
||||
|
||||
/**
|
||||
* All memberships of the roles.
|
||||
|
|
@ -195,7 +191,7 @@ public class Role implements Serializable, Exportable {
|
|||
@XmlElementWrapper(name = "role-memberships", namespace = CORE_XML_NS)
|
||||
@XmlElement(name = "role-membership", namespace = CORE_XML_NS)
|
||||
@JsonIgnore
|
||||
private Set<RoleMembership> memberships = new HashSet<>();
|
||||
private Set<RoleMembership> memberships;
|
||||
|
||||
/**
|
||||
* Permissions granted to the role.
|
||||
|
|
@ -205,14 +201,18 @@ public class Role implements Serializable, Exportable {
|
|||
@XmlElementWrapper(name = "permissions", namespace = CORE_XML_NS)
|
||||
@XmlElement(name = "permission", namespace = CORE_XML_NS)
|
||||
@JsonIgnore
|
||||
private List<Permission> permissions = new ArrayList<>();
|
||||
private List<Permission> permissions;
|
||||
|
||||
@OneToMany(mappedBy = "role", fetch = FetchType.LAZY)
|
||||
@JsonIgnore
|
||||
private List<TaskAssignment> assignedTasks = new ArrayList<>();
|
||||
private List<TaskAssignment> assignedTasks;
|
||||
|
||||
public Role() {
|
||||
super();
|
||||
description = new LocalizedString();
|
||||
memberships = new HashSet<>();
|
||||
permissions = new ArrayList<>();
|
||||
assignedTasks = new ArrayList<>();
|
||||
}
|
||||
|
||||
public long getRoleId() {
|
||||
|
|
@ -249,7 +249,7 @@ public class Role implements Serializable, Exportable {
|
|||
}
|
||||
|
||||
protected void setMemberships(final Set<RoleMembership> memberships) {
|
||||
this.memberships = memberships;
|
||||
this.memberships = new HashSet<>(memberships);
|
||||
}
|
||||
|
||||
protected void addMembership(final RoleMembership membership) {
|
||||
|
|
@ -269,7 +269,7 @@ public class Role implements Serializable, Exportable {
|
|||
}
|
||||
|
||||
protected void setPermissions(final List<Permission> permissions) {
|
||||
this.permissions = permissions;
|
||||
this.permissions = new ArrayList<>(permissions);
|
||||
}
|
||||
|
||||
protected void addPermission(final Permission permission) {
|
||||
|
|
@ -289,7 +289,7 @@ public class Role implements Serializable, Exportable {
|
|||
}
|
||||
|
||||
protected void setAssignedTasks(final List<TaskAssignment> assignedTasks) {
|
||||
this.assignedTasks = assignedTasks;
|
||||
this.assignedTasks = new ArrayList<>(assignedTasks);
|
||||
}
|
||||
|
||||
public void addAssignedTask(final TaskAssignment taskAssignment) {
|
||||
|
|
@ -301,7 +301,7 @@ public class Role implements Serializable, Exportable {
|
|||
}
|
||||
|
||||
public LocalizedString getDescription() {
|
||||
return this.description;
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final LocalizedString description) {
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ public class ConfigurationLoaderTest {
|
|||
@Test
|
||||
@ShouldMatchDataSet(
|
||||
value = "datasets/org/libreccm/modules/ConfigurationLoaderTest/"
|
||||
+ "after-load.yml",
|
||||
+ "after-load.xml",
|
||||
excludeColumns = {"setting_id", "entry_id"})
|
||||
public void loadConfiguration() {
|
||||
final ConfigurationLoader confLoader = new ConfigurationLoader(
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
setting_id="120"
|
||||
configuration_class="org.libreccm.configuration.ExampleConfiguration"
|
||||
name="title"
|
||||
setting_value_localized_string="{'de': 'Versuch', 'en': 'Test'}"
|
||||
setting_value_localized_string='{"de": "Versuch", "en": "Test"}'
|
||||
/>
|
||||
<ccm_core.settings
|
||||
dtype="BooleanSetting"
|
||||
|
|
|
|||
Loading…
Reference in New Issue