001
014
015 package com.liferay.portal.model.impl;
016
017 import com.liferay.portal.kernel.util.StringBundler;
018 import com.liferay.portal.kernel.util.StringPool;
019 import com.liferay.portal.model.CacheModel;
020 import com.liferay.portal.model.Organization;
021
022 import java.io.Externalizable;
023 import java.io.IOException;
024 import java.io.ObjectInput;
025 import java.io.ObjectOutput;
026
027
034 public class OrganizationCacheModel implements CacheModel<Organization>,
035 Externalizable {
036 @Override
037 public String toString() {
038 StringBundler sb = new StringBundler(23);
039
040 sb.append("{organizationId=");
041 sb.append(organizationId);
042 sb.append(", companyId=");
043 sb.append(companyId);
044 sb.append(", parentOrganizationId=");
045 sb.append(parentOrganizationId);
046 sb.append(", treePath=");
047 sb.append(treePath);
048 sb.append(", name=");
049 sb.append(name);
050 sb.append(", type=");
051 sb.append(type);
052 sb.append(", recursable=");
053 sb.append(recursable);
054 sb.append(", regionId=");
055 sb.append(regionId);
056 sb.append(", countryId=");
057 sb.append(countryId);
058 sb.append(", statusId=");
059 sb.append(statusId);
060 sb.append(", comments=");
061 sb.append(comments);
062 sb.append("}");
063
064 return sb.toString();
065 }
066
067 public Organization toEntityModel() {
068 OrganizationImpl organizationImpl = new OrganizationImpl();
069
070 organizationImpl.setOrganizationId(organizationId);
071 organizationImpl.setCompanyId(companyId);
072 organizationImpl.setParentOrganizationId(parentOrganizationId);
073
074 if (treePath == null) {
075 organizationImpl.setTreePath(StringPool.BLANK);
076 }
077 else {
078 organizationImpl.setTreePath(treePath);
079 }
080
081 if (name == null) {
082 organizationImpl.setName(StringPool.BLANK);
083 }
084 else {
085 organizationImpl.setName(name);
086 }
087
088 if (type == null) {
089 organizationImpl.setType(StringPool.BLANK);
090 }
091 else {
092 organizationImpl.setType(type);
093 }
094
095 organizationImpl.setRecursable(recursable);
096 organizationImpl.setRegionId(regionId);
097 organizationImpl.setCountryId(countryId);
098 organizationImpl.setStatusId(statusId);
099
100 if (comments == null) {
101 organizationImpl.setComments(StringPool.BLANK);
102 }
103 else {
104 organizationImpl.setComments(comments);
105 }
106
107 organizationImpl.resetOriginalValues();
108
109 return organizationImpl;
110 }
111
112 public void readExternal(ObjectInput objectInput) throws IOException {
113 organizationId = objectInput.readLong();
114 companyId = objectInput.readLong();
115 parentOrganizationId = objectInput.readLong();
116 treePath = objectInput.readUTF();
117 name = objectInput.readUTF();
118 type = objectInput.readUTF();
119 recursable = objectInput.readBoolean();
120 regionId = objectInput.readLong();
121 countryId = objectInput.readLong();
122 statusId = objectInput.readInt();
123 comments = objectInput.readUTF();
124 }
125
126 public void writeExternal(ObjectOutput objectOutput)
127 throws IOException {
128 objectOutput.writeLong(organizationId);
129 objectOutput.writeLong(companyId);
130 objectOutput.writeLong(parentOrganizationId);
131
132 if (treePath == null) {
133 objectOutput.writeUTF(StringPool.BLANK);
134 }
135 else {
136 objectOutput.writeUTF(treePath);
137 }
138
139 if (name == null) {
140 objectOutput.writeUTF(StringPool.BLANK);
141 }
142 else {
143 objectOutput.writeUTF(name);
144 }
145
146 if (type == null) {
147 objectOutput.writeUTF(StringPool.BLANK);
148 }
149 else {
150 objectOutput.writeUTF(type);
151 }
152
153 objectOutput.writeBoolean(recursable);
154 objectOutput.writeLong(regionId);
155 objectOutput.writeLong(countryId);
156 objectOutput.writeInt(statusId);
157
158 if (comments == null) {
159 objectOutput.writeUTF(StringPool.BLANK);
160 }
161 else {
162 objectOutput.writeUTF(comments);
163 }
164 }
165
166 public long organizationId;
167 public long companyId;
168 public long parentOrganizationId;
169 public String treePath;
170 public String name;
171 public String type;
172 public boolean recursable;
173 public long regionId;
174 public long countryId;
175 public int statusId;
176 public String comments;
177 }