-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release 1.0.0.1 (Start)
- Loading branch information
Showing
80 changed files
with
14,373 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>ImprimePonto</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
eclipse.preferences.version=1 | ||
encoding//src/main/java=UTF-8 | ||
encoding//src/main/resources=UTF-8 | ||
encoding//src/test/java=UTF-8 | ||
encoding//src/test/resources=UTF-8 | ||
encoding/<project>=UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.source=1.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=1 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="ASCII"?> | ||
<anttasks:AntTask xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:anttasks="http://org.eclipse.fx.ide.jdt/1.0" buildDirectory="${project}/build"> | ||
<deploy> | ||
<application name="ImprimePonto"/> | ||
<info/> | ||
</deploy> | ||
<signjar/> | ||
</anttasks:AntTask> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>br.com.hoyler.apps.imprimeponto</groupId> | ||
<artifactId>ImprimePonto</artifactId> | ||
<version>0.0.0.1-SNAPSHOT</version> | ||
<name>Projeto Imprime Ponto</name> | ||
<url>http://www.hoyler.com.br</url> | ||
<description>Projeto Imprime Folha de Ponto para Funcionarios</description> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.7.0</version> | ||
<configuration> | ||
<release>8</release> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<!-- Driver SQLite --> | ||
<dependency> | ||
<groupId>org.xerial</groupId> | ||
<artifactId>sqlite-jdbc</artifactId> | ||
<version>3.23.1</version> | ||
</dependency> | ||
|
||
<!-- https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports --> | ||
<dependency> | ||
<groupId>net.sf.jasperreports</groupId> | ||
<artifactId>jasperreports</artifactId> | ||
<version>6.6.0</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>com.ibm.icu</groupId> | ||
<artifactId>icu4j</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-annotations</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>stax</groupId> | ||
<artifactId>stax-api</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>stax</groupId> | ||
<artifactId>stax</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>javax.xml.stream</groupId> | ||
<artifactId>stax-api</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.codehaus.castor</groupId> | ||
<artifactId>castor-xml</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.jfree</groupId> | ||
<artifactId>jfreechart</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.jfree</groupId> | ||
<artifactId>jcommon</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.bouncycastle</groupId> | ||
<artifactId>bcprov-jdk15on</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
</project> |
221 changes: 221 additions & 0 deletions
221
ProjetoAplicacao/src/main/java/br/com/hoyler/apps/database/sqlite/Database.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
package br.com.hoyler.apps.database.sqlite; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.PreparedStatement; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
|
||
import org.sqlite.SQLiteConfig; | ||
|
||
import br.com.hoyler.apps.tools.CheckFile; | ||
import br.com.hoyler.apps.tools.ProgramDirectoryUtilities; | ||
|
||
public class Database { | ||
|
||
private Connection connection = null; | ||
private PreparedStatement preparedStatement = null; | ||
|
||
private final String BANCO_DE_DADOS = ("ImprimeFolha.s3db"); | ||
|
||
public final String TABELA_FUNCOES = ("Funcoes"); | ||
public final String TABELA_EMPRESAS = ("Empresas"); | ||
public final String TABELA_PESSOAS = ("Pessoas"); | ||
|
||
public final String CAMPO_CODIGO = "CODIGO"; | ||
public final String CAMPO_NOME = "NOME"; | ||
public final String CAMPO_CNPJ = "CNPJ"; | ||
public final String CAMPO_CTPS = "CTPS"; | ||
public final String CAMPO_ENDERECO = "ENDERECO"; | ||
public final String CAMPO_ADMISSAO = "ADMISSAO"; | ||
public final String CAMPO_FUNCAO_CODIGO = "FUNCAO_CODIGO"; | ||
public final String CAMPO_EMPRESA_CODIGO = "EMPRESA_CODIGO"; | ||
|
||
// public final String PATCH_FILE = String.format("%s\\%s", | ||
// "ImprimeFolha\\Database",BANCO_DE_DADOS); | ||
public final String PATCH_FILE = String.format("%s\\ImprimePonto\\Database\\%s", | ||
ProgramDirectoryUtilities.getProgramDirectory(), BANCO_DE_DADOS); | ||
|
||
public Connection getConnection() { | ||
return connection; | ||
} | ||
|
||
public void setConnection(Connection connection) { | ||
this.connection = connection; | ||
} | ||
|
||
public PreparedStatement getPreparedStatement() { | ||
return preparedStatement; | ||
} | ||
|
||
public void setPreparedStatement(PreparedStatement preparedStatement) { | ||
this.preparedStatement = preparedStatement; | ||
} | ||
|
||
public void CriarConexaoDB() { | ||
|
||
Boolean BANCO_EXISTE = (new CheckFile().FileExists(PATCH_FILE)); | ||
|
||
if (BANCO_EXISTE) { | ||
|
||
String DatabaseURL = String.format("%s%s", "jdbc:sqlite:", PATCH_FILE); | ||
|
||
String DB_URL = DatabaseURL; | ||
|
||
String DRIVER = "org.sqlite.JDBC"; | ||
|
||
try { | ||
|
||
Class.forName(DRIVER); | ||
|
||
SQLiteConfig config = new SQLiteConfig(); | ||
config.setBusyTimeout("15000"); | ||
config.enforceForeignKeys(true); | ||
|
||
connection = DriverManager.getConnection(DB_URL, config.toProperties()); | ||
|
||
} catch (ClassNotFoundException e) { | ||
|
||
System.out.println( | ||
String.format("public class br.com.hoyler.apps.database.sqlite CriarConexaoDB DRIVER: [%s] [CATCH ERRO]", DRIVER)); | ||
|
||
// e.printStackTrace(); | ||
|
||
} catch (SQLException e) { | ||
|
||
System.out.println( | ||
String.format("public class br.com.hoyler.apps.database.sqlite CriarConexaoDB DB_URL: [%s] [CATCH ERRO]", DB_URL)); | ||
|
||
// e.printStackTrace(); | ||
|
||
} | ||
|
||
} else | ||
|
||
{ | ||
System.out | ||
.println(String.format("public class br.com.hoyler.apps.database.sqlite CriarConexaoDB BANCO_EXISTE: [%s] [ELSE ERRO]", | ||
BANCO_EXISTE.toString())); | ||
|
||
} | ||
|
||
} | ||
|
||
public void ConexaoDBClose() throws SQLException { | ||
|
||
if (connection.isClosed()) { | ||
|
||
connection = null; | ||
preparedStatement = null; | ||
System.out.println("ConexaoDBClose NULL [OK]\n"); | ||
} else { | ||
connection.close(); | ||
preparedStatement.close(); | ||
ConexaoDBClose(); | ||
System.out.println("ConexaoDBClose IS CLOSE [OK]\n"); | ||
} | ||
} | ||
|
||
public Boolean DeletarCodigos(String tablela, String campo, int codigo) { | ||
|
||
Boolean retornoBool = false; | ||
|
||
int LinhasAfetadas = -9999; | ||
|
||
Boolean bancoExiste = (new CheckFile().FileExists(PATCH_FILE)); | ||
|
||
if (bancoExiste) { | ||
String DeletarFuncoesCodigoSQL = String.format("DELETE FROM [%s] WHERE %s = (?);", tablela, campo); | ||
try { | ||
|
||
this.CriarConexaoDB(); | ||
|
||
preparedStatement = connection.prepareStatement(DeletarFuncoesCodigoSQL); | ||
preparedStatement.setInt(1, codigo); | ||
|
||
LinhasAfetadas = preparedStatement.executeUpdate(); | ||
|
||
System.out.println(String.format( | ||
"public class br.com.hoyler.apps.database.sqlite DeletarCodigos TABELA: [%s] - CAMPO: [%s] - VALOR: [%s] DELETADO: [%s] [OK]", | ||
tablela, campo, Integer.toString(codigo), LinhasAfetadas)); | ||
|
||
retornoBool = true; | ||
|
||
} catch (SQLException ex) { | ||
|
||
System.out.println(String.format( | ||
"public class br.com.hoyler.apps.database.sqlite DeletarCodigos TABELA: [%s] - CAMPO: [%s] - VALOR: [%s] DELETADO: [%s] [TRY ERRO]\n%s", | ||
tablela, campo, Integer.toString(codigo), LinhasAfetadas, ex.getMessage())); | ||
} | ||
|
||
} else { | ||
|
||
System.out.println(String.format( | ||
"public class br.com.hoyler.apps.database.sqlite DeletarCodigos TABELA: [%s] - CAMPO: [%s] - VALOR: [%s] DELETADO: [%s] [ELSE ERRO]", | ||
tablela, campo, Integer.toString(codigo), LinhasAfetadas)); | ||
} | ||
|
||
return retornoBool; | ||
} | ||
|
||
public Boolean DeletarNomes(String tablela, String campo, String nome) { | ||
|
||
Boolean retornoBool = false; | ||
|
||
int LinhasAfetadas = -9999; | ||
|
||
Boolean bancoExiste = (new CheckFile().FileExists(PATCH_FILE)); | ||
|
||
if (bancoExiste) { | ||
|
||
String DeletarFuncoesCodigoSQL = String.format("DELETE FROM [%s] WHERE %s = (?);", tablela, campo); | ||
try { | ||
|
||
this.CriarConexaoDB(); | ||
|
||
preparedStatement = connection.prepareStatement(DeletarFuncoesCodigoSQL); | ||
preparedStatement.setString(1, nome); | ||
|
||
LinhasAfetadas = preparedStatement.executeUpdate(); | ||
|
||
System.out.println(String.format( | ||
"public class br.com.hoyler.apps.database.sqlite DeletarNomes TABELA: [%s] - CAMPO: [%s] - VALOR: [%s] DELETADO: [%s] [OK]", | ||
tablela, campo, nome, LinhasAfetadas)); | ||
|
||
retornoBool = true; | ||
|
||
} catch (SQLException ex) { | ||
System.out.println(String.format( | ||
"public class br.com.hoyler.apps.database.sqlite DeletarNomes TABELA: [%s] - CAMPO: [%s] - VALOR: [%s] [TRY ERRO]\n%s", | ||
tablela, campo, nome)); | ||
} | ||
|
||
} else { | ||
System.out.println(String.format( | ||
"public class br.com.hoyler.apps.database.sqlite DeletarNomes TABELA: [%s] - CAMPO: [%s] - VALOR: [%s] DELETADO: [%s] [ELSE ERRO]", | ||
tablela, campo, nome, LinhasAfetadas)); | ||
} | ||
|
||
return retornoBool; | ||
} | ||
|
||
public ResultSet ExecutarSQL(String scriptSQL) { | ||
|
||
ResultSet returnResultSet = null; | ||
|
||
this.CriarConexaoDB(); | ||
|
||
try { | ||
|
||
preparedStatement = connection.prepareStatement(scriptSQL); | ||
|
||
returnResultSet = preparedStatement.executeQuery(); | ||
|
||
} catch (SQLException e) { | ||
|
||
System.out.println(String.format("public class br.com.hoyler.apps.database.sqlite ExecutarSQL SQL: [%s] [TRY ERRO]", scriptSQL)); | ||
} | ||
|
||
return (returnResultSet); | ||
} | ||
} |
Oops, something went wrong.