Add description field to OrganizationEntity
Closes #29356 Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
This commit is contained in:
parent
11a35e708e
commit
aa945d5636
7 changed files with 41 additions and 0 deletions
|
@ -29,6 +29,7 @@ public class OrganizationRepresentation {
|
||||||
private String id;
|
private String id;
|
||||||
private String name;
|
private String name;
|
||||||
private boolean enabled = true;
|
private boolean enabled = true;
|
||||||
|
private String description;
|
||||||
private Map<String, List<String>> attributes;
|
private Map<String, List<String>> attributes;
|
||||||
private Set<OrganizationDomainRepresentation> domains;
|
private Set<OrganizationDomainRepresentation> domains;
|
||||||
|
|
||||||
|
@ -56,6 +57,14 @@ public class OrganizationRepresentation {
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, List<String>> getAttributes() {
|
public Map<String, List<String>> getAttributes() {
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,9 @@ public class OrganizationEntity {
|
||||||
@Column(name = "ENABLED")
|
@Column(name = "ENABLED")
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
|
@Column(name = "DESCRIPTION")
|
||||||
|
private String description;
|
||||||
|
|
||||||
@Column(name = "REALM_ID")
|
@Column(name = "REALM_ID")
|
||||||
private String realmId;
|
private String realmId;
|
||||||
|
|
||||||
|
@ -83,6 +86,14 @@ public class OrganizationEntity {
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
public String getRealmId() {
|
public String getRealmId() {
|
||||||
return realmId;
|
return realmId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,16 @@ public final class OrganizationAdapter implements OrganizationModel, JpaModel<Or
|
||||||
entity.setEnabled(enabled);
|
entity.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return entity.getDescription();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDescription(String description) {
|
||||||
|
entity.setDescription(description);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAttributes(Map<String, List<String>> attributes) {
|
public void setAttributes(Map<String, List<String>> attributes) {
|
||||||
if (attributes == null) {
|
if (attributes == null) {
|
||||||
|
|
|
@ -95,6 +95,7 @@
|
||||||
<column name="NAME" type="VARCHAR(255)">
|
<column name="NAME" type="VARCHAR(255)">
|
||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
|
<column name="DESCRIPTION" type="VARCHAR(4000)"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
<addUniqueConstraint tableName="ORG" columnNames="REALM_ID, NAME" constraintName="UK_ORG_NAME"/>
|
<addUniqueConstraint tableName="ORG" columnNames="REALM_ID, NAME" constraintName="UK_ORG_NAME"/>
|
||||||
<addUniqueConstraint tableName="ORG" columnNames="GROUP_ID" constraintName="UK_ORG_GROUP"/>
|
<addUniqueConstraint tableName="ORG" columnNames="GROUP_ID" constraintName="UK_ORG_GROUP"/>
|
||||||
|
|
|
@ -38,6 +38,10 @@ public interface OrganizationModel {
|
||||||
|
|
||||||
void setEnabled(boolean enabled);
|
void setEnabled(boolean enabled);
|
||||||
|
|
||||||
|
String getDescription();
|
||||||
|
|
||||||
|
void setDescription(String description);
|
||||||
|
|
||||||
Map<String, List<String>> getAttributes();
|
Map<String, List<String>> getAttributes();
|
||||||
|
|
||||||
void setAttributes(Map<String, List<String>> attributes);
|
void setAttributes(Map<String, List<String>> attributes);
|
||||||
|
|
|
@ -174,6 +174,7 @@ public class OrganizationResource {
|
||||||
rep.setId(model.getId());
|
rep.setId(model.getId());
|
||||||
rep.setName(model.getName());
|
rep.setName(model.getName());
|
||||||
rep.setEnabled(model.isEnabled());
|
rep.setEnabled(model.isEnabled());
|
||||||
|
rep.setDescription(model.getDescription());
|
||||||
rep.setAttributes(model.getAttributes());
|
rep.setAttributes(model.getAttributes());
|
||||||
model.getDomains().filter(Objects::nonNull).map(this::toRepresentation)
|
model.getDomains().filter(Objects::nonNull).map(this::toRepresentation)
|
||||||
.forEach(rep::addDomain);
|
.forEach(rep::addDomain);
|
||||||
|
@ -195,6 +196,7 @@ public class OrganizationResource {
|
||||||
|
|
||||||
model.setName(rep.getName());
|
model.setName(rep.getName());
|
||||||
model.setEnabled(rep.isEnabled());
|
model.setEnabled(rep.isEnabled());
|
||||||
|
model.setDescription(rep.getDescription());
|
||||||
model.setAttributes(rep.getAttributes());
|
model.setAttributes(rep.getAttributes());
|
||||||
model.setDomains(Optional.ofNullable(rep.getDomains()).orElse(Set.of()).stream()
|
model.setDomains(Optional.ofNullable(rep.getDomains()).orElse(Set.of()).stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
|
|
|
@ -24,6 +24,7 @@ import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.hasSize;
|
import static org.hamcrest.Matchers.hasSize;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
|
import static org.hamcrest.Matchers.notNullValue;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
@ -56,6 +57,7 @@ public class OrganizationTest extends AbstractOrganizationTest {
|
||||||
assertEquals(organizationName, expected.getName());
|
assertEquals(organizationName, expected.getName());
|
||||||
expected.setName("acme");
|
expected.setName("acme");
|
||||||
expected.setEnabled(false);
|
expected.setEnabled(false);
|
||||||
|
expected.setDescription("ACME Corporation Organization");
|
||||||
|
|
||||||
OrganizationResource organization = testRealm().organizations().get(expected.getId());
|
OrganizationResource organization = testRealm().organizations().get(expected.getId());
|
||||||
|
|
||||||
|
@ -68,6 +70,8 @@ public class OrganizationTest extends AbstractOrganizationTest {
|
||||||
assertEquals(expected.getName(), existing.getName());
|
assertEquals(expected.getName(), existing.getName());
|
||||||
assertEquals(1, existing.getDomains().size());
|
assertEquals(1, existing.getDomains().size());
|
||||||
assertThat(existing.isEnabled(), is(false));
|
assertThat(existing.isEnabled(), is(false));
|
||||||
|
assertThat(existing.getDescription(), notNullValue());
|
||||||
|
assertThat(expected.getDescription(), is(equalTo(existing.getDescription())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in a new issue