]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.migration.ui/src/org/simantics/migration/ui/IsMigrationPossible.java
(refs #7614) Assign type-checked expression back to list comprehension
[simantics/platform.git] / bundles / org.simantics.migration.ui / src / org / simantics / migration / ui / IsMigrationPossible.java
1 package org.simantics.migration.ui;
2
3 import org.simantics.browsing.ui.model.tests.Test;
4 import org.simantics.db.ReadGraph;
5 import org.simantics.db.Resource;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.layer0.SoftwareConfigurationResources;
8
9 public class IsMigrationPossible implements Test {
10
11     @Override
12     public boolean isCompatible(Class<?> contentType) {
13         return contentType.equals(Resource.class);
14     }
15
16     @Override
17     public boolean test(ReadGraph graph, Object content) throws DatabaseException {
18         Resource resource = (Resource)content;
19         SoftwareConfigurationResources SC = SoftwareConfigurationResources.getInstance(graph);
20         
21         for(Resource version : graph.getObjects(resource, SC.IsCompatibleWith))
22             if(graph.hasStatement(version, SC.Version_HasUpdate))
23                 return true;
24         return false;
25     }
26
27 }