Search in sources :

Example 6 with WSViewItem

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

the class ViewProcessImportHandler method beforeCreatingItem.

@Override
protected void beforeCreatingItem(ImportItem selectedImportItem) {
    Item item = selectedImportItem.getItem();
    String statePath = item.getState().getPath();
    if (item instanceof WSViewItem) {
        if (RepositoryTransformUtil.getInstance().getViewType(item.getProperty().getLabel()) == IViewNodeConstDef.TYPE_WEBFILTER) {
            if (!statePath.startsWith(IPath.SEPARATOR + IViewNodeConstDef.PATH_WEBFILTER)) {
                item.getState().setPath(IPath.SEPARATOR + IViewNodeConstDef.PATH_WEBFILTER + statePath);
            }
        } else {
            if (!statePath.startsWith(IPath.SEPARATOR + IViewNodeConstDef.PATH_SEARCHFILTER)) {
                item.getState().setPath(IPath.SEPARATOR + IViewNodeConstDef.PATH_SEARCHFILTER + statePath);
            }
        }
        OperatorUpdatorProvider.instance().updateOperator(item);
    }
    if (item instanceof WSTransformerV2Item) {
        String processName = item.getProperty().getLabel();
        int processType = RepositoryTransformUtil.getInstance().getProcessType(processName);
        switch(processType) {
            case ITransformerV2NodeConsDef.TYPE_BEFORESAVE:
                if (!statePath.startsWith(IPath.SEPARATOR + ITransformerV2NodeConsDef.PATH_BEFORESAVE)) {
                    item.getState().setPath(IPath.SEPARATOR + ITransformerV2NodeConsDef.PATH_BEFORESAVE + statePath);
                }
                break;
            case ITransformerV2NodeConsDef.TYPE_BEFOREDEL:
                if (!statePath.startsWith(IPath.SEPARATOR + ITransformerV2NodeConsDef.PATH_BEFOREDEL)) {
                    item.getState().setPath(IPath.SEPARATOR + ITransformerV2NodeConsDef.PATH_BEFOREDEL + statePath);
                }
                break;
            case ITransformerV2NodeConsDef.TYPE_ENTITYACTION:
                if (!statePath.startsWith(IPath.SEPARATOR + ITransformerV2NodeConsDef.PATH_ENTITYACTION)) {
                    item.getState().setPath(IPath.SEPARATOR + ITransformerV2NodeConsDef.PATH_ENTITYACTION + statePath);
                }
                break;
            case ITransformerV2NodeConsDef.TYPE_WELCOMEACTION:
                if (!statePath.startsWith(IPath.SEPARATOR + ITransformerV2NodeConsDef.PATH_WELCOMEACTION)) {
                    item.getState().setPath(IPath.SEPARATOR + ITransformerV2NodeConsDef.PATH_WELCOMEACTION + statePath);
                }
                break;
            case ITransformerV2NodeConsDef.TYPE_SMARTVIEW:
                if (!statePath.startsWith(IPath.SEPARATOR + ITransformerV2NodeConsDef.PATH_SMARTVIEW)) {
                    item.getState().setPath(IPath.SEPARATOR + ITransformerV2NodeConsDef.PATH_SMARTVIEW + statePath);
                }
                break;
            case ITransformerV2NodeConsDef.TYPE_OTHER:
                if (!statePath.startsWith(IPath.SEPARATOR + ITransformerV2NodeConsDef.PATH_OTHER)) {
                    item.getState().setPath(IPath.SEPARATOR + ITransformerV2NodeConsDef.PATH_OTHER + statePath);
                }
                break;
            default:
                break;
        }
    }
}
Also used : ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) WSTransformerV2Item(org.talend.mdm.repository.model.mdmproperties.WSTransformerV2Item) Item(org.talend.core.model.properties.Item) WSViewItem(org.talend.mdm.repository.model.mdmproperties.WSViewItem) WSViewItem(org.talend.mdm.repository.model.mdmproperties.WSViewItem) WSTransformerV2Item(org.talend.mdm.repository.model.mdmproperties.WSTransformerV2Item)

Example 7 with WSViewItem

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

the class ViewOperatorUpdator method updateConditionOperator.

public boolean updateConditionOperator(Item item) {
    boolean modified = false;
    List<String> opers = getOperators();
    if (item != null && item instanceof WSViewItem) {
        WSViewItem viewItem = (WSViewItem) item;
        WSViewE wsView = viewItem.getWsView();
        EList<WSWhereConditionE> whereConditions = wsView.getWhereConditions();
        if (whereConditions != null) {
            for (WSWhereConditionE whereConditionE : whereConditions) {
                WSWhereOperatorE operator = whereConditionE.getOperator();
                if (!opers.contains(operator.getValue())) {
                    operator.setValue(WSWhereOperator.CONTAINS.name());
                    modified = true;
                }
            }
        }
    }
    return modified;
}
Also used : WSWhereOperatorE(org.talend.mdm.repository.model.mdmserverobject.WSWhereOperatorE) WSViewItem(org.talend.mdm.repository.model.mdmproperties.WSViewItem) WSViewE(org.talend.mdm.repository.model.mdmserverobject.WSViewE) WSWhereConditionE(org.talend.mdm.repository.model.mdmserverobject.WSWhereConditionE)

Example 8 with WSViewItem

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

the class ViewValidator method validate.

@Override
public ValidationReport validate(String uri, InputStream inputstream, NestedValidatorContext context) {
    ViewValidationReport viewValidationReport = new ViewValidationReport(uri);
    // $NON-NLS-1$
    String fileName = uri.substring(uri.lastIndexOf("/") + 1);
    String viewName = getViewName(fileName);
    // $NON-NLS-1$ //$NON-NLS-2$
    viewName = viewName.replace("$", "#");
    IRepositoryViewObject viewObj = RepositoryResourceUtil.findViewObjectByName(IServerObjectRepositoryType.TYPE_VIEW, viewName);
    if (viewObj != null) {
        WSViewItem item = (WSViewItem) viewObj.getProperty().getItem();
        WSViewE view = (WSViewE) item.getMDMServerObject();
        EList<WSWhereConditionE> whereConditions = view.getWhereConditions();
        if (whereConditions != null && whereConditions.size() > 0) {
            for (WSWhereConditionE conditionE : whereConditions) {
                String userVarValue = conditionE.getRightValueOrPath();
                boolean isValid = UserVarValueValidator.validate(userVarValue);
                if (!isValid) {
                    String validateMsg = Messages.bind(Messages.ViewValidator_error, userVarValue, viewName);
                    viewValidationReport.addValidationMessage(new ValidationMessage(validateMsg, -1, -1));
                }
            }
        }
    }
    return viewValidationReport;
}
Also used : ValidationMessage(org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage) WSViewItem(org.talend.mdm.repository.model.mdmproperties.WSViewItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WSViewE(org.talend.mdm.repository.model.mdmserverobject.WSViewE) WSWhereConditionE(org.talend.mdm.repository.model.mdmserverobject.WSWhereConditionE)

Aggregations

WSViewItem (org.talend.mdm.repository.model.mdmproperties.WSViewItem)8 WSViewE (org.talend.mdm.repository.model.mdmserverobject.WSViewE)5 WSWhereConditionE (org.talend.mdm.repository.model.mdmserverobject.WSWhereConditionE)3 Resource (org.eclipse.emf.ecore.resource.Resource)2 Test (org.junit.Test)2 Item (org.talend.core.model.properties.Item)2 ItemState (org.talend.core.model.properties.ItemState)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 WSWhereOperatorE (org.talend.mdm.repository.model.mdmserverobject.WSWhereOperatorE)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 Point (org.eclipse.swt.graphics.Point)1 IEditorPart (org.eclipse.ui.IEditorPart)1 PartInitException (org.eclipse.ui.PartInitException)1 ValidationMessage (org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)1 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)1 WSTransformerV2Item (org.talend.mdm.repository.model.mdmproperties.WSTransformerV2Item)1 AbstractSimpleAddActionTest (org.talend.mdm.repository.ui.actions.AbstractSimpleAddActionTest)1