Skip to content

Instantly share code, notes, and snippets.

/ver_empleado() Secret
Created Mar 6, 2015

Embed
What would you like to do?
private void ver_empleado()
{
LinkedHashMap<String, Integer> columnsProps = new LinkedHashMap<>();
columnsProps.put("DNI", 80);
columnsProps.put("Nombre y Apellidos", 300);
columnsProps.put("Categoria", 90);
columnsProps.put("Cargo", 200);
columnsProps.put("Fec. Ingreso", 70);
columnsProps.put("Contrato", 70);
columnsProps.put("Fec. Ven. Co.", 70);
columnsProps.put("Poliza SCTR", 70);
columnsProps.put("EMO", 70);
columnsProps.put("Ant. Polic.", 70);
columnsProps.put("Ant. Penales", 70);
columnsProps.put("Ant. Judic.", 70);
columnsProps.put("Estado", 50);
for (Map.Entry<String, Integer> column : columnsProps.entrySet())
{
tableModel.addColumn(column.getKey());
}
try
{
URL url = new URL("http://tupagina.com/get_empleados.php");
try (InputStream is = url.openStream();
JsonReader reader = Json.createReader(is))
{
JsonObject empleadosObject = reader.readObject();
JsonArray empleados = empleadosObject.getJsonArray("data");
empleados.getValuesAs(JsonObject.class).stream().forEach((empleado) ->
{
Object fila[] = new Object[14];
fila[0] = empleado.getString("dni_col");
fila[1] = empleado.getString("nom_col");
fila[2] = empleado.getString("descripcion");
fila[3] = empleado.getString("desc_car");
fila[4] = "-";
fila[5] = "NO";
fila[6] = "-";
if( empleado.getOrDefault("fec_ini", null) != null )
{
fila[5] = "SI";
fila[6] = empleado.getString("fec_ini");
}
fila[7] = fila[8] = fila[9]
= fila[10] = fila[11] = "-";
fila[12] = empleado.getString("est_col").equals("1") ? "ACTIVO" : "-";
tableModel.addRow(fila);
});
}
}
catch(Exception e){ System.out.println(e.getMessage()); }
int columnIndex = 0;
for (Map.Entry<String, Integer> column : columnsProps.entrySet())
{
table.getColumnModel().getColumn(columnIndex++).setMinWidth(column.getValue());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.