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