/* (non-Javadoc) * @see org.pentaho.di.trans.step.StepAttributesInterface#findAttribute(java.lang.String) */ public KettleAttributeInterface findAttribute(String key) { for (KettleAttributeInterface attribute : attributes) { if (attribute.getKey().equals(key)) { return attribute; } } return null; }
/* (non-Javadoc) * @see org.pentaho.di.trans.step.StepAttributesInterface#findParent(java.util.List, java.lang.String) */ public KettleAttributeInterface findParent( List<KettleAttributeInterface> attributes, String parentId) { if (Const.isEmpty(parentId)) { return null; } for (KettleAttributeInterface attribute : attributes) { if (attribute.getKey().equals(parentId)) { return attribute; } } return null; }
/** Describe the metadata attributes that can be injected into this step metadata object. */ public List<StepInjectionMetaEntry> getStepInjectionMetadataEntries(Class<?> PKG) { List<StepInjectionMetaEntry> entries = new ArrayList<StepInjectionMetaEntry>(); for (KettleAttributeInterface attr : attributes) { if (attr.getParent() == null) { entries.add(createEntry(attr, PKG)); } else { StepInjectionMetaEntry entry = createEntry(attr, PKG); StepInjectionMetaEntry parentEntry = findParentEntry(entries, attr.getParent().getKey()); if (parentEntry == null) { throw new RuntimeException( "An error was detected in the step attributes' definition: the parent was not found for attribute " + attr); } parentEntry.getDetails().add(entry); } } return entries; }
/* (non-Javadoc) * @see org.pentaho.di.trans.step.StepAttributesInterface#getRepCode(java.lang.String) */ public String getRepCode(String attributeKey) { KettleAttributeInterface attr = findAttribute(attributeKey); return Const.isEmpty(attr.getRepCode()) ? attr.getXmlCode() : attr.getRepCode(); }
/** * Creates the entry. * * @param attr the attr * @param PKG the pkg * @return the step injection meta entry */ protected StepInjectionMetaEntry createEntry(KettleAttributeInterface attr, Class<?> PKG) { return new StepInjectionMetaEntry( attr.getKey(), attr.getType(), BaseMessages.getString(PKG, attr.getDescription())); }
public void injectStepMetadataEntries(List<StepInjectionMetaEntry> metadata) { for (StepInjectionMetaEntry entry : metadata) { KettleAttributeInterface attr = findAttribute(entry.getKey()); // Set top level attributes... // if (entry.getValueType() != ValueMetaInterface.TYPE_NONE) { if (entry.getKey().equals("SCHEMA")) { schemaName = (String) entry.getValue(); } else if (entry.getKey().equals("TABLE")) { tableName = (String) entry.getValue(); } else if (entry.getKey().equals("LOADACTION")) { loadAction = (String) entry.getValue(); } else if (entry.getKey().equals("PSQLPATH")) { setPsqlpath((String) entry.getValue()); } else if (entry.getKey().equals("DBNAMEOVERRIDE")) { dbNameOverride = (String) entry.getValue(); } else if (entry.getKey().equals("ENCLOSURE")) { enclosure = (String) entry.getValue(); } else if (entry.getKey().equals("DELIMITER")) { delimiter = (String) entry.getValue(); } else if (entry.getKey().equals("STOPONERROR")) { stopOnError = (Boolean) entry.getValue(); } else { throw new RuntimeException( "Unhandled metadata injection of attribute: " + attr.toString() + " - " + attr.getDescription()); } } else { // The data sets... // if (attr.getKey().equals("MAPPINGS")) { List<StepInjectionMetaEntry> selectMappings = entry.getDetails(); fieldTable = new String[selectMappings.size()]; fieldStream = new String[selectMappings.size()]; dateMask = new String[selectMappings.size()]; for (int row = 0; row < selectMappings.size(); row++) { StepInjectionMetaEntry selectField = selectMappings.get(row); List<StepInjectionMetaEntry> fieldAttributes = selectField.getDetails(); // CHECKSTYLE:Indentation:OFF for (int i = 0; i < fieldAttributes.size(); i++) { StepInjectionMetaEntry fieldAttribute = fieldAttributes.get(i); KettleAttributeInterface fieldAttr = findAttribute(fieldAttribute.getKey()); String attributeValue = (String) fieldAttribute.getValue(); if (fieldAttr.getKey().equals("STREAMNAME")) { getFieldStream()[row] = attributeValue; } else if (fieldAttr.getKey().equals("FIELDNAME")) { getFieldTable()[row] = attributeValue; } else if (fieldAttr.getKey().equals("DATEMASK")) { getDateMask()[row] = attributeValue; } else { throw new RuntimeException( "Unhandled metadata injection of attribute: " + fieldAttr.toString() + " - " + fieldAttr.getDescription()); } } } } if (!Const.isEmpty(getFieldStream())) { for (int i = 0; i < getFieldStream().length; i++) { logDetailed( "row " + Integer.toString(i) + ": stream=" + getFieldStream()[i] + " : table=" + getFieldTable()[i]); } } } } }