Search in sources :

Example 6 with WSDataModelItem

use of org.talend.mdm.repository.model.mdmproperties.WSDataModelItem in project tmdm-studio-se by Talend.

the class DatamodelOperatorUpdatorTest method testUpdateConditionOperator.

@Test
public void testUpdateConditionOperator() {
    // $NON-NLS-1$
    String filename = "Product_0.1.xsd";
    // $NON-NLS-1$
    File file = new File("temp/" + filename);
    try {
        byte[] fbyteArray = IOUtils.toByteArray(new FileInputStream(file));
        WSDataModelItem wsdataModelItem = MdmpropertiesFactory.eINSTANCE.createWSDataModelItem();
        ReferenceFileItem xsdFileItem = PropertiesFactory.eINSTANCE.createReferenceFileItem();
        ByteArray byteArray = PropertiesFactory.eINSTANCE.createByteArray();
        // 
        byteArray = spy(byteArray);
        // 
        when(byteArray.getInnerContent()).thenReturn(fbyteArray);
        xsdFileItem.setContent(byteArray);
        xsdFileItem.setExtension("xsd");
        wsdataModelItem.getReferenceResources().add(xsdFileItem);
        WSDataModelE wsdataModelE = MdmserverobjectFactory.eINSTANCE.createWSDataModelE();
        wsdataModelE.setXsdSchema(null);
        wsdataModelItem.setWsDataModel(wsdataModelE);
        PowerMockito.mockStatic(RepositoryResourceUtil.class);
        boolean updated = new DatamodelOperatorUpdator().updateConditionOperator(wsdataModelItem);
        String xsdSchema = wsdataModelItem.getWsDataModel().getXsdSchema();
        assertTrue(updated);
        assertNotNull(xsdSchema);
        // $NON-NLS-1$
        assertFalse(xsdSchema.contains("Strict Contains"));
        // $NON-NLS-1$
        assertFalse(xsdSchema.contains("Contains Text Of"));
        // $NON-NLS-1$
        assertTrue(xsdSchema.contains("Contains"));
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : ReferenceFileItem(org.talend.core.model.properties.ReferenceFileItem) WSDataModelItem(org.talend.mdm.repository.model.mdmproperties.WSDataModelItem) WSDataModelE(org.talend.mdm.repository.model.mdmserverobject.WSDataModelE) ByteArray(org.talend.core.model.properties.ByteArray) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 7 with WSDataModelItem

use of org.talend.mdm.repository.model.mdmproperties.WSDataModelItem in project tmdm-studio-se by Talend.

the class DataModelMainPage2 method updateSchemaToItem.

// 
public Item updateSchemaToItem(Item item) {
    WSDataModelE wsDataModelE = ((WSDataModelItem) item).getWsDataModel();
    WSDataModel wsDataModel = (WSDataModel) xobject.getWsObject();
    wsDataModelE.setXsdSchema(wsDataModel.getXsdSchema());
    return item;
}
Also used : WSDataModel(com.amalto.workbench.webservices.WSDataModel) WSDataModelItem(org.talend.mdm.repository.model.mdmproperties.WSDataModelItem) WSDataModelE(org.talend.mdm.repository.model.mdmserverobject.WSDataModelE)

Example 8 with WSDataModelItem

use of org.talend.mdm.repository.model.mdmproperties.WSDataModelItem in project tmdm-studio-se by Talend.

the class DataModelNodeResourceProvider method save.

@Override
public Resource save(Item item) throws PersistenceException {
    if (item instanceof WSDataModelItem) {
        Resource resource = xmiResourceManager.getItemResource(item);
        resource.getContents().clear();
        resource.getContents().add(((WSDataModelItem) item).getWsDataModel());
        return resource;
    }
    return null;
}
Also used : WSDataModelItem(org.talend.mdm.repository.model.mdmproperties.WSDataModelItem) Resource(org.eclipse.emf.ecore.resource.Resource)

Aggregations

WSDataModelItem (org.talend.mdm.repository.model.mdmproperties.WSDataModelItem)8 ItemState (org.talend.core.model.properties.ItemState)4 WSDataModelE (org.talend.mdm.repository.model.mdmserverobject.WSDataModelE)4 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 ByteArray (org.talend.core.model.properties.ByteArray)2 ReferenceFileItem (org.talend.core.model.properties.ReferenceFileItem)2 ImportExchangeOptionsDialog (com.amalto.workbench.dialogs.ImportExchangeOptionsDialog)1 WSDataModel (com.amalto.workbench.webservices.WSDataModel)1 FileFilter (java.io.FileFilter)1 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 Item (org.talend.core.model.properties.Item)1 Property (org.talend.core.model.properties.Property)1