com.backendless.transaction.UnitOfWorkCreateImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-sdk-common Show documentation
Show all versions of java-sdk-common Show documentation
Provides access to Backendless API
The newest version!
package com.backendless.transaction;
import com.backendless.exceptions.ExceptionMessage;
import com.backendless.persistence.BackendlessSerializer;
import java.util.List;
import java.util.Map;
class UnitOfWorkCreateImpl implements UnitOfWorkCreate
{
private final List operations;
private final OpResultIdGenerator opResultIdGenerator;
private final Map clazzes;
UnitOfWorkCreateImpl( List operations, OpResultIdGenerator opResultIdGenerator,
Map clazzes )
{
this.operations = operations;
this.opResultIdGenerator = opResultIdGenerator;
this.clazzes = clazzes;
}
@Override
public OpResult create( E instance )
{
Map entityMap = SerializationHelper.serializeEntityToMap( instance );
String tableName = BackendlessSerializer.getSimpleName( instance.getClass() );
clazzes.put( tableName, instance.getClass() );
return create( tableName, entityMap );
}
@Override
public OpResult create( String tableName, Map objectMap )
{
if( objectMap == null )
throw new IllegalArgumentException( ExceptionMessage.NULL_MAP );
TransactionHelper.makeReferenceToValueFromOpResult( objectMap );
String operationResultId = opResultIdGenerator.generateOpResultId( OperationType.CREATE, tableName );
OperationCreate operationCreate = new OperationCreate( OperationType.CREATE, tableName, operationResultId, objectMap );
operations.add( operationCreate );
return TransactionHelper.makeOpResult( tableName, operationResultId, OperationType.CREATE );
}
@Override
public OpResult bulkCreate( List instances )
{
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy