Skip to content

Commit

Permalink
Merge branch 'releases/release-0.6.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
valesu committed Oct 3, 2017
2 parents 3a161c2 + 2e1ab4f commit 3057758
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>ee.eesti.riha</groupId>
<artifactId>rest</artifactId>
<version>0.5.0</version>
<version>0.6.0</version>

<packaging>war</packaging>

Expand Down
2 changes: 1 addition & 1 deletion sql/create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ CREATE TABLE riha.comment
infosystem_uuid UUID,
comment VARCHAR,
author_name VARCHAR(255) NULL,
author_personal_code VARCHAR(11) NULL,
author_personal_code VARCHAR(13) NULL,
organization_name VARCHAR(255) NULL,
organization_code VARCHAR(50) NULL,
status VARCHAR(150) NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE riha.comment ALTER COLUMN author_personal_code TYPE VARCHAR(13);
15 changes: 12 additions & 3 deletions src/main/java/ee/eesti/riha/rest/dao/ApiGenericDAOImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ public int update(T newValue, Integer id) throws RihaRestException {
if (JsonContentBasedTable.isJsonContentBasedTable(clazz)) {
return updateJsonContentEntity(existing, newValue);
} else {
return updateEntity(newValue);
return updateEntity(existing, newValue);
}

}
Expand Down Expand Up @@ -554,9 +554,18 @@ private int updateJsonContentEntity(T existing, T newValue) throws RihaRestExcep
return 1;
}

private int updateEntity(T updatedEntity) {
private int updateEntity(T existing, T updatedEntity) {
Session session = sessionFactory.getCurrentSession();
session.merge(updatedEntity);

try {
copyNotNullValues(existing, updatedEntity);
session.update(existing);
} catch (IntrospectionException | IllegalAccessException | InvocationTargetException e) {
LOG.error("Failed to update entity {}", existing);
LOG.debug("Failed to update entity", e);

return 0;
}
return 1;
}

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/ee/eesti/riha/rest/model/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public Integer getComment_parent_id() {
*
* @param aComment_parent_id the new comment_parent_id
*/
@DisallowUseMethodForUpdate
public void setComment_parent_id(Integer aComment_parent_id) {
comment_parent_id = aComment_parent_id;
}
Expand Down Expand Up @@ -301,6 +302,7 @@ public String getAuthor_name() {
return author_name;
}

@DisallowUseMethodForUpdate
public void setAuthor_name(String author_name) {
this.author_name = author_name;
}
Expand All @@ -309,6 +311,7 @@ public String getAuthor_personal_code() {
return author_personal_code;
}

@DisallowUseMethodForUpdate
public void setAuthor_personal_code(String author_personal_code) {
this.author_personal_code = author_personal_code;
}
Expand All @@ -317,6 +320,7 @@ public String getOrganization_name() {
return organization_name;
}

@DisallowUseMethodForUpdate
public void setOrganization_name(String organization_name) {
this.organization_name = organization_name;
}
Expand All @@ -325,6 +329,7 @@ public String getOrganization_code() {
return organization_code;
}

@DisallowUseMethodForUpdate
public void setOrganization_code(String organization_code) {
this.organization_code = organization_code;
}
Expand All @@ -341,6 +346,7 @@ public String getType() {
return type;
}

@DisallowUseMethodForUpdate
public void setType(String type) {
this.type = type;
}
Expand All @@ -349,6 +355,7 @@ public String getSub_type() {
return sub_type;
}

@DisallowUseMethodForUpdate
public void setSub_type(String sub_type) {
this.sub_type = sub_type;
}
Expand Down

0 comments on commit 3057758

Please sign in to comment.