Search in sources :

Example 1 with JSONFileConnectionItem

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;
}
Also used : Item(org.talend.core.model.properties.Item) JSONFileConnectionItem(org.talend.repository.model.json.JSONFileConnectionItem) RepositoryComponentSetting(org.talend.core.repository.RepositoryComponentSetting) ArrayList(java.util.ArrayList) JSONFileConnectionItem(org.talend.repository.model.json.JSONFileConnectionItem)

Example 2 with JSONFileConnectionItem

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;
}
Also used : JSONFileConnection(org.talend.repository.model.json.JSONFileConnection) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) JSONFileConnection(org.talend.repository.model.json.JSONFileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) JSONFileConnectionItem(org.talend.repository.model.json.JSONFileConnectionItem)

Example 3 with JSONFileConnectionItem

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;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) Resource(org.eclipse.emf.ecore.resource.Resource) JSONFileConnectionItem(org.talend.repository.model.json.JSONFileConnectionItem)

Example 4 with JSONFileConnectionItem

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;
    }
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) JSONFileConnectionItem(org.talend.repository.model.json.JSONFileConnectionItem) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 5 with JSONFileConnectionItem

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;
}
Also used : IComponentsService(org.talend.core.model.components.IComponentsService) JSONFileConnection(org.talend.repository.model.json.JSONFileConnection) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) JSONFileConnectionItem(org.talend.repository.model.json.JSONFileConnectionItem)

Aggregations

JSONFileConnectionItem (org.talend.repository.model.json.JSONFileConnectionItem)6 JSONFileConnection (org.talend.repository.model.json.JSONFileConnection)3 ArrayList (java.util.ArrayList)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)2 EClass (org.eclipse.emf.ecore.EClass)1 IComponent (org.talend.core.model.components.IComponent)1 IComponentsService (org.talend.core.model.components.IComponentsService)1 Connection (org.talend.core.model.metadata.builder.connection.Connection)1 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 Item (org.talend.core.model.properties.Item)1 RepositoryComponentSetting (org.talend.core.repository.RepositoryComponentSetting)1 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)1 RecordFile (orgomg.cwm.resource.record.RecordFile)1