Use java.time.LocalDate instead of java.util.Date for Domain#released
parent
176f2e52cc
commit
df9d854b4a
|
|
@ -35,6 +35,8 @@ import org.libreccm.categorization.DomainManager;
|
||||||
import org.libreccm.categorization.DomainRepository;
|
import org.libreccm.categorization.DomainRepository;
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -187,7 +189,8 @@ class DomainForm extends Form {
|
||||||
}
|
}
|
||||||
final String versionData = data.getString(VERSION);
|
final String versionData = data.getString(VERSION);
|
||||||
final java.util.Date releasedData = (java.util.Date) data.get(
|
final java.util.Date releasedData = (java.util.Date) data.get(
|
||||||
RELEASED);
|
RELEASED
|
||||||
|
);
|
||||||
final String rootCategoryNameData = data.getString(
|
final String rootCategoryNameData = data.getString(
|
||||||
ROOT_CATEGORY_NAME);
|
ROOT_CATEGORY_NAME);
|
||||||
|
|
||||||
|
|
@ -207,7 +210,7 @@ class DomainForm extends Form {
|
||||||
domain.setDomainKey(domainKeyData);
|
domain.setDomainKey(domainKeyData);
|
||||||
domain.setUri(domainUriData);
|
domain.setUri(domainUriData);
|
||||||
domain.setVersion(versionData);
|
domain.setVersion(versionData);
|
||||||
domain.setReleased(releasedData);
|
domain.setReleased(LocalDate.from(releasedData.toInstant()));
|
||||||
|
|
||||||
domainRepository.save(domain);
|
domainRepository.save(domain);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,9 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||||
|
|
||||||
import org.libreccm.imexport.Exportable;
|
import org.libreccm.imexport.Exportable;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
@ -196,9 +199,9 @@ public class Domain extends CcmObject implements Serializable, Exportable {
|
||||||
* A timestamp for the release date of the {@code Domain}.
|
* A timestamp for the release date of the {@code Domain}.
|
||||||
*/
|
*/
|
||||||
@Column(name = "RELEASED")
|
@Column(name = "RELEASED")
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
// @Temporal(TemporalType.TIMESTAMP)
|
||||||
@XmlElement(name = "released", namespace = CAT_XML_NS)
|
@XmlElement(name = "released", namespace = CAT_XML_NS)
|
||||||
private Date released;
|
private LocalDate released;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The root category of the domain.
|
* The root category of the domain.
|
||||||
|
|
@ -267,20 +270,12 @@ public class Domain extends CcmObject implements Serializable, Exportable {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getReleased() {
|
public LocalDate getReleased() {
|
||||||
if (released == null) {
|
return released;
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new Date(released.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReleased(final Date released) {
|
public void setReleased(final LocalDate released) {
|
||||||
if (released == null) {
|
this.released = released;
|
||||||
this.released = null;
|
|
||||||
} else {
|
|
||||||
this.released = new Date(released.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Category getRoot() {
|
public Category getRoot() {
|
||||||
|
|
@ -399,18 +394,24 @@ public class Domain extends CcmObject implements Serializable, Exportable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(final String data) {
|
public String toString(final String data) {
|
||||||
|
final String releasedStr;
|
||||||
|
if (released == null) {
|
||||||
|
releasedStr = "";
|
||||||
|
} else {
|
||||||
|
releasedStr = DateTimeFormatter.ISO_DATE.format(released);
|
||||||
|
}
|
||||||
return String.format(
|
return String.format(
|
||||||
", domainKey = \"%s\", "
|
", domainKey = \"%s\", "
|
||||||
+ "uri = \"%s\", "
|
+ "uri = \"%s\", "
|
||||||
+ "title = \"%s\", "
|
+ "title = \"%s\", "
|
||||||
+ "version = \"%s\", "
|
+ "version = \"%s\", "
|
||||||
+ "released = %tF %<tT, "
|
+ "released = %s, "
|
||||||
+ "root = \"%s\"%s",
|
+ "root = \"%s\"%s",
|
||||||
domainKey,
|
domainKey,
|
||||||
Objects.toString(uri),
|
Objects.toString(uri),
|
||||||
Objects.toString(title),
|
Objects.toString(title),
|
||||||
version,
|
version,
|
||||||
released,
|
releasedStr,
|
||||||
Objects.toString(root),
|
Objects.toString(root),
|
||||||
data
|
data
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import org.libreccm.categorization.DomainOwnership;
|
||||||
import org.libreccm.ui.Message;
|
import org.libreccm.ui.Message;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
|
|
@ -74,7 +75,7 @@ public class CategorySystemDetailsModel {
|
||||||
public long getCategorySystemId() {
|
public long getCategorySystemId() {
|
||||||
return categorySystemId;
|
return categorySystemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setCategorySystemId(final long categorySystemId) {
|
protected void setCategorySystemId(final long categorySystemId) {
|
||||||
this.categorySystemId = categorySystemId;
|
this.categorySystemId = categorySystemId;
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +87,7 @@ public class CategorySystemDetailsModel {
|
||||||
public String getUuid() {
|
public String getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUuid(final String uuid) {
|
protected void setUuid(final String uuid) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +95,7 @@ public class CategorySystemDetailsModel {
|
||||||
public String getDomainKey() {
|
public String getDomainKey() {
|
||||||
return domainKey;
|
return domainKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setDomainKey(final String uuid) {
|
protected void setDomainKey(final String uuid) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +103,7 @@ public class CategorySystemDetailsModel {
|
||||||
public String getUri() {
|
public String getUri() {
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUri(final String uri) {
|
protected void setUri(final String uri) {
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
}
|
}
|
||||||
|
|
@ -114,25 +115,20 @@ public class CategorySystemDetailsModel {
|
||||||
protected void setVersion(final String version) {
|
protected void setVersion(final String version) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getReleased() {
|
public String getReleased() {
|
||||||
return released;
|
return released;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setReleased(final String released) {
|
protected void setReleased(final String released) {
|
||||||
this.released = released;
|
this.released = released;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setReleased(final Date released) {
|
protected void setReleased(final LocalDate released) {
|
||||||
if (released == null) {
|
if (released == null) {
|
||||||
this.released = "";
|
this.released = "";
|
||||||
} else {
|
} else {
|
||||||
this.released = DateTimeFormatter.ISO_DATE.format(
|
this.released = DateTimeFormatter.ISO_DATE.format(released);
|
||||||
LocalDateTime.ofInstant(
|
|
||||||
Instant.ofEpochMilli(released.getTime()),
|
|
||||||
ZoneOffset.UTC
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,12 +168,9 @@ public class CategorySystemDetailsModel {
|
||||||
if (domain.getReleased() == null) {
|
if (domain.getReleased() == null) {
|
||||||
released = "";
|
released = "";
|
||||||
} else {
|
} else {
|
||||||
released = DateTimeFormatter.ISO_DATE_TIME.format(
|
released = DateTimeFormatter.ISO_DATE_TIME
|
||||||
LocalDateTime.ofInstant(
|
.withZone(ZoneOffset.systemDefault())
|
||||||
Instant.ofEpochMilli(domain.getReleased().getTime()),
|
.format(domain.getReleased());
|
||||||
ZoneOffset.UTC
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
title = domain
|
title = domain
|
||||||
.getTitle()
|
.getTitle()
|
||||||
|
|
|
||||||
|
|
@ -31,18 +31,10 @@ import org.libreccm.ui.Message;
|
||||||
import org.libreccm.ui.MessageType;
|
import org.libreccm.ui.MessageType;
|
||||||
import org.libreccm.ui.admin.AdminMessages;
|
import org.libreccm.ui.admin.AdminMessages;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.TemporalAccessor;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
|
@ -99,7 +91,7 @@ public class CategorySystemFormController {
|
||||||
|
|
||||||
final Domain domain = domainManager.createDomain(domainKey, domainKey);
|
final Domain domain = domainManager.createDomain(domainKey, domainKey);
|
||||||
|
|
||||||
if (!isValidUri(uri)) {
|
if (!isValidUri()) {
|
||||||
categorySystemDetailsModel.setDomainKey(domainKey);
|
categorySystemDetailsModel.setDomainKey(domainKey);
|
||||||
categorySystemDetailsModel.setUri(uri);
|
categorySystemDetailsModel.setUri(uri);
|
||||||
categorySystemDetailsModel.setVersion(version);
|
categorySystemDetailsModel.setVersion(version);
|
||||||
|
|
@ -154,7 +146,7 @@ public class CategorySystemFormController {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.isPresent()) {
|
if (result.isPresent()) {
|
||||||
if (!isValidUri(uri)) {
|
if (!isValidUri()) {
|
||||||
categorySystemDetailsModel.setDomainKey(domainKey);
|
categorySystemDetailsModel.setDomainKey(domainKey);
|
||||||
categorySystemDetailsModel.setUri(uri);
|
categorySystemDetailsModel.setUri(uri);
|
||||||
categorySystemDetailsModel.setVersion(version);
|
categorySystemDetailsModel.setVersion(version);
|
||||||
|
|
@ -166,6 +158,7 @@ public class CategorySystemFormController {
|
||||||
"categorysystems.form.errors.uri_invalid"),
|
"categorysystems.form.errors.uri_invalid"),
|
||||||
MessageType.PRIMARY)
|
MessageType.PRIMARY)
|
||||||
);
|
);
|
||||||
|
return "org/libreccm/ui/admin/categories/categorysystem-form.xhtml";
|
||||||
}
|
}
|
||||||
final Domain domain = result.get();
|
final Domain domain = result.get();
|
||||||
domain.setDomainKey(domainKey);
|
domain.setDomainKey(domainKey);
|
||||||
|
|
@ -196,16 +189,14 @@ public class CategorySystemFormController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Date convertReleased() {
|
private LocalDate convertReleased() {
|
||||||
final String param = String.format("%sT00:00:00", released);
|
return LocalDate.parse(
|
||||||
return Date.from(
|
released,
|
||||||
LocalDateTime
|
DateTimeFormatter.ISO_DATE.withZone(ZoneOffset.systemDefault())
|
||||||
.parse(param, DateTimeFormatter.ISO_DATE_TIME)
|
|
||||||
.toInstant(ZoneOffset.UTC)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValidUri(final String uriStr) {
|
private boolean isValidUri() {
|
||||||
final UrlValidator urlValidator = new UrlValidator();
|
final UrlValidator urlValidator = new UrlValidator();
|
||||||
return urlValidator.isValid(uri);
|
return urlValidator.isValid(uri);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public class CategorySystemsTableModel {
|
||||||
if (domain.getReleased() != null) {
|
if (domain.getReleased() != null) {
|
||||||
row.setReleased(
|
row.setReleased(
|
||||||
DateTimeFormatter.ISO_DATE_TIME.format(
|
DateTimeFormatter.ISO_DATE_TIME.format(
|
||||||
domain.getReleased().toInstant()
|
domain.getReleased()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@
|
||||||
|
|
||||||
create table CCM_CORE.CATEGORY_DOMAINS (
|
create table CCM_CORE.CATEGORY_DOMAINS (
|
||||||
DOMAIN_KEY varchar(255) not null,
|
DOMAIN_KEY varchar(255) not null,
|
||||||
RELEASED timestamp,
|
RELEASED date,
|
||||||
URI varchar(1024),
|
URI varchar(1024),
|
||||||
VERSION varchar(255),
|
VERSION varchar(255),
|
||||||
OBJECT_ID bigint not null,
|
OBJECT_ID bigint not null,
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
|
|
||||||
create table CCM_CORE.CATEGORY_DOMAINS (
|
create table CCM_CORE.CATEGORY_DOMAINS (
|
||||||
DOMAIN_KEY varchar(255) not null,
|
DOMAIN_KEY varchar(255) not null,
|
||||||
RELEASED timestamp,
|
RELEASED date,
|
||||||
URI varchar(1024),
|
URI varchar(1024),
|
||||||
VERSION varchar(255),
|
VERSION varchar(255),
|
||||||
OBJECT_ID int8 not null,
|
OBJECT_ID int8 not null,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue