Commit 687ec6e3 authored by Maxym Borodenko's avatar Maxym Borodenko Committed by Matija Obreza

Extended CooperatorOwnedLang with entity property

parent 7f03740e
......@@ -65,7 +65,7 @@ public class CodeValue extends CooperatorOwnedModel {
@OneLine
private String value;
@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "codeValue")
@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "entity")
@JsonIgnore
private List<CodeValueLang> langs;
......
......@@ -28,13 +28,10 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Entity
@Table(name = "code_value_lang")
@JsonIdentityInfo(scope = CodeValueLang.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@AssociationOverride(name = "entity", joinColumns = { @JoinColumn(name = "code_value_id", nullable = false) })
public class CodeValueLang extends CooperatorOwnedLang<CodeValue> {
private static final long serialVersionUID = -8056778240683451739L;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "code_value_id", nullable = false)
private CodeValue codeValue;
@Id
@JsonProperty
@GeneratedValue(strategy = GenerationType.IDENTITY)
......@@ -48,14 +45,6 @@ public class CodeValueLang extends CooperatorOwnedLang<CodeValue> {
this.id = id;
}
public CodeValue getCodeValue() {
return codeValue;
}
public void setCodeValue(final CodeValue codeValue) {
this.codeValue = codeValue;
}
public Long getId() {
return id;
}
......
......@@ -32,6 +32,10 @@ import javax.persistence.MappedSuperclass;
public abstract class CooperatorOwnedLang<T extends CooperatorOwnedModel> extends CooperatorOwnedModel {
private static final long serialVersionUID = -8074420732594755502L;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn
protected T entity;
@Basic
@Column
@Lob
......@@ -45,6 +49,14 @@ public abstract class CooperatorOwnedLang<T extends CooperatorOwnedModel> extend
@JoinColumn(name = "sys_lang_id", nullable = false)
protected SysLang sysLang;
public T getEntity() {
return entity;
}
public void setEntity(final T entity) {
this.entity = entity;
}
public String getDescription() {
return description;
}
......
......@@ -106,7 +106,7 @@ public class CropTrait extends CooperatorOwnedModel implements Copyable<CropTrai
@Column(name = "original_value_type_code", length = 20)
private String originalValueTypeCode;
@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "cropTrait")
@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "entity")
@JsonIgnore
private List<CropTraitLang> cropTraitLangs;
......
......@@ -48,7 +48,7 @@ public class CropTraitCode extends CooperatorOwnedModel {
@Column(name = "crop_trait_code_id")
private Long id;
@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "cropTraitCode")
@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "entity")
@JsonIgnore
private List<CropTraitCodeLang> codeLangs;
......
......@@ -28,14 +28,10 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Entity
@Table(name = "crop_trait_code_lang")
@JsonIdentityInfo(scope = CropTraitCodeLang.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@AttributeOverride(name = "title", column = @Column(nullable = true, length = 500))
@AssociationOverride(name = "entity", joinColumns = { @JoinColumn(name = "crop_trait_code_id", nullable = false) })
public class CropTraitCodeLang extends CooperatorOwnedLang<CropTraitCode> {
private static final long serialVersionUID = 8734983132443264074L;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "crop_trait_code_id", nullable = false)
private CropTraitCode cropTraitCode;
@Id
@JsonProperty
@GeneratedValue(strategy = GenerationType.IDENTITY)
......@@ -49,14 +45,6 @@ public class CropTraitCodeLang extends CooperatorOwnedLang<CropTraitCode> {
this.id = id;
}
public CropTraitCode getCropTraitCode() {
return cropTraitCode;
}
public void setCropTraitCode(final CropTraitCode cropTraitCode) {
this.cropTraitCode = cropTraitCode;
}
public Long getId() {
return id;
}
......
......@@ -28,14 +28,10 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Entity
@Table(name = "crop_trait_lang")
@JsonIdentityInfo(scope = CropTraitLang.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@AttributeOverride(name = "title", column = @Column(nullable = true, length = 500))
@AssociationOverride(name = "entity", joinColumns = { @JoinColumn(name = "crop_trait_id", nullable = false) })
public class CropTraitLang extends CooperatorOwnedLang<CropTrait> {
private static final long serialVersionUID = 1415634897733917322L;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "crop_trait_id", nullable = false)
private CropTrait cropTrait;
@Id
@JsonProperty
@GeneratedValue(strategy = GenerationType.IDENTITY)
......@@ -49,14 +45,6 @@ public class CropTraitLang extends CooperatorOwnedLang<CropTrait> {
this.id = id;
}
public CropTrait getCropTrait() {
return cropTrait;
}
public void setCropTrait(final CropTrait cropTrait) {
this.cropTrait = cropTrait;
}
public Long getId() {
return id;
}
......
......@@ -28,7 +28,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Entity
@Table(name = "source_descriptor_code_lang")
@JsonIdentityInfo(scope = SourceDescriptorCodeLang.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@AttributeOverride(name = "title", column = @Column(nullable = true, length = 500))
@AssociationOverride(name = "entity", joinColumns = { @JoinColumn(name = "source_descriptor_code_id", nullable = false) })
public class SourceDescriptorCodeLang extends CooperatorOwnedLang<SourceDescriptorCode> {
private static final long serialVersionUID = -6651240212098239872L;
......@@ -38,10 +38,6 @@ public class SourceDescriptorCodeLang extends CooperatorOwnedLang<SourceDescript
@Column(name = "source_descriptor_code_lang_id")
private Long id;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "source_descriptor_code_id", nullable = false)
private SourceDescriptorCode sourceDescriptorCode;
public SourceDescriptorCodeLang() {
}
......@@ -57,12 +53,4 @@ public class SourceDescriptorCodeLang extends CooperatorOwnedLang<SourceDescript
this.id = id;
}
public SourceDescriptorCode getSourceDescriptorCode() {
return sourceDescriptorCode;
}
public void setSourceDescriptorCode(final SourceDescriptorCode sourceDescriptorCode) {
this.sourceDescriptorCode = sourceDescriptorCode;
}
}
\ No newline at end of file
......@@ -28,7 +28,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Entity
@Table(name = "source_descriptor_lang")
@JsonIdentityInfo(scope = SourceDescriptorLang.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@AttributeOverride(name = "title", column = @Column(nullable = true, length = 500))
@AssociationOverride(name = "entity", joinColumns = { @JoinColumn(name = "source_descriptor_id", nullable = false) })
public class SourceDescriptorLang extends CooperatorOwnedLang<SourceDescriptor> {
private static final long serialVersionUID = 7116474808205086996L;
......@@ -38,10 +38,6 @@ public class SourceDescriptorLang extends CooperatorOwnedLang<SourceDescriptor>
@Column(name = "source_descriptor_lang_id")
private Long id;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "source_descriptor_id", nullable = false)
private SourceDescriptor sourceDescriptor;
public SourceDescriptorLang() {
}
......@@ -57,12 +53,4 @@ public class SourceDescriptorLang extends CooperatorOwnedLang<SourceDescriptor>
this.id = id;
}
public SourceDescriptor getSourceDescriptor() {
return sourceDescriptor;
}
public void setSourceDescriptor(final SourceDescriptor sourceDescriptor) {
this.sourceDescriptor = sourceDescriptor;
}
}
\ No newline at end of file
......@@ -28,6 +28,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Entity
@Table(name = "sys_datatrigger_lang")
@JsonIdentityInfo(scope = SysDatatriggerLang.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@AssociationOverride(name = "entity", joinColumns = { @JoinColumn(name = "sys_datatrigger_id", nullable = false) })
public class SysDatatriggerLang extends CooperatorOwnedLang<SysDatatrigger> {
private static final long serialVersionUID = -4460748968617104284L;
......@@ -37,10 +38,6 @@ public class SysDatatriggerLang extends CooperatorOwnedLang<SysDatatrigger> {
@Column(name = "sys_datatrigger_lang_id")
private Long id;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "sys_datatrigger_id", nullable = false)
private SysDatatrigger sysDatatrigger;
public SysDatatriggerLang() {
}
......@@ -56,11 +53,4 @@ public class SysDatatriggerLang extends CooperatorOwnedLang<SysDatatrigger> {
this.id = id;
}
public SysDatatrigger getSysDatatrigger() {
return sysDatatrigger;
}
public void setSysDatatrigger(final SysDatatrigger sysDatatrigger) {
this.sysDatatrigger = sysDatatrigger;
}
}
\ No newline at end of file
......@@ -85,8 +85,8 @@ public class SysDataview extends CooperatorOwnedModel {
@Column(name = "transform_field_for_values", length = 50)
private String transformFieldForValues;
@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "dataview")
@JsonIgnoreProperties({ "dataview" })
@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "entity")
@JsonIgnoreProperties({ "entity" })
private List<SysDataviewLang> langs;
@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "dataview")
......
......@@ -93,7 +93,7 @@ public class SysDataviewField extends CooperatorOwnedModel {
@Column(name = "table_alias_name", length = 100)
private String tableAliasName;
@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "sysDataviewField")
@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "entity")
@JsonIgnore
private List<SysDataviewFieldLang> langs;
......
......@@ -29,6 +29,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Cacheable
@Table(name = "sys_dataview_field_lang")
@JsonIdentityInfo(scope = SysDataviewFieldLang.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@AssociationOverride(name = "entity", joinColumns = { @JoinColumn(name = "sys_dataview_field_id", nullable = false) })
public class SysDataviewFieldLang extends CooperatorOwnedLang<SysDataviewField> {
private static final long serialVersionUID = -6367401516327563260L;
......@@ -38,10 +39,6 @@ public class SysDataviewFieldLang extends CooperatorOwnedLang<SysDataviewField>
@Column(name = "sys_dataview_field_lang_id")
private Long id;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "sys_dataview_field_id", nullable = false)
private SysDataviewField sysDataviewField;
public SysDataviewFieldLang() {
}
......@@ -57,12 +54,4 @@ public class SysDataviewFieldLang extends CooperatorOwnedLang<SysDataviewField>
this.id = id;
}
public SysDataviewField getSysDataviewField() {
return sysDataviewField;
}
public void setSysDataviewField(final SysDataviewField sysDataviewField) {
this.sysDataviewField = sysDataviewField;
}
}
\ No newline at end of file
......@@ -29,6 +29,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Cacheable
@Table(name = "sys_dataview_lang")
@JsonIdentityInfo(scope = SysDataviewLang.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@AssociationOverride(name = "entity", joinColumns = { @JoinColumn(name = "sys_dataview_id", nullable = false) })
public class SysDataviewLang extends CooperatorOwnedLang<SysDataview> {
private static final long serialVersionUID = -6532597361966857246L;
......@@ -38,10 +39,6 @@ public class SysDataviewLang extends CooperatorOwnedLang<SysDataview> {
@Column(name = "sys_dataview_lang_id")
private Long id;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "sys_dataview_id", nullable = false)
private SysDataview dataview;
public SysDataviewLang() {
}
......@@ -57,11 +54,4 @@ public class SysDataviewLang extends CooperatorOwnedLang<SysDataview> {
this.id = id;
}
public SysDataview getDataview() {
return dataview;
}
public void setDataview(final SysDataview sysDataview) {
this.dataview = sysDataview;
}
}
\ No newline at end of file
......@@ -28,6 +28,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Entity
@Table(name = "sys_file_lang")
@JsonIdentityInfo(scope = SysFileLang.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@AssociationOverride(name = "entity", joinColumns = { @JoinColumn(name = "sys_file_id", nullable = false) })
public class SysFileLang extends CooperatorOwnedLang<SysFile> {
private static final long serialVersionUID = 7172737067204909917L;
......@@ -37,10 +38,6 @@ public class SysFileLang extends CooperatorOwnedLang<SysFile> {
@Column(name = "sys_file_lang_id")
private Long id;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "sys_file_id", nullable = false)
private SysFile sysFile;
public SysFileLang() {
}
......@@ -56,11 +53,4 @@ public class SysFileLang extends CooperatorOwnedLang<SysFile> {
this.id = id;
}
public SysFile getSysFile() {
return sysFile;
}
public void setSysFile(final SysFile sysFile) {
this.sysFile = sysFile;
}
}
\ No newline at end of file
......@@ -28,6 +28,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Entity
@Table(name = "sys_group_lang")
@JsonIdentityInfo(scope = SysGroupLang.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@AssociationOverride(name = "entity", joinColumns = { @JoinColumn(name = "sys_group_id", nullable = false) })
public class SysGroupLang extends CooperatorOwnedLang<SysGroup> {
private static final long serialVersionUID = -7062292145715663004L;
......@@ -37,10 +38,6 @@ public class SysGroupLang extends CooperatorOwnedLang<SysGroup> {
@Column(name = "sys_group_lang_id")
private Long id;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "sys_group_id", nullable = false)
private SysGroup sysGroup;
public SysGroupLang() {
}
......@@ -56,12 +53,4 @@ public class SysGroupLang extends CooperatorOwnedLang<SysGroup> {
this.id = id;
}
public SysGroup getSysGroup() {
return sysGroup;
}
public void setSysGroup(final SysGroup sysGroup) {
this.sysGroup = sysGroup;
}
}
\ No newline at end of file
......@@ -28,6 +28,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Entity
@Table(name = "sys_permission_lang")
@JsonIdentityInfo(scope = SysPermissionLang.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@AssociationOverride(name = "entity", joinColumns = { @JoinColumn(name = "sys_permission_id", nullable = false) })
public class SysPermissionLang extends CooperatorOwnedLang<SysPermission> {
private static final long serialVersionUID = 727395435818941738L;
......@@ -37,10 +38,6 @@ public class SysPermissionLang extends CooperatorOwnedLang<SysPermission> {
@Column(name = "sys_permission_lang_id")
private Long id;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "sys_permission_id", nullable = false)
private SysPermission sysPermission;
public SysPermissionLang() {
}
......@@ -56,12 +53,4 @@ public class SysPermissionLang extends CooperatorOwnedLang<SysPermission> {
this.id = id;
}
public SysPermission getSysPermission() {
return sysPermission;
}
public void setSysPermission(final SysPermission sysPermission) {
this.sysPermission = sysPermission;
}
}
\ No newline at end of file
......@@ -120,7 +120,7 @@ public class SysTableField extends CooperatorOwnedModel {
@JsonIdentityInfo(scope = SysTable.class, property = "tableName", generator = ObjectIdGenerators.PropertyGenerator.class)
private SysTable table;
@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "sysTableField")
@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "entity")
@JsonIgnore
private List<SysTableFieldLang> langs;
......
......@@ -29,6 +29,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Cacheable
@Table(name = "sys_table_field_lang")
@JsonIdentityInfo(scope = SysTableFieldLang.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@AssociationOverride(name = "entity", joinColumns = { @JoinColumn(name = "sys_table_field_id", nullable = false) })
public class SysTableFieldLang extends CooperatorOwnedLang<SysTableField> {
private static final long serialVersionUID = -8788993073221533512L;
......@@ -38,10 +39,6 @@ public class SysTableFieldLang extends CooperatorOwnedLang<SysTableField> {
@Column(name = "sys_table_field_lang_id")
private Long id;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "sys_table_field_id", nullable = false)
private SysTableField sysTableField;
public SysTableFieldLang() {
}
......@@ -57,12 +54,4 @@ public class SysTableFieldLang extends CooperatorOwnedLang<SysTableField> {
this.id = id;
}
public SysTableField getSysTableField() {
return sysTableField;
}
public void setSysTableField(final SysTableField sysTableField) {
this.sysTableField = sysTableField;
}
}
\ No newline at end of file
......@@ -29,6 +29,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Cacheable
@Table(name = "sys_table_lang")
@JsonIdentityInfo(scope = SysTableLang.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@AssociationOverride(name = "entity", joinColumns = { @JoinColumn(name = "sys_table_id", nullable = false) })
public class SysTableLang extends CooperatorOwnedLang<SysTable> {
private static final long serialVersionUID = -978641915860457412L;
......@@ -38,10 +39,6 @@ public class SysTableLang extends CooperatorOwnedLang<SysTable> {
@Column(name = "sys_table_lang_id")
private Long id;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "sys_table_id", nullable = false)
private SysTable sysTable;
public SysTableLang() {
}
......@@ -57,11 +54,4 @@ public class SysTableLang extends CooperatorOwnedLang<SysTable> {
this.id = id;
}
public SysTable getSysTable() {
return sysTable;
}
public void setSysTable(final SysTable sysTable) {
this.sysTable = sysTable;
}
}
\ No newline at end of file
......@@ -25,6 +25,6 @@ import org.springframework.stereotype.Repository;
@Repository
public interface SysDataviewLangRepository extends JpaRepository<SysDataviewLang, Long>, QuerydslPredicateExecutor<SysDataviewLang> {
SysDataviewLang findByDataviewAndSysLang(SysDataview dataview, SysLang lang);
SysDataviewLang findByEntityAndSysLang(SysDataview dataview, SysLang lang);
}
......@@ -59,10 +59,10 @@ public class CodeValueServiceImpl implements CodeValueService {
codeValue = codeValueRepository.save(codeValue);
CodeValueLang codeValueLang = new CodeValueLang();
codeValueLang.setCodeValue(codeValue);
codeValueLang.setEntity(codeValue);
codeValueLang.setTitle(title);
codeValueLang.setDescription(description);
codeValueLang.setSysLang(new SysLang(1l)); // English
codeValueLang.setSysLang(new SysLang(1L)); // English
codeValueLangRepository.save(codeValueLang);
}
......
......@@ -318,7 +318,7 @@ public class AppControllerTest extends AbstractApiV1Test {
codeValueLang.setTitle(title);
codeValueLang.setDescription(sysLang.getIetfTag() + " text for " + codeValue.getValue());
codeValueLang.setSysLang(sysLang);
codeValueLang.setCodeValue(codeValue);
codeValueLang.setEntity(codeValue);
return codeValueLangRepository.save(codeValueLang);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment