Search in sources :

Example 1 with TDQSourceFileItem

use of org.talend.dataquality.properties.TDQSourceFileItem in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method createRealSourceFileNode.

public static SourceFileRepNode createRealSourceFileNode(String name, RepositoryNode parentNode, IPath createPath, Boolean isDelete) {
    SourceFileRepNode fileRepNode = null;
    TDQSourceFileItem sourceFileItem = PropertiesFactoryImpl.eINSTANCE.createTDQSourceFileItem();
    org.talend.core.model.properties.Property fileProperty = PropertiesFactory.eINSTANCE.createProperty();
    fileProperty.setId(EcoreUtil.generateUUID());
    fileProperty.setItem(sourceFileItem);
    fileProperty.setLabel(name);
    sourceFileItem.setProperty(fileProperty);
    sourceFileItem.setFilename(name);
    sourceFileItem.setName(name);
    ByteArray byteArray = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createByteArray();
    byteArray.setInnerContent(PluginConstant.EMPTY_STRING.getBytes());
    sourceFileItem.setContent(byteArray);
    ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(isDelete);
    sourceFileItem.setState(itemState);
    try {
        ProxyRepositoryFactory.getInstance().create(sourceFileItem, createPath, false);
        IRepositoryViewObject fileViewObject = new RepositoryViewObject(fileProperty);
        fileRepNode = new SourceFileRepNode(fileViewObject, parentNode, ENodeType.REPOSITORY_ELEMENT, null);
        fileRepNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
        fileRepNode.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
        fileViewObject.setRepositoryNode(fileRepNode);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    return fileRepNode;
}
Also used : TDQSourceFileItem(org.talend.dataquality.properties.TDQSourceFileItem) ItemState(org.talend.core.model.properties.ItemState) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ByteArray(org.talend.core.model.properties.ByteArray) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) Property(org.talend.core.model.properties.Property) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 2 with TDQSourceFileItem

use of org.talend.dataquality.properties.TDQSourceFileItem in project tdq-studio-se by Talend.

the class DQStructureManager method createSourceFileItem.

/**
 * DOC qiongli Comment method "createSourceFileItem".
 *
 * @param content:cotanin sql sentence
 * @param path
 * @param label:file name
 * @param extension:file extension
 * @return
 */
public TDQSourceFileItem createSourceFileItem(String content, IPath path, String label, String extension) {
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    property.setVersion(VersionUtils.DEFAULT_VERSION);
    property.setStatusCode(PluginConstant.EMPTY_STRING);
    property.setLabel(label);
    TDQSourceFileItem sourceFileItem = org.talend.dataquality.properties.PropertiesFactory.eINSTANCE.createTDQSourceFileItem();
    sourceFileItem.setProperty(property);
    sourceFileItem.setName(label);
    sourceFileItem.setExtension(extension);
    ByteArray byteArray = PropertiesFactory.eINSTANCE.createByteArray();
    // MOD sizhaoliu 2012-04-02 for TDQ-5070 Encoding issue with saving generated sql query action
    // $NON-NLS-1$
    byteArray.setInnerContent(content.getBytes(Charset.forName("UTF-8")));
    sourceFileItem.setContent(byteArray);
    IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
    try {
        property.setId(repositoryFactory.getNextId());
        repositoryFactory.create(sourceFileItem, path);
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    return sourceFileItem;
}
Also used : TDQSourceFileItem(org.talend.dataquality.properties.TDQSourceFileItem) PersistenceException(org.talend.commons.exception.PersistenceException) ByteArray(org.talend.core.model.properties.ByteArray) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 3 with TDQSourceFileItem

use of org.talend.dataquality.properties.TDQSourceFileItem in project tdq-studio-se by Talend.

the class DQStructureManager method createSourceFileItem.

public TDQSourceFileItem createSourceFileItem(File initFile, IPath path, String label, String extension) {
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    property.setVersion(VersionUtils.DEFAULT_VERSION);
    property.setStatusCode(PluginConstant.EMPTY_STRING);
    property.setLabel(label);
    TDQSourceFileItem sourceFileItem = org.talend.dataquality.properties.PropertiesFactory.eINSTANCE.createTDQSourceFileItem();
    sourceFileItem.setProperty(property);
    sourceFileItem.setName(label);
    sourceFileItem.setExtension(extension);
    ByteArray byteArray = PropertiesFactory.eINSTANCE.createByteArray();
    try {
        byteArray.setInnerContentFromFile(initFile);
    } catch (IOException e) {
        ExceptionHandler.process(e);
    }
    sourceFileItem.setContent(byteArray);
    String sqlFileName = // $NON-NLS-1$ //$NON-NLS-2$
    property.getLabel() + "_" + property.getVersion() + "." + extension;
    IFile file = ResourceManager.getSourceFileFolder().getFile(path.append(new Path(sqlFileName)));
    if (file == null || !file.exists()) {
        IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
        try {
            property.setId(repositoryFactory.getNextId());
            repositoryFactory.create(sourceFileItem, path);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
    return sourceFileItem;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) TDQSourceFileItem(org.talend.dataquality.properties.TDQSourceFileItem) PersistenceException(org.talend.commons.exception.PersistenceException) ByteArray(org.talend.core.model.properties.ByteArray) IOException(java.io.IOException) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 4 with TDQSourceFileItem

use of org.talend.dataquality.properties.TDQSourceFileItem in project tdq-studio-se by Talend.

the class SqlSourceFileUpdateTask method initItem.

private Item initItem(File srcFile) throws IOException {
    TDQSourceFileItem item = org.talend.dataquality.properties.PropertiesFactory.eINSTANCE.createTDQSourceFileItem();
    item.setExtension(FileUtils.getExtension(srcFile));
    item.setName(FileUtils.getName(srcFile));
    ByteArray byteArray = PropertiesFactory.eINSTANCE.createByteArray();
    byteArray.setInnerContentFromFile(srcFile);
    item.setContent(byteArray);
    ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(false);
    IPath rootPath = getWorkspacePath().append(TDQ_SOURCE_FILE_PATH);
    IPath folderPath = new Path(srcFile.getAbsolutePath()).removeLastSegments(1);
    IPath itemStatePath = folderPath.makeRelativeTo(rootPath);
    itemState.setPath(itemStatePath.toString());
    item.setState(itemState);
    return item;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) TDQSourceFileItem(org.talend.dataquality.properties.TDQSourceFileItem) ItemState(org.talend.core.model.properties.ItemState) ByteArray(org.talend.core.model.properties.ByteArray)

Example 5 with TDQSourceFileItem

use of org.talend.dataquality.properties.TDQSourceFileItem in project tdq-studio-se by Talend.

the class DependenciesHandler method getClintDependency.

/**
 * @param property
 * @return SupplierDependency
 *
 * getClintDependency
 */
public List<Property> getClintDependency(Property property) {
    List<Property> listProperty = new ArrayList<Property>();
    if (property == null) {
        return listProperty;
    }
    ModelElement modelElement = PropertyHelper.getModelElement(property);
    // MOD qiongli 2012-5-15 TDQ-5259,avoid NPE.
    if (modelElement == null) {
        return listProperty;
    }
    if (property.getItem() instanceof TDQSourceFileItem) {
        return listProperty;
    }
    EList<Dependency> clientDependency = modelElement.getClientDependency();
    for (Dependency clienter : clientDependency) {
        for (ModelElement depencyModelElement : clienter.getSupplier()) {
            Property dependencyProperty = PropertyHelper.getProperty(depencyModelElement);
            // IRepositoryViewObject repositoryViewObject = new RepositoryViewObject(property);
            if (dependencyProperty != null) {
                listProperty.add(dependencyProperty);
            }
        }
    }
    return listProperty;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TDQSourceFileItem(org.talend.dataquality.properties.TDQSourceFileItem) ArrayList(java.util.ArrayList) Dependency(orgomg.cwm.objectmodel.core.Dependency) Property(org.talend.core.model.properties.Property)

Aggregations

TDQSourceFileItem (org.talend.dataquality.properties.TDQSourceFileItem)5 ByteArray (org.talend.core.model.properties.ByteArray)4 Property (org.talend.core.model.properties.Property)4 PersistenceException (org.talend.commons.exception.PersistenceException)3 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 ItemState (org.talend.core.model.properties.ItemState)2 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 IFile (org.eclipse.core.resources.IFile)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 RepositoryViewObject (org.talend.core.model.repository.RepositoryViewObject)1 SourceFileRepNode (org.talend.dq.nodes.SourceFileRepNode)1 Dependency (orgomg.cwm.objectmodel.core.Dependency)1 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)1