Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 26001 implement sync feature for content types #26312

Merged
merged 9 commits into from
Sep 29, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public interface ContentTypeAPI {
)
ResponseEntityView<List<ContentType>> getContentTypes(@QueryParam("filter") String filter,
@QueryParam("page") Integer page,
@QueryParam("perPage") Integer perPage,
@QueryParam("per_page") Integer perPage,
@QueryParam("orderBy") String orderBy,
@QueryParam("direction") String direction,
@QueryParam("type") String type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package com.dotcms.contenttype.model.field;

import com.dotcms.api.provider.ClientObjectMapper;
import com.dotcms.contenttype.model.field.Field.ClassNameAliasResolver;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
Expand All @@ -14,9 +13,11 @@
import com.fasterxml.jackson.databind.jsontype.impl.ClassNameIdResolver;
import com.fasterxml.jackson.databind.type.TypeFactory;
import java.io.IOException;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import javax.annotation.Nullable;
import org.immutables.value.Value;
import org.immutables.value.Value.Default;

@JsonTypeInfo(
Expand Down Expand Up @@ -57,23 +58,35 @@
})
public abstract class Field {

@Nullable
public abstract Boolean searchable();
@Value.Default
public Boolean searchable() {
return false;
}

@Nullable
public abstract Boolean unique();
@Value.Default
public Boolean unique() {
return false;
}

@Nullable
public abstract Boolean indexed();
@Value.Default
public Boolean indexed() {
return false;
}

@Nullable
public abstract Boolean listed();
@Value.Default
public Boolean listed() {
return false;
}

@Nullable
public abstract Boolean readOnly();
@Value.Default
public Boolean readOnly() {
return false;
}

@Nullable
public abstract Boolean forceIncludeInApi();
@Value.Default
public Boolean forceIncludeInApi() {
return false;
}

@Nullable
public abstract String owner();
Expand All @@ -84,6 +97,13 @@ public abstract class Field {
@Nullable
public abstract String inode();

/**
* The modDate attribute is marked as auxiliary to exclude it from the equals, hashCode, and
* toString methods. This ensures that two instances of Field can be considered equal even if
* their modDate values differ. This decision was made because under certain circumstances, the
* modDate value is set using the current date.
*/
@Value.Auxiliary
@Nullable
public abstract Date modDate();

Expand All @@ -97,11 +117,15 @@ public String name() {
@Nullable
public abstract String relationType();

@Nullable
public abstract Boolean required();
@Value.Default
public Boolean required() {
return false;
}

@Nullable
public abstract Integer sortOrder();
@Value.Default
public Integer sortOrder() {
return 0;
}

@Nullable
public abstract String values();
Expand All @@ -115,8 +139,10 @@ public String name() {
@Nullable
public abstract String defaultValue();

@Nullable
public abstract Boolean fixed();
@Value.Default
public Boolean fixed() {
return false;
}

public abstract DataTypes dataType();

Expand All @@ -129,14 +155,25 @@ public String name() {
@Nullable
public abstract String fieldTypeLabel();

@Nullable
public abstract List<FieldVariable> fieldVariables();
@Value.Default
public List<FieldVariable> fieldVariables() {
return Collections.emptyList();
}

/**
* The iDate attribute is marked as auxiliary to exclude it from the equals, hashCode, and
* toString methods. This ensures that two instances of Field can be considered equal even if
* their iDate values differ. This decision was made because under certain circumstances, the
* iDate value is set using the current date.
*/
@Value.Auxiliary
@Nullable
public abstract Date iDate();

@Nullable
public abstract List<ContentTypeFieldProperties> fieldContentTypeProperties();
@Value.Default
public List<ContentTypeFieldProperties> fieldContentTypeProperties() {
return Collections.emptyList();
}

static class ClassNameAliasResolver extends ClassNameIdResolver {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.fasterxml.jackson.databind.jsontype.impl.ClassNameIdResolver;
import com.fasterxml.jackson.databind.type.TypeFactory;
import java.io.IOException;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -76,6 +77,13 @@ public String name() {
@Nullable
public abstract String variable();

/**
* The modDate attribute is marked as auxiliary to exclude it from the equals, hashCode, and
* toString methods. This ensures that two instances of ContentType can be considered equal even
* if their modDate values differ. This decision was made because under certain circumstances,
* the modDate value is set using the current date.
*/
@Value.Auxiliary
@Nullable
public abstract Date modDate();

Expand All @@ -85,9 +93,18 @@ public String name() {
@Nullable
public abstract String expireDateVar();

@Nullable
public abstract Boolean fixed();
@Value.Default
public Boolean fixed() {
return false;
}

/**
* The iDate attribute is marked as auxiliary to exclude it from the equals, hashCode, and
* toString methods. This ensures that two instances of ContentType can be considered equal even
* if their iDate values differ. This decision was made because under certain circumstances, the
* iDate value is set using the current date.
*/
@Value.Auxiliary
@Nullable
public abstract Date iDate();

Expand Down Expand Up @@ -115,14 +132,18 @@ public String name() {
@Nullable
public abstract String description();

@Nullable
public abstract Boolean defaultType();
@Value.Default
public Boolean defaultType() {
return false;
}

@Value.Default
public BaseContentType baseType() { return BaseContentType.CONTENT; };

@Nullable
public abstract Boolean system();
@Value.Default
public Boolean system() {
return false;
}

@Nullable
public abstract String owner();
Expand All @@ -138,8 +159,10 @@ public String name() {
@Nullable
public abstract String urlMapPattern();

@Nullable
public abstract List<Workflow> workflows();
@Value.Default
public List<Workflow> workflows() {
return Collections.emptyList();
}

//System action mappings are rendered quite differently depending on what endpoint gets called
//if it's coming from an endpoint that returns a list of CT we get a simplified version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,44 @@
@JsonDeserialize(as = ImmutableWorkflow.class)
public interface Workflow {

@Nullable
Boolean archived();
@Value.Default
default Boolean archived() {
return false;
}

@Nullable
Date creationDate();

@Nullable
Boolean defaultScheme();
@Value.Default
default Boolean defaultScheme() {
return false;
}

@Nullable
String description();
@Value.Default
default String description() {
return "";
}

@Nullable
String entryActionId();

@Nullable
String id();

@Nullable
Boolean mandatory();
@Value.Default
default Boolean mandatory() {
return false;
}

@Nullable
Date modDate();

@Nullable
String name();

@Nullable
Boolean system();
@Value.Default
default Boolean system() {
return false;
}

}
Loading