Search in sources :

Example 26 with Point

use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryStepDelegate method loadStepMeta.

/**
 * Create a new step by loading the metadata from the specified repository.
 *
 * @param rep
 * @param stepId
 * @param databases
 * @param counters
 * @param partitionSchemas
 * @throws KettleException
 */
public StepMeta loadStepMeta(ObjectId stepId, List<DatabaseMeta> databases, List<PartitionSchema> partitionSchemas) throws KettleException {
    StepMeta stepMeta = new StepMeta();
    PluginRegistry registry = PluginRegistry.getInstance();
    try {
        RowMetaAndData r = getStep(stepId);
        if (r != null) {
            stepMeta.setObjectId(stepId);
            stepMeta.setName(r.getString(KettleDatabaseRepository.FIELD_STEP_NAME, null));
            stepMeta.setDescription(r.getString(KettleDatabaseRepository.FIELD_STEP_DESCRIPTION, null));
            long id_step_type = r.getInteger(KettleDatabaseRepository.FIELD_STEP_ID_STEP_TYPE, -1L);
            RowMetaAndData steptyperow = getStepType(new LongObjectId(id_step_type));
            stepMeta.setStepID(steptyperow.getString(KettleDatabaseRepository.FIELD_STEP_TYPE_CODE, null));
            stepMeta.setDistributes(r.getBoolean(KettleDatabaseRepository.FIELD_STEP_DISTRIBUTE, true));
            int copies = (int) r.getInteger(KettleDatabaseRepository.FIELD_STEP_COPIES, 1);
            String copiesString = r.getString(KettleDatabaseRepository.FIELD_STEP_COPIES_STRING, null);
            if (!Utils.isEmpty(copiesString)) {
                stepMeta.setCopiesString(copiesString);
            } else {
                stepMeta.setCopies(copies);
            }
            int x = (int) r.getInteger(KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_X, 0);
            int y = (int) r.getInteger(KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_Y, 0);
            stepMeta.setLocation(new Point(x, y));
            stepMeta.setDraw(r.getBoolean(KettleDatabaseRepository.FIELD_STEP_GUI_DRAW, false));
            // Generate the appropriate class...
            PluginInterface sp = registry.findPluginWithId(StepPluginType.class, stepMeta.getStepID());
            if (sp == null) {
                stepMeta.setStepMetaInterface(new MissingTrans(stepMeta.getName(), stepMeta.getStepID()));
            } else {
                stepMeta.setStepMetaInterface((StepMetaInterface) registry.loadClass(sp));
            }
            if (stepMeta.getStepMetaInterface() != null) {
                // Read the step info from the repository!
                readRepCompatibleStepMeta(stepMeta.getStepMetaInterface(), repository, stepMeta.getObjectId(), databases);
                stepMeta.getStepMetaInterface().readRep(repository, repository.metaStore, stepMeta.getObjectId(), databases);
            }
            // Get the partitioning as well...
            // 
            stepMeta.setStepPartitioningMeta(loadStepPartitioningMeta(stepMeta.getObjectId()));
            stepMeta.getStepPartitioningMeta().setPartitionSchemaAfterLoading(partitionSchemas);
            // Get the cluster schema name
            // 
            stepMeta.setClusterSchemaName(repository.getStepAttributeString(stepId, "cluster_schema"));
            // Are we using a custom row distribution plugin?
            // 
            String rowDistributionCode = repository.getStepAttributeString(stepId, 0, "row_distribution_code");
            RowDistributionInterface rowDistribution = PluginRegistry.getInstance().loadClass(RowDistributionPluginType.class, rowDistributionCode, RowDistributionInterface.class);
            stepMeta.setRowDistribution(rowDistribution);
            // Load the attribute groups map
            // 
            stepMeta.setAttributesMap(loadStepAttributesMap(stepId));
            // 
            return stepMeta;
        } else {
            throw new KettleException(BaseMessages.getString(PKG, "StepMeta.Exception.StepInfoCouldNotBeFound", String.valueOf(stepId)));
        }
    } catch (KettleDatabaseException dbe) {
        throw new KettleException(BaseMessages.getString(PKG, "StepMeta.Exception.StepCouldNotBeLoaded", String.valueOf(stepMeta.getObjectId())), dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) LongObjectId(org.pentaho.di.repository.LongObjectId) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Point(org.pentaho.di.core.gui.Point) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) MissingTrans(org.pentaho.di.trans.steps.missing.MissingTrans) RowDistributionInterface(org.pentaho.di.trans.step.RowDistributionInterface)

Example 27 with Point

use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.

the class TransAction method setPosition.

public void setPosition(Object[] obj, int[] idx, Point[] prev, Point[] curr) {
    if (prev.length != curr.length) {
        return;
    }
    previous_location = new Point[prev.length];
    current_location = new Point[curr.length];
    current = obj;
    current_index = idx;
    for (int i = 0; i < prev.length; i++) {
        previous_location[i] = new Point(prev[i].x, prev[i].y);
        current_location[i] = new Point(curr[i].x, curr[i].y);
    }
    Object fobj = obj[0];
    if (fobj instanceof StepMeta) {
        type = TYPE_ACTION_POSITION_STEP;
    }
    if (fobj instanceof NotePadMeta) {
        type = TYPE_ACTION_POSITION_NOTE;
    }
    if (fobj instanceof JobEntryCopy) {
        type = TYPE_ACTION_POSITION_JOB_ENTRY;
    }
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Point(org.pentaho.di.core.gui.Point) NotePadMeta(org.pentaho.di.core.NotePadMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point)

Example 28 with Point

use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.

the class MetricsPainter method drawTimeScaleLine.

void drawTimeScaleLine(int height, double pixelsPerMs, long periodInMs) {
    int log10 = (int) Math.log10(periodInMs) + 1;
    int timeLineDistance = (int) Math.pow(10, log10 - 1) / 2;
    int incrementUnit = Math.max(timeLineDistance, 1);
    for (int time = timeLineDistance; time <= periodInMs; time += incrementUnit) {
        int x = (int) (time * pixelsPerMs);
        getGc().setForeground(EColor.LIGHTGRAY);
        getGc().drawLine(x, 0, x, height);
        String marker = Integer.toString(time);
        Point point = getGc().textExtent(marker);
        getGc().setForeground(EColor.DARKGRAY);
        getGc().drawText(marker, x - (point.x / 2), 0, true);
    }
}
Also used : Point(org.pentaho.di.core.gui.Point) Point(org.pentaho.di.core.gui.Point)

Example 29 with Point

use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.

the class JobDelegateTest method testElementToDataNodeSavesCopyAttributes.

@Test
public void testElementToDataNodeSavesCopyAttributes() throws KettleException {
    JobMeta mockJobMeta = mock(JobMeta.class);
    IUnifiedRepository mockUnifiedRepository = mock(IUnifiedRepository.class);
    JobDelegate jobDelegate = new JobDelegate(mockPurRepository, mockUnifiedRepository);
    JobLogTable mockJobLogTable = mock(JobLogTable.class);
    JobEntryCopy mockJobEntryCopy = mock(JobEntryCopy.class);
    Map<String, Map<String, String>> attributes = new HashMap<String, Map<String, String>>();
    Map<String, String> group = new HashMap<String, String>();
    final String mockGroup = "MOCK_GROUP";
    final String mockProperty = "MOCK_PROPERTY";
    final String mockValue = "MOCK_VALUE";
    group.put(mockProperty, mockValue);
    attributes.put(mockGroup, group);
    when(mockJobEntryCopy.getAttributesMap()).thenReturn(attributes);
    JobEntryBaseAndInterface mockJobEntry = mock(JobEntryBaseAndInterface.class);
    when(mockJobMeta.listParameters()).thenReturn(new String[] {});
    when(mockJobMeta.getJobLogTable()).thenReturn(mockJobLogTable);
    when(mockJobMeta.nrJobEntries()).thenReturn(1);
    when(mockJobMeta.getJobEntry(0)).thenReturn(mockJobEntryCopy);
    when(mockJobEntryCopy.getName()).thenReturn("MOCK_NAME");
    when(mockJobEntryCopy.getLocation()).thenReturn(new Point(0, 0));
    when(mockJobEntryCopy.getEntry()).thenReturn(mockJobEntry);
    DataNode dataNode = jobDelegate.elementToDataNode(mockJobMeta);
    DataNode groups = dataNode.getNode("entries").getNodes().iterator().next().getNode(AttributesMapUtil.NODE_ATTRIBUTE_GROUPS);
    DataNode mockGroupNode = groups.getNode(mockGroup);
    assertEquals(mockValue, mockGroupNode.getProperty(mockProperty).getString());
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobLogTable(org.pentaho.di.core.logging.JobLogTable) HashMap(java.util.HashMap) Point(org.pentaho.di.core.gui.Point) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) HashMap(java.util.HashMap) Map(java.util.Map) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Test(org.junit.Test)

Example 30 with Point

use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.

the class StarModelPainter method drawCircleName.

private void drawCircleName(Point center, LogicalTable logicalTable) {
    String name = ConceptUtil.getName(logicalTable, locale);
    if (!Utils.isEmpty(name)) {
        Point nameSize = gc.textExtent(name);
        int margin = 20;
        nameSize.x += margin;
        nameSize.y += margin;
        EColor bg = EColor.BACKGROUND;
        TableType tableType = (TableType) logicalTable.getProperty(DefaultPropertyID.TABLE_TYPE.getId());
        if (tableType != null && TableType.FACT == tableType) {
            bg = EColor.LIGHTGRAY;
        }
        gc.setBackground(bg);
        gc.fillRoundRectangle(center.x - nameSize.x / 2, center.y - nameSize.y / 2, nameSize.x, nameSize.y, 20, 20);
        gc.drawRoundRectangle(center.x - nameSize.x / 2, center.y - nameSize.y / 2, nameSize.x, nameSize.y, 20, 20);
        gc.drawText(name, center.x - nameSize.x / 2 + margin / 2, center.y - nameSize.y / 2 + margin / 2, true);
        gc.setBackground(EColor.BACKGROUND);
    }
}
Also used : TableType(org.pentaho.metadata.model.concept.types.TableType) Point(org.pentaho.di.core.gui.Point) EColor(org.pentaho.di.core.gui.PrimitiveGCInterface.EColor) Point(org.pentaho.di.core.gui.Point)

Aggregations

Point (org.pentaho.di.core.gui.Point)141 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)72 Test (org.junit.Test)37 StepMeta (org.pentaho.di.trans.step.StepMeta)34 NotePadMeta (org.pentaho.di.core.NotePadMeta)29 KettleException (org.pentaho.di.core.exception.KettleException)28 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)28 PrintWriter (java.io.PrintWriter)26 HttpServletRequest (javax.servlet.http.HttpServletRequest)26 HttpServletResponse (javax.servlet.http.HttpServletResponse)26 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)26 TransMeta (org.pentaho.di.trans.TransMeta)25 StringWriter (java.io.StringWriter)24 AreaOwner (org.pentaho.di.core.gui.AreaOwner)22 Trans (org.pentaho.di.trans.Trans)18 JobMeta (org.pentaho.di.job.JobMeta)17 ArrayList (java.util.ArrayList)16 TransHopMeta (org.pentaho.di.trans.TransHopMeta)14 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)14 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)12