From 0d7a683417875d117fbaf3da5539a52160cee841 Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Date: Wed, 25 Jul 2012 19:16:14 +0200 Subject: [PATCH 1/3] Debug .gephi serialization of attributes and filters. --- AttributesImpl/manifest.mf | 2 +- .../serialization/AttributeRowSerializer.java | 14 +++++++------- FiltersImpl/manifest.mf | 3 +-- .../filters/FilterModelPersistenceProvider.java | 7 ++++++- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/AttributesImpl/manifest.mf b/AttributesImpl/manifest.mf index 5a20eea938..b9ac1e8eff 100644 --- a/AttributesImpl/manifest.mf +++ b/AttributesImpl/manifest.mf @@ -2,5 +2,5 @@ Manifest-Version: 1.0 AutoUpdate-Essential-Module: true OpenIDE-Module: org.gephi.data.attributes OpenIDE-Module-Localizing-Bundle: org/gephi/data/attributes/Bundle.properties -OpenIDE-Module-Specification-Version: 0.8.0.3 +OpenIDE-Module-Specification-Version: 0.8.0.4 diff --git a/AttributesImpl/src/org/gephi/data/attributes/serialization/AttributeRowSerializer.java b/AttributesImpl/src/org/gephi/data/attributes/serialization/AttributeRowSerializer.java index 84ab0cc7a8..4249d325b0 100644 --- a/AttributesImpl/src/org/gephi/data/attributes/serialization/AttributeRowSerializer.java +++ b/AttributesImpl/src/org/gephi/data/attributes/serialization/AttributeRowSerializer.java @@ -151,7 +151,7 @@ public boolean writeRow(XMLStreamWriter writer, AttributeRowImpl row) throws XML public void readRow(XMLStreamReader reader, AbstractAttributeModel model, AttributeTableImpl table, AttributeRowImpl row) throws XMLStreamException { row.setRowVersion(Integer.parseInt(reader.getAttributeValue(null, "version"))); - AttributeColumnImpl col = null; + Integer index = null; String value = ""; boolean end = false; @@ -162,11 +162,11 @@ public void readRow(XMLStreamReader reader, AbstractAttributeModel model, Attrib case XMLStreamReader.START_ELEMENT: String name = reader.getLocalName(); if (ELEMENT_VALUE.equalsIgnoreCase(name)) { - col = (AttributeColumnImpl) table.getColumn(Integer.parseInt(reader.getAttributeValue(null, "index"))); + index = Integer.parseInt(reader.getAttributeValue(null, "index")); } break; case XMLStreamReader.CHARACTERS: - if (!reader.isWhiteSpace() && col != null) { + if (!reader.isWhiteSpace() && index != null) { value += reader.getText(); } break; @@ -174,14 +174,14 @@ public void readRow(XMLStreamReader reader, AbstractAttributeModel model, Attrib if (ELEMENT_NODE_ROW.equalsIgnoreCase(reader.getLocalName()) || ELEMENT_EDGE_ROW.equalsIgnoreCase(reader.getLocalName())) { end = true; } - if (!value.isEmpty() && col != null) { - AttributeType type = col.getType(); + if (!value.isEmpty() && index != null) { + AttributeType type = table.getColumn(index).getType(); Object v = type.parse(value); v = model.getManagedValue(v, type); - row.setValue(col, v); + row.setValue(index, v); } value = ""; - col = null; + index = null; break; } } diff --git a/FiltersImpl/manifest.mf b/FiltersImpl/manifest.mf index f658863e4a..e41f6b098f 100644 --- a/FiltersImpl/manifest.mf +++ b/FiltersImpl/manifest.mf @@ -2,5 +2,4 @@ Manifest-Version: 1.0 AutoUpdate-Essential-Module: true OpenIDE-Module: org.gephi.filters OpenIDE-Module-Localizing-Bundle: org/gephi/filters/Bundle.properties -OpenIDE-Module-Specification-Version: 0.8.0.5 - +OpenIDE-Module-Specification-Version: 0.8.0.6 diff --git a/FiltersImpl/src/org/gephi/filters/FilterModelPersistenceProvider.java b/FiltersImpl/src/org/gephi/filters/FilterModelPersistenceProvider.java index 6eed9d37d7..9f97671f0a 100644 --- a/FiltersImpl/src/org/gephi/filters/FilterModelPersistenceProvider.java +++ b/FiltersImpl/src/org/gephi/filters/FilterModelPersistenceProvider.java @@ -185,7 +185,12 @@ public void readXML(XMLStreamReader reader) throws XMLStreamException { if (parent != null) { int parentId = Integer.parseInt(parent); Query parentQuery = idMap.get(parentId); - model.setSubQuery(parentQuery, query); + + //A plugin filter may be missing, or the parent filter could not be deserialized. + //For example a partition filter, which depends on partitions, and partitions are not serialized + if (parentQuery != null) { + model.setSubQuery(parentQuery, query); + } } else { //Top query model.addFirst(query); From 69facc3b204aa33b9971beb2bbf9af50d503dc43 Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Date: Wed, 8 Aug 2012 19:04:13 +0200 Subject: [PATCH 2/3] Fix bug in AttributeTableImpl at getting column by id + type --- AttributesImpl/manifest.mf | 2 +- .../data/attributes/AttributeTableImpl.java | 87 ++++++++++--------- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/AttributesImpl/manifest.mf b/AttributesImpl/manifest.mf index b9ac1e8eff..0ad45bbd6d 100644 --- a/AttributesImpl/manifest.mf +++ b/AttributesImpl/manifest.mf @@ -2,5 +2,5 @@ Manifest-Version: 1.0 AutoUpdate-Essential-Module: true OpenIDE-Module: org.gephi.data.attributes OpenIDE-Module-Localizing-Bundle: org/gephi/data/attributes/Bundle.properties -OpenIDE-Module-Specification-Version: 0.8.0.4 +OpenIDE-Module-Specification-Version: 0.8.0.5 diff --git a/AttributesImpl/src/org/gephi/data/attributes/AttributeTableImpl.java b/AttributesImpl/src/org/gephi/data/attributes/AttributeTableImpl.java index a597cceccf..f76880178f 100644 --- a/AttributesImpl/src/org/gephi/data/attributes/AttributeTableImpl.java +++ b/AttributesImpl/src/org/gephi/data/attributes/AttributeTableImpl.java @@ -1,43 +1,43 @@ /* -Copyright 2008-2010 Gephi -Authors : Mathieu Bastian , Martin Škurla -Website : http://www.gephi.org - -This file is part of Gephi. - -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - -Copyright 2011 Gephi Consortium. All rights reserved. - -The contents of this file are subject to the terms of either the GNU -General Public License Version 3 only ("GPL") or the Common -Development and Distribution License("CDDL") (collectively, the -"License"). You may not use this file except in compliance with the -License. You can obtain a copy of the License at -http://gephi.org/about/legal/license-notice/ -or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the -specific language governing permissions and limitations under the -License. When distributing the software, include this License Header -Notice in each file and include the License files at -/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the -License Header, with the fields enclosed by brackets [] replaced by -your own identifying information: -"Portions Copyrighted [year] [name of copyright owner]" - -If you wish your version of this file to be governed by only the CDDL -or only the GPL Version 3, indicate your decision by adding -"[Contributor] elects to include this software in this distribution -under the [CDDL or GPL Version 3] license." If you do not indicate a -single choice of license, a recipient has the option to distribute -your version of this file under either the CDDL, the GPL Version 3 or -to extend the choice of license to its licensees as provided above. -However, if you add GPL Version 3 code and therefore, elected the GPL -Version 3 license, then the option applies only if the new code is -made subject to such option by the copyright holder. - -Contributor(s): - -Portions Copyrighted 2011 Gephi Consortium. + Copyright 2008-2010 Gephi + Authors : Mathieu Bastian , Martin Škurla + Website : http://www.gephi.org + + This file is part of Gephi. + + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + + Copyright 2011 Gephi Consortium. All rights reserved. + + The contents of this file are subject to the terms of either the GNU + General Public License Version 3 only ("GPL") or the Common + Development and Distribution License("CDDL") (collectively, the + "License"). You may not use this file except in compliance with the + License. You can obtain a copy of the License at + http://gephi.org/about/legal/license-notice/ + or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the + specific language governing permissions and limitations under the + License. When distributing the software, include this License Header + Notice in each file and include the License files at + /cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the + License Header, with the fields enclosed by brackets [] replaced by + your own identifying information: + "Portions Copyrighted [year] [name of copyright owner]" + + If you wish your version of this file to be governed by only the CDDL + or only the GPL Version 3, indicate your decision by adding + "[Contributor] elects to include this software in this distribution + under the [CDDL or GPL Version 3] license." If you do not indicate a + single choice of license, a recipient has the option to distribute + your version of this file under either the CDDL, the GPL Version 3 or + to extend the choice of license to its licensees as provided above. + However, if you add GPL Version 3 code and therefore, elected the GPL + Version 3 license, then the option applies only if the new code is + made subject to such option by the copyright holder. + + Contributor(s): + + Portions Copyrighted 2011 Gephi Consortium. */ package org.gephi.data.attributes; @@ -127,8 +127,10 @@ private synchronized AttributeColumnImpl addColumn(String id, String title, Attr AttributeColumnImpl column = new AttributeColumnImpl(this, columns.size(), id, title, type, origin, defaultValue, attributeValueDelegateProvider); columns.add(column); columnsMap.put(id, column); + columnsMap.put(id.toLowerCase(), column); if (title != null && !title.equals(id)) { columnsMap.put(title, column); + columnsMap.put(title.toLowerCase(), column); } columnsSet.put(column, column); @@ -184,14 +186,16 @@ public synchronized AttributeColumn replaceColumn(AttributeColumn source, Attrib targetImpl.index = index; columns.set(index, targetImpl); columnsMap.put(targetImpl.id, targetImpl); + columnsMap.put(targetImpl.id.toLowerCase(), targetImpl); if (targetImpl.title != null && !targetImpl.title.equals(targetImpl.id)) { columnsMap.put(targetImpl.title.toLowerCase(), targetImpl); + columnsMap.put(targetImpl.title, targetImpl); } columnsSet.put(targetImpl, targetImpl); model.fireAttributeEvent( new ColumnEvent(AttributeEvent.EventType.REPLACE_COLUMN, (AttributeColumnImpl) source)); - + //Version version++; return targetImpl; @@ -230,6 +234,9 @@ public synchronized AttributeColumnImpl getColumn(String id) { public synchronized AttributeColumnImpl getColumn(String title, AttributeType type) { AttributeColumnImpl c = columnsMap.get(title.toLowerCase()); + if (c == null) { + columnsMap.get(title); + } if (c != null && c.getType().equals(type)) { return c; } From 1d5ec0803f00920b15edc5c3d74e6384fcd2894f Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Date: Wed, 8 Aug 2012 20:30:37 +0200 Subject: [PATCH 3/3] Better fix for last commit. --- .../data/attributes/AttributeTableImpl.java | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/AttributesImpl/src/org/gephi/data/attributes/AttributeTableImpl.java b/AttributesImpl/src/org/gephi/data/attributes/AttributeTableImpl.java index f76880178f..04d40bcd58 100644 --- a/AttributesImpl/src/org/gephi/data/attributes/AttributeTableImpl.java +++ b/AttributesImpl/src/org/gephi/data/attributes/AttributeTableImpl.java @@ -45,10 +45,10 @@ Development and Distribution License("CDDL") (collectively, the import java.util.HashMap; import java.util.List; import java.util.Map; -import org.gephi.data.attributes.api.AttributeTable; import org.gephi.data.attributes.api.AttributeColumn; import org.gephi.data.attributes.api.AttributeEvent; import org.gephi.data.attributes.api.AttributeOrigin; +import org.gephi.data.attributes.api.AttributeTable; import org.gephi.data.attributes.api.AttributeType; import org.gephi.data.attributes.event.ColumnEvent; import org.gephi.data.attributes.spi.AttributeValueDelegateProvider; @@ -126,10 +126,8 @@ private synchronized AttributeColumnImpl addColumn(String id, String title, Attr } AttributeColumnImpl column = new AttributeColumnImpl(this, columns.size(), id, title, type, origin, defaultValue, attributeValueDelegateProvider); columns.add(column); - columnsMap.put(id, column); columnsMap.put(id.toLowerCase(), column); if (title != null && !title.equals(id)) { - columnsMap.put(title, column); columnsMap.put(title.toLowerCase(), column); } columnsSet.put(column, column); @@ -157,9 +155,9 @@ public synchronized void removeColumn(AttributeColumn column) { } //Remove from collections columns.remove((AttributeColumnImpl) column); - columnsMap.remove(column.getId()); + columnsMap.remove(column.getId().toLowerCase()); if (column.getTitle() != null && !column.getTitle().equals(column.getId())) { - columnsMap.remove(column.getTitle()); + columnsMap.remove(column.getTitle().toLowerCase()); } columnsSet.remove(column); @@ -176,20 +174,18 @@ public synchronized AttributeColumn replaceColumn(AttributeColumn source, Attrib return null; } //Remove from collections - columnsMap.remove(source.getId()); + columnsMap.remove(source.getId().toLowerCase()); if (source.getTitle() != null && !source.getTitle().equals(source.getId())) { - columnsMap.remove(source.getTitle()); + columnsMap.remove(source.getTitle().toLowerCase()); } columnsSet.remove(source); //Add targetImpl.index = index; columns.set(index, targetImpl); - columnsMap.put(targetImpl.id, targetImpl); columnsMap.put(targetImpl.id.toLowerCase(), targetImpl); if (targetImpl.title != null && !targetImpl.title.equals(targetImpl.id)) { columnsMap.put(targetImpl.title.toLowerCase(), targetImpl); - columnsMap.put(targetImpl.title, targetImpl); } columnsSet.put(targetImpl, targetImpl); @@ -225,18 +221,11 @@ public synchronized AttributeColumnImpl getColumn(int index) { } public synchronized AttributeColumnImpl getColumn(String id) { - AttributeColumnImpl col = columnsMap.get(id); - if (col == null) { - return columnsMap.get(id.toLowerCase()); - } - return col; + return columnsMap.get(id.toLowerCase()); } public synchronized AttributeColumnImpl getColumn(String title, AttributeType type) { AttributeColumnImpl c = columnsMap.get(title.toLowerCase()); - if (c == null) { - columnsMap.get(title); - } if (c != null && c.getType().equals(type)) { return c; }