Code Search for Developers
 
 
  

ReportTypeClient.java from Negest at Krugle


Show ReportTypeClient.java syntax highlighted

package tk.sabreWulf.negest.test;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

import tk.sabreWulf.negest.entity.reports.ReportTypeEJB;
import tk.sabreWulf.negest.entity.security.UsuarioEJB;
import tk.sabreWulf.negest.reports.ReportTypeAgentRemote;

public class ReportTypeClient {
	
	private static ReportTypeAgentRemote remote;
	
	public static void main(String[] args){
		launch();
	}
	
	public static void launch(){	
			try {
				Context jndiContext = getInitialContext();
				Object ref = jndiContext.lookup("negestSvr/ReportTypeAgentBean/remote");
				remote = (ReportTypeAgentRemote) PortableRemoteObject.narrow(ref, ReportTypeAgentRemote.class);
				
				createReportType();
				
				
				ReportTypeEJB reportType2 = remote.getReportTypeByPK(2);

				
				if (reportType2 != null){
					System.out.println(reportType2.getName());
					deleteReportType(reportType2);
				}
				reportType2 = remote.getReportTypeByPK(19);
				if (reportType2 != null){
//					System.out.println("Empresa asociada: " + reportType2.getFirms().iterator().next().getNombre());
//					System.out.println("Rol asociado: " + reportType2.getRoles().iterator().next().getDescripcion());
				}
				
			} catch (NamingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
	}
	
	public static Context getInitialContext() throws NamingException{
		 java.util.Properties properties = new java.util.Properties();
		 properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
		 properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
		 properties.put(Context.PROVIDER_URL, "jnp://localhost:1099");
		 return new InitialContext(properties);
	}
	
	private static ReportTypeEJB createReportType(){
			ReportTypeEJB reportType = new ReportTypeEJB();
			reportType.setName("Name");
			System.out.println(reportType.getName());
			reportType = remote.createReportType(reportType);
			
			System.out.println("Report created, Id:" + reportType.getId());
			return reportType;
	}
	
	private static void modifyReportType(ReportTypeEJB reportType){
		reportType.setName(reportType.getName() +"a");
		remote.modifyReportType(reportType);
		System.out.println("ReportType modified, Id:" + reportType.getId());
	}
	
	private static void deleteReportType(ReportTypeEJB reportType){
		remote.deleteReportType(reportType);
		System.out.println("Report deleted, Id:" + reportType.getId());
	}

}




See more files for this project here

Negest

This project aims to offer the SOHO integrated platform to track their customers, the events generated by/with them, the orders and billing, warehouses, customer locations and equipment. Its a CMP/ERP, with its focus on water treatment business, for this

Project homepage: http://sourceforge.net/projects/negest
Programming language(s): Java,XML
License: other

  All.java
  CustomerClient.java
  EmpresaClient.java
  ParameterClient.java
  ParameterOptionsClient.java
  ReportInstanceClient.java
  ReportTypeClient.java
  ReportTypeVersionClient.java
  RolClient.java
  UserClient.java