<commit_before>package org.csstudio.diag.pvfields.sns;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import org.csstudio.diag.pvfields.model.PVFieldsAPI;
import org.csstudio.diag.pvfields.model.PVInfo;
import org.csstudio.platform.utility.rdb.RDBUtil;

/**
 * Implementation of PVFieldsAPI for SNS RDB and EPICS PVs
 * 
 * @author <NAME>
 * @author <NAME>
 */
@SuppressWarnings("nls")
public class SNSPVFieldsData implements PVFieldsAPI
{
    final private RDBUtil rdbutil;
    final private static String URL = "jdbc:oracle:thin:@(DESCRIPTION=(SOURCE_ROUTE=YES)(ADDRESS_LIST=(LOAD_BALANCE=OFF)(FAILOVER=ON)(ADDRESS=(PROTOCOL=TCP)(HOST=snsapp1a.sns.ornl.gov)(PORT=1610))(ADDRESS=(PROTOCOL=TCP)(HOST=snsapp1b.sns.ornl.gov)(PORT=1610)))(ADDRESS_LIST=(LOAD_BALANCE=OFF)(ADDRESS=(PROTOCOL=TCP)(HOST=172.31.75.138)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.31.75.141)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.31.73.93 )(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ics_prod_lba)))";
    final private static String USER = "sns_reports";
    final private static String PASSWORD = "<PASSWORD>";
    private ArrayList<String> extraFields = new ArrayList<String>(); 
    
    // private static final String URL =
    // "jdbc:oracle:thin:sns_reports/sns@//snsdev3.sns.ornl.gov:1521/devl";

    public SNSPVFieldsData() throws Exception
    {
        rdbutil = RDBUtil.connect(URL, USER, PASSWORD, true);
    }

	public PVInfo [] getPVInfo(String pv_name, String field) throws Exception {

		final Connection connection = rdbutil.getConnection();
        final ArrayList<PVInfo> pvList = new ArrayList<PVInfo>();
    	
        /** Setup first portion of select statement */ 
        String pvSelect = "select distinct sgnl_id,rec_type_id, fld_id, dbd_type_id, fld_val, ioc_nm," +
        		" to_char(boot_dte,'Month DD, YYYY \"at\" HH:MI am') as boot_dte, file_nm ";
        String pvFrom	= "from epics.sgnl_fld_v ";
        
        /** Determine type of where clause for PV */ 
        String pvPVWhere = "where sgnl_id = ? ";
        if (pv_name.contains("%")) pvPVWhere = "where sgnl_id like ? ";
        
        /** Determine type of where clause for the Field(s) */        
        String pvFieldWhere = "";
        String unionClause = "";
        String orderByClause = " order by fld_id,sgnl_id";
        
        // Useful field selector?
        if (field != null)<commit_msg>URL for Office and CCR. Log Error<commit_after>package org.csstudio.diag.pvfields.sns;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import org.csstudio.diag.pvfields.model.PVFieldsAPI;
import org.csstudio.diag.pvfields.model.PVInfo;
import org.csstudio.platform.logging.CentralLogger;
import org.csstudio.platform.utility.rdb.RDBUtil;

/**
 * Implementation of PVFieldsAPI for SNS RDB and EPICS PVs
 * 
 * @author <NAME>
 * @author <NAME>
 */
@SuppressWarnings("nls")
public class SNSPVFieldsData implements PVFieldsAPI
{
    final private RDBUtil rdbutil;
    final private static String URL = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=OFF)(ADDRESS=(PROTOCOL=TCP)(HOST=172.31.75.138)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.31.75.141)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ics_prod_lba)))";
    final private static String USER = "sns_reports";
    final private static String PASSWORD = "<PASSWORD>";
    private ArrayList<String> extraFields = new ArrayList<String>(); 
    
    // private static final String URL =
    // "jdbc:oracle:thin:sns_reports/sns@//snsdev3.sns.ornl.gov:1521/devl";

    public SNSPVFieldsData() throws Exception
    {
    	try
    	{
    		rdbutil = RDBUtil.connect(URL, USER, PASSWORD, true);
    	}
    	catch (Exception ex)
    	{
    		CentralLogger.getInstance().getLogger(this).error("Cannot connect to RDB " + URL);
    		throw ex;
    	}
    }

	public PVInfo [] getPVInfo(String pv_name, String field) throws Exception {

		final Connection connection = rdbutil.getConnection();
        final ArrayList<PVInfo> pvList = new ArrayList<PVInfo>();
    	
        /** Setup first portion of select statement */ 
        String pvSelect = "select distinct sgnl_id,rec_type_id, fld_id, dbd_type_id, fld_val, ioc_nm," +
        		" to_char(boot_dte,'Month DD, YYYY \"at\" HH:MI am') as boot_dte, file_nm ";
        String pvFrom	= "from epics.sgnl_fld_v ";
        
        /** Determine type of where clause for PV */ 
        String pvPVWhere = "where sgnl_id = ? ";
        if (pv_name.contains("%")) pvPVWhere = "where sgnl_id like ? ";
        
        /** Determine type of where clause for the Field(s) */        
        String pvFieldWhere = "";
        String unionClause = "";
        String orderByClause = " order by fld_id,sgnl_id";
        
        // Useful field selector?
        if (field != null)
{'fraction_non_alphanumeric': 0.1263523167993468, 'fraction_numerical': 0.01816697285160237, 'mean_word_length': 3.5623836126629422, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 5, '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': '6894957', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1638, 'n_words': 343}