8000 File store basis by hmlnarik · Pull Request #16001 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,14 @@ public void generate(TypeElement e) throws IOException {
pw.println(" return this.entityFieldDelegate;");
pw.println(" }");

pw.println(" @Override public boolean isUpdated() {");
pw.println(" return entityFieldDelegate.isUpdated();");
pw.println(" }");

pw.println(" @Override public void clearUpdatedFlag() {");
pw.println(" entityFieldDelegate.clearUpdatedFlag();");
pw.println(" }");

getAllAbstractMethods(e)
.forEach(ee -> {
String originalField = m2field.get(ee);
Expand All @@ -540,16 +548,8 @@ public void generate(TypeElement e) throws IOException {
TypeMirror fieldType = determineFieldType(originalField, methodsPerAttribute.get(originalField));
String field = fieldsClassName + "." + toEnumConstant(originalField);

if (ee.getReturnType().getKind() == TypeKind.BOOLEAN && "isUpdated".equals(ee.getSimpleName().toString())) {
pw.println(" return entityFieldDelegate.isUpdated();");
pw.println(" }");
} else if (ee.getReturnType().getKind() == TypeKind.VOID && "clearUpdatedFlag".equals(ee.getSimpleName().toString())) {
pw.println(" return entityFieldDelegate.clearUpdatedFlag();");
pw.println(" }");
} else {
FieldAccessorType fat = FieldAccessorType.determineType(ee, originalField, types, fieldType);
printMethodBody(pw, fat, ee, field, fieldType);
}
FieldAccessorType fat = FieldAccessorType.determineType(ee, originalField, types, fieldType);
printMethodBody(pw, fat, ee, field, fieldType);
});

autogenerated.add(" ENTITY_FIELD_DELEGATE_CREATORS.put(" + className + ".class, (EntityFieldDelegateCreator<" + className + ">) " + mapClassName + "::new);");
Expand Down Expand Up @@ -649,11 +649,7 @@ public void generate(TypeElement e) throws IOException {

getAllAbstractMethods(e)
.forEach(ee -> {
pw.println(" @Override "
+ ee.getModifiers().stream().filter(m -> m != Modifier.ABSTRACT).map(Object::toString).collect(Collectors.joining(" "))
+ " " + ee.getReturnType()
+ " " + ee.getSimpleName()
+ "(" + methodParameters(ee.getParameters()) + ") {");
printMethodHeader(pw, ee);
String field = m2field.get(ee);
field = field == null ? "null" : fieldsClassName + "." + toEnumConstant(field);
if (ee.getReturnType().getKind() == TypeKind.BOOLEAN && "isUpdated".equals(ee.getSimpleName().toString())) {
Expand Down Expand Up @@ -681,6 +677,14 @@ public void generate(TypeElement e) throws IOException {
}
}

protected void printMethodHeader(final PrintWriter pw, ExecutableElement ee) {
pw.println(" @Override "
+ ee.getModifiers().stream().filter(m -> m != Modifier.ABSTRACT).map(Object::toString).collect(Collectors.joining(" "))
+ " " + ee.getReturnType()
+ " " + ee.getSimpleName()
+ "(" + methodParameters(ee.getParameters()) + ") {");
}

private class ClonerGenerator implements Generator {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.keycloak.models.map.annotations.IgnoreForEntityImplementationGenerator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
Expand Down Expand Up @@ -46,7 +47,7 @@
public class Util {

private static final Set<String> LIST_TYPES = Set.of(List.class.getCanonicalName(), ArrayList.class.getCanonicalName(), LinkedList.class.getCanonicalName());
private static final Set<String> SET_TYPES = Set.of(Set.class.getCanonicalName(), TreeSet.class.getCanonicalName(), HashSet.class.getCanonicalName(), LinkedHashSet.class.getCanonicalName());
private static final Set<String> SET_TYPES = Set.of(Set.class.getCanonicalName(), TreeSet.class.getCanonicalName(), HashSet.class.getCanonicalName(), LinkedHashSet.class.getCanonicalName(), Collection.class.getCanonicalName());
Comment thread
hmlnarik marked this conversation as resolved.
Resolved
private static final Set<String> MAP_TYPES = Set.of(Map.class.getCanonicalName(), HashMap.class.getCanonicalName());

public static List<TypeMirror> getGenericsDeclaration(TypeMirror fieldType) {
Expand Down
13 changes: 10 additions & 3 deletions model/map-file/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,22 @@

<artifactId>keycloak-model-map-file</artifactId>
<name>Keycloak Model Map File</name>

<properties>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-model-map</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<groupId>org.snakeyaml</groupId>
<artifactId>snakeyaml-engine</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2023 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.models.map.storage.file;

import org.keycloak.models.map.storage.criteria.DescriptiveModelCriteria;
import org.keycloak.models.map.storage.criteria.ModelCriteriaNode;

/**
*
* @author hmlnarik
*/
public class FileCriteriaBuilder<M> extends DescriptiveModelCriteria<M, FileCriteriaBuilder<M>> {

private static final FileCriteriaBuilder<?> INSTANCE = new FileCriteriaBuilder<>(null);

private FileCriteriaBuilder(ModelCriteriaNode<M> node) {
super(node);
}

@SuppressWarnings("unchecked")
public static <M> FileCriteriaBuilder<M> criteria() {
return (FileCriteriaBuilder<M>) INSTANCE;
}

@Override
protected FileCriteriaBuilder<M> instantiateForNode(ModelCriteriaNode<M> targetNode) {
return new FileCriteriaBuilder<>(targetNode);
}

}

This file was deleted.

Loading
0