All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hpccsystems.ws.client.platform.Result Maven / Gradle / Ivy

Go to download

This project allows a user to interact with ESP services in a controlled manner. The API calls available under org.hpccsystems.ws.client.platform allow for a user to target ESP's across multiple environments running a range of hpccsystems-platform versions. There is no guarantee that if a user utilizes org.hpccsystems.ws.client.gen generated stub code from wsdl, that the calls will be backwards compatible with older hpccsystems-platform versions.

There is a newer version: 9.6.10-1
Show newest version
/*******************************************************************************
 * Copyright (c) 2011 HPCC Systems. All rights reserved. This program and the accompanying materials are made available
 * under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors: HPCC Systems - initial API and implementation
 ******************************************************************************/
package org.hpccsystems.ws.client.platform;

import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;

import org.hpccsystems.ws.client.HPCCWsWorkUnitsClient;
import org.hpccsystems.ws.client.gen.axis2.wsworkunits.latest.ECLResult;
import org.hpccsystems.ws.client.gen.axis2.wsworkunits.latest.WUResultResponse;
import org.hpccsystems.ws.client.utils.DataSingleton;
import org.hpccsystems.ws.client.utils.DatasetParser;
import org.hpccsystems.ws.client.utils.EqualsUtil;
import org.hpccsystems.ws.client.utils.HashCodeUtil;
import org.hpccsystems.ws.client.wrappers.WUState;
import org.xml.sax.InputSource;

public class Result extends DataSingleton
{
    private static Map Results = new HashMap();

    /**
     * Gets the.
     *
     * @param workunit
     *            the workunit
     * @param sequence
     *            the sequence
     * @return the result
     */
    public static synchronized Result get(Workunit workunit, Integer sequence)
    {
        Result result = new Result(workunit, sequence);
        if (Results.containsKey(result.hashCode()))
        {
            return Results.get(result.hashCode());
        }
        else
        {
            Results.put(result.hashCode(), result);
        }
        return result;
    }

    private Workunit  workunit;
    private ECLResult info;

    public enum Notification
    {
        RESULT
    }

    class ResultData
    {
        final int                       PAGE_SIZE   = 180;
        final int                       PAGE_BEFORE = 60;
        Map> data;

        /**
         * Instantiates a new result data.
         */
        ResultData()
        {
            data = new HashMap>();
        }

        /**
         * Gets the cell.
         *
         * @param row
         *            the row
         * @param col
         *            the col
         * @return the string
         */
        String GetCell(long row, int col)
        {
            if (data.containsKey(row))
            {
                return data.get(row).get(col);
            }

            Long start = row;
            for (int i = 0; i < PAGE_BEFORE; ++i)
            {
                if (start - 1 < 0)
                {
                    break;
                }

                if (data.containsKey(start - 1))
                {
                    break;
                }

                --start;
            }

            int count = (int) (row - start);
            for (int i = count; i < PAGE_SIZE; ++i)
            {
                if (data.containsKey(start + count))
                {
                    break;
                }
                ++count;
            }

            HPCCWsWorkUnitsClient wsWorkunitsClient;
            try
            {
                wsWorkunitsClient = workunit.getPlatform().getWsClient().getWsWorkunitsClient();
                WUResultResponse response = wsWorkunitsClient.fetchRawResults(workunit.getWuid(), true, info.getSequence(), null, true, start, count);

                String resultString = response.getResult();

                if (resultString != null && !resultString.isEmpty())
                {
                    //Rodrigo: this is using the migrated parser...
                    //I'm more inclined to use Utils.parseECLResults
                    int offset = resultString.indexOf("




© 2015 - 2024 Weber Informatics LLC | Privacy Policy