use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class GenericRepository method storeProperties.
@Override
public String storeProperties(ComponentProperties properties, String name, String repositoryLocation, String schemaPropertyName) {
if (properties == null) {
//$NON-NLS-1$
throw new RuntimeException("Properties argument cannot be null!");
}
// Add repository value if it is from repository
List<org.talend.daikon.properties.property.Property> propertyValues = ComponentsUtils.getAllValuedProperties(properties);
for (org.talend.daikon.properties.property.Property property : propertyValues) {
property.setTaggedValue(IGenericConstants.REPOSITORY_VALUE, property.getName());
}
String serializedProperties = properties.toSerialized();
if (repositoryLocation.contains(IGenericConstants.REPOSITORY_LOCATION_SEPARATOR)) {
// nested properties to be
GenericConnectionItem item = getGenericConnectionItem(repositoryLocation.substring(0, repositoryLocation.indexOf(IGenericConstants.REPOSITORY_LOCATION_SEPARATOR)));
if (item == null) {
//$NON-NLS-1$
throw new RuntimeException("Failed to find the GenericConnectionItem for location:" + repositoryLocation);
}
GenericConnection connection = (GenericConnection) item.getConnection();
orgomg.cwm.objectmodel.core.Package parentContainer = null;
if (repositoryLocation.endsWith(IGenericConstants.REPOSITORY_LOCATION_SEPARATOR)) {
// first nested property
parentContainer = connection;
} else {
parentContainer = getContainer(connection, repositoryLocation);
}
ModelElement childElement = null;
if (schemaPropertyName == null) {
// If schema property name is not provided, then create the subcontainer.
childElement = createContainer(name, serializedProperties);
} else {
// Remove Repository Value tag value for schema property.
org.talend.daikon.properties.property.Property<?> schemaProperty = properties.getValuedProperty(schemaPropertyName);
if (schemaProperty != null) {
schemaProperty.setTaggedValue(IGenericConstants.REPOSITORY_VALUE, null);
}
childElement = SchemaUtils.createSchema(name, properties, schemaPropertyName);
}
parentContainer.getOwnedElement().add(childElement);
return repositoryLocation + IGenericConstants.REPOSITORY_LOCATION_SEPARATOR + name;
} else {
// simple properties to be set
GenericConnectionItem item = getGenericConnectionItem(repositoryLocation);
if (item != null) {
GenericConnection connection = (GenericConnection) item.getConnection();
connection.setCompProperties(serializedProperties);
connection.getOwnedElement().clear();
return repositoryLocation + IGenericConstants.REPOSITORY_LOCATION_SEPARATOR;
} else {
//$NON-NLS-1$
throw new RuntimeException("Failed to find the GenericConnectionItem for location:" + repositoryLocation);
}
}
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class TalendImportUtil method openJobs.
private static void openJobs(List<IRepositoryNode> nodes) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
for (IRepositoryNode node : nodes) {
Property property = node.getObject().getProperty();
if (property != null) {
Item item = property.getItem();
if (!(item instanceof ProcessItem)) {
continue;
}
try {
ProcessItem processItem = (ProcessItem) item;
final JobEditorInput fileEditorInput = getEditorInput(processItem);
// checkUnLoadedNodeForProcess(fileEditorInput);
final IEditorPart editorPart = page.findEditor(fileEditorInput);
if (editorPart == null) {
fileEditorInput.setRepositoryNode(node);
page.openEditor(fileEditorInput, getEditorId(), true);
} else {
((AbstractMultiPageTalendEditor) editorPart).setReadOnly(fileEditorInput.setForceReadOnly(false));
page.activate(editorPart);
}
} catch (Throwable e) {
CommonExceptionHandler.process(e);
}
}
}
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class NewGenericWizardMigrationTask method updateComponentProperties.
protected boolean updateComponentProperties(Connection oldConnection, ComponentProperties componentProperties, Properties props) {
boolean modified = false;
if (props != null) {
for (Object element : props.keySet()) {
boolean changed = false;
String propsKey = (String) element;
String propsValue = props.getProperty(propsKey);
if (propsValue != null && !"".equals(propsValue.trim())) {
//$NON-NLS-1$
Object value = getValueFromOldConnection(oldConnection, propsValue);
if (value != null) {
NamedThing namedThing = componentProperties.getProperty(propsKey);
if (namedThing != null && namedThing instanceof org.talend.daikon.properties.property.Property) {
org.talend.daikon.properties.property.Property<?> property = (org.talend.daikon.properties.property.Property<?>) namedThing;
if (GenericTypeUtils.isEnumType(property)) {
//$NON-NLS-1$
Object obj = props.get(propsKey + "." + value);
if (obj != null) {
List<?> propertyPossibleValues = property.getPossibleValues();
Object newValue = null;
if (propertyPossibleValues != null) {
for (Object possibleValue : propertyPossibleValues) {
if (possibleValue.toString().equals(obj)) {
newValue = possibleValue;
break;
}
}
}
if (newValue == null) {
// set default value
newValue = propertyPossibleValues.get(0);
}
componentProperties.setValue(propsKey, newValue);
property.setTaggedValue(IGenericConstants.REPOSITORY_VALUE, property.getName());
changed = true;
}
}
if (GenericTypeUtils.isBooleanType(property)) {
if (value != null && value instanceof String) {
try {
value = new Boolean((String) value);
} catch (Exception e) {
value = Boolean.FALSE;
}
}
}
if (GenericTypeUtils.isIntegerType(property) && !oldConnection.isContextMode()) {
if (value != null && value instanceof String) {
try {
value = new Integer((String) value);
} catch (Exception e) {
value = 0;
}
}
}
if (property.isFlag(org.talend.daikon.properties.property.Property.Flags.ENCRYPT) && !oldConnection.isContextMode()) {
componentProperties.setValue(propsKey, CryptoHelper.getDefault().decrypt(String.valueOf(value)));
property.setTaggedValue(IGenericConstants.REPOSITORY_VALUE, property.getName());
modified = true;
changed = true;
}
if (!changed) {
property.setStoredValue(value);
property.setTaggedValue(IGenericConstants.REPOSITORY_VALUE, property.getName());
modified = true;
}
}
}
}
}
}
return modified;
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class NewGenericWizardMigrationTask method initProperty.
protected Property initProperty(ConnectionItem oldConnectionItem, ConnectionItem newConnectionItem) {
if (oldConnectionItem == null || newConnectionItem == null) {
return null;
}
Property oldProperty = oldConnectionItem.getProperty();
Property newProperty = PropertiesFactory.eINSTANCE.createProperty();
newProperty.setId(oldProperty.getId());
newProperty.setLabel(oldProperty.getLabel());
newProperty.setDisplayName(oldProperty.getDisplayName());
newProperty.setDescription(oldProperty.getDescription());
newProperty.setAuthor(oldProperty.getAuthor());
newProperty.setCreationDate(oldProperty.getCreationDate());
newProperty.setMaxInformationLevel(oldProperty.getMaxInformationLevel());
newProperty.setModificationDate(oldProperty.getModificationDate());
newProperty.setOldStatusCode(oldProperty.getOldStatusCode());
newProperty.setPurpose(oldProperty.getPurpose());
newProperty.setStatusCode(oldProperty.getStatusCode());
newProperty.setVersion(oldProperty.getVersion());
newProperty.setItem(newConnectionItem);
newConnectionItem.setProperty(newProperty);
return newProperty;
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class GenericConnPropertiesWizard method performFinish.
@Override
public boolean performFinish() {
boolean done = super.performFinish();
if (done) {
Property property = object.getProperty();
GenericConnectionItem gcItem = (GenericConnectionItem) property.getItem();
boolean itemChanged = GenericConnectionUtil.synNamePropertyWithItem(gcItem);
if (itemChanged) {
try {
ProxyRepositoryFactory.getInstance().save(gcItem);
} catch (PersistenceException e) {
done = false;
ExceptionHandler.process(e);
}
}
}
return done;
}
Aggregations