[EDIT] Cambios

parent 3524a041
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for --> <!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. --> <!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) --> <!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. --> <!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if --> <!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. --> <!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting --> <!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.--> <!-- in the project's Project Properties dialog box.-->
<project name="demojsoncrud" default="default" basedir="."> <project name="demojsoncrud" default="default" basedir=".">
<description>Builds, tests, and runs the project demojsoncrud.</description> <description>Builds, tests, and runs the project demojsoncrud.</description>
<import file="nbproject/build-impl.xml"/> <import file="nbproject/build-impl.xml"/>
<!-- <!--
There exist several targets which are by default empty and which can be There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed used for execution of your tasks. These targets are usually executed
before and after some main targets. They are: before and after some main targets. They are:
-pre-init: called before initialization of project properties -pre-init: called before initialization of project properties
-post-init: called after initialization of project properties -post-init: called after initialization of project properties
-pre-compile: called before javac compilation -pre-compile: called before javac compilation
-post-compile: called after javac compilation -post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file -pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file -post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests -pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests -post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test -pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test -post-compile-test-single: called after javac compilation of single JUunit test
-pre-dist: called before archive building -pre-dist: called before archive building
-post-dist: called after archive building -post-dist: called after archive building
-post-clean: called after cleaning build products -post-clean: called after cleaning build products
-pre-run-deploy: called before deploying -pre-run-deploy: called before deploying
-post-run-deploy: called after deploying -post-run-deploy: called after deploying
Example of pluging an obfuscator after the compilation could look like Example of pluging an obfuscator after the compilation could look like
<target name="-post-compile"> <target name="-post-compile">
<obfuscate> <obfuscate>
<fileset dir="${build.classes.dir}"/> <fileset dir="${build.classes.dir}"/>
</obfuscate> </obfuscate>
</target> </target>
For list of available properties check the imported For list of available properties check the imported
nbproject/build-impl.xml file. nbproject/build-impl.xml file.
Other way how to customize the build is by overriding existing main targets. Other way how to customize the build is by overriding existing main targets.
The target of interest are: The target of interest are:
init-macrodef-javac: defines macro for javac compilation init-macrodef-javac: defines macro for javac compilation
init-macrodef-junit: defines macro for junit execution init-macrodef-junit: defines macro for junit execution
init-macrodef-debug: defines macro for class debugging init-macrodef-debug: defines macro for class debugging
do-dist: archive building do-dist: archive building
run: execution of project run: execution of project
javadoc-build: javadoc generation javadoc-build: javadoc generation
Example of overriding the target for project execution could look like Example of overriding the target for project execution could look like
<target name="run" depends="<PROJNAME>-impl.jar"> <target name="run" depends="<PROJNAME>-impl.jar">
<exec dir="bin" executable="launcher.exe"> <exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/> <arg file="${dist.jar}"/>
</exec> </exec>
</target> </target>
Notice that overridden target depends on jar target and not only on Notice that overridden target depends on jar target and not only on
compile target as regular run target does. Again, for list of available compile target as regular run target does. Again, for list of available
properties which you can use check the target you are overriding in properties which you can use check the target you are overriding in
nbproject/build-impl.xml file. nbproject/build-impl.xml file.
--> -->
</project> </project>
This source diff could not be displayed because it is too large. You can view the blob instead.
build.xml.data.CRC32=4cd4cb5e build.xml.data.CRC32=66ba06da
build.xml.script.CRC32=615931b7 build.xml.script.CRC32=615931b7
build.xml.stylesheet.CRC32=651128d4@1.77.1.1 build.xml.stylesheet.CRC32=651128d4@1.77.1.1
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=4cd4cb5e nbproject/build-impl.xml.data.CRC32=66ba06da
nbproject/build-impl.xml.script.CRC32=efa11df6 nbproject/build-impl.xml.script.CRC32=816bdc64
nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.77.1.1 nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.77.1.1
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1"> <project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.web.project</type> <type>org.netbeans.modules.web.project</type>
<configuration> <configuration>
<data xmlns="http://www.netbeans.org/ns/web-project/3"> <data xmlns="http://www.netbeans.org/ns/web-project/3">
<name>demojsoncrud</name> <name>demojsoncrud</name>
<minimum-ant-version>1.6.5</minimum-ant-version> <minimum-ant-version>1.6.5</minimum-ant-version>
<web-module-libraries> <web-module-libraries>
<library dirs="200"> <library dirs="200">
<file>${file.reference.json-20160810.jar}</file> <file>${file.reference.json-20160212.jar}</file>
<path-in-war>WEB-INF/lib</path-in-war> <path-in-war>WEB-INF/lib</path-in-war>
</library> </library>
<library dirs="200"> <library dirs="200">
<file>${file.reference.sqljdbc4-2.0.jar}</file> <file>${file.reference.sqljdbc4.jar}</file>
<path-in-war>WEB-INF/lib</path-in-war> <path-in-war>WEB-INF/lib</path-in-war>
</library> </library>
</web-module-libraries> </web-module-libraries>
<web-module-additional-libraries/> <web-module-additional-libraries/>
<source-roots> <source-roots>
<root id="src.dir"/> <root id="src.dir"/>
</source-roots> </source-roots>
<test-roots> <test-roots>
<root id="test.src.dir"/> <root id="test.src.dir"/>
</test-roots> </test-roots>
</data> </data>
</configuration> </configuration>
</project> </project>
/* package demojsoncrud.beans;
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates import java.io.Serializable;
* and open the template in the editor.
*/ /**
package demojsoncrud.beans; *
* @author Alonso
import java.io.Serializable; */
public class PersonaBean implements Serializable {
/**
* private String codigo;
* @author Alonso private String dni;
*/ private String apellidos;
public class PersonaBean implements Serializable { private String nombres;
private String edad;
private String codigo; private String correo;
private String dni; private String estado;
private String apellidos;
private String nombres; public PersonaBean() {
private String edad; }
private String correo;
private String estado; public String getCodigo() {
return codigo;
public PersonaBean() { }
}
public void setCodigo(String codigo) {
public String getCodigo() { this.codigo = codigo;
return codigo; }
}
public String getDni() {
public void setCodigo(String codigo) { return dni;
this.codigo = codigo; }
}
public void setDni(String dni) {
public String getDni() { this.dni = dni;
return dni; }
}
public String getApellidos() {
public void setDni(String dni) { return apellidos;
this.dni = dni; }
}
public void setApellidos(String apellidos) {
public String getApellidos() { this.apellidos = apellidos;
return apellidos; }
}
public String getNombres() {
public void setApellidos(String apellidos) { return nombres;
this.apellidos = apellidos; }
}
public void setNombres(String nombres) {
public String getNombres() { this.nombres = nombres;
return nombres; }
}
public String getEdad() {
public void setNombres(String nombres) { return edad;
this.nombres = nombres; }
}
public void setEdad(String edad) {
public String getEdad() { this.edad = edad;
return edad; }
}
public String getCorreo() {
public void setEdad(String edad) { return correo;
this.edad = edad; }
}
public void setCorreo(String correo) {
public String getCorreo() { this.correo = correo;
return correo; }
}
public String getEstado() {
public void setCorreo(String correo) { return estado;
this.correo = correo; }
}
public void setEstado(String estado) {
public String getEstado() { this.estado = estado;
return estado; }
}
}
public void setEstado(String estado) {
this.estado = estado;
}
}
/* package demojsoncrud.dao;
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates import demojsoncrud.sqlserverdao.SqlserverDAOFactory;
* and open the template in the editor.
*/ public abstract class DAOFactory {
package demojsoncrud.dao;
public static final int SQL_SERVER = 1;
import demojsoncrud.sqlserverdao.SqlserverDAOFactory; public static final int MYSQL = 2;
/** public static DAOFactory getDAOFactory(int whichFactory) {
* switch (whichFactory) {
* @author Alonso case SQL_SERVER:
*/ return new SqlserverDAOFactory();
public abstract class DAOFactory { default:
return null;
public static final int SQL_SERVER = 1; }
public static final int MYSQL = 2; }
public static DAOFactory getDAOFactory(int whichFactory) { public abstract PersonaDAO getPersonaDAO();
switch (whichFactory) {
case SQL_SERVER: }
return new SqlserverDAOFactory();
default:
return null;
}
}
public abstract PersonaDAO getPersonaDAO();
}
/* package demojsoncrud.dao;
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates import demojsoncrud.beans.PersonaBean;
* and open the template in the editor. import org.json.JSONObject;
*/
package demojsoncrud.dao; public interface PersonaDAO {
import demojsoncrud.beans.PersonaBean; public JSONObject listarPersonaTest();
import org.json.JSONObject;
public JSONObject listarPersona(String search, String draw, String start, String length);
/**
* public JSONObject registrarPersona(PersonaBean bean);
* @author Alonso
*/ public JSONObject editarPersona(PersonaBean bean);
public interface PersonaDAO {
public JSONObject activarPersona(PersonaBean bean);
public JSONObject listarPersonaTest();
public JSONObject desactivarPersona(PersonaBean bean);
public JSONObject listarPersona(String search, String draw, String start, String length);
}
public JSONObject registrarPersona(PersonaBean bean);
public JSONObject editarPersona(PersonaBean bean);
public JSONObject activarPersona(PersonaBean bean);
public JSONObject desactivarPersona(PersonaBean bean);
}
/* package demojsoncrud.services;
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates import demojsoncrud.beans.PersonaBean;
* and open the template in the editor. import demojsoncrud.dao.DAOFactory;
*/ import demojsoncrud.dao.PersonaDAO;
package demojsoncrud.services; import org.json.JSONObject;
import demojsoncrud.beans.PersonaBean; public class PersonaService {
import demojsoncrud.dao.DAOFactory;
import demojsoncrud.dao.PersonaDAO; DAOFactory daoFactory = DAOFactory.getDAOFactory(DAOFactory.SQL_SERVER);
import org.json.JSONObject; PersonaDAO service = daoFactory.getPersonaDAO();
/** public JSONObject listarPersonaTest() {
* JSONObject jsonReturn = null;
* @author Alonso try {
*/ jsonReturn = service.listarPersonaTest();
public class PersonaService { } catch (Exception e) {
e.getMessage();
DAOFactory daoFactory = DAOFactory.getDAOFactory(DAOFactory.SQL_SERVER); }
PersonaDAO service = daoFactory.getPersonaDAO(); return jsonReturn;
}
public JSONObject listarPersonaTest() {
JSONObject jsonReturn = null; public JSONObject listarPersona(String search, String draw, String start, String length) {
try { JSONObject jsonReturn = null;
jsonReturn = service.listarPersonaTest(); try {
} catch (Exception e) { jsonReturn = service.listarPersona(search, draw, start, length);
e.getMessage(); } catch (Exception e) {
} e.getMessage();
return jsonReturn; }
} return jsonReturn;
}
public JSONObject listarPersona(String search, String draw, String start, String length) {
JSONObject jsonReturn = null; public JSONObject registrarPersona(PersonaBean bean) {
try { JSONObject jsonReturn = null;
jsonReturn = service.listarPersona(search, draw, start, length); try {
} catch (Exception e) { jsonReturn = service.registrarPersona(bean);
e.getMessage(); } catch (Exception e) {
} e.getMessage();
return jsonReturn; }
} return jsonReturn;
}
public JSONObject registrarPersona(PersonaBean bean) {
JSONObject jsonReturn = null; public JSONObject editarPersona(PersonaBean bean) {
try { JSONObject jsonReturn = null;
jsonReturn = service.registrarPersona(bean); try {
} catch (Exception e) { jsonReturn = service.editarPersona(bean);
e.getMessage(); } catch (Exception e) {
} e.getMessage();
return jsonReturn; }
} return jsonReturn;
}
public JSONObject editarPersona(PersonaBean bean) {
JSONObject jsonReturn = null; public JSONObject activarPersona(PersonaBean bean) {
try { JSONObject jsonReturn = null;
jsonReturn = service.editarPersona(bean); try {
} catch (Exception e) { jsonReturn = service.activarPersona(bean);
e.getMessage(); } catch (Exception e) {
} }
return jsonReturn; return jsonReturn;
} }
public JSONObject activarPersona(PersonaBean bean) { public JSONObject desactivarPersona(PersonaBean bean) {
JSONObject jsonReturn = null; JSONObject jsonReturn = null;
try { try {
jsonReturn = service.activarPersona(bean); jsonReturn = service.desactivarPersona(bean);
} catch (Exception e) { } catch (Exception e) {
} }
return jsonReturn; return jsonReturn;
} }
public JSONObject desactivarPersona(PersonaBean bean) { }
JSONObject jsonReturn = null;
try {
jsonReturn = service.desactivarPersona(bean);
} catch (Exception e) {
}
return jsonReturn;
}
}
/* package demojsoncrud.sqlserverdao;
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates import demojsoncrud.dao.DAOFactory;
* and open the template in the editor. import demojsoncrud.dao.PersonaDAO;
*/ import java.sql.Connection;
package demojsoncrud.sqlserverdao; import java.sql.DriverManager;
import java.sql.SQLException;
import demojsoncrud.dao.DAOFactory;
import demojsoncrud.dao.PersonaDAO; public class SqlserverDAOFactory extends DAOFactory {
import java.sql.Connection;
import java.sql.DriverManager; public static Connection obtenerConexion(String base) {
import java.sql.SQLException; Connection connection = null;
if (base.equalsIgnoreCase("demojsoncrud")) {
/** String user = "sa";
* String pwd = "Saco1357$";
* @author Alonso String url = "jdbc:sqlserver://172.16.2.118:1433;databaseName=demojsoncrud";
*/ String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
public class SqlserverDAOFactory extends DAOFactory { try {
Class.forName(driver);
public static Connection obtenerConexion(String base) { connection = DriverManager.getConnection(url, user, pwd);
Connection connection = null; } catch (ClassNotFoundException | SQLException e) {
if (base.equalsIgnoreCase("demojsoncrud")) { System.out.println("Error al conectarse => " + e.getMessage());
String user = "sa"; }
String pwd = "Saco1357$"; }
String url = "jdbc:sqlserver://localhost:1433;databaseName=demojsoncrud";
String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; return connection;
try { }
Class.forName(driver);
connection = DriverManager.getConnection(url, user, pwd); // public static void main(String[] args) {
} catch (ClassNotFoundException | SQLException e) { // SqlserverDAOFactory sqlserverDAOFactory = new SqlserverDAOFactory();
System.out.println("Error al conectarse => " + e.getMessage()); // System.out.println(sqlserverDAOFactory.obtenerConexion("demojsoncrud"));
} // }
} @Override
public PersonaDAO getPersonaDAO() {
return connection; return new PersonaSqlserverDAO();
} }
}
// public static void main(String[] args) {
// SqlserverDAOFactory sqlserverDAOFactory = new SqlserverDAOFactory();
// System.out.println(sqlserverDAOFactory.obtenerConexion("demojsoncrud"));
// }
@Override
public PersonaDAO getPersonaDAO() {
return new PersonaSqlserverDAO();
}
}
/* package demojsoncrud.utilities;
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates import java.io.Serializable;
* and open the template in the editor. import org.json.JSONObject;
*/
package demojsoncrud.utils; public class ResponseHelper implements Serializable {
import java.io.Serializable; private JSONObject data;
import org.json.JSONObject; private boolean status;
private String message;
/**
* public ResponseHelper() {
* @author Alonso
*/ }
public class ResponseHelper implements Serializable {
public JSONObject getData() {
private JSONObject data; return data;
private boolean status; }
private String message;
public boolean isStatus() {
public ResponseHelper() { return status;
}
}
public String getMessage() {
public JSONObject getData() { return message;
return data; }
}
public void setData(JSONObject data) {
public boolean isStatus() { this.data = data;
return status; }
}
public void setStatus(boolean status) {
public String getMessage() { this.status = status;
return message; }
}
public void setMessage(String message) {
public void setData(JSONObject data) { this.message = message;
this.data = data; }
}
}
public void setStatus(boolean status) {
this.status = status;
}
public void setMessage(String message) {
this.message = message;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment