diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/PersonModel.java b/ccm-cms/src/main/java/org/librecms/pages/models/PersonModel.java new file mode 100644 index 000000000..1febf8237 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/pages/models/PersonModel.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2021 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.pages.models; + +import org.librecms.assets.Person; + +/** + * + * @author Jens Pelzetter + */ +public class PersonModel extends ContactableEntityModel { + + private String surname; + + private String givenName; + + private String prefix; + + private String suffix; + + private String birthdate; + + @Override + public String getType() { + return Person.class.getName(); + } + + public String getSurname() { + return surname; + } + + public void setSurname(final String surname) { + this.surname = surname; + } + + public String getGivenName() { + return givenName; + } + + public void setGivenName(final String givenName) { + this.givenName = givenName; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(final String prefix) { + this.prefix = prefix; + } + + public String getSuffix() { + return suffix; + } + + public void setSuffix(final String suffix) { + this.suffix = suffix; + } + + public String getBirthdate() { + return birthdate; + } + + public void setBirthdate(final String birthdate) { + this.birthdate = birthdate; + } + + + +} diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/PersonModelBuilder.java b/ccm-cms/src/main/java/org/librecms/pages/models/PersonModelBuilder.java new file mode 100644 index 000000000..1161de626 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/pages/models/PersonModelBuilder.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2021 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.pages.models; + +import org.librecms.assets.Person; + +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; + +/** + * + * @author Jens Pelzetter + */ +public class PersonModelBuilder + extends AbstractContactableEntityModelBuilder { + + @Override + public Class buildsAssetModelFor() { + return Person.class; + } + + @Override + protected PersonModel buildModel() { + return new PersonModel(); + } + + @Override + protected void addProperties(final Person person, final PersonModel model) { + super.addProperties(person, model); + model.setBirthdate( + DateTimeFormatter.ISO_DATE + .withZone(ZoneId.systemDefault()) + .format(person.getBirthdate()) + ); + model.setGivenName(person.getPersonName().getGivenName()); + model.setPrefix(person.getPersonName().getPrefix()); + model.setSuffix(person.getPersonName().getSuffix()); + model.setSurname(person.getPersonName().getSurname()); + } + +}