<commit_before>/*
 * Created on Jun 14, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package gov.nih.nci.sdk.codegen.clientlayer;

import gov.nih.nci.sdk.codegen.CodeFormatter;
import gov.nih.nci.sdk.codegen.CodeGenUtils;
import gov.nih.nci.sdk.codegen.StringUtilities;

import java.io.FileWriter;
import java.util.ArrayList;

import test.gov.nih.nci.sdk.codegen.TestApplicationService;

/**
 * @author kumarvi
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class ClientSessionGenerator {
	public Class applicationService;
	private String basePackage;
	private String parentPackage;
	private String classPackage = "application.client";
	private String sourceDirName = null;
	
	
	public ClientSessionGenerator(String sourceDirName,String basePackage,Class applicationService){
		this.applicationService= applicationService;
		this.sourceDirName=sourceDirName;
		if(StringUtilities.isBlank(basePackage)){
			this.basePackage=classPackage;
		}else{
			parentPackage = basePackage+".";
			this.basePackage= basePackage+"."+classPackage;
		}
	}
	public void generate(){
		String remoteApplicationServiceName = "Remote"+CodeGenUtils.getPartialName(applicationService);
		String sourceClassName = "ClientSession";
		FileWriter sourceFileWriter = CodeGenUtils.getSourceFileWriter(sourceDirName,basePackage,sourceClassName);
		
		StringBuffer stbr = new StringBuffer();
		StringBuffer code = new StringBuffer();
		
		CodeGenUtils.addPackageStatement(code,basePackage);
		
		CodeFormatter.newLine(code);
		
		ArrayList impStmts = new ArrayList();
		impStmts.add("import "+parentPackage+basePackage+"."+remoteApplicationServiceName+";\n");
		impStmts.add("import "+"org.springframework.context.ApplicationContext"+";\n");
		impStmts.add("import "+"org.springframework.context.support.ClassPathXmlApplicationContext"+";\n");
		CodeGenUtils.addImportStatements(code,impStmts);
		
		CodeFormatter.addLines(code,2);
		code.append("public class ClientSession");
		CodeFormatter.openClassBody(code);
		CodeFormatter.addLines(code,2);
		this.addMembers(code);
		code.append("     private ").append(remoteApplicationServiceName).append(" ").append("remoteService;\n");
		CodeFormatter.addLines(code,2);
		this.addGeneralMethods(code);
		
		/**
		 * Add RemoteService Accessor Method
		 */
		CodeFormatter.newLine(code);
		CodeFormatter.addSpaces(code,2);
		code.append("private "+"Remote"+CodeGenUtils.getPartialName(applicationService)+" getRemoteServiceFromClassPath()");
		CodeFormatter.startMethod(code);
		code.append("ApplicationContext ctx = new ClassPathXmlApplicationContext(\"");
		code.append("remoteService.xml");
		code.append("\")");<commit_msg>*** empty log message ***<commit_after>/*
 * Created on Jun 14, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package gov.nih.nci.sdk.codegen.clientlayer;

import gov.nih.nci.sdk.codegen.CodeFormatter;
import gov.nih.nci.sdk.codegen.CodeGenUtils;
import gov.nih.nci.sdk.codegen.StringUtilities;

import java.io.FileWriter;
import java.util.ArrayList;

import test.gov.nih.nci.sdk.codegen.TestApplicationService;

/**
 * @author kumarvi
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class ClientSessionGenerator {
	public Class applicationService;
	private String basePackage;
	private String parentPackage;
	private String classPackage = "application.client";
	private String sourceDirName = null;
	
	
	public ClientSessionGenerator(String sourceDirName,String basePackage,Class applicationService){
		this.applicationService= applicationService;
		this.sourceDirName=sourceDirName;
		if(StringUtilities.isBlank(basePackage)){
			this.basePackage=classPackage;
		}else{
			parentPackage = basePackage+".";
			this.basePackage= basePackage+"."+classPackage;
		}
	}
	public void generate(){
		String remoteApplicationServiceName = "Remote"+CodeGenUtils.getPartialName(applicationService);
		String sourceClassName = "ClientSession";
		FileWriter sourceFileWriter = CodeGenUtils.getSourceFileWriter(sourceDirName,basePackage,sourceClassName);
		
		StringBuffer stbr = new StringBuffer();
		StringBuffer code = new StringBuffer();
		
		CodeGenUtils.addPackageStatement(code,basePackage);
		
		CodeFormatter.newLine(code);
		
		ArrayList impStmts = new ArrayList();
		impStmts.add("import "+basePackage+"."+remoteApplicationServiceName+";\n");
		impStmts.add("import "+"org.springframework.context.ApplicationContext"+";\n");
		impStmts.add("import "+"org.springframework.context.support.ClassPathXmlApplicationContext"+";\n");
		CodeGenUtils.addImportStatements(code,impStmts);
		
		CodeFormatter.addLines(code,2);
		code.append("public class ClientSession");
		CodeFormatter.openClassBody(code);
		CodeFormatter.addLines(code,2);
		this.addMembers(code);
		code.append("     private ").append(remoteApplicationServiceName).append(" ").append("remoteService;\n");
		CodeFormatter.addLines(code,2);
		this.addGeneralMethods(code);
		
		/**
		 * Add RemoteService Accessor Method
		 */
		CodeFormatter.newLine(code);
		CodeFormatter.addSpaces(code,2);
		code.append("private "+"Remote"+CodeGenUtils.getPartialName(applicationService)+" getRemoteServiceFromClassPath()");
		CodeFormatter.startMethod(code);
		code.append("ApplicationContext ctx = new ClassPathXmlApplicationContext(\"");
		code.append("remoteService.xml");
		code.append("\")");
{'fraction_non_alphanumeric': 0.11911504424778761, 'fraction_numerical': 0.0035398230088495575, 'mean_word_length': 5.800240673886884, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5833963', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1605, 'n_words': 315}