Search in sources :

Example 86 with Entry

use of java.util.Map.Entry in project tdi-studio-se by Talend.

the class JobletContainerFigure method refreshMRstatus.

public void refreshMRstatus() {
    if (this.jobletContainer.getNode().isMapReduceStart()) {
        Iterator<Entry<String, SimpleHtmlFigure>> ite = mrFigures.entrySet().iterator();
        while (ite.hasNext()) {
            Entry<String, SimpleHtmlFigure> entry = ite.next();
            SimpleHtmlFigure value = entry.getValue();
            for (Object obj : value.getChildren()) {
                if (obj instanceof Figure) {
                    if (this.jobletContainer.getSubjobContainer() != null && this.jobletContainer.getSubjobContainer().isCollapsed()) {
                        ((Figure) obj).setVisible(false);
                    } else {
                        ((Figure) obj).setVisible(true);
                    }
                }
            }
        }
    }
}
Also used : Entry(java.util.Map.Entry) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure) IFigure(org.eclipse.draw2d.IFigure) ImageFigure(org.eclipse.draw2d.ImageFigure) RectangleFigure(org.eclipse.draw2d.RectangleFigure) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure) Figure(org.eclipse.draw2d.Figure)

Example 87 with Entry

use of java.util.Map.Entry in project tdi-studio-se by Talend.

the class WebServiceTableLiner method onXPathValueChanged.

public void onXPathValueChanged(Table sourceTable, Table targetTable, String oldValue, String newValue, String inComeName, int itemIndex) {
    TableItem tabletraItem = targetTable.getItem(itemIndex);
    boolean needAddLink = true;
    TableItem[] items = sourceTable.getItems();
    List<TableItem> itemList = new ArrayList<TableItem>();
    for (int i = 0; i < items.length; i++) {
        String columnLabel = null;
        IMetadataColumn column = null;
        ParameterInfo parame = null;
        if (items[i].getData() instanceof IMetadataColumn) {
            column = (IMetadataColumn) items[i].getData();
            columnLabel = column.getLabel();
        } else // }
        if (items[i].getData() instanceof OutPutMappingData) {
            parame = ((OutPutMappingData) items[i].getData()).getParameter();
            if (!parame.getParameterInfos().isEmpty()) {
                continue;
            }
            // columnLabel = parame.getName();
            columnLabel = ((OutPutMappingData) items[i].getData()).getParameterName();
            int m = columnLabel.lastIndexOf(".");
            columnLabel = columnLabel.substring(m + 1);
        }
        if (newValue.contains(columnLabel)) {
            // if (!pattern(columnLabel, newValue)) {
            if (inComeName != null) {
                WebServiceExpressionParser webParser = new WebServiceExpressionParser("\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*");
                Map<String, String> itemNamemap = webParser.parseInTableEntryLocations(newValue);
                Set<Entry<String, String>> set = itemNamemap.entrySet();
                Iterator<Entry<String, String>> ite = set.iterator();
                while (ite.hasNext()) {
                    Entry<String, String> entry = ite.next();
                    String columnValue = entry.getKey();
                    String rowValue = entry.getValue();
                    if (!isPatternWord(inComeName + "." + columnLabel, rowValue + "." + columnValue)) {
                        linksManager.removeLinksFromDataItem2(tabletraItem.getData());
                        if (tabletraItem.getData() instanceof InputMappingData) {
                            InputMappingData data = (InputMappingData) tabletraItem.getData();
                            List<IMetadataColumn> list = data.getMetadataColumnList();
                            if (column != null) {
                                list.remove(column);
                            }
                        }
                        needAddLink = false;
                        for (TableItem item : itemList) {
                            addLinks(item, item.getData(), targetTable, tabletraItem.getData(), "INPUTMAPPING");
                        }
                        getBackgroundRefresher().refreshBackground();
                    // return;
                    }
                }
            } else {
                WebServiceExpressionParser webParser = new WebServiceExpressionParser("\\s*\\w+(\\[\\d+?\\])?\\s*");
                Set<String> set = webParser.parseOutTableEntryLocations(newValue);
                Iterator<String> ite = set.iterator();
                while (ite.hasNext()) {
                    String columnValue = ite.next();
                    // if (columnValue.equals(columnLabel)) {
                    if (!isPatternWord(columnLabel, columnValue)) {
                        linksManager.removeLinksFromDataItem2(tabletraItem.getData());
                        OutPutMappingData data = (OutPutMappingData) tabletraItem.getData();
                        if (parame != null) {
                            data.getParameterList().remove(parame);
                        }
                        needAddLink = false;
                        for (TableItem item : itemList) {
                            addLinks(item, item.getData(), targetTable, tabletraItem.getData(), "OUTPUTMAPPING");
                        }
                        getBackgroundRefresher().refreshBackground();
                    // return;
                    // }
                    }
                }
            }
            if (true) {
                // if (!mark) {
                if (inComeName != null) {
                    WebServiceExpressionParser webParser = new WebServiceExpressionParser("\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*");
                    Map<String, String> itemNamemap = webParser.parseInTableEntryLocations(newValue);
                    Set<Entry<String, String>> set = itemNamemap.entrySet();
                    Iterator<Entry<String, String>> ite = set.iterator();
                    while (ite.hasNext()) {
                        Entry<String, String> entry = ite.next();
                        String columnValue = entry.getKey();
                        String rowValue = entry.getValue();
                        if (isPatternWord(inComeName + "." + columnLabel, rowValue + "." + columnValue)) {
                            itemList.add(items[i]);
                            addLinks(items[i], items[i].getData(), targetTable, tabletraItem.getData(), "INPUTMAPPING");
                            getBackgroundRefresher().refreshBackground();
                            if (tabletraItem.getData() instanceof InputMappingData) {
                                InputMappingData data = (InputMappingData) tabletraItem.getData();
                                List<IMetadataColumn> list = data.getMetadataColumnList();
                                if (column != null && !list.contains(column)) {
                                    list.add(column);
                                }
                            }
                        }
                    }
                } else {
                    WebServiceExpressionParser webParser = new WebServiceExpressionParser("\\s*\\w+(\\[\\d+?\\])?\\s*");
                    Set<String> set = webParser.parseOutTableEntryLocations(newValue);
                    Iterator<String> ite = set.iterator();
                    while (ite.hasNext()) {
                        String columnValue = ite.next();
                        if (isPatternWord(columnLabel, columnValue)) {
                            itemList.add(items[i]);
                            addLinks(items[i], items[i].getData(), targetTable, tabletraItem.getData(), "OUTPUTMAPPING");
                            getBackgroundRefresher().refreshBackground();
                        }
                    }
                }
            }
        } else if (oldValue.contains(columnLabel)) {
            linksManager.removeLinksFromDataItem2(tabletraItem.getData());
            if (tabletraItem.getData() instanceof InputMappingData) {
                InputMappingData data = (InputMappingData) tabletraItem.getData();
                List<IMetadataColumn> list = data.getMetadataColumnList();
                if (column != null) {
                    list.remove(column);
                }
            } else if (tabletraItem.getData() instanceof OutPutMappingData) {
                OutPutMappingData data = (OutPutMappingData) tabletraItem.getData();
                if (parame != null) {
                    data.getParameterList().remove(parame);
                }
            }
            for (TableItem item : itemList) {
                if (inComeName != null) {
                    addLinks(item, item.getData(), targetTable, tabletraItem.getData(), "INPUTMAPPING");
                } else {
                    addLinks(item, item.getData(), targetTable, tabletraItem.getData(), "OUTPUTMAPPING");
                }
            }
            getBackgroundRefresher().refreshBackground();
        }
    }
// createFieldLinks(newValue, tableItem, null);
}
Also used : OutPutMappingData(org.talend.designer.webservice.data.OutPutMappingData) InputMappingData(org.talend.designer.webservice.data.InputMappingData) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) Point(org.eclipse.swt.graphics.Point) Entry(java.util.Map.Entry) WebServiceExpressionParser(org.talend.designer.webservice.ui.WebServiceExpressionParser) ArrayList(java.util.ArrayList) List(java.util.List)

Example 88 with Entry

use of java.util.Map.Entry in project tdi-studio-se by Talend.

the class DynamicComposite method reverseParameters.

private List<ElementParameter> reverseParameters(List<ElementParameter> parameters) {
    List<ElementParameter> reversedParameters = new ArrayList<>();
    Map<Integer, List<ElementParameter>> paramMap = new LinkedHashMap<>();
    for (ElementParameter parameter : parameters) {
        int numRow = parameter.getNumRow();
        List<ElementParameter> params = paramMap.get(numRow);
        if (params == null) {
            params = new ArrayList<>();
            paramMap.put(numRow, params);
        }
        params.add(parameter);
    }
    Set<Entry<Integer, List<ElementParameter>>> paramEntrySet = paramMap.entrySet();
    Iterator<Entry<Integer, List<ElementParameter>>> paramIterator = paramEntrySet.iterator();
    while (paramIterator.hasNext()) {
        Entry<Integer, List<ElementParameter>> paramEntry = paramIterator.next();
        List<ElementParameter> params = paramEntry.getValue();
        if (params != null && params.size() > 1) {
            Collections.reverse(params);
        }
        reversedParameters.addAll(params);
    }
    return reversedParameters;
}
Also used : ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) Entry(java.util.Map.Entry) List(java.util.List) ArrayList(java.util.ArrayList)

Example 89 with Entry

use of java.util.Map.Entry in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class BlockPosToShipUUIDData method writeToNBT.

@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
    Set<Entry<UUID, ChunkSet>> entries = UUIDToChunkSet.entrySet();
    //2 ints, 1 byte (radius), and 2 longs for each ship, that comes out to 25 bytes per entry
    int byteArraySize = entries.size() * 25;
    ByteBuffer buffer = ByteBuffer.allocate(byteArraySize);
    for (Entry<UUID, ChunkSet> entry : entries) {
        int centerX = entry.getValue().centerX;
        int centerZ = entry.getValue().centerZ;
        byte radius = (byte) entry.getValue().radius;
        long mostBits = entry.getKey().getMostSignificantBits();
        long leastBits = entry.getKey().getLeastSignificantBits();
        buffer.putInt(centerX);
        buffer.putInt(centerZ);
        buffer.put(radius);
        buffer.putLong(mostBits);
        buffer.putLong(leastBits);
    }
    NBTUtils.setByteBuf("WorldChunkSetUUIDMix", buffer, compound);
    return compound;
}
Also used : Entry(java.util.Map.Entry) ChunkSet(ValkyrienWarfareBase.ChunkManagement.ChunkSet) UUID(java.util.UUID) ByteBuffer(java.nio.ByteBuffer)

Example 90 with Entry

use of java.util.Map.Entry in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ShipUUIDToPosData method writeToNBT.

@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
    Set<Entry<Long, ShipPositionData>> entries = dataMap.entrySet();
    //Each ship has 19 floats, and 1 long; that comes out (19 * 4 + 1 * 8) = 84 bytes per ship
    int byteArraySize = entries.size() * 84;
    ByteBuffer buffer = ByteBuffer.allocate(byteArraySize);
    for (Entry<Long, ShipPositionData> entry : entries) {
        long mostBits = entry.getKey();
        ShipPositionData posData = entry.getValue();
        buffer.putLong(mostBits);
        posData.writeToByteBuffer(buffer);
    }
    NBTUtils.setByteBuf("ShipPositionByteBuf", buffer, compound);
    return compound;
}
Also used : Entry(java.util.Map.Entry) ByteBuffer(java.nio.ByteBuffer)

Aggregations

Entry (java.util.Map.Entry)2862 Map (java.util.Map)804 HashMap (java.util.HashMap)786 ArrayList (java.util.ArrayList)749 List (java.util.List)579 IOException (java.io.IOException)314 Iterator (java.util.Iterator)311 Test (org.junit.Test)308 Set (java.util.Set)294 HashSet (java.util.HashSet)271 LinkedHashMap (java.util.LinkedHashMap)194 Collection (java.util.Collection)186 Collectors (java.util.stream.Collectors)179 File (java.io.File)146 TreeMap (java.util.TreeMap)125 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)114 Key (org.apache.accumulo.core.data.Key)112 Value (org.apache.accumulo.core.data.Value)111 Collections (java.util.Collections)104 LinkedList (java.util.LinkedList)103