Search in sources :

Example 31 with DataServiceMeta

use of org.pentaho.di.trans.dataservice.DataServiceMeta in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceStepHandler method newDataService.

public void newDataService() {
    DataServiceMeta dataServiceByStepName = delegate.getDataServiceByStepName(getActiveTrans(), getCurrentStep().getName());
    if (dataServiceByStepName != null && !dataServiceByStepName.isUserDefined()) {
        delegate.removeDataService(dataServiceByStepName);
    }
    delegate.createNewDataService(getCurrentStep().getName());
}
Also used : DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta)

Example 32 with DataServiceMeta

use of org.pentaho.di.trans.dataservice.DataServiceMeta in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceStepDeleteExtensionPointPlugin method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
    if (object != null && object instanceof StepMeta[]) {
        StepMeta[] stepsToBeRemoved = (StepMeta[]) object;
        TransMeta trans = stepsToBeRemoved[0].getParentTransMeta();
        List<String> stepsToBeRemovedNames = new ArrayList<>(stepsToBeRemoved.length);
        for (StepMeta step : stepsToBeRemoved) {
            stepsToBeRemovedNames.add(step.getName());
        }
        List<String> transSteps = Arrays.asList(trans.getStepNames());
        List<String> remainingStepNames = ListUtils.subtract(transSteps, stepsToBeRemovedNames);
        for (StepMeta stepToBeRemoved : stepsToBeRemoved) {
            DataServiceMeta dataService = dataServiceDelegate.getDataServiceByStepName(stepToBeRemoved.getParentTransMeta(), stepToBeRemoved.getName());
            if (dataService != null) {
                List<String> dataServiceSteps = new ArrayList<>();
                for (DataServiceMeta ds : dataServiceDelegate.getDataServices(stepToBeRemoved.getParentTransMeta())) {
                    dataServiceSteps.add(ds.getStepname());
                }
                switch(dataServiceDelegate.showRemapConfirmationDialog(dataService, ListUtils.subtract(remainingStepNames, dataServiceSteps))) {
                    case CANCEL:
                        throw new KettleException("Steps deletion cancelled by user");
                    case REMAP:
                        if (dataServiceDelegate.showRemapStepChooserDialog(dataService, ListUtils.subtract(remainingStepNames, dataServiceSteps), trans) == DataServiceRemapStepChooserDialog.Action.CANCEL) {
                            throw new KettleException("Steps deletion cancelled by user");
                        }
                        break;
                    case DELETE:
                        context.getDataServiceDelegate().removeDataService(dataService);
                        break;
                }
            }
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) TransMeta(org.pentaho.di.trans.TransMeta) ArrayList(java.util.ArrayList) StepMeta(org.pentaho.di.trans.step.StepMeta)

Example 33 with DataServiceMeta

use of org.pentaho.di.trans.dataservice.DataServiceMeta in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceTreeDelegateExtension method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface log, Object extension) throws KettleException {
    SpoonTreeDelegateExtension treeDelExt = (SpoonTreeDelegateExtension) extension;
    int caseNumber = treeDelExt.getCaseNumber();
    if (!(treeDelExt.getTransMeta() instanceof TransMeta)) {
        return;
    }
    TransMeta transMeta = (TransMeta) treeDelExt.getTransMeta();
    String[] path = treeDelExt.getPath();
    List<TreeSelection> objects = treeDelExt.getObjects();
    TreeSelection object = null;
    if (path[2].equals(STRING_DATA_SERVICES)) {
        switch(caseNumber) {
            case 3:
                object = new TreeSelection(path[2], DataServiceMeta.class, transMeta);
                break;
            case 4:
                try {
                    DataServiceMeta dataService = metaStoreUtil.getDataService(path[3], transMeta);
                    object = new TreeSelection(path[3], dataService, transMeta);
                } catch (Exception e) {
                // Do Nothing
                }
                break;
        }
    }
    if (object != null) {
        objects.add(object);
    }
}
Also used : DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) TreeSelection(org.pentaho.di.ui.spoon.TreeSelection) SpoonTreeDelegateExtension(org.pentaho.di.ui.spoon.delegates.SpoonTreeDelegateExtension) TransMeta(org.pentaho.di.trans.TransMeta) ExtensionPoint(org.pentaho.di.core.extension.ExtensionPoint) KettleException(org.pentaho.di.core.exception.KettleException)

Example 34 with DataServiceMeta

use of org.pentaho.di.trans.dataservice.DataServiceMeta in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceModel method getDataService.

public DataServiceMeta getDataService() {
    DataServiceMeta dataService = new DataServiceMeta(transMeta);
    dataService.setName(getServiceName());
    dataService.setPushDownOptimizationMeta(getPushDownOptimizations());
    dataService.setStepname(getServiceStep());
    dataService.setStreaming(isStreaming());
    dataService.setRowLimit(serviceMaxRows);
    dataService.setTimeLimit(serviceMaxTime);
    for (PushDownOptimizationMeta pushDownOptimization : pushDownOptimizations) {
        pushDownOptimization.getType().init(transMeta, dataService, pushDownOptimization);
    }
    return dataService;
}
Also used : DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)

Example 35 with DataServiceMeta

use of org.pentaho.di.trans.dataservice.DataServiceMeta in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceMetaStoreUtil method checkConflict.

public DataServiceMeta checkConflict(DataServiceMeta dataServiceMeta, String ignored) throws MetaStoreException, DataServiceAlreadyExistsException {
    TransMeta serviceTrans = dataServiceMeta.getServiceTrans();
    // Ensure this output step does not already have a data service
    DataServiceMeta stepConflict = getDataServiceByStepName(serviceTrans, dataServiceMeta.getStepname());
    if (stepConflict != null && !stepConflict.getName().equals(ignored)) {
        throw new DataServiceAlreadyExistsException(dataServiceMeta, getString(PKG, "Messages.SaveError.StepConflict", stepConflict.getStepname(), stepConflict.getName()));
    }
    String name = dataServiceMeta.getName();
    // If name hasn't changed, look no further
    if (name.equals(ignored)) {
        return dataServiceMeta;
    }
    // Scan local trans and meta store for conflict
    if (getDataServiceNames(serviceTrans).contains(name)) {
        throw new DataServiceAlreadyExistsException(dataServiceMeta);
    }
    // Scan MetaStore for conflict
    if (getServiceTransMap(serviceTrans).containsKey(name)) {
        throw new DataServiceAlreadyExistsException(dataServiceMeta);
    }
    return dataServiceMeta;
}
Also used : DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) TransMeta(org.pentaho.di.trans.TransMeta) BaseMessages.getString(org.pentaho.di.i18n.BaseMessages.getString)

Aggregations

DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)52 Test (org.junit.Test)29 TransMeta (org.pentaho.di.trans.TransMeta)16 PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)9 KettleException (org.pentaho.di.core.exception.KettleException)8 DataServiceContext (org.pentaho.di.trans.dataservice.DataServiceContext)6 DataServiceDelegate (org.pentaho.di.trans.dataservice.ui.DataServiceDelegate)6 StepMeta (org.pentaho.di.trans.step.StepMeta)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 Before (org.junit.Before)4 RowMeta (org.pentaho.di.core.row.RowMeta)4 DataServiceResolver (org.pentaho.di.trans.dataservice.resolvers.DataServiceResolver)4 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)4 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)4 MetastoreLocator (org.pentaho.osgi.metastore.locator.api.MetastoreLocator)4 ModelAnnotationGroup (org.pentaho.agilebi.modeler.models.annotations.ModelAnnotationGroup)3 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)3 File (java.io.File)2 IOException (java.io.IOException)2 URL (java.net.URL)2