package art.servers.transactionsserver.test.persistence;
|
|
import art.library.interop.serialization.Serialization;
|
import art.library.model.devices.DevicePersistenceTimeless;
|
import art.library.model.devices.user.User;
|
import art.library.model.devices.user.UserInformation;
|
import art.library.persistence.PersistenceDatabase;
|
import art.library.persistence.PersistenceDatabaseParameters;
|
import art.library.utils.licence.Licence;
|
import java.lang.annotation.Annotation;
|
import java.util.List;
|
import java.util.logging.Level;
|
import java.util.logging.Logger;
|
|
public class PersistanceTestUsers
|
{
|
|
static PersistenceDatabase persistence = null;
|
|
public static void main(String[] args) throws Exception
|
{
|
try
|
{
|
PersistenceDatabaseParameters p = new PersistenceDatabaseParameters();
|
p.type = "postgresql";
|
p.driver = "org.postgresql.Driver";
|
p.connectionString = "jdbc:postgresql://172.16.11.204:5432/ARTIC";
|
p.user = "ARTIC";
|
p.password = "chronos";
|
p.connections = 1;
|
p.pendingFolder = "database/pending/timeless";
|
p.pendingDays = 7;
|
p.pendingTimer = 60;
|
persistence = new PersistenceDatabase(p);
|
|
User user = new User();
|
user.username = Licence.encrypt("root");
|
user.information = new UserInformation();
|
UserInformation information = user.getDeviceInformation();
|
information.password = Licence.encrypt("626d77");
|
information.group = "Administrator";
|
information.name = "";
|
information.surname = "";
|
information.role = "Administrator";
|
information.email = "sat.sistemas@aluvisagrupo.com";
|
information.phone = "937119461";
|
information.company = "ALUVISA";
|
information.jobTitle = "IT Department";
|
information.description = "Information Technology Department";
|
|
String data = Serialization.toPrettyString(user);
|
System.out.println(data);
|
|
persistence.updateOrAddObject(new DevicePersistenceTimeless(user));
|
|
List<User> users = (List<User>) (List<?>) persistence.getObject(DevicePersistenceTimeless.class.getName(), "type = '" + User.class.getName() + "'");
|
|
} catch (Exception e)
|
{
|
Logger.getLogger(PersistanceTestUsers.class.getName()).log(Level.INFO, "", e);
|
}
|
}
|
|
public static Object getAnnotation(Class clase, String annotationName, String attributeName) throws Exception
|
{
|
Annotation[] annotations = clase.getDeclaredAnnotations();
|
|
for (Annotation annotation : annotations)
|
{
|
if (annotation.annotationType().getSimpleName().equals(annotationName))
|
{
|
Object result = annotation.annotationType().getMethod(attributeName).invoke(annotation);
|
return result;
|
}
|
}
|
|
throw new Exception();
|
}
|
|
}
|