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);
}
}
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;
}
}
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);
}
}
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());
}
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);
}
}
Aggregations