Example usage for org.apache.commons.lang.builder ToStringBuilder reflectionToString

List of usage examples for org.apache.commons.lang.builder ToStringBuilder reflectionToString

Introduction

In this page you can find the example usage for org.apache.commons.lang.builder ToStringBuilder reflectionToString.

Prototype

public static String reflectionToString(Object object, ToStringStyle style) 

Source Link

Document

Forwards to ReflectionToStringBuilder.

Usage

From source file:com.taobao.itest.spring.aop.LogInterceptor.java

private String stringBuilder(Object obj) {
    if (null == obj) {
        return null;
    }//from   w w w. j av a2 s  . c  o m
    if (ReflectionUtils.findMethod(obj.getClass(), "toString") != null) {
        return obj.toString();
    } else {
        return ToStringBuilder.reflectionToString(obj, ToStringStyle.MULTI_LINE_STYLE);
    }
}

From source file:com.cubeia.backoffice.accounting.core.entity.CurrencyRate.java

@Override
public String toString() {
    return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
}

From source file:com.alibaba.jstorm.schedule.default_assign.DefaultTopologyAssignContext.java

public String toDetailString() {
    return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}

From source file:com.mxhero.plugin.cloudstorage.onedrive.api.OneDrive.java

/**
 * Redeem daemon./*from   w  w w.j  a  v a2 s.c o m*/
 *
 * @param redeemDaemonRequest the redeem daemon request
 * @return the Access Token redeemed it
 * @throws AuthenticationException the authentication exception
 */
public static String redeemDaemon(RedeemDaemonRequest redeemDaemonRequest) throws AuthenticationException {
    ExecutorService service = Executors.newCachedThreadPool();
    AuthenticationResult authenticationResult = null;
    String authority = String.format(ApiEnviroment.tokenDaemonBaseUrl.getValue(),
            redeemDaemonRequest.getTenantId());
    logger.debug("Trying to get App Only token for {}", redeemDaemonRequest);
    try {
        AuthenticationContext authenticationContext = new AuthenticationContext(authority, false, service);
        String filePkcs12 = ApiEnviroment.fileUrlPkcs12Certificate.getValue();
        if (StringUtils.isNotEmpty(redeemDaemonRequest.getFileUrlPkcs12Certificate())) {
            filePkcs12 = redeemDaemonRequest.getFileUrlPkcs12Certificate();
        }

        String filePkcs12Secret = ApiEnviroment.pkcs12CertificateSecret.getValue();
        if (StringUtils.isNotEmpty(redeemDaemonRequest.getCertificateSecret())) {
            filePkcs12Secret = redeemDaemonRequest.getCertificateSecret();
        }

        Validate.notEmpty(filePkcs12,
                "Pkcs12 Key file path must be provided or configured. You can set it on environment var 'ONEDRIVE_DAEMON_PKCS12_FILE_URL' or through Java System Property 'onedrive.daemon.pkcs12.file.url'");
        Validate.notEmpty(filePkcs12Secret,
                "Pkcs12 Secret Key file must be provided or configured. You can set it on environment var 'ONEDRIVE_DAEMON_PKCS12_FILE_SECRET' or through Java System Property 'onedrive.daemon.pkcs12.file.secret'");

        InputStream pkcs12Certificate = new FileInputStream(filePkcs12);
        AsymmetricKeyCredential credential = AsymmetricKeyCredential.create(redeemDaemonRequest.getClientId(),
                pkcs12Certificate, filePkcs12Secret);

        Future<AuthenticationResult> future = authenticationContext
                .acquireToken(redeemDaemonRequest.getResourceSharepointId(), credential, null);
        authenticationResult = future.get(10, TimeUnit.SECONDS);
        logger.debug("Token retrieved {}",
                ToStringBuilder.reflectionToString(authenticationResult, ToStringStyle.SHORT_PREFIX_STYLE));
        return authenticationResult.getAccessToken();
    } catch (Exception e) {
        logger.error("Error trying to get new App Only Token", e);
        throw new AuthenticationException(
                String.format("Error trying to get new App Only Token for tenantId %s and sharepointUri %s",
                        redeemDaemonRequest.getTenantId(), redeemDaemonRequest.getResourceSharepointId()));
    } finally {
        service.shutdown();
    }

}

From source file:com.gemini.provision.security.openstack.SecurityProviderOpenStackImpl.java

@Override
public List<GeminiSecurityGroup> listServerSecurityGroups(GeminiTenant tenant, GeminiEnvironment env,
        GeminiServer server) {/*from  w ww . java  2s.c  o  m*/
    List<GeminiSecurityGroup> listSecGrps = Collections.synchronizedList(new ArrayList());

    //authenticate the session with the OpenStack installation
    OSClient os = OSFactory.builder().endpoint(env.getEndPoint())
            .credentials(env.getAdminUserName(), env.getAdminPassword()).tenantName(tenant.getName())
            .authenticate();
    if (os == null) {
        Logger.error("Failed to authenticate Tenant: {}",
                ToStringBuilder.reflectionToString(tenant, ToStringStyle.MULTI_LINE_STYLE));
        return null;
    }

    //get the list from OpenStack
    List<? extends SecGroupExtension> osSecGrps = os.compute().securityGroups()
            .listServerGroups(server.getCloudID());
    osSecGrps.stream().forEach(osSecGrp -> {
        //see if this security group already exists in the environment
        GeminiSecurityGroup tmpSecGrp = env.getSecurityGroups().stream()
                .filter(s -> s.getName().equals(osSecGrp.getName())).findFirst().get();
        GeminiSecurityGroup newGemSecGrp = null;
        if (tmpSecGrp == null) {
            //The OpenStack security group hasn't been mapped to an object on the Gemini side, so create it and add to the environment
            newGemSecGrp = new GeminiSecurityGroup();
            newGemSecGrp.setCloudID(osSecGrp.getId());
            newGemSecGrp.setProvisioned(true);
            newGemSecGrp.setName(osSecGrp.getName());
            newGemSecGrp.setDescription(osSecGrp.getDescription());
            env.addSecurityGroup(newGemSecGrp);
        }

        //check to see if this group's rules are mapped on the Gemini side
        List<? extends Rule> osSecGrpRules = osSecGrp.getRules();
        final GeminiSecurityGroup gemSecGrp = tmpSecGrp == null ? newGemSecGrp : tmpSecGrp;
        osSecGrpRules.stream().filter(osSecGrpRule -> osSecGrpRule != null).forEach(osSecGrpRule -> {
            GeminiSecurityGroupRule gemSecGrpRule = gemSecGrp.getSecurityRules().stream()
                    .filter(sr -> sr.getName().equals(osSecGrpRule.getName())).findFirst().get();
            if (gemSecGrpRule == null) {
                //the rule has not been mapped on the Gemini side, so create it
                gemSecGrpRule = new GeminiSecurityGroupRule();
            }
            gemSecGrpRule.setCloudID(osSecGrpRule.getId());
            gemSecGrpRule.setProvisioned(true);
            gemSecGrpRule.setPortRangeMin(osSecGrpRule.getFromPort());
            gemSecGrpRule.setPortRangeMax(osSecGrpRule.getToPort());
            gemSecGrpRule.setProtocol(Protocol.fromString(osSecGrpRule.getIPProtocol().toString()));
            gemSecGrpRule.setCidr(osSecGrpRule.getRange().getCidr());
            gemSecGrp.addSecurityRule(gemSecGrpRule);
        });

        //check if this security group is attached to server on the gemini side
        if (server.getSecGroupNames().stream().noneMatch(s -> s.equals(osSecGrp.getName()))) {
            //it isn't so add it to the server
            server.addSecGroupName(osSecGrp.getName());
        }

        listSecGrps.add(gemSecGrp);
    });

    Logger.debug("Successfully retrieved security groups Tenant: {} Env: {} server {}{", tenant.getName(),
            env.getName(), server.getName());
    return listSecGrps;
}

From source file:net.handle.servlet.AdminRecordAdapter.java

/**
 * <p>//ww w . j  a  v  a 2  s . c o m
 * </p>
 *
 * @see java.lang.Object#toString()
 */
@Override
public String toString() {
    return ToStringBuilder.reflectionToString(this, OpenHandle.TO_STRING_STYLE);
}

From source file:com.careerly.common.support.response.StandardJsonObject.java

/** -----------------equals/hashCode--------------------- **/

@Override/* w  w w  .j a  va  2  s .  c  o  m*/
public String toString() {
    return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}

From source file:edu.harvard.iq.dvn.ingest.dsb.impl.DvnRforeignFileConversionServiceImpl.java

/** *************************************************************
 * Execute an R-based dvn statistical analysis request 
 *
 * @param sro    a DvnRJobRequest object that contains various parameters
 * @return    a Map that contains various information about results
 *//*from  www .java 2 s  .  c om*/

public Map<String, String> execute(DvnRJobRequest sro) {
    dbgLog.fine("***** DvnRforeignFileConversionServiceImpl: execute() starts here *****");

    // set the return object
    Map<String, String> result = new HashMap<String, String>();
    // temporary result
    Map<String, String> tmpResult = new HashMap<String, String>();

    try {
        // Set up an Rserve connection
        dbgLog.fine("sro dump:\n" + ToStringBuilder.reflectionToString(sro, ToStringStyle.MULTI_LINE_STYLE));

        dbgLog.fine("RSERVE_USER=" + RSERVE_USER + "[default=rserve]");
        dbgLog.fine("RSERVE_PWD=" + RSERVE_PWD + "[default=rserve]");
        dbgLog.fine("RSERVE_PORT=" + RSERVE_PORT + "[default=6311]");

        RConnection c = new RConnection(RSERVE_HOST, RSERVE_PORT);
        dbgLog.fine("hostname=" + RSERVE_HOST);

        c.login(RSERVE_USER, RSERVE_PWD);
        dbgLog.fine(">" + c.eval("R.version$version.string").asString() + "<");

        // check working directories
        // This needs to be done *before* we try to create any files 
        // there!
        setupWorkingDirectory(c);

        // save the data file at the Rserve side
        String infile = sro.getSubsetFileName();
        InputStream inb = new BufferedInputStream(new FileInputStream(infile));

        int bufsize;
        byte[] bffr = new byte[1024];

        RFileOutputStream os = c.createFile(tempFileName);
        while ((bufsize = inb.read(bffr)) != -1) {
            os.write(bffr, 0, bufsize);
        }
        os.close();
        inb.close();

        // Rserve code starts here
        dbgLog.fine("wrkdir=" + wrkdir);
        c.voidEval(librarySetup);

        // variable type
        /* 
        vartyp <-c(1,1,1)
        */
        // java side
        // int [] jvartyp  = {1,1,1};// = mp.get("vartyp").toArray()
        // int [] jvartyp  = sro.getVariableTypes();
        /*
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0 ; i< jvartyp.length; i++){
        if (i == (jvartyp.length -1)){
            sb.append(String.valueOf(jvartyp[i]));
        } else {
            sb.append(String.valueOf(jvartyp[i])+", ");
        }
                    }
                            
                    // R side
        */

        /*
         * Note that we want to use the "getVariableTypesWithBoolean method 
         * below; when we create a SRO object for analysis, in 
         * DvnRDataAnalysisServiceImpl, we'll still be using getVariableTypes
         * method, that don't recognize Booleans as a distinct class of 
         * variables. So those would be treated simply as numeric categoricals 
         * (factors) with the "TRUE" and "FALSE" labels. But for the purposes
         * of saving the subset in R format, we want to convert these into
         * R "logical" vectors.
         */

        dbgLog.fine("raw variable type=" + sro.getVariableTypesWithBoolean());
        c.assign("vartyp", new REXPInteger(sro.getVariableTypesWithBoolean()));
        String[] tmpt = c.eval("vartyp").asStrings();
        dbgLog.fine("vartyp length=" + tmpt.length + "\t " + StringUtils.join(tmpt, ","));

        // variable format (date/time)
        /* 
        varFmt<-list();
        c.voidEval("varFmt<-list()");
        */

        Map<String, String> tmpFmt = sro.getVariableFormats();
        dbgLog.fine("tmpFmt=" + tmpFmt);
        if (tmpFmt != null) {
            Set<String> vfkeys = tmpFmt.keySet();
            String[] tmpfk = (String[]) vfkeys.toArray(new String[vfkeys.size()]);
            String[] tmpfv = getValueSet(tmpFmt, tmpfk);
            c.assign("tmpfk", new REXPString(tmpfk));
            c.assign("tmpfv", new REXPString(tmpfv));
            String fmtNamesLine = "names(tmpfv)<- tmpfk";
            c.voidEval(fmtNamesLine);
            String fmtValuesLine = "varFmt<- as.list(tmpfv)";
            c.voidEval(fmtValuesLine);
        } else {
            String[] varFmtN = {};
            List<String> varFmtV = new ArrayList<String>();
            c.assign("varFmt", new REXPList(new RList(varFmtV, varFmtN)));
        }
        /*
        vnames<-c("race","age","vote")
        */

        // variable names
        // String [] jvnames = {"race","age","vote"};
        String[] jvnamesRaw = sro.getVariableNames();
        String[] jvnames = null;

        //VariableNameFilterForR nf = new VariableNameFilterForR(jvnamesRaw);

        if (sro.hasUnsafedVariableNames) {
            // create  list
            jvnames = sro.safeVarNames;
            dbgLog.fine("renamed=" + StringUtils.join(jvnames, ","));
        } else {
            jvnames = jvnamesRaw;
        }
        String vnQList = DvnDSButil.joinNelementsPerLine(jvnames, true);

        c.assign("vnames", new REXPString(jvnames));

        // confirmation
        String[] tmpjvnames = c.eval("vnames").asStrings();
        dbgLog.fine("vnames:" + StringUtils.join(tmpjvnames, ","));

        /*
        x<-read.table141vdc(file="/tmp/VDC/t.28948.1.tab", 
            col.names=vnames, colClassesx=vartyp, varFormat=varFmt)
        */

        //String datafilename = "/nfs/home/A/asone/java/rcode/t.28948.1.tab";

        // tab-delimited file name = tempFileName

        // Parameters:
        // file -> tempFileName
        // col.names -> Arrays.deepToString(new REXPString(jvnames)).asStrings())
        // colClassesx -> Arrays.deepToString((new REXPInteger(sro.getVariableTypes())).asStrings())
        // varFormat -> Arrays.deepToString((new REXPString(getValueSet(tmpFmt, tmpFmt.keySet().toArray(new String[tmpFmt.keySet().size()])))).asStrings())

        dbgLog.fine("<<<<<<<<<<<<<<<<<<<<<<<<<");
        dbgLog.fine("col.names = " + Arrays.deepToString((new REXPString(jvnames)).asStrings()));
        dbgLog.fine("colClassesx = "
                + Arrays.deepToString((new REXPInteger(sro.getVariableTypesWithBoolean())).asStrings()));
        dbgLog.fine("varFormat = " + Arrays.deepToString((new REXPString(
                getValueSet(tmpFmt, tmpFmt.keySet().toArray(new String[tmpFmt.keySet().size()]))))
                        .asStrings()));
        dbgLog.fine(">>>>>>>>>>>>>>>>>>>>>>>>>");

        String readtableline = "x<-read.table141vdc(file='" + tempFileName
                + "', col.names=vnames, colClassesx=vartyp, varFormat=varFmt )";
        dbgLog.fine("readtable=" + readtableline);

        c.voidEval(readtableline);

        // safe-to-raw variable name
        /* 
          attr(x, "Rsafe2raw")<-list();
        */
        //if (nf.hasRenamedVariables()){
        if (sro.hasUnsafedVariableNames) {
            dbgLog.fine("unsafeVariableNames exist");
            // create  list
            //jvnames = nf.getFilteredVarNames();
            jvnames = sro.safeVarNames;
            String[] rawNameSet = sro.renamedVariableArray;
            String[] safeNameSet = sro.renamedResultArray;

            c.assign("tmpRN", new REXPString(rawNameSet));
            c.assign("tmpSN", new REXPString(safeNameSet));

            String raw2safevarNameTableLine = "names(tmpRN)<- tmpSN";
            c.voidEval(raw2safevarNameTableLine);
            String attrRsafe2rawLine = "attr(x, 'Rsafe2raw')<- as.list(tmpRN)";
            c.voidEval(attrRsafe2rawLine);
        } else {
            String attrRsafe2rawLine = "attr(x, 'Rsafe2raw')<-list();";
            c.voidEval(attrRsafe2rawLine);
        }

        //Map<String, String> Rsafe2raw = sro.getRaw2SafeVarNameTable();

        // asIs
        /* 
        for (i in 1:dim(x)[2]){if (attr(x,"var.type")[i] == 0) {
        x[[i]]<-I(x[[i]]);  x[[i]][ x[[i]] == '' ]<-NA  }}
        */
        String asIsline = "for (i in 1:dim(x)[2]){ " + "if (attr(x,'var.type')[i] == 0) {"
                + "x[[i]]<-I(x[[i]]);  x[[i]][ x[[i]] == '' ]<-NA  }}";
        c.voidEval(asIsline);

        // replication: copy the data.frame
        String repDVN_Xdupline = "dvnData<-x";
        c.voidEval(repDVN_Xdupline);
        tmpResult.put("dvn_dataframe", "dvnData");

        // subsetting (mutating the data.frame strips non-default attributes 
        // 
        // variable type must be re-attached

        //String varTypeNew = "vartyp<-c(" + StringUtils.join( sro.getUpdatedVariableTypesAsString(),",")+")";
        // c.voidEval(varTypeNew);
        dbgLog.fine("updated var Type =" + sro.getUpdatedVariableTypes());
        c.assign("vartyp", new REXPInteger(sro.getUpdatedVariableTypes()));

        String reattachVarTypeLine = "attr(x, 'var.type') <- vartyp";
        c.voidEval(reattachVarTypeLine);

        // TODO: 
        // "getUpdatedVariableTypesWithBooleans" ?? -- L.A.

        // replication: variable type
        String repDVN_vt = "attr(dvnData, 'var.type') <- vartyp";
        c.voidEval(repDVN_vt);

        // variable Id
        /* 
        attr(x, "var.nmbr")<-c("v198057","v198059","v198060")
        */

        // String[] jvarnmbr = {"v198057","v198059","v198060"};
        //String[] jvarnmbr = sro.getVariableIds();
        // after recoding 
        String[] jvarnmbr = sro.getUpdatedVariableIds();

        String viQList = DvnDSButil.joinNelementsPerLine(jvarnmbr, true);
        c.assign("varnmbr", new REXPString(jvarnmbr));

        String attrVarNmbrLine = "attr(x, 'var.nmbr')<-varnmbr";
        c.voidEval(attrVarNmbrLine);

        // confirmation
        String[] vno = c.eval("attr(x, 'var.nmbr')").asStrings();
        dbgLog.fine("varNo=" + StringUtils.join(vno, ","));

        // replication: variable number
        String repDVN_vn = "attr(dvnData, 'var.nmbr') <- varnmbr";
        c.voidEval(repDVN_vn);

        // variable labels
        /* 
        attr(x, "var.labels")<-c("race","age","vote")
        */

        // String[] jvarlabels = {"race","age","vote"};
        // String[] jvarlabels = sro.getVariableLabels();
        // after recoding
        String[] jvarlabels = sro.getUpdatedVariableLabels();

        String vlQList = DvnDSButil.joinNelementsPerLine(jvarlabels, true);

        c.assign("varlabels", new REXPString(jvarlabels));

        String attrVarLabelsLine = "attr(x, 'var.labels')<-varlabels";
        c.voidEval(attrVarLabelsLine);

        // confirmation
        String[] vlbl = c.eval("attr(x, 'var.labels')").asStrings();
        dbgLog.fine("varlabels=" + StringUtils.join(vlbl, ","));

        // replication: 
        String repDVN_vl = "attr(dvnData, 'var.labels') <- varlabels";
        c.voidEval(repDVN_vl);

        // --------- start: block to be used for the production code
        // value-label table
        /* 
        VALTABLE<-list()
        VALTABLE[["1"]]<-list(
        "2"="white",
        "1"="others")
        attr(x, 'val.table')<-VALTABLE
        */

        // create the VALTABLE
        String vtFirstLine = "VALTABLE<-list()";
        c.voidEval(vtFirstLine);

        // vltbl includes both base and recoded cases when it was generated
        Map<String, Map<String, String>> vltbl = sro.getValueTable();
        Map<String, String> rnm2vi = sro.getRawVarNameToVarIdTable();
        String[] updatedVariableIds = sro.getUpdatedVariableIds();

        //for (int j=0;j<jvnamesRaw.length;j++){
        for (int j = 0; j < updatedVariableIds.length; j++) {
            // if this variable has its value-label table,
            // pass its key and value arrays to the Rserve
            // and finalize a value-table at the Rserve

            //String varId = rnm2vi.get(jvnamesRaw[j]);
            String varId = updatedVariableIds[j];

            if (vltbl.containsKey(varId)) {

                Map<String, String> tmp = (HashMap<String, String>) vltbl.get(varId);
                Set<String> vlkeys = tmp.keySet();
                String[] tmpk = (String[]) vlkeys.toArray(new String[vlkeys.size()]);
                String[] tmpv = getValueSet(tmp, tmpk);
                // debug
                dbgLog.fine("tmp:k=" + StringUtils.join(tmpk, ","));
                dbgLog.fine("tmp:v=" + StringUtils.join(tmpv, ","));

                // index number starts from 1(not 0)
                int indx = j + 1;
                dbgLog.fine("index=" + indx);

                if (tmpv.length > 0) {

                    c.assign("tmpk", new REXPString(tmpk));

                    c.assign("tmpv", new REXPString(tmpv));

                    String namesValueLine = "names(tmpv)<- tmpk";
                    c.voidEval(namesValueLine);

                    String sbvl = "VALTABLE[['" + Integer.toString(indx) + "']]" + "<- as.list(tmpv)";
                    dbgLog.fine("frag=" + sbvl);
                    c.voidEval(sbvl);

                    // confirmation test for j-th variable name
                    REXP jl = c.parseAndEval(sbvl);
                    dbgLog.fine("jl(" + j + ") = " + jl);
                }
            }
        }

        // debug: confirmation test for value-table
        dbgLog.fine("length of vl=" + c.eval("length(VALTABLE)").asInteger());
        String attrValTableLine = "attr(x, 'val.table')<-VALTABLE";
        c.voidEval(attrValTableLine);

        // replication: value-label table
        String repDVN_vlt = "attr(dvnData, 'val.table') <- VALTABLE";
        c.voidEval(repDVN_vlt);

        // --------- end: block to be used for the production code

        // missing-value list: TO DO
        /*
        MSVLTBL<-list(); attr(x, 'missval.table')<-MSVLTBL
        */
        String msvStartLine = "MSVLTBL<-list();";
        c.voidEval(msvStartLine);
        // data structure
        String attrMissvalLine = "attr(x, 'missval.table')<-MSVLTBL";
        c.voidEval(attrMissvalLine);

        // replication: missing value table
        String repDVN_mvlt = "attr(dvnData, 'missval.table') <- MSVLTBL";
        c.voidEval(repDVN_mvlt);

        // attach attributes(tables) to the data.frame
        /*
        x<-createvalindex(dtfrm=x, attrname='val.index')
        x<-createvalindex(dtfrm=x, attrname='missval.index')
        */
        String createVIndexLine = "x<-createvalindex(dtfrm=x, attrname='val.index');";
        c.voidEval(createVIndexLine);
        String createMVIndexLine = "x<-createvalindex(dtfrm=x, attrname='missval.index');";
        c.voidEval(createMVIndexLine);

        // reflection block: start ------------------------------------------>

        String requestTypeToken = sro.getRequestType();// (Download|EDA|Xtab|Zelig)
        dbgLog.fine("requestTypeToken=" + requestTypeToken);
        // get a test method
        Method mthd = runMethods.get(requestTypeToken);
        dbgLog.fine("method=" + mthd);

        try {
            // invoke this method
            result = (Map<String, String>) mthd.invoke(this, sro, c);
        } catch (InvocationTargetException e) {
            //Throwable cause = e.getCause();
            //err.format(cause.getMessage());
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

        // add the variable list
        result.put("variableList", joinNelementsPerLine(jvnamesRaw, 5, null, false, null, null));

        //result.put("variableList",StringUtils.join(jvnamesRaw, ", "));

        // replication: var-level unf
        String repDVN_varUNF = "attr(dvnData, 'variableUNF') <- paste(unf(dvnData,version=3))";
        c.voidEval(repDVN_varUNF);

        // calculate the file-leve UNF

        String fileUNFline = "fileUNF <- paste(summary(unf(dvnData, version=3)))";
        c.voidEval(fileUNFline);
        String fileUNF = c.eval("fileUNF").asString();
        if (fileUNF == null) {
            fileUNF = "NA";
        }

        // replication: file-level unf
        String repDVN_fileUNF = "attr(dvnData, 'fileUNF') <- fileUNF";
        c.voidEval(repDVN_fileUNF);

        String RversionLine = "R.Version()$version.string";
        String Rversion = c.eval(RversionLine).asString();

        // replication: R version
        String repDVN_Rversion = "attr(dvnData, 'R.version') <- R.Version()$version.string";
        c.voidEval(repDVN_Rversion);

        String zeligVersionLine = "packageDescription('Zelig')$Version";
        String zeligVersion = c.eval(zeligVersionLine).asString();

        //String RexecDate = c.eval("date()").asString();
        String RexecDate = c.eval("as.character(as.POSIXct(Sys.time()))").asString();
        // replication: date
        String repDVN_date = "attr(dvnData, 'date') <- as.character(as.POSIXct(Sys.time()))";
        c.voidEval(repDVN_date);

        String repDVN_dfOrigin = "attr(dvnData, 'data.frame.origin')<- "
                + "list('provider'='Dataverse Network Project',"
                + "'format' = list('name' = 'DVN data.frame', 'version'='1.3'))";
        c.voidEval(repDVN_dfOrigin);
        /*
        if (result.containsKey("option")){
        result.put("R_run_status", "T");
        } else {
        result.put("option", requestTypeToken.toLowerCase()); //download  zelig eda xtab
        result.put("R_run_status", "F");
        }
        */
        if (sro.hasRecodedVariables()) {
            if (sro.getSubsetConditions() != null) {
                result.put("subsettingCriteria", StringUtils.join(sro.getSubsetConditions(), "\n"));
                // replication: subset lines
                String[] sbst = null;
                sbst = (String[]) sro.getSubsetConditions()
                        .toArray(new String[sro.getSubsetConditions().size()]);

                c.assign("sbstLines", new REXPString(sbst));

                String repDVN_sbst = "attr(dvnData, 'subsetLines') <- sbstLines";
                c.voidEval(repDVN_sbst);
            }
            /* to be used in the future? */
            if (sro.getRecodeConditions() != null) {
                result.put("recodingCriteria", StringUtils.join(sro.getRecodeConditions(), "\n"));
                String[] rcd = null;
                rcd = (String[]) sro.getRecodeConditions()
                        .toArray(new String[sro.getRecodeConditions().size()]);

                c.assign("rcdtLines", new REXPString(rcd));

                String repDVN_rcd = "attr(dvnData, 'recodeLines') <- rcdtLines";
                c.voidEval(repDVN_rcd);
            }

        }

        // save workspace as a replication data set

        String RdataFileName = "DVNdataFrame." + PID + ".RData";
        result.put("Rdata", "/" + requestdir + "/" + RdataFileName);

        String saveWS = "save('dvnData', file='" + wrkdir + "/" + RdataFileName + "')";
        dbgLog.fine("save the workspace=" + saveWS);
        c.voidEval(saveWS);

        // write back the R workspace to the dvn 

        String wrkspFileName = wrkdir + "/" + RdataFileName;
        dbgLog.fine("wrkspFileName=" + wrkspFileName);

        int wrkspflSize = getFileSize(c, wrkspFileName);

        File wsfl = writeBackFileToDvn(c, wrkspFileName, RWRKSP_FILE_PREFIX, "RData", wrkspflSize);

        result.put("dvn_RData_FileName", wsfl.getName());

        if (wsfl != null) {
            result.put("wrkspFileName", wsfl.getAbsolutePath());
            dbgLog.fine("wrkspFileName=" + wsfl.getAbsolutePath());
        } else {
            dbgLog.fine("wrkspFileName is null");
        }

        result.put("library_1", "VDCutil");

        result.put("fileUNF", fileUNF);
        result.put("dsbHost", RSERVE_HOST);
        result.put("dsbPort", DSB_HOST_PORT);
        result.put("dsbContextRootDir", DSB_CTXT_DIR);
        result.put("PID", PID);
        result.put("Rversion", Rversion);
        result.put("zeligVersion", zeligVersion);
        result.put("RexecDate", RexecDate);

        result.putAll(tmpResult);
        dbgLog.fine("result object (before closing the Rserve):\n" + result);

        // reflection block: end

        // close the Rserve connection
        c.close();

    } catch (RserveException rse) {
        // RserveException (Rserve is not running)
        rse.printStackTrace();

        result.put("dsbContextRootDir", DSB_CTXT_DIR);
        result.put("PID", PID);
        result.put("option", sro.getRequestType().toLowerCase());

        result.put("RexecError", "true");
        return result;

    } catch (REXPMismatchException mme) {

        // REXP mismatch exception (what we got differs from what we expected)
        mme.printStackTrace();

        result.put("dsbContextRootDir", DSB_CTXT_DIR);
        result.put("PID", PID);
        result.put("option", sro.getRequestType().toLowerCase());

        result.put("RexecError", "true");
        return result;

    } catch (IOException ie) {
        ie.printStackTrace();

        result.put("dsbContextRootDir", DSB_CTXT_DIR);
        result.put("PID", PID);
        result.put("option", sro.getRequestType().toLowerCase());

        result.put("RexecError", "true");
        return result;

    } catch (Exception ex) {
        ex.printStackTrace();

        result.put("dsbContextRootDir", DSB_CTXT_DIR);
        result.put("PID", PID);

        result.put("option", sro.getRequestType().toLowerCase());

        result.put("RexecError", "true");
        return result;
    }

    return result;

}

From source file:com.icebreak.p2p.dataobject.InstitutionsInfoDO.java

/**
 * @return//from  ww w .  jav  a  2  s  .  c  o m
 * 
 * @see java.lang.Object#toString()
 */
@Override
public String toString() {

    return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}

From source file:com.krminc.phr.domain.clinical.CcrActor.java

@Override
public String toString() {
    final StandardToStringStyle style = new StandardToStringStyle();
    style.setNullText("---NULL---");
    style.setFieldSeparator(";\n");
    style.setArrayStart("{{{");
    style.setArrayEnd("}}}");
    style.setArraySeparator("|");
    style.setFieldNameValueSeparator(":");
    return ToStringBuilder.reflectionToString(this, style);
}