Commit 67c5336e authored by Adrien's avatar Adrien Committed by Romain Bioteau
Browse files

fix export diagram with wml variable (#615)

* Avoid exception at export when an xml process variable has not been
declared

closes [BS-16853](https://bonitasoft.atlassian.net/browse/BS-16853)
parent da675745
/** /**
* Copyright (C) 2010 BonitaSoft S.A. * Copyright (C) 2010 BonitaSoft S.A.
* BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble * BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or * the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version. * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
...@@ -19,6 +16,7 @@ package org.bonitasoft.studio.xml.export; ...@@ -19,6 +16,7 @@ package org.bonitasoft.studio.xml.export;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import org.bonitasoft.studio.common.emf.tools.ModelHelper; import org.bonitasoft.studio.common.emf.tools.ModelHelper;
...@@ -35,24 +33,22 @@ import org.eclipse.emf.ecore.EObject; ...@@ -35,24 +33,22 @@ import org.eclipse.emf.ecore.EObject;
/** /**
* @author Romain Bioteau * @author Romain Bioteau
*
*/ */
public class XSDResourceProvider implements IBOSArchiveFileStoreProvider { public class XSDResourceProvider implements IBOSArchiveFileStoreProvider {
@Override @Override
public Set<IRepositoryFileStore> getFileStoreForConfiguration(AbstractProcess process, Configuration configuration) { public Set<IRepositoryFileStore> getFileStoreForConfiguration(AbstractProcess process, Configuration configuration) {
final Set<IRepositoryFileStore> files = new HashSet<IRepositoryFileStore>() ; final Set<IRepositoryFileStore> files = new HashSet<IRepositoryFileStore>();
final XSDRepositoryStore store = (XSDRepositoryStore) RepositoryManager.getInstance().getRepositoryStore(XSDRepositoryStore.class) ; final XSDRepositoryStore store = (XSDRepositoryStore) RepositoryManager.getInstance()
.getRepositoryStore(XSDRepositoryStore.class);
List<EObject> xmlData = ModelHelper.getAllItemsOfType(process, ProcessPackage.Literals.XML_DATA); List<EObject> xmlData = ModelHelper.getAllItemsOfType(process, ProcessPackage.Literals.XML_DATA);
for (EObject item : xmlData) { for (EObject item : xmlData) {
XMLData data = (XMLData)item; XMLData data = (XMLData) item;
XSDFileStore artifact = store.findArtifactWithNamespace(data.getNamespace()); Optional<XSDFileStore> artifact = Optional.ofNullable(store.findArtifactWithNamespace(data.getNamespace()));
files.add(artifact) ; artifact.ifPresent(files::add);
} }
return files; return files;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment