Search in sources :

Example 6 with WSDataModelE

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

the class MDMImportItemsWizardPage method exchangeImport.

protected void exchangeImport() {
    ImportExchangeOptionsDialog dlg = getExchangeOptionsDialog();
    dlg.setBlockOnOpen(true);
    if (dlg.open() == Window.OK) {
        File directory = new File(zipFileRepository.toString());
        File[] files = directory.listFiles(new FileFilter() {

            public boolean accept(File pathname) {
                // $NON-NLS-1$
                return pathname.getName().endsWith(".xsd");
            }
        });
        if (null != files && files.length > 0) {
            try {
                MDMRepositoryView view = MDMRepositoryView.show();
                for (File file : files) {
                    final String label = file.getName().substring(0, file.getName().lastIndexOf('.'));
                    final WSDataModelItem item = MdmpropertiesFactory.eINSTANCE.createWSDataModelItem();
                    ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
                    item.setState(itemState);
                    WSDataModelE dataModel = MdmserverobjectFactory.eINSTANCE.createWSDataModelE();
                    dataModel.setName(label);
                    InputStream stream = null;
                    try {
                        stream = new FileInputStream(file);
                        dataModel.setXsdSchema(IOUtils.toString(stream));
                        item.setWsDataModel(dataModel);
                    } catch (Exception e) {
                        log.error(e.getMessage());
                    }
                    IOUtils.closeQuietly(stream);
                    // $NON-NLS-1$
                    item.getState().setPath("");
                    RepositoryResourceUtil.createItem(item, label);
                    view.refreshRootNode(IServerObjectRepositoryType.TYPE_DATAMODEL);
                }
            } catch (Exception ex) {
                log.error(ex.getMessage());
            }
            WizardDialog dialog = (WizardDialog) getWizard().getContainer();
            dialog.close();
        } else {
            MessageDialog.openWarning(getShell(), null, Messages.NO_XSD_RESOURCE);
        }
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) WSDataModelE(org.talend.mdm.repository.model.mdmserverobject.WSDataModelE) ImportExchangeOptionsDialog(com.amalto.workbench.dialogs.ImportExchangeOptionsDialog) FileInputStream(java.io.FileInputStream) WSDataModelItem(org.talend.mdm.repository.model.mdmproperties.WSDataModelItem) ItemState(org.talend.core.model.properties.ItemState) FileFilter(java.io.FileFilter) MDMRepositoryView(org.talend.mdm.repository.ui.navigator.MDMRepositoryView) File(java.io.File) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 7 with WSDataModelE

use of org.talend.mdm.repository.model.mdmserverobject.WSDataModelE 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 8 with WSDataModelE

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

the class WSDataModelItemImpl method setWsDataModel.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setWsDataModel(WSDataModelE newWsDataModel) {
    WSDataModelE oldWsDataModel = wsDataModel;
    wsDataModel = newWsDataModel;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, MdmpropertiesPackage.WS_DATA_MODEL_ITEM__WS_DATA_MODEL, oldWsDataModel, wsDataModel));
    }
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) WSDataModelE(org.talend.mdm.repository.model.mdmserverobject.WSDataModelE)

Example 9 with WSDataModelE

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

the class XpathSelectDialog2 method changeDomTree.

@Override
protected void changeDomTree(final TreeParent pObject, String filter) {
    String modelDisplay = dataModelCombo.getText();
    if (modelDisplay.length() == 0) {
        return;
    }
    this.dataModelName = modelDisplay;
    try {
        XSDSchema xsd = Util.getXSDSchemaOfDirtyEditor(dataModelName);
        if (null == xsd) {
            WSDataModelE wsDataModel = RepositoryQueryService.findDataModelByName(dataModelName);
            if (wsDataModel != null) {
                // Util.nodeToString(xsdSchema.getDocument());
                String schema = wsDataModel.getXsdSchema();
                xsd = Util.createXsdSchema(schema, pObject);
            }
        }
        if (null != xsd) {
            provideViwerContent(xsd, filter);
        }
    } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
    }
}
Also used : WSDataModelE(org.talend.mdm.repository.model.mdmserverobject.WSDataModelE) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 10 with WSDataModelE

use of org.talend.mdm.repository.model.mdmserverobject.WSDataModelE 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)

Aggregations

WSDataModelE (org.talend.mdm.repository.model.mdmserverobject.WSDataModelE)11 WSDataModelItem (org.talend.mdm.repository.model.mdmproperties.WSDataModelItem)4 XSDSchema (org.eclipse.xsd.XSDSchema)3 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 ItemState (org.talend.core.model.properties.ItemState)2 ImportExchangeOptionsDialog (com.amalto.workbench.dialogs.ImportExchangeOptionsDialog)1 XtentisException (com.amalto.workbench.utils.XtentisException)1 WSConceptKey (com.amalto.workbench.webservices.WSConceptKey)1 WSDataModel (com.amalto.workbench.webservices.WSDataModel)1 FileFilter (java.io.FileFilter)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 CoreException (org.eclipse.core.runtime.CoreException)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1