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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations