package model.builder.core

import model.builder.web.api.APIManager
import org.cytoscape.model.CyNetwork
import org.cytoscape.task.NetworkTaskFactory
import org.cytoscape.work.TaskIterator
import org.openbel.kamnav.core.AddBelColumnsToCurrentFactory

class ImportRevisionFromMenuFactory implements NetworkTaskFactory {

    final APIManager apiManager
    final Expando cyRef
    final AddBelColumnsToCurrentFactory belFac

    ImportRevisionFromMenuFactory(APIManager apiManager, Expando cyRef,
                                  AddBelColumnsToCurrentFactory belFac) {
        this.apiManager = apiManager
        this.cyRef = cyRef
        this.belFac = belFac
    }

    @Override
    TaskIterator createTaskIterator(CyNetwork cyN) {
        TaskIterator tasks = new TaskIterator(
            new CreateCyNetworkForModelRevisionTunable(cyN, apiManager, cyRef))
        tasks.append(belFac.createTaskIterator())
        tasks
    }

    @Override
    boolean isReady(CyNetwork cyN) {
        def mgr = cyRef.cyTableManager
        cyN && mgr.globalTables?.any{it.title == 'SDP.Revisions'}
    }
}

package model.builder.core

import groovy.transform.TupleConstructor
import model.builder.web.api.APIManager
import model.builder.web.api.AuthorizedAPI
import org.cytoscape.model.CyNetwork
import org.cytoscape.task.NetworkTaskFactory
import org.cytoscape.work.TaskIterator
import org.openbel.kamnav.core.AddBelColumnsToCurrentFactory

@TupleConstructor
class ImportRevisionFromMenuFactory implements NetworkTaskFactory {

    final APIManager apiManager
    final Expando cyRef
    final AddBelColumnsToCurrentFactory addBelFac

    @Override
    TaskIterator createTaskIterator(CyNetwork cyN) {
        TaskIterator tasks = new TaskIterator(
            new CreateCyNetworkForModelRevisionTunable(cyN, apiManager, cyRef))
        tasks.append(addBelFac.createTaskIterator())
        tasks
    }

    @Override
    boolean isReady(CyNetwork cyN) {
        def mgr = cyRef.cyTableManager
        cyN && mgr.globalTables?.any{it.title == 'SDP.Revisions'}
    }
}

Revert "replaced TupleConstructor with java style constructor"
Revert "replaced TupleConstructor with java style constructor"

This reverts commit eb271099c4cba7ac3ec6d632edf52f50b0687b61.
