[DEV] remove scenarium

This commit is contained in:
Edouard DUPIN 2022-10-04 00:30:01 +02:00
parent 32eb062784
commit d3d4c0818f
8 changed files with 6 additions and 1355 deletions

View File

@ -12,6 +12,6 @@ open module org.atriasoft.aknot {
exports org.atriasoft.aknot.exception;
requires transitive org.atriasoft.etk;
requires transitive io.scenarium.logger;
requires transitive org.atriasoft.reggol;
requires java.base;
}

View File

@ -5,8 +5,8 @@
*/
package org.atriasoft.aknot.internal;
import io.scenarium.logger.LogLevel;
import io.scenarium.logger.Logger;
import org.atriasoft.reggol.LogLevel;
import org.atriasoft.reggol.Logger;
public class Log {
private static final boolean FORCE_ALL = false;

View File

@ -7,6 +7,7 @@ import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.pojo.IntrospectionProperty;
public abstract class IntrospectionModel {
public static final String STUPID_TOCKEN = "___aé\"'__-è==**ù!^$:;,;AZEARTYUIOPMLKJHGFDSQW>XCVBN?"; // can not exist ....
protected static final Boolean DEFAULT_ATTRIBUTE = false;
protected static final Boolean DEFAULT_IGNORE_UNBKNOWN = false;
protected static final Boolean DEFAULT_DEFAULT_NULL_VALUE = false;

View File

@ -28,7 +28,7 @@ public class IntrospectionModelArray extends IntrospectionModel {
public Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes) throws AknotException {
List<Object> tmp = null;
if (this.nodeName == null) {
tmp = nodes.get(IntrospectionObject.STUPID_TOCKEN);
tmp = nodes.get(STUPID_TOCKEN);
} else {
tmp = nodes.get(this.nodeName);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +0,0 @@
package org.atriasoft.aknot.pojo;
import org.atriasoft.aknot.StringSerializer;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.model.IntrospectionModel;
import org.atriasoft.aknot.model.MapKey;
public class IntrospectionModelFactory {
public static IntrospectionModel createModel(final MapKey modelType) throws AknotException {
if (StringSerializer.contains(modelType.type())) {
return new IntrospectionModelBaseType(modelType.type());
}
return new IntrospectionModelComplex(modelType.type());
}
public static IntrospectionModel createModelArray(final String nodeName, final MapKey modelType) throws AknotException {
return new IntrospectionModelArray(nodeName, modelType.type());
}
public static IntrospectionModel createModelEnum(final MapKey modelType) throws AknotException {
return new IntrospectionModelComplex(modelType.type());
}
public static IntrospectionModel createModelList(final String nodeName, final MapKey modelType) throws AknotException {
return new IntrospectionModelList(nodeName, modelType.type());
}
private IntrospectionModelFactory() {}
}

View File

@ -19,7 +19,7 @@ public class IntrospectionModelList extends IntrospectionModel {
@Override
public Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes) throws AknotException {
if (this.nodeName == null) {
return nodes.get(IntrospectionObject.STUPID_TOCKEN);
return nodes.get(STUPID_TOCKEN);
}
return nodes.get(this.nodeName);
}

View File

@ -1,167 +0,0 @@
package org.atriasoft.aknot.pojo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.internal.Log;
import org.atriasoft.aknot.model.IntrospectionModel;
public class IntrospectionObject {
public static final String PUBLIC_TEXT_NAME = "##<< ** TEXT-ZONE ** >>##";
public static final String STUPID_TOCKEN = "___aé\"'__-è==**ù!^$:;,;AZEARTYUIOPMLKJHGFDSQW>XCVBN?"; // can not exist ....
private final IntrospectionModel modelInterface;
private Object data = null;
private final Map<String, Object> properties = new HashMap<>();
private final Map<String, List<Object>> nodes = new HashMap<>();
public IntrospectionObject(final IntrospectionModel dataInterface) {
this.modelInterface = dataInterface;
}
@SuppressWarnings("unchecked")
public void addObject(final String nodeName, final Object value) throws AknotException {
if (value == null) {
// specific case when a List is empty <links></links> but define for a specific list ==> need no action
return;
}
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
throw new AknotException("The node '" + nodeName + "' Does not exist...");
}
List<Object> node = this.nodes.get(beanName);
if (node == null) {
if (List.class.isAssignableFrom(value.getClass())) {
node = (List<Object>) value;
} else if (value.getClass().isArray()) {
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
} else {
node = new ArrayList<>();
node.add(value);
}
this.nodes.put(beanName, node);
} else if (value.getClass().isArray()) {
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
Log.error("this is a big problem ...");
} else if (List.class.isAssignableFrom(value.getClass())) {
final List<Object> nodeIn = (List<Object>) value;
node.addAll(nodeIn);
} else {
node.add(value);
}
}
public void generateTheObject() throws AknotException {
if (this.data != null) {
// nothing to do ... ==> element already created
return;
}
Log.warning("Create the element for the Specific node ... type = " + this.modelInterface.getClassType().getCanonicalName() + (this.modelInterface.isArray() ? "[array]" : "")
+ (this.modelInterface.isList() ? "[List]" : ""));
Log.warning(" Properties : " + this.properties.keySet());
Log.warning(" Nodes : " + this.nodes.keySet());
this.data = this.modelInterface.createObject(this.properties, this.nodes);
}
public Object getData() {
return this.data;
}
public IntrospectionModel getModelIntrospection() {
return this.modelInterface;
}
public String getTreeNameOfSubNode(final String nodeName) throws AknotException {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
throw new AknotException("The node '" + nodeName + "' Does not exist...");
}
return this.modelInterface.getTreeNameOfSubNode(beanName);
}
public Class<?> getTypeOfProperty(final String nodeName) throws AknotException {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
throw new AknotException("The node '" + nodeName + "' Does not exist...");
}
return this.modelInterface.getTypeOfProperty(beanName);
}
/**
* Detect a subNode, and ask the type of the node at the parent Class
* @param nodeName Name of the node
* @return Class of the node to create
*/
public Class<?> getTypeOfSubNode(final String nodeName) throws AknotException {
final String beanName = this.modelInterface.getBeanNameModel(nodeName);
if (beanName == null) {
throw new AknotException("The node '" + nodeName + "' Does not exist...");
}
return this.modelInterface.getTypeOfSubNode(beanName);
}
public Class<?> getTypeOfSubNodeSubType(final String nodeName) throws AknotException {
final String beanName = this.modelInterface.getBeanNameModel(nodeName);
if (beanName == null) {
throw new AknotException("The node '" + nodeName + "' Does not exist...");
}
return this.modelInterface.getTypeOfSubNodeList(beanName);
}
public Class<?> getTypeOfSubProperty(final String nodeName) throws AknotException {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
throw new AknotException("The node '" + nodeName + "' Does not exist...");
}
return this.modelInterface.getTypeOfSubProperty(beanName);
}
public boolean isSubNodeOrPropertyExist(final String nodeName) {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
return false;
}
return true;
}
public void putProperty(final String propertyName, final Object propertyValue) throws AknotException {
String beanName = null;
if (propertyName == PUBLIC_TEXT_NAME) {
beanName = this.modelInterface.getTextBeanName();
} else {
beanName = this.modelInterface.getBeanName(propertyName);
}
if (this.properties.containsKey(beanName)) {
throw new AknotException("Property have multiple values ==> impossible case; A Node must contain only 1 attibutes");
}
this.properties.put(beanName, propertyValue);
}
public void setText(final String text) throws AknotException {
if (this.data != null) {
throw new AknotException("Can not set multiple text value in a single NODE ...");
}
this.data = this.modelInterface.getValueFromText(text);
}
}