|
|
|
|
@ -1,10 +1,14 @@
|
|
|
|
|
package siprp.data;
|
|
|
|
|
|
|
|
|
|
import java.sql.Timestamp;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
|
|
import com.evolute.adt.Pair;
|
|
|
|
|
import com.evolute.entity.evo.EvoDataException;
|
|
|
|
|
import com.evolute.entity.evo.EvoDataObject;
|
|
|
|
|
import com.evolute.utils.strings.UnicodeChecker;
|
|
|
|
|
@ -19,6 +23,8 @@ public abstract class BaseObject extends EvoDataObject
|
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
|
|
|
|
private static final String [] SOFT_DELETE_KEYS = new String[]{ "deleted_stamp", "deleted_date", "inactivo" };
|
|
|
|
|
|
|
|
|
|
public static final DateFormat DATE_FORMAT = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
|
|
|
|
|
|
|
|
|
|
protected static final String isNewMessage = " ";
|
|
|
|
|
@ -39,4 +45,58 @@ public abstract class BaseObject extends EvoDataObject
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Object getSoftDeleteObject( Class<?> returnClass )
|
|
|
|
|
{
|
|
|
|
|
Object result = null;
|
|
|
|
|
if( Timestamp.class.isAssignableFrom( returnClass ) )
|
|
|
|
|
{
|
|
|
|
|
result = new Timestamp( System.currentTimeMillis() );
|
|
|
|
|
}
|
|
|
|
|
else if( Date.class.isAssignableFrom( returnClass ) )
|
|
|
|
|
{
|
|
|
|
|
result = new Date();
|
|
|
|
|
}
|
|
|
|
|
else if( String.class.isAssignableFrom( returnClass ) )
|
|
|
|
|
{
|
|
|
|
|
result = "y";
|
|
|
|
|
}
|
|
|
|
|
else if( Boolean.class.isAssignableFrom( returnClass ) )
|
|
|
|
|
{
|
|
|
|
|
result = true;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Pair<String,Object> getSoftDelete()
|
|
|
|
|
{
|
|
|
|
|
String resultKey = null;
|
|
|
|
|
Object resultObject = null;
|
|
|
|
|
List<String> keys = Arrays.asList( getFieldNames() );
|
|
|
|
|
for( String key : SOFT_DELETE_KEYS )
|
|
|
|
|
{
|
|
|
|
|
if( keys.contains( key ) )
|
|
|
|
|
{
|
|
|
|
|
resultKey = key;
|
|
|
|
|
resultObject = getSoftDeleteObject( getFieldClass( key ) );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return resultKey == null ? null : new Pair<String, Object>(resultKey,resultObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void delete() throws EvoDataException
|
|
|
|
|
{
|
|
|
|
|
Pair<String,Object> softDelete = getSoftDelete();
|
|
|
|
|
if( softDelete != null )
|
|
|
|
|
{
|
|
|
|
|
set( softDelete.getLeft(), softDelete.getRight() );
|
|
|
|
|
save();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
super.delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|