Package org.zanata.async

Examples of org.zanata.async.AsyncTaskHandle


        return this.getProcessStatus(taskId.toString());
    }

    @Override
    public ProcessStatus getProcessStatus(String processId) {
        AsyncTaskHandle handle =
                asyncTaskHandleManager.getHandleByKey(processId);

        if (handle == null) {
            throw new NotFoundException("A process was not found for id "
                    + processId);
        }

        ProcessStatus status = new ProcessStatus();
        status.setStatusCode(handle.isDone() ? ProcessStatusCode.Finished
                : ProcessStatusCode.Running);
        int perComplete = 100;
        if (handle.getMaxProgress() > 0) {
            perComplete =
                    (handle.getCurrentProgress() * 100 / handle
                            .getMaxProgress());
        }
        status.setPercentageComplete(perComplete);
        status.setUrl("" + processId);

        if (handle.isDone()) {
            Object result = null;
            try {
                result = handle.getResult();
            } catch (InterruptedException e) {
                // The process was forcefully cancelled
                status.setStatusCode(ProcessStatusCode.Failed);
                status.setMessages(Lists.newArrayList(e.getMessage()));
            } catch (ExecutionException e) {
View Full Code Here


        return true;
    }

    public void clearTransMemory(final String transMemorySlug) {
        String name = "TranslationMemoryAction.clearTransMemory: "+transMemorySlug;
        AsyncTaskHandle handle = new AsyncTaskHandle();
        asyncTaskHandleManager.registerTaskHandle(handle,
                new ClearTransMemoryProcessKey(transMemorySlug));
        translationMemoryResource
                .deleteTranslationUnitsUnguardedAsync(transMemorySlug, handle);
        transMemoryList = null; // Force refresh next time list is requested
View Full Code Here

TOP

Related Classes of org.zanata.async.AsyncTaskHandle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.