| /** |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| * |
| * This copyright notice shows up in the generated Java code |
| */ |
| package org.eclipse.osbp.xtext.topologydsl.validation; |
| |
| import com.google.common.base.Objects; |
| import java.util.ArrayList; |
| import java.util.HashMap; |
| import java.util.List; |
| import org.eclipse.emf.common.util.EList; |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartDefinition; |
| import org.eclipse.osbp.xtext.datamartdsl.EventBrokerDataMart; |
| import org.eclipse.osbp.xtext.topologydsl.Topology; |
| import org.eclipse.osbp.xtext.topologydsl.TopologyDSLPackage; |
| import org.eclipse.osbp.xtext.topologydsl.validation.AbstractTopologyDSLValidator; |
| import org.eclipse.xtext.validation.Check; |
| import org.eclipse.xtext.xbase.lib.CollectionLiterals; |
| |
| /** |
| * Custom validation rules. |
| * |
| * see http://www.eclipse.org/Xtext/documentation.html#validation |
| */ |
| @SuppressWarnings("all") |
| public class TopologyDSLValidator extends AbstractTopologyDSLValidator { |
| @Check |
| public void checkDuplicateDatamartFilters(final Topology topology) { |
| HashMap<String, List<String>> usedFilterMap = CollectionLiterals.<String, List<String>>newHashMap(); |
| EList<EventBrokerDataMart> _datamarts = topology.getDatamarts(); |
| for (final EventBrokerDataMart dat : _datamarts) { |
| boolean _and = false; |
| boolean _notEquals = (!Objects.equal(dat, null)); |
| if (!_notEquals) { |
| _and = false; |
| } else { |
| DatamartDefinition _datamartDef = dat.getDatamartDef(); |
| boolean _notEquals_1 = (!Objects.equal(_datamartDef, null)); |
| _and = _notEquals_1; |
| } |
| if (_and) { |
| DatamartDefinition _datamartDef_1 = dat.getDatamartDef(); |
| String _name = _datamartDef_1.getName(); |
| List<String> usedFilter = usedFilterMap.get(_name); |
| boolean _equals = Objects.equal(usedFilter, null); |
| if (_equals) { |
| ArrayList<String> _newArrayList = CollectionLiterals.<String>newArrayList(); |
| usedFilter = _newArrayList; |
| } |
| String _filter = dat.getFilter(); |
| boolean _contains = usedFilter.contains(_filter); |
| if (_contains) { |
| DatamartDefinition _datamartDef_2 = dat.getDatamartDef(); |
| String _name_1 = _datamartDef_2.getName(); |
| String _concat = "Duplicate filter: ".concat(_name_1); |
| this.error(_concat, dat, TopologyDSLPackage.Literals.TOPOLOGY_BASE__NAME); |
| } else { |
| String _filter_1 = dat.getFilter(); |
| usedFilter.add(_filter_1); |
| DatamartDefinition _datamartDef_3 = dat.getDatamartDef(); |
| String _name_2 = _datamartDef_3.getName(); |
| usedFilterMap.put(_name_2, usedFilter); |
| } |
| } |
| } |
| } |
| } |