/*
* The Kuali Financial System, a comprehensive financial management system for higher education.
*
* Copyright 2005-2014 The Kuali Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.kuali.rice.kim.impl.jaxb;
import java.io.Serializable;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.kuali.rice.core.util.jaxb.NameAndNamespacePair;
import org.kuali.rice.core.util.jaxb.NameAndNamespacePairValidatingAdapter;
import org.kuali.rice.core.util.jaxb.StringTrimmingAdapter;
import org.kuali.rice.kim.api.jaxb.NameAndNamespacePairToKimTypeIdAdapter;
import org.kuali.rice.kim.api.role.RoleContract;
/**
* This class represents a <role> XML element.
*
* @author Kuali Rice Team (rice.collab@kuali.org)
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name="RoleType", propOrder={
"roleNameAndNamespace", "kimTypeId", "roleDescription", "active", "roleMembers", "rolePermissions"
})
public class RoleXmlDTO implements Serializable {
private static final long serialVersionUID = 1L;
@XmlTransient
private String roleId;
@XmlElement(name="roleName")
@XmlJavaTypeAdapter(NameAndNamespacePairValidatingAdapter.class)
private NameAndNamespacePair roleNameAndNamespace;
@XmlElement(name="kimTypeName")
@XmlJavaTypeAdapter(NameAndNamespacePairToKimTypeIdAdapter.class)
private String kimTypeId;
@XmlElement(name="description")
@XmlJavaTypeAdapter(StringTrimmingAdapter.class)
private String roleDescription;
@XmlElement(name="active")
private Boolean active;
@XmlElement(name="roleMembers")
private RoleMembersXmlDTO.WithinRole roleMembers;
@XmlElement(name="rolePermissions")
private RolePermissionsXmlDTO.WithinRole rolePermissions;
@XmlTransient
private boolean alreadyPersisted = false;
@XmlTransient
private Set<String> existingRoleMemberIds;
public RoleXmlDTO() {
this.active = Boolean.TRUE;
}
public RoleXmlDTO(RoleContract role, RoleMembersXmlDTO.WithinRole roleMembers, RolePermissionsXmlDTO.WithinRole rolePermissions) {
if (role == null) {
throw new IllegalArgumentException("role cannot be null");
}
this.roleNameAndNamespace = new NameAndNamespacePair(role.getNamespaceCode(), role.getName());
this.kimTypeId = role.getKimTypeId();
this.roleDescription = role.getDescription();
this.active = Boolean.valueOf(role.isActive());
this.roleMembers = roleMembers;
this.rolePermissions = rolePermissions;
}
/**
* @return the roleId
*/
public String getRoleId() {
return this.roleId;
}
/**
* @param roleId the roleId to set
*/
public void setRoleId(String roleId) {
this.roleId = roleId;
}
/**
* @return the roleNameAndNamespace
*/
public NameAndNamespacePair getRoleNameAndNamespace() {
return this.roleNameAndNamespace;
}
/**
* @param roleNameAndNamespace the roleNameAndNamespace to set
*/
public void setRoleNameAndNamespace(NameAndNamespacePair roleNameAndNamespace) {
this.roleNameAndNamespace = roleNameAndNamespace;
}
/**
* @return the kimTypeId
*/
public String getKimTypeId() {
return this.kimTypeId;
}
/**
* @param kimTypeId the kimTypeId to set
*/
public void setKimTypeId(String kimTypeId) {
this.kimTypeId = kimTypeId;
}
/**
* @return the roleDescription
*/
public String getRoleDescription() {
return this.roleDescription;
}
/**
* @param roleDescription the roleDescription to set
*/
public void setRoleDescription(String roleDescription) {
this.roleDescription = roleDescription;
}
/**
* @return the active
*/
public Boolean getActive() {
return this.active;
}
/**
* @param active the active to set
*/
public void setActive(Boolean active) {
this.active = active;
}
/**
* @return the roleMembers
*/
public RoleMembersXmlDTO.WithinRole getRoleMembers() {
return this.roleMembers;
}
/**
* @param roleMembers the roleMembers to set
*/
public void setRoleMembers(RoleMembersXmlDTO.WithinRole roleMembers) {
this.roleMembers = roleMembers;
}
/**
* @return the rolePermissions
*/
public RolePermissionsXmlDTO.WithinRole getRolePermissions() {
return this.rolePermissions;
}
/**
* @param rolePermissions the rolePermissions to set
*/
public void setRolePermissions(RolePermissionsXmlDTO.WithinRole rolePermissions) {
this.rolePermissions = rolePermissions;
}
/**
* @return the alreadyPersisted
*/
public boolean isAlreadyPersisted() {
return this.alreadyPersisted;
}
/**
* @param alreadyPersisted the alreadyPersisted to set
*/
public void setAlreadyPersisted(boolean alreadyPersisted) {
this.alreadyPersisted = alreadyPersisted;
}
/**
* @return the existingRoleMemberIds
*/
public Set<String> getExistingRoleMemberIds() {
return this.existingRoleMemberIds;
}
/**
* @param existingRoleMemberIds the existingRoleMemberIds to set
*/
public void setExistingRoleMemberIds(Set<String> existingRoleMemberIds) {
this.existingRoleMemberIds = existingRoleMemberIds;
}
/**
* Retrieves the role's name from the role-name-and-namespace combo.
*
* @return The name of the role, or null if the role-name-and-namespace combo is null.
*/
public String getRoleName() {
return (roleNameAndNamespace != null) ? roleNameAndNamespace.getName() : null;
}
/**
* Retrieves the role's namespace code from the role-name-and-namespace combo.
*
* @return The namespace code of the role, or null if the role-name-and-namespace combo is null.
*/
public String getNamespaceCode() {
return (roleNameAndNamespace != null) ? roleNameAndNamespace.getNamespaceCode() : null;
}
}