Search in sources :

Example 6 with AElementPersistance

use of org.talend.dq.writer.AElementPersistance in project tdq-studio-se by Talend.

the class UpdatePropertiesFileTask method saveObject.

private void saveObject(EMFUtil emfUtil, File file, URI uri, EObject eObject) {
    ModelElement modelElement = (ModelElement) eObject;
    AElementPersistance writer = ElementWriterFactory.getInstance().create(modelElement);
    Property oldPropery = PropertyHelper.getProperty(modelElement);
    if (writer != null) {
        Property property = writer.initProperty(modelElement);
        if (oldPropery != null) {
            property.setId(oldPropery.getId());
            property.setAuthor(oldPropery.getAuthor());
            property.getItem().setState(oldPropery.getItem().getState());
        }
        String statePathStr = PropertyHelper.computePath(property, file);
        property.getItem().getState().setPath(statePathStr);
        URI propURI = uri.trimFileExtension().appendFileExtension(FactoriesUtil.PROPERTIES_EXTENSION);
        Resource propResource = emfUtil.getResourceSet().createResource(propURI);
        propResource.getContents().add(property);
        propResource.getContents().add(property.getItem());
        propResource.getContents().add(property.getItem().getState());
        EMFUtil.saveResource(propResource);
    } else {
        // $NON-NLS-1$
        log.warn(DefaultMessagesImpl.getString("UpdatePropertiesFileTask_5", modelElement.getName()));
    }
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Resource(org.eclipse.emf.ecore.resource.Resource) AElementPersistance(org.talend.dq.writer.AElementPersistance) Property(org.talend.core.model.properties.Property) URI(org.eclipse.emf.common.util.URI)

Aggregations

AElementPersistance (org.talend.dq.writer.AElementPersistance)6 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)6 Resource (org.eclipse.emf.ecore.resource.Resource)3 Property (org.talend.core.model.properties.Property)3 IFile (org.eclipse.core.resources.IFile)2 IFolder (org.eclipse.core.resources.IFolder)2 URI (org.eclipse.emf.common.util.URI)2 Item (org.talend.core.model.properties.Item)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 EObject (org.eclipse.emf.ecore.EObject)1 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)1 TDQFileItem (org.talend.dataquality.properties.TDQFileItem)1 TDQSourceFileItem (org.talend.dataquality.properties.TDQSourceFileItem)1 EResourceConstant (org.talend.resource.EResourceConstant)1 Dependency (orgomg.cwm.objectmodel.core.Dependency)1