![JAR search and dependency download from the Maven repository](/logo.png)
com.gs.fw.common.mithra.util.serializer.ReladomoSerializationContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of reladomo Show documentation
Show all versions of reladomo Show documentation
Reladomo is an object-relational mapping framework.
/*
Copyright 2016 Goldman Sachs.
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 com.gs.fw.common.mithra.util.serializer;
import com.gs.fw.common.mithra.MithraList;
import com.gs.fw.common.mithra.MithraObject;
import com.gs.fw.common.mithra.MithraTransactionalObject;
import com.gs.fw.common.mithra.attribute.*;
import com.gs.fw.common.mithra.finder.AbstractRelatedFinder;
import com.gs.fw.common.mithra.util.Time;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
public class ReladomoSerializationContext
{
public static final String RELADOMO_PREFIX = "_rdo";
public static final String RELADOMO_META_DATA = RELADOMO_PREFIX + "MetaData";
public static final String RELADOMO_CLASS_NAME = RELADOMO_PREFIX + "ClassName";
public static final String RELADOMO_STATE = RELADOMO_PREFIX + "State";
public static final String RELADOMO_LIST_SIZE = RELADOMO_PREFIX + "ListSize";
public static final byte READ_ONLY_STATE = 10;
public static final byte DETACHED_STATE = 20;
public static final byte IN_MEMORY_STATE = 30;
public static final byte DELETED_OR_TERMINATED_STATE = 40;
protected final SerializationConfig serializationConfig;
protected final SerialWriter writer;
protected Object currentObjectBeingSerialized;
protected SerializationNode currentNode;
public ReladomoSerializationContext(SerializationConfig serializationConfig, SerialWriter writer)
{
this.serializationConfig = serializationConfig;
this.currentNode = this.serializationConfig.getRootNode();
this.writer = writer;
}
public void serializeReladomoObject(MithraObject reladomoObject)
{
try
{
writer.startReladomoObject(reladomoObject, this);
Object previousObject = this.currentObjectBeingSerialized;
this.currentObjectBeingSerialized = reladomoObject;
if (this.serializationConfig.serializeMetaData())
{
writer.startMetadata(reladomoObject, this);
serializeClassMetadata(reladomoObject);
writer.writeMetadataEnd(reladomoObject, this);
}
writer.startAttributes(this, this.currentNode.getAttributes().size());
serializeAttributes(reladomoObject);
writer.endAttributes(this);
writer.startRelationships(this, this.currentNode.getChildren().size());
serializeRelationships(reladomoObject);
writer.endRelationships(this);
writer.startLinks(this, this.currentNode.getLinks().size());
serializeLinks(reladomoObject);
writer.endLinks(this);
List annotatedMethods = getAnnotatedMethods(reladomoObject);
writer.startAnnotatedMethod(reladomoObject, this, annotatedMethods.size());
serializeAnnotatedMethods(reladomoObject, annotatedMethods);
writer.endAnnotatedMethod(reladomoObject, this);
writer.endReladomoObject(reladomoObject, this);
this.currentObjectBeingSerialized = previousObject;
}
catch (Exception e)
{
throw new RuntimeException("Could not serialize object", e);
}
}
protected List getAnnotatedMethods(Object reladomoObject)
{
return this.serializationConfig.getAnnotatedMethods(reladomoObject.getClass());
}
protected void serializeLinks(MithraObject reladomoObject) throws Exception
{
List links = this.currentNode.getLinks();
for(int i=0;i annotatedMethods) throws Exception
{
for(int i=0;i annotatedMethods) throws Exception
{
for(int i=0;i 4 && Character.isUpperCase(name.charAt(3)))
{
return Character.toLowerCase(name.charAt(3))+name.substring(4);
}
return name;
}
protected void serializeRelationships(MithraObject reladomoObject) throws Exception
{
SerializationNode pushedNode = this.currentNode;
List children = this.currentNode.getChildren();
for(int i=0;i attributes = this.currentNode.getAttributes();
for(int i=0;i annotatedMethods = getAnnotatedMethods(reladomoList);
writer.startListAnnotatedMethods(reladomoList, this, annotatedMethods.size());
serializeAnnotatedListMethods(reladomoList, annotatedMethods);
writer.endListAnnotatedMethods(reladomoList, this);
writer.startReladomoListElements(reladomoList, this);
for(int i=0;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy