use of org.talend.repository.model.json.JSONFileConnectionItem in project tdi-studio-se by Talend.
the class JSONDragAndDropHandler method getCorrespondingComponentName.
@Override
public IComponentName getCorrespondingComponentName(Item item, ERepositoryObjectType type) {
RepositoryComponentSetting setting = null;
if (item instanceof JSONFileConnectionItem) {
setting = new RepositoryComponentSetting();
setting.setName(JSON);
setting.setRepositoryType(JSON);
setting.setWithSchema(true);
setting.setInputComponent(INPUT);
setting.setOutputComponent(OUTPUT);
List<Class<Item>> list = new ArrayList<Class<Item>>();
Class clazz = null;
try {
clazz = Class.forName(JSONFileConnectionItem.class.getName());
} catch (ClassNotFoundException e) {
ExceptionHandler.process(e);
}
list.add(clazz);
setting.setClasses(list.toArray(new Class[0]));
}
return setting;
}
use of org.talend.repository.model.json.JSONFileConnectionItem in project tdi-studio-se by Talend.
the class JsonPathMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
boolean modified = false;
if (item instanceof JSONFileConnectionItem) {
Connection conn = ((JSONFileConnectionItem) item).getConnection();
if (conn instanceof JSONFileConnection) {
((JSONFileConnection) conn).setReadbyMode(EJsonReadbyMode.XPATH.getValue());
modified = true;
}
}
try {
if (modified) {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.repository.model.json.JSONFileConnectionItem in project tdi-studio-se by Talend.
the class JSONRepositoryContentHandler method save.
@Override
public Resource save(Item item) throws PersistenceException {
Resource itemResource = null;
EClass eClass = item.eClass();
if (eClass.eContainer() == JsonPackage.eINSTANCE) {
switch(eClass.getClassifierID()) {
case JsonPackage.JSON_FILE_CONNECTION_ITEM:
itemResource = save((JSONFileConnectionItem) item);
return itemResource;
default:
return null;
}
}
return null;
}
use of org.talend.repository.model.json.JSONFileConnectionItem in project tdi-studio-se by Talend.
the class JSONRepositoryContentHandler method create.
@Override
public Resource create(IProject project, Item item, int classifierID, IPath path) throws PersistenceException {
Resource itemResource = null;
ERepositoryObjectType type;
switch(classifierID) {
case JsonPackage.JSON_FILE_CONNECTION_ITEM:
if (item != null && item instanceof JSONFileConnectionItem) {
type = JSONRepositoryNodeType.JSON;
itemResource = create(project, (JSONFileConnectionItem) item, path, type);
return itemResource;
}
default:
return itemResource;
}
}
use of org.talend.repository.model.json.JSONFileConnectionItem in project tdi-studio-se by Talend.
the class JSONDragAndDropHandler method filterNeededComponents.
@Override
public List<IComponent> filterNeededComponents(Item item, RepositoryNode seletetedNode, ERepositoryObjectType type) {
List<IComponent> neededComponents = new ArrayList<IComponent>();
if (!(item instanceof JSONFileConnectionItem)) {
return neededComponents;
}
IComponentsService service = (IComponentsService) GlobalServiceRegister.getDefault().getService(IComponentsService.class);
Set<IComponent> components = service.getComponentsFactory().getComponents();
JSONFileConnection connection = (JSONFileConnection) ((JSONFileConnectionItem) item).getConnection();
for (IComponent component : components) {
if (!connection.isInputModel()) {
if (isValid(item, type, seletetedNode, component, "JSONOUTPUT") && !neededComponents.contains(component)) {
neededComponents.add(component);
}
} else {
if (isValid(item, type, seletetedNode, component, JSON) && !neededComponents.contains(component)) {
neededComponents.add(component);
}
}
}
// type);
return neededComponents;
}
Aggregations