Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions component/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,48 +24,54 @@
<parent>
<groupId>com.celements</groupId>
<artifactId>celements</artifactId>
<version>6.6</version>
<version>7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>celements-structuredDataEditor</artifactId>
<version>6.5-SNAPSHOT</version>
<version>7.0-SNAPSHOT</version>
<description>Celements structured data editor</description>
<dependencies>
<dependency>
<groupId>com.celements</groupId>
<artifactId>celements-model</artifactId>
<version>6.6</version>
<version>7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.celements</groupId>
<artifactId>celements-core</artifactId>
<version>6.14</version>
<version>7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.celements</groupId>
<artifactId>celements-search</artifactId>
<version>6.3</version>
<version>7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.celements</groupId>
<artifactId>celements-tag</artifactId>
<version>6.5</version>
<version>7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.celements</groupId>
<artifactId>celements-scheduler</artifactId>
<version>7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>com.celements</groupId>
<artifactId>celements-layout</artifactId>
<version>6.4</version>
<version>7.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.celements</groupId>
<artifactId>celements-spring-security</artifactId>
<version>6.0</version>
<version>7.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
package com.celements.struct;

import static java.util.stream.Collectors.*;

import java.util.List;
import java.util.Optional;

Expand Down Expand Up @@ -88,7 +86,7 @@ public Optional<TableConfig> loadTableConfig(XWikiDocument cellDoc) {
.map(tableConverter).findFirst();
tableCfg.ifPresent(cfg -> {
List<ColumnConfig> columns = XWikiObjectFetcher.on(cellDoc).filter(columnClass).stream()
.map(columnConverter).collect(toList());
.map(columnConverter).toList();
cfg.setColumns(columns);
});
LOGGER.info("loadTableConfig: for '{}' got '{}'", cellDoc, tableCfg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,14 @@ public Optional<DocumentReference> getSelectedValue(DocumentReference cellDocRef
*/
protected Stream<Supplier<Optional<DocumentReference>>> getValueSuppliers(XWikiDocument cellDoc) {
return Stream.of(
() -> getValueFromRequest(cellDoc),
() -> getValueOnDoc(cellDoc),
() -> getDefaultValue(cellDoc));
}

/**
* @deprecated incorporated in {@link #getValueOnDoc(XWikiDocument)}
*/
@Deprecated(since = "7.0")
protected final Optional<DocumentReference> getValueFromRequest(XWikiDocument cellDoc) {
Optional<DocumentReference> ret = context.getDocument()
.flatMap(onDoc -> structEditService.getAttributeName(cellDoc, onDoc))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
package com.celements.struct.table;

import static com.google.common.base.MoreObjects.*;
import static java.util.Comparator.*;
import static java.util.stream.Collectors.*;

Expand Down Expand Up @@ -89,7 +88,7 @@ public Integer getResultLimit() {
}

public void setResultLimit(Integer resultLimit) {
this.resultLimit = firstNonNull(resultLimit, -1);
this.resultLimit = (resultLimit != null) && (resultLimit > 0) ? resultLimit : -1;
}

public String getCssId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import org.xwiki.model.reference.ClassReference;
import org.xwiki.velocity.XWikiVelocityException;

import com.celements.cells.div.CellRenderStrategy;
import com.celements.cells.AbstractRenderStrategy;
import com.celements.model.access.IModelAccessFacade;
import com.celements.model.classes.ClassDefinition;
import com.celements.model.classes.ClassIdentity;
Expand Down Expand Up @@ -158,16 +158,17 @@ private Optional<Integer> tryDetermineObjNb(XWikiDocument cellDoc, XWikiDocument
*/
private int getCreateObjNb(XWikiDocument cellDoc) {
ClassReference classRef = getCellClassRef(cellDoc).orElseThrow(IllegalStateException::new);
Map<String, Integer> objNbs = getCreateObjNbExecutionCache()
.computeIfAbsent(classRef, ref -> new HashMap<>());
Map<String, Integer> objNbs = getCreateObjNbExecutionCache(classRef);
String keyValueId = fetchKeyValues(cellDoc, Sets.union(LABELS_AND, LABELS_OR))
.mapKeyValue((key, val) -> key + ":" + val.orElse(""))
.joining(",");
return objNbs.computeIfAbsent(keyValueId, key -> -(1 + objNbs.size()));
}

private Map<ClassReference, Map<String, Integer>> getCreateObjNbExecutionCache() {
return exec.getContext().computeIfAbsent("struct_create_obj_nbs", HashMap::new);
private Map<String, Integer> getCreateObjNbExecutionCache(ClassReference classRef) {
Map<ClassReference, Map<String, Integer>> objNbCache = exec.getContext()
.computeIfAbsent("struct_create_obj_nbs", HashMap::new);
return objNbCache.computeIfAbsent(classRef, ref -> new HashMap<>());
}

@Override
Expand Down Expand Up @@ -197,8 +198,7 @@ private Optional<String> getOptionTagValue(XWikiDocument cellDoc) {
@Override
public Optional<String> getDateFormatFromField(XWikiDocument cellDoc) {
Optional<PropertyClass> field = getCellPropertyClass(cellDoc);
if (field.isPresent() && (field.get() instanceof DateClass)) {
DateClass dateField = (DateClass) field.get();
if (field.isPresent() && (field.get() instanceof DateClass dateField)) {
return Optional.ofNullable(dateField.getDateFormat());
}
return Optional.empty();
Expand Down Expand Up @@ -300,11 +300,31 @@ public List<String> getCellListValue(XWikiDocument cellDoc, XWikiDocument onDoc)
.orElseGet(List::of);
return values.stream()
.map(elem -> (elem != null) ? elem.toString() : "")
.collect(toList());
.toList();
}

@Override
public Optional<Object> getCellValue(XWikiDocument cellDoc, XWikiDocument onDoc) {
List<String> requestValues = getValuesFromRequest(cellDoc, onDoc);
if (requestValues.isEmpty()) {
return getCellValueOnDoc(cellDoc, onDoc);
} else if (requestValues.size() == 1) {
return Optional.of(requestValues.get(0));
} else {
return Optional.of(requestValues);
}
}

private List<String> getValuesFromRequest(XWikiDocument cellDoc, XWikiDocument onDoc) {
return getAttributeName(cellDoc, onDoc)
.flatMap(name -> context.request()
.flatMap(r -> Optional.ofNullable(r.getParameterValues(name))))
.map(Stream::of).orElse(Stream.empty())
.filter(Objects::nonNull)
.toList();
}

private Optional<Object> getCellValueOnDoc(XWikiDocument cellDoc, XWikiDocument onDoc) {
Optional<String> fieldName = getCellFieldName(cellDoc);
Object value = null;
if (fieldName.isPresent()) {
Expand Down Expand Up @@ -396,8 +416,8 @@ public static String buildNumberRequestKey(ClassReference classRef,
}

private Optional<Integer> getNumberFromExecutionContext() {
return Stream.of("objNb", CellRenderStrategy.EXEC_CTX_KEY_OBJ_NB,
CellRenderStrategy.EXEC_CTX_KEY_GLOBAL_OBJ_NB)
return Stream.of("objNb", AbstractRenderStrategy.EXEC_CTX_KEY_OBJ_NB,
AbstractRenderStrategy.EXEC_CTX_KEY_GLOBAL_OBJ_NB)
.map(exec.getContext()::getProperty)
.map(Objects::toString)
.map(Ints::tryParse)
Expand Down
17 changes: 13 additions & 4 deletions web-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
<parent>
<groupId>com.celements</groupId>
<artifactId>celementsweb</artifactId>
<version>6.2</version>
<version>7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>structuredDataEditor-web</artifactId>
<packaging>war</packaging>
<name>Celements Structured Data Editor Web-Module</name>
<version>6.9-SNAPSHOT</version>
<version>7.0-SNAPSHOT</version>
<description> </description>
<licenses>
<license>
Expand All @@ -51,15 +51,24 @@
<dependency>
<groupId>com.celements</groupId>
<artifactId>celements-structuredDataEditor</artifactId>
<version>6.5-SNAPSHOT</version>
<version>7.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<finalName>structuredDataEditor-web</finalName>
<plugins>
<plugin>
<groupId>com.jarslab.maven</groupId>
<artifactId>babel-maven-plugin</artifactId>
<artifactId>babel-maven-plugin</artifactId>
<executions>
<execution>
<id>js-transpile</id>
<configuration>
<babelSrc>${project.basedir}/babel-jslib/babel.min.js</babelSrc>
<targetDir>${project.basedir}/target/${project.build.finalName}/resources/</targetDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
input {
box-sizing: border-box;
border: 1px solid #9fb0cd;
border: 1px solid #ccc;
box-shadow: none;
border-radius: 0px;
padding: 0px 3px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ul.struct_object > li.cel-data-removing {
}

.struct_table.border ul.struct_table_data li.struct_table_row {
border-color: #888;
border-color: #ccc;
border-top: 1px solid;
border-right: 1px solid;
border-left: 1px solid;
Expand Down Expand Up @@ -114,7 +114,7 @@ ul.struct_object > li.cel-data-removing {

.struct_table.border ul.struct_table_data .struct_table_cell.edit,
.struct_table.border ul.struct_table_data .struct_table_cell.delete {
border-color: #888;
border-color: #ccc;
border-left: 1px solid;
}

Expand Down Expand Up @@ -220,7 +220,7 @@ ul.struct_object > li.cel-data-removing {
.select2-container .cel_button .view_cel_buttonLink {
float: none;
width: 170px;
border: 1px solid #9fb0cd;
border: 1px solid #ccc;
margin-right: 5px;
margin-bottom: 5px;
padding: 3px;
Expand Down