Commit bf58fd02 authored by Romain Bioteau's avatar Romain Bioteau
Browse files

BS-11286

Remove view form on tasks
parent 8c9fc856
......@@ -97,6 +97,13 @@ public abstract class AbstractRepositoryStore<T extends IRepositoryFileStore> im
public final T importInputStream(final String fileName,final InputStream inputStream) {
Assert.isNotNull(inputStream);
Assert.isNotNull(fileName);
try {
if (inputStream.available() == 0) {
return null;
}
} catch (final IOException e1) {
BonitaStudioLog.error(e1);
}
InputStream newIs = null;
try {
newIs = handlePreImport(fileName,inputStream);
......
......@@ -27,6 +27,7 @@ import org.bonitasoft.studio.migration.migrator.ReportCustomMigration;
import org.bonitasoft.studio.migration.utils.StringToExpressionConverter;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.edapt.migration.Instance;
import org.eclipse.emf.edapt.migration.Metamodel;
import org.eclipse.emf.edapt.migration.MigrationException;
......@@ -38,17 +39,17 @@ import org.eclipse.emf.edapt.migration.Model;
*/
public class PageFlowMigration extends ReportCustomMigration {
private Map<String, String> confirmationMessages = new HashMap<String,String>();
private Map<String, String> entryRedirectionUrls = new HashMap<String,String>();
private Map<String, String> viewRedirectionUrls = new HashMap<String,String>();
private Map<String, String> recapRedirectionUrls = new HashMap<String,String>();
private Map<String, String> pageFlowTransitionConditions = new HashMap<String,String>();
private Map<String, List<Instance>> entryRedirectionActions = new HashMap<String,List<Instance>>();
private final Map<String, String> confirmationMessages = new HashMap<String,String>();
private final Map<String, String> entryRedirectionUrls = new HashMap<String,String>();
private final Map<String, String> viewRedirectionUrls = new HashMap<String,String>();
private final Map<String, String> recapRedirectionUrls = new HashMap<String,String>();
private final Map<String, String> pageFlowTransitionConditions = new HashMap<String,String>();
private final Map<String, List<Instance>> entryRedirectionActions = new HashMap<String,List<Instance>>();
@Override
public void migrateBefore(Model model, Metamodel metamodel)
public void migrateBefore(final Model model, final Metamodel metamodel)
throws MigrationException {
for(Instance pageFlow : model.getAllInstances("process.PageFlow")){
for(final Instance pageFlow : model.getAllInstances("process.PageFlow")){
final String confirmationScript = pageFlow.get("confirmationMessage");
final String redirectionScript = pageFlow.get("entryRedirectionURL");
pageFlow.set("confirmationMessage", null);
......@@ -60,10 +61,10 @@ public class PageFlowMigration extends ReportCustomMigration {
entryRedirectionUrls.put(pageFlow.getUuid(), redirectionScript);
}
final List<Instance> actions = pageFlow.get("entryRedirectionActions");
List<Instance> operations = new ArrayList<Instance>();
for(Instance groovyScript : actions){
final List<Instance> operations = new ArrayList<Instance>();
for(final Instance groovyScript : actions){
final StringToExpressionConverter converter = getConverter(model,getScope(pageFlow));
Instance operation = converter.parseOperation(groovyScript, String.class.getName(), true);
final Instance operation = converter.parseOperation(groovyScript, String.class.getName(), true);
operations.add(operation);
model.delete(groovyScript);
}
......@@ -71,24 +72,24 @@ public class PageFlowMigration extends ReportCustomMigration {
entryRedirectionActions.put(pageFlow.getUuid(), operations);
}
}
for(Instance pageFlow : model.getAllInstances("process.ViewPageFlow")){
for(final Instance pageFlow : model.getAllInstances("process.ViewPageFlow")){
final String redirectionScript = pageFlow.get("viewPageFlowRedirectionURL");
pageFlow.set("viewPageFlowRedirectionURL", null);
if(redirectionScript != null && !redirectionScript.trim().isEmpty()){
viewRedirectionUrls.put(pageFlow.getUuid(), redirectionScript);
}
}
for(Instance pageFlow : model.getAllInstances("process.RecapFlow")){
for(final Instance pageFlow : model.getAllInstances("process.RecapFlow")){
final String redirectionScript = pageFlow.get("recapPageFlowRedirectionURL");
pageFlow.set("recapPageFlowRedirectionURL", null);
if(redirectionScript != null && !redirectionScript.trim().isEmpty()){
recapRedirectionUrls.put(pageFlow.getUuid(), redirectionScript);
}
}
for(Instance pageFlowTransition : model.getAllInstances("process.PageFlowTransition")){
for(final Instance pageFlowTransition : model.getAllInstances("process.PageFlowTransition")){
final String condition = pageFlowTransition.get("condition");
pageFlowTransition.set("condition", null);
if(condition != null && !condition.trim().isEmpty()){
......@@ -96,28 +97,58 @@ public class PageFlowMigration extends ReportCustomMigration {
}
}
}
@Override
public void migrateAfter(Model model, Metamodel metamodel)
public void migrateAfter(final Model model, final Metamodel metamodel)
throws MigrationException {
for(Instance pageFlow : model.getAllInstances("process.PageFlow")){
for(final Instance pageFlow : model.getAllInstances("process.PageFlow")){
setConfirmationMessage(pageFlow, model);
setEntryRedirectionURL(pageFlow,model);
setRedirectionActions(pageFlow,model);
}
for(Instance pageFlow : model.getAllInstances("process.ViewPageFlow")){
for(final Instance pageFlow : model.getAllInstances("process.ViewPageFlow")){
setViewRedirectionURL(pageFlow,model);
final List<Instance> transientDataInstances = pageFlow.get("viewTransientData");
for (final Instance viewTransientData : transientDataInstances) {
model.delete(viewTransientData);
}
final List<Instance> connectorDataInstances = pageFlow.get("viewPageFlowConnectors");
for (final Instance viewConnectorData : connectorDataInstances) {
model.delete(viewConnectorData);
}
final List<Instance> transitionsInstances = pageFlow.get("viewPageFlowTransitions");
for (final Instance transition : transitionsInstances) {
model.delete(transition);
}
}
for(Instance pageFlow : model.getAllInstances("process.RecapFlow")){
for(final Instance pageFlow : model.getAllInstances("process.RecapFlow")){
setRecapRedirectionURL(pageFlow,model);
}
for(Instance pageFlowTransition : model.getAllInstances("process.PageFlowTransition")){
for(final Instance pageFlowTransition : model.getAllInstances("process.PageFlowTransition")){
setPageFlowTransitionCondition(pageFlowTransition,model);
}
for (final Instance viewForm : model.getAllInstances("form.ViewForm")) {
final EReference ref = viewForm.getContainerReference();
if (ref != null
&& ref.getName().equals(ProcessPackage.Literals.VIEW_PAGE_FLOW__VIEW_FORM.getName())
&& ref.getEContainingClass().getName().equals(ProcessPackage.Literals.VIEW_PAGE_FLOW.getName())) {
model.delete(viewForm);
}
}
for (final Instance viewForm : model.getAllInstances("form.ViewForm")) {
final EReference ref = viewForm.getContainerReference();
if (ref != null
&& ref.getName().equals(ProcessPackage.Literals.VIEW_PAGE_FLOW__VIEW_FORM.getName())
&& ref.getEContainingClass().getName().equals(ProcessPackage.Literals.VIEW_PAGE_FLOW.getName())) {
model.delete(viewForm);
}
}
}
private void setPageFlowTransitionCondition(Instance pageFlowTransition,Model model) {
Instance expression = null;
private void setPageFlowTransitionCondition(final Instance pageFlowTransition,final Model model) {
Instance expression = null;
if(pageFlowTransitionConditions.containsKey(pageFlowTransition.getUuid())){
final StringToExpressionConverter converter = getConverter(model,getScope(pageFlowTransition));
final String url = pageFlowTransitionConditions.get(pageFlowTransition.getUuid());
......@@ -139,11 +170,11 @@ public class PageFlowMigration extends ReportCustomMigration {
expression = StringToExpressionConverter.createExpressionInstance(model, "", "", Boolean.class.getName(), ExpressionConstants.CONSTANT_TYPE, true);
}
pageFlowTransition.set("condition", expression);
}
private void setRecapRedirectionURL(Instance pageFlow, Model model) {
Instance expression = null;
private void setRecapRedirectionURL(final Instance pageFlow, final Model model) {
Instance expression = null;
if(recapRedirectionUrls.containsKey(pageFlow.getUuid())){
final StringToExpressionConverter converter = getConverter(model,getScope(pageFlow));
final String url = recapRedirectionUrls.get(pageFlow.getUuid());
......@@ -158,8 +189,8 @@ public class PageFlowMigration extends ReportCustomMigration {
pageFlow.set("recapPageFlowRedirectionURL", expression);
}
private void setViewRedirectionURL(Instance pageFlow, Model model) {
Instance expression = null;
private void setViewRedirectionURL(final Instance pageFlow, final Model model) {
Instance expression = null;
if(viewRedirectionUrls.containsKey(pageFlow.getUuid())){
final StringToExpressionConverter converter = getConverter(model,getScope(pageFlow));
final String url = viewRedirectionUrls.get(pageFlow.getUuid());
......@@ -174,18 +205,18 @@ public class PageFlowMigration extends ReportCustomMigration {
pageFlow.set("viewPageFlowRedirectionURL", expression);
}
private void setRedirectionActions(Instance pageFlow, Model model) {
private void setRedirectionActions(final Instance pageFlow, final Model model) {
if(entryRedirectionActions.containsKey(pageFlow.getUuid())){
pageFlow.get("entryRedirectionActions");
for(Instance operation : entryRedirectionActions.get(pageFlow.getUuid())){
for(final Instance operation : entryRedirectionActions.get(pageFlow.getUuid())){
pageFlow.add("entryRedirectionActions", operation);
addReportChange((String) pageFlow.get("name"),pageFlow.getType().getEClass().getName(), pageFlow.getUuid(),Messages.redirectionActionMigrationDescription, Messages.entryPageflowProperty, ExpressionConstants.SCRIPT_TYPE.equals(((Instance)operation.get("rightOperand")).get("type")) ? IStatus.WARNING : IStatus.OK);
}
}
}
private void setEntryRedirectionURL(Instance pageFlow, Model model) {
Instance expression = null;
private void setEntryRedirectionURL(final Instance pageFlow, final Model model) {
Instance expression = null;
if(entryRedirectionUrls.containsKey(pageFlow.getUuid())){
final StringToExpressionConverter converter = getConverter(model,getScope(pageFlow));
final String url = entryRedirectionUrls.get(pageFlow.getUuid());
......@@ -200,8 +231,8 @@ public class PageFlowMigration extends ReportCustomMigration {
pageFlow.set("entryRedirectionURL", expression);
}
private void setConfirmationMessage(Instance pageFlow, Model model) {
Instance expression = null;
private void setConfirmationMessage(final Instance pageFlow, final Model model) {
Instance expression = null;
if(confirmationMessages.containsKey(pageFlow.getUuid())){
final StringToExpressionConverter converter = getConverter(model,getScope(pageFlow));
final String confirmationMessage = confirmationMessages.get(pageFlow.getUuid());
......@@ -214,6 +245,6 @@ public class PageFlowMigration extends ReportCustomMigration {
expression = StringToExpressionConverter.createExpressionInstance(model, "", "", String.class.getName(), ExpressionConstants.CONSTANT_TYPE, true);
}
pageFlow.set("confirmationMessage", expression);
}
}
......@@ -39,17 +39,17 @@ import org.bonitasoft.studio.importer.bar.i18n.Messages;
*/
public class BarReaderUtil {
static List<String> findCustomConnectorClassName(File archiveFile) throws ZipException, IOException {
List<String> res = new ArrayList<String>();
static List<String> findCustomConnectorClassName(final File archiveFile) throws ZipException, IOException {
final List<String> res = new ArrayList<String>();
ZipFile zipfile = null;
try {
try {
zipfile = new ZipFile(archiveFile);
} catch (ZipException ex){
} catch (final ZipException ex){
BonitaStudioLog.error(ex);
return null;
return res;
}
Enumeration<?> enumEntries = zipfile.entries();
final Enumeration<?> enumEntries = zipfile.entries();
ZipEntry zipEntry = null;
String className = null;
String startWith = null;
......@@ -58,9 +58,9 @@ public class BarReaderUtil {
if (!zipEntry.isDirectory() && zipEntry.getName().endsWith(".class")) {
startWith = zipEntry.toString().replace(".class", "");
className = zipEntry.toString().replace("/", ".").replace(".class", "");
Enumeration<? extends ZipEntry> newEntries = zipfile.entries();
final Enumeration<? extends ZipEntry> newEntries = zipfile.entries();
while (newEntries.hasMoreElements()) {
ZipEntry newEntry = (ZipEntry) newEntries.nextElement();
final ZipEntry newEntry = newEntries.nextElement();
if (!newEntry.isDirectory() && newEntry.toString().endsWith(startWith + ".properties")) {
res.add(className);
}
......@@ -72,11 +72,10 @@ public class BarReaderUtil {
zipfile.close();
}
}
return res;
}
static File getProcFormBar(File archiveFile) throws Exception {
static File getProcFormBar(final File archiveFile) throws Exception {
ZipInputStream zin = null;
FileOutputStream out = null;
try {
......@@ -88,12 +87,12 @@ public class BarReaderUtil {
if (zipEntry == null) {
throw new FileNotFoundException(Messages.bind(Messages.invalidArchiveStructure, archiveFile.getName()));
}
String entryName = zipEntry.getName();
final String entryName = zipEntry.getName();
if (entryName.indexOf("/") != -1) {
entryName.substring(entryName.lastIndexOf("/"));
}
final File tempFile = new File(ProjectUtil.getBonitaStudioWorkFolder(), entryName);
byte[] buf = new byte[1024];
final byte[] buf = new byte[1024];
tempFile.delete();
int len;
out = new FileOutputStream(tempFile);
......
......@@ -118,12 +118,15 @@ public class CustomConnectorMigrator {
fos.close();
}
}
final URLClassLoader customURLClassLoader = createBarClassloader(archiveFile, tmpConnectorJarFile);
BonitaStudioLog.debug("Searching for custom connector in " + tmpConnectorJarFile.getName() + "...", BarImporterPlugin.PLUGIN_ID);
if (tmpConnectorJarFile.length() == 0) {
BonitaStudioLog.debug(tmpConnectorJarFile.getName() + " is empty.", BarImporterPlugin.PLUGIN_ID);
return;
}
final URLClassLoader customURLClassLoader = createBarClassloader(archiveFile, tmpConnectorJarFile);
final List<String> connectorClassnames = BarReaderUtil.findCustomConnectorClassName(tmpConnectorJarFile);
if (connectorClassnames == null || connectorClassnames.isEmpty()) {
if (connectorClassnames.isEmpty()) {
BonitaStudioLog.debug("No custom connector found in:" + tmpConnectorJarFile.getName(), BarImporterPlugin.PLUGIN_ID);
} else {
for (final String connectorClassname : connectorClassnames) {
......
......@@ -5,12 +5,12 @@
* 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
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
......@@ -43,6 +43,7 @@ import org.bonitasoft.studio.common.repository.Repository;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.common.repository.model.IRepositoryFileStore;
import org.bonitasoft.studio.data.attachment.repository.DocumentRepositoryStore;
import org.bonitasoft.studio.dependencies.repository.DependencyFileStore;
import org.bonitasoft.studio.dependencies.repository.DependencyRepositoryStore;
import org.bonitasoft.studio.diagram.custom.repository.ApplicationResourceRepositoryStore;
import org.bonitasoft.studio.diagram.custom.repository.DiagramRepositoryStore;
......@@ -87,7 +88,7 @@ import org.eclipse.ui.PlatformUI;
/**
* @author Romain Bioteau
*
*
*/
public class EdaptBarToProcProcessor extends ToProcProcessor {
......@@ -305,7 +306,10 @@ public class EdaptBarToProcProcessor extends ToProcProcessor {
zipEntry = (ZipEntry) enumEntries.nextElement();
final File currentFile = new File(zipEntry.getName());
if (!zipEntry.isDirectory() && zipEntry.getName().contains(FORMS_LIBS) && zipEntry.getName().endsWith(".jar")) {
store.importInputStream(currentFile.getName(), zipfile.getInputStream(zipEntry));
final DependencyFileStore dependencyFileStore = store.importInputStream(currentFile.getName(), zipfile.getInputStream(zipEntry));
if (dependencyFileStore == null) {
BonitaStudioLog.debug("Failed to import application dependency " + currentFile.getName(), BarImporterPlugin.PLUGIN_ID);
}
}
if (!zipEntry.isDirectory() && zipEntry.getName().contains(VALIDATORS) && zipEntry.getName().endsWith(".jar")) {
if (store.getChild(currentFile.getName()) == null) {
......@@ -331,7 +335,10 @@ public class EdaptBarToProcProcessor extends ToProcProcessor {
final File currentFile = new File(zipEntry.getName());
if (!zipEntry.isDirectory() && zipEntry.getName().contains(LIBS) && zipEntry.getName().endsWith(".jar")) {
if (!customConnectorMigrator.getImportedJarNames().contains(currentFile.getName()) && store.getChild(currentFile.getName()) == null) {
store.importInputStream(currentFile.getName(), zipfile.getInputStream(zipEntry));
final DependencyFileStore dependencyFileStore = store.importInputStream(currentFile.getName(), zipfile.getInputStream(zipEntry));
if (dependencyFileStore == null) {
BonitaStudioLog.debug("Failed to import process dependency " + currentFile.getName(), BarImporterPlugin.PLUGIN_ID);
}
}
}
}
......
Supports Markdown
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