Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2013-01-18 19:31:46 +0000
committerRoberto E. Escobar2013-01-18 19:37:25 +0000
commit1be9de09381c28eebb3df604ae645f3210d9474c (patch)
tree7adb1584383fcb58a4fe6e45334056788b060227
parent020d9bb530a0f53cc18e2be4520c8bed49fb3dcc (diff)
downloadorg.eclipse.osee-1be9de09381c28eebb3df604ae645f3210d9474c.tar.gz
org.eclipse.osee-1be9de09381c28eebb3df604ae645f3210d9474c.tar.xz
org.eclipse.osee-1be9de09381c28eebb3df604ae645f3210d9474c.zip
feature[ats_L63H6]: Implement client rest search api
-rw-r--r--features/org.eclipse.osee.core.feature/feature.xml7
-rw-r--r--features/org.eclipse.osee.framework.feature.source/feature.xml7
-rw-r--r--features/org.eclipse.osee.framework.feature/feature.xml7
-rw-r--r--features/org.eclipse.osee.orcs.feature.source/feature.xml7
-rw-r--r--features/org.eclipse.osee.orcs.feature/feature.xml7
-rw-r--r--features/org.eclipse.osee.x.core.external.feature/feature.xml1
-rw-r--r--features/org.eclipse.osee.x.server.external.feature/feature.xml2
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/StateManager.java3
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ArtifactImpactToActionSearchItem.java6
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java2
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/review/ReviewWorldSearchItem.java6
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/OpenByIdSearchPerformance.java100
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ActionableItemWorldSearchItem.java4
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/GoalSearchItem.java4
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MyGoalWorkflowItem.java3
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MyReviewWorkflowItem.java3
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ShowOpenWorkflowsByArtifactType.java4
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/TaskSearchWorldSearchItem.java3
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/TeamWorldSearchItem.java8
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/UserWorldSearchItem.java4
-rw-r--r--plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddRequirementData.java6
-rw-r--r--plugins/org.eclipse.osee.client.integration.tests/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.client.integration.tests/osee-application-server.xml2
-rw-r--r--plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactLoaderTest.java14
-rw-r--r--plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java25
-rw-r--r--plugins/org.eclipse.osee.client.parent/pom.xml2
-rw-r--r--plugins/org.eclipse.osee.client.test.framework/src/org/eclipse/osee/client/test/framework/OseeClientIntegrationRule.java9
-rw-r--r--plugins/org.eclipse.osee.display.presenter/src/org/eclipse/osee/display/presenter/ArtifactProviderImpl.java9
-rw-r--r--plugins/org.eclipse.osee.framework.core.client/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.framework.core.client/OSGI-INF/client.uri.provider.xml7
-rw-r--r--plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/internal/URIProviderImpl.java49
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/URIProvider.java27
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CaseType.java (renamed from plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/CaseType.java)9
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/MatchTokenCountType.java28
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/Operator.java44
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/OptionVisitor.java26
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/QueryOption.java19
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/StringOperator.java (renamed from plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/StringOperator.java)10
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/TokenDelimiterMatch.java42
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/TokenOrderType.java28
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/Conditions.java7
-rw-r--r--plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SearchEngineServlet.java10
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/AllSkynetCoreJunitTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactSearchTestSuite.java23
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeCriteriaTest.java57
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/search/RelationCriteriaTest.java44
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java8
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactTypeManager.java11
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AbstractArtifactSearchCriteria.java36
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java43
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java433
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactSearchCriteria.java (renamed from plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/Operator.java)22
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeCriteria.java163
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/QueryOptions.java35
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/RelationCriteria.java45
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/search/QueryStatisticsTest.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaAttributeKeyword.java24
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaAttributeOther.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CallableQueryFactory.java12
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CriteriaFactory.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryBuilderImpl.java33
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractArtifactSearchCallable.java33
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractSearchCallable.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/LocalIdSearchCallable.java156
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCallable.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCountCallable.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchMatchesCallable.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImplTest.java39
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlHandlerFactoryImplTest.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcherTest.java222
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/UtilityTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcherTest.java93
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryModuleFactory.java13
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlWriter.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeOtherSqlHandler.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTokenSqlHandler.java66
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/BaseAttributeTagger.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/DefaultAttributeTagger.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/StreamMatcher.java25
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/Tagger.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TaggingEngine.java18
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlAttributeTagger.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AbstractQueryPostProcessor.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AnyTokenOrderProcessor.java103
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/CheckedOptions.java84
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/DataPostProcessorFactoryImpl.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/MatchTokenOrderProcessor.java81
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/MatcherFactory.java34
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcher.java103
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenOrderProcessor.java34
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenOrderProcessorFactory.java20
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcher.java119
-rw-r--r--plugins/org.eclipse.osee.orcs.parent/pom.xml1
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/.classpath7
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/.project33
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/META-INF/MANIFEST.MF25
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/OSGI-INF/osee.client.xml9
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/OSGI-INF/web.client.provider.xml8
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/build.properties10
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/pom.xml35
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java22
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/QueryBuilder.java196
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/Options.java82
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java64
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/WebClientProvider.java28
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/WebClientProviderImpl.java102
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/OptionConverter.java89
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactory.java46
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactoryImpl.java161
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryBuilderImpl.java284
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryOptions.java64
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/SearchResultProvider.java29
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/V1SearchResultProvider.java93
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/.classpath7
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/.project28
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/META-INF/MANIFEST.MF15
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/build.properties6
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/pom.xml34
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Branch.java60
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Transaction.java78
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/OutputFormat.java18
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/Predicate.java (renamed from plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/Predicate.java)34
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/RequestType.java19
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchFlag.java (renamed from plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchFlag.java)11
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchMethod.java (renamed from plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchMethod.java)5
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchOp.java (renamed from plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchOp.java)6
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchParameters.java123
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchResult.java (renamed from plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/SearchResult.java)26
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImplTest.java56
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java117
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandlerTest.java132
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java191
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IdsPredicateHandlerTest.java96
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandlerTest.java65
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandlerTest.java89
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/build.properties3
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/ArtifactSearch_V1.java78
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/PredicateHandler.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/SearchParameters.java67
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslFactory.java (renamed from plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/PredicateHandlerFactory.java)17
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslator.java24
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImpl_V1.java (renamed from plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImpl.java)36
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchQueryBuilder.java (renamed from plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDsl.java)42
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandler.java95
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandler.java27
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IdsPredicateHandler.java21
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandler.java11
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/PredicateHandlerUtil.java19
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandler.java60
-rw-r--r--plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsAttributeLoadingTest.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsAttributeSearchTest.java12
-rw-r--r--plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsRelationLoadingTest.java2
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/ApiTester.java1
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/QueryBuilder.java21
161 files changed, 4277 insertions, 1785 deletions
diff --git a/features/org.eclipse.osee.core.feature/feature.xml b/features/org.eclipse.osee.core.feature/feature.xml
index 4c7b01a1ad0..11f7c2ce354 100644
--- a/features/org.eclipse.osee.core.feature/feature.xml
+++ b/features/org.eclipse.osee.core.feature/feature.xml
@@ -69,4 +69,11 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.eclipse.osee.orcs.rest.model"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
diff --git a/features/org.eclipse.osee.framework.feature.source/feature.xml b/features/org.eclipse.osee.framework.feature.source/feature.xml
index f08385136d2..26107fe650a 100644
--- a/features/org.eclipse.osee.framework.feature.source/feature.xml
+++ b/features/org.eclipse.osee.framework.feature.source/feature.xml
@@ -122,4 +122,11 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.eclipse.osee.orcs.rest.client.source"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
diff --git a/features/org.eclipse.osee.framework.feature/feature.xml b/features/org.eclipse.osee.framework.feature/feature.xml
index b3e2ff79e7f..368d4f3a3aa 100644
--- a/features/org.eclipse.osee.framework.feature/feature.xml
+++ b/features/org.eclipse.osee.framework.feature/feature.xml
@@ -136,4 +136,11 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.eclipse.osee.orcs.rest.client"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
diff --git a/features/org.eclipse.osee.orcs.feature.source/feature.xml b/features/org.eclipse.osee.orcs.feature.source/feature.xml
index 4c557d32189..00c1d839a7c 100644
--- a/features/org.eclipse.osee.orcs.feature.source/feature.xml
+++ b/features/org.eclipse.osee.orcs.feature.source/feature.xml
@@ -88,6 +88,13 @@
unpack="false"/>
<plugin
+ id="org.eclipse.osee.orcs.rest.model.source"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
id="org.eclipse.osee.framework.core.dsl.source"
download-size="0"
install-size="0"
diff --git a/features/org.eclipse.osee.orcs.feature/feature.xml b/features/org.eclipse.osee.orcs.feature/feature.xml
index ecaee921e69..58abe76fab1 100644
--- a/features/org.eclipse.osee.orcs.feature/feature.xml
+++ b/features/org.eclipse.osee.orcs.feature/feature.xml
@@ -108,4 +108,11 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.eclipse.osee.orcs.rest.model"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
diff --git a/features/org.eclipse.osee.x.core.external.feature/feature.xml b/features/org.eclipse.osee.x.core.external.feature/feature.xml
index 136558ab9cd..855349f397a 100644
--- a/features/org.eclipse.osee.x.core.external.feature/feature.xml
+++ b/features/org.eclipse.osee.x.core.external.feature/feature.xml
@@ -30,6 +30,7 @@
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.slf4j.api" version="1.6.1" match="equivalent"/>
<import plugin="javax.servlet" version="2.5.0" match="compatible"/>
+ <import plugin="org.apache.log4j" version="1.2.15" match="greaterOrEqual"/>
</requires>
<plugin
diff --git a/features/org.eclipse.osee.x.server.external.feature/feature.xml b/features/org.eclipse.osee.x.server.external.feature/feature.xml
index 1506ccf54ef..40183243b69 100644
--- a/features/org.eclipse.osee.x.server.external.feature/feature.xml
+++ b/features/org.eclipse.osee.x.server.external.feature/feature.xml
@@ -38,7 +38,7 @@
<import plugin="org.eclipse.emf.ecore" version="2.5.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.emf.common" version="2.5.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.xtext.util" version="2.0.0" match="greaterOrEqual"/>
- <import plugin="org.apache.log4j"/>
+ <import plugin="org.apache.log4j" version="1.2.15" match="greaterOrEqual"/>
<import plugin="org.eclipse.emf.ecore" version="2.3.2" match="greaterOrEqual"/>
<import plugin="org.eclipse.core.runtime" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.emf.common" version="2.8.0" match="compatible"/>
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/StateManager.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/StateManager.java
index 6080dc58045..aabc4215851 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/StateManager.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/StateManager.java
@@ -58,6 +58,7 @@ import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.artifact.search.QueryOptions;
/**
* @author Donald G. Dunne
@@ -315,7 +316,7 @@ public class StateManager implements IAtsNotificationListener, WorkStateProvider
public static Set<Artifact> getAssigned(String userId, Class<?> clazz) throws OseeCoreException {
Set<Artifact> assigned = new HashSet<Artifact>();
for (Artifact artifact : ArtifactQuery.getArtifactListFromAttribute(AtsAttributeTypes.CurrentState,
- "%<" + userId + ">%", AtsUtilCore.getAtsBranch())) {
+ "<" + userId + ">", AtsUtilCore.getAtsBranch(), QueryOptions.CONTAINS_MATCH_OPTIONS)) {
if (clazz == null || clazz.isInstance(artifact)) {
assigned.add(artifact);
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ArtifactImpactToActionSearchItem.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ArtifactImpactToActionSearchItem.java
index 869ae12759a..e25a62aac7c 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ArtifactImpactToActionSearchItem.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ArtifactImpactToActionSearchItem.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.ats.navigate;
-import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED;
+import static org.eclipse.osee.framework.core.enums.DeletionFlag.*;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -33,6 +33,7 @@ import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.artifact.search.QueryOptions;
import org.eclipse.osee.framework.skynet.core.revision.ChangeManager;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
@@ -93,7 +94,8 @@ public class ArtifactImpactToActionSearchItem extends XNavigateItemAction {
private void getMatrixItems() throws OseeCoreException {
final Collection<Artifact> srchArts =
- ArtifactQuery.getArtifactListFromName("%" + artifactName + "%", branch, INCLUDE_DELETED);
+ ArtifactQuery.getArtifactListFromName(artifactName, branch, INCLUDE_DELETED,
+ QueryOptions.CONTAINS_MATCH_OPTIONS);
final Set<Artifact> processArts = new HashSet<Artifact>();
if (srchArts.isEmpty()) {
return;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java
index 06c24edc6a8..f013e7f151c 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java
@@ -46,7 +46,6 @@ import org.eclipse.osee.ats.util.AtsEditor;
import org.eclipse.osee.ats.util.ConvertAIsAndTeamDefinitions;
import org.eclipse.osee.ats.util.CreateActionUsingAllActionableItems;
import org.eclipse.osee.ats.util.DoesNotWorkItemAts;
-import org.eclipse.osee.ats.util.OpenByIdSearchPerformance;
import org.eclipse.osee.ats.util.Import.ImportActionsViaSpreadsheetBlam;
import org.eclipse.osee.ats.version.CreateNewVersionItem;
import org.eclipse.osee.ats.version.GenerateFullVersionReportItem;
@@ -171,7 +170,6 @@ public final class AtsNavigateViewItems implements XNavigateViewItems, IXNavigat
new MultipleHridSearchOperationFactory("Search by ID(s) - Open Workflow Editor", AtsEditor.WorkflowEditor)));
items.add(new XNavigateItemOperation(item, AtsImage.GLOBE, "Quick Search",
new AtsQuickSearchOperationFactory()));
- items.add(new OpenByIdSearchPerformance(item));
items.add(new ArtifactImpactToActionSearchItem(null));
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/review/ReviewWorldSearchItem.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/review/ReviewWorldSearchItem.java
index a7f5ea9b9da..13005b35777 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/review/ReviewWorldSearchItem.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/review/ReviewWorldSearchItem.java
@@ -41,7 +41,7 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeTypeDoesNotExist;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.search.AbstractArtifactSearchCriteria;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactSearchCriteria;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.artifact.search.AttributeCriteria;
import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager;
@@ -147,7 +147,7 @@ public class ReviewWorldSearchItem extends WorldUISearchItem {
actionableItemGuids.add(aia.getGuid());
}
}
- List<AbstractArtifactSearchCriteria> criteria = new ArrayList<AbstractArtifactSearchCriteria>();
+ List<ArtifactSearchCriteria> criteria = new ArrayList<ArtifactSearchCriteria>();
if (actionableItemGuids.isEmpty()) {
criteria.add(new AttributeCriteria(AtsAttributeTypes.ActionableItem));
} else {
@@ -219,7 +219,7 @@ public class ReviewWorldSearchItem extends WorldUISearchItem {
}
- public static void addIncludeCompletedCancelledCriteria(List<AbstractArtifactSearchCriteria> criteria, boolean includeCompleted, boolean includeCancelled) throws OseeCoreException {
+ public static void addIncludeCompletedCancelledCriteria(List<ArtifactSearchCriteria> criteria, boolean includeCompleted, boolean includeCancelled) throws OseeCoreException {
try {
if (AttributeTypeManager.getType(AtsAttributeTypes.CurrentStateType) != null) {
if (!includeCancelled && !includeCompleted) {
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/OpenByIdSearchPerformance.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/OpenByIdSearchPerformance.java
deleted file mode 100644
index e54e95db67a..00000000000
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/OpenByIdSearchPerformance.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.ats.util;
-
-import java.rmi.activation.Activator;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
-import org.eclipse.osee.ats.api.team.IAtsTeamDefinition;
-import org.eclipse.osee.ats.world.search.LegacyPcrIdQuickSearch;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.logging.OseeLevel;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache;
-import org.eclipse.osee.framework.skynet.core.artifact.search.AbstractArtifactSearchCriteria;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
-import org.eclipse.osee.framework.skynet.core.artifact.search.AttributeCriteria;
-import org.eclipse.osee.framework.skynet.core.utility.ElapsedTime;
-import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
-import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
-import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
-import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItemAction;
-
-/**
- * @author Donald G. Dunne
- */
-public class OpenByIdSearchPerformance extends XNavigateItemAction {
-
- public OpenByIdSearchPerformance(XNavigateItem parent) {
- super(parent, "OpenByIdSearchPerformance", PluginUiImage.ADMIN);
- }
-
- @Override
- public void run(TableLoadOption... tableLoadOptions) {
-
- List<String> pcrIds = new ArrayList<String>();
- pcrIds.add("8125");
-
- try {
- ElapsedTime time = new ElapsedTime("LegacyPCRActions");
- List<Artifact> resultAtsArts = new ArrayList<Artifact>();
- resultAtsArts.addAll(LegacyPCRActions.getTeamsTeamWorkflowArtifacts(pcrIds,
- (Collection<IAtsTeamDefinition>) null));
- System.out.println("Found " + resultAtsArts.size());
- time.end();
-
- // decache to make it fair
- for (Artifact resulArtifact : resultAtsArts) {
- ArtifactCache.deCache(resulArtifact);
- }
- resultAtsArts.clear();
-
- time = new ElapsedTime("getArtifactListFromAttribute");
- resultAtsArts.addAll(ArtifactQuery.getArtifactListFromAttribute(AtsAttributeTypes.LegacyPcrId, "8125",
- AtsUtil.getAtsBranchToken()));
- System.out.println("Found " + resultAtsArts.size());
- time.end();
-
- // decache to make it fair
- for (Artifact resulArtifact : resultAtsArts) {
- ArtifactCache.deCache(resulArtifact);
- }
- resultAtsArts.clear();
-
- time = new ElapsedTime("criteria search");
- List<AbstractArtifactSearchCriteria> criteria = new ArrayList<AbstractArtifactSearchCriteria>(4);
- criteria.add(new AttributeCriteria(AtsAttributeTypes.LegacyPcrId, pcrIds));
- ArtifactQuery.getArtifactListFromCriteria(AtsUtil.getAtsBranch(), 200, criteria);
- System.out.println("Found " + resultAtsArts.size());
- time.end();
-
- // decache to make it fair
- for (Artifact resulArtifact : resultAtsArts) {
- ArtifactCache.deCache(resulArtifact);
- }
- resultAtsArts.clear();
-
- time = new ElapsedTime("attr quicksearch");
- LegacyPcrIdQuickSearch search = new LegacyPcrIdQuickSearch(Arrays.asList("8125"));
- resultAtsArts.addAll(search.performSearch());
- System.out.println("Found " + resultAtsArts.size());
- time.end();
-
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
- }
-
- }
-}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ActionableItemWorldSearchItem.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ActionableItemWorldSearchItem.java
index 220d24dcffc..e647a830c49 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ActionableItemWorldSearchItem.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ActionableItemWorldSearchItem.java
@@ -28,7 +28,7 @@ import org.eclipse.osee.ats.util.widgets.dialog.ActionActionableItemListDialog;
import org.eclipse.osee.framework.core.enums.Active;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.search.AbstractArtifactSearchCriteria;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactSearchCriteria;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.artifact.search.AttributeCriteria;
@@ -128,7 +128,7 @@ public class ActionableItemWorldSearchItem extends WorldUISearchItem {
for (IAtsActionableItem ai : items) {
actionItemGuids.add(ai.getGuid());
}
- List<AbstractArtifactSearchCriteria> criteria = new ArrayList<AbstractArtifactSearchCriteria>();
+ List<ArtifactSearchCriteria> criteria = new ArrayList<ArtifactSearchCriteria>();
criteria.add(new AttributeCriteria(AtsAttributeTypes.ActionableItem, actionItemGuids));
// exclude completed or canceled
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/GoalSearchItem.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/GoalSearchItem.java
index 559cb0add33..29bafdf3380 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/GoalSearchItem.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/GoalSearchItem.java
@@ -29,7 +29,7 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.skynet.core.User;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.search.AbstractArtifactSearchCriteria;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactSearchCriteria;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.artifact.search.AttributeCriteria;
@@ -108,7 +108,7 @@ public class GoalSearchItem extends WorldUISearchItem {
teamDefinitionGuids.add(teamDef.getGuid());
}
}
- List<AbstractArtifactSearchCriteria> criteria = new ArrayList<AbstractArtifactSearchCriteria>();
+ List<ArtifactSearchCriteria> criteria = new ArrayList<ArtifactSearchCriteria>();
if (!teamDefinitionGuids.isEmpty()) {
criteria.add(new AttributeCriteria(AtsAttributeTypes.TeamDefinition, teamDefinitionGuids));
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MyGoalWorkflowItem.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MyGoalWorkflowItem.java
index d2f61939a37..3b2b83ad3a9 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MyGoalWorkflowItem.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MyGoalWorkflowItem.java
@@ -25,6 +25,7 @@ import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.artifact.search.QueryOptions;
import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
/**
@@ -62,7 +63,7 @@ public class MyGoalWorkflowItem extends UserSearchItem {
artifacts.addAll(RelationManager.getRelatedArtifacts(assigned, 1, AtsRelationTypes.SmaToTask_Sma));
} else {
artifacts.addAll(ArtifactQuery.getArtifactListFromAttribute(AtsAttributeTypes.State,
- "%<" + user.getUserId() + ">%", AtsUtil.getAtsBranch()));
+ "<" + user.getUserId() + ">", AtsUtil.getAtsBranch(), QueryOptions.CONTAINS_MATCH_OPTIONS));
}
List<Artifact> artifactsToReturn = new ArrayList<Artifact>(artifacts.size());
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MyReviewWorkflowItem.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MyReviewWorkflowItem.java
index 1ca60fb8f2b..d4010b92425 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MyReviewWorkflowItem.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MyReviewWorkflowItem.java
@@ -25,6 +25,7 @@ import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.artifact.search.QueryOptions;
import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
/**
@@ -62,7 +63,7 @@ public class MyReviewWorkflowItem extends UserSearchItem {
artifacts.addAll(RelationManager.getRelatedArtifacts(assigned, 1, AtsRelationTypes.SmaToTask_Sma));
} else {
artifacts.addAll(ArtifactQuery.getArtifactListFromAttribute(AtsAttributeTypes.State,
- "%<" + user.getUserId() + ">%", AtsUtil.getAtsBranch()));
+ "<" + user.getUserId() + ">", AtsUtil.getAtsBranch(), QueryOptions.CONTAINS_MATCH_OPTIONS));
}
List<Artifact> artifactsToReturn = new ArrayList<Artifact>(artifacts.size());
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ShowOpenWorkflowsByArtifactType.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ShowOpenWorkflowsByArtifactType.java
index c4a4e6ebdcf..3ec042414f3 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ShowOpenWorkflowsByArtifactType.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/ShowOpenWorkflowsByArtifactType.java
@@ -18,7 +18,7 @@ import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.search.AbstractArtifactSearchCriteria;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactSearchCriteria;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
import org.eclipse.osee.framework.ui.swt.KeyedImage;
@@ -51,7 +51,7 @@ public class ShowOpenWorkflowsByArtifactType extends WorldUISearchItem {
List<Artifact> artifacts = null;
if (!showFinished) {
- List<AbstractArtifactSearchCriteria> criteria = new ArrayList<AbstractArtifactSearchCriteria>();
+ List<ArtifactSearchCriteria> criteria = new ArrayList<ArtifactSearchCriteria>();
TeamWorldSearchItem.addIncludeCompletedCancelledCriteria(criteria, showFinished, showFinished);
artifacts = ArtifactQuery.getArtifactListFromTypeAnd(artifactType, AtsUtil.getAtsBranch(), 500, criteria);
} else {
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/TaskSearchWorldSearchItem.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/TaskSearchWorldSearchItem.java
index ad36cc5b48d..e26d9711db3 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/TaskSearchWorldSearchItem.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/TaskSearchWorldSearchItem.java
@@ -50,6 +50,7 @@ import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.User;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.artifact.search.QueryOptions;
import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
import org.eclipse.osee.framework.ui.skynet.widgets.XCheckBox;
@@ -120,7 +121,7 @@ public class TaskSearchWorldSearchItem extends TaskEditorParameterSearchItem {
// Note: Don't need to do this for Originator, Subscribed or Favorites, cause it does completed canceled in it's own searches
userTaskArts.addAll(Collections.castMatching(TaskArtifact.class,
ArtifactQuery.getArtifactListFromTypeAndAttribute(AtsArtifactTypes.Task, AtsAttributeTypes.State,
- "%<" + user.getUserId() + ">%", AtsUtil.getAtsBranch())));
+ "<" + user.getUserId() + ">", AtsUtil.getAtsBranch(), QueryOptions.CONTAINS_MATCH_OPTIONS)));
}
Set<TaskArtifact> removeTaskArts = new HashSet<TaskArtifact>();
for (TaskArtifact taskArt : userTaskArts) {
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/TeamWorldSearchItem.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/TeamWorldSearchItem.java
index e430afc0f84..400ff34ce0c 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/TeamWorldSearchItem.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/TeamWorldSearchItem.java
@@ -35,14 +35,14 @@ import org.eclipse.osee.ats.core.config.TeamDefinitions;
import org.eclipse.osee.ats.internal.Activator;
import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.enums.Operator;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeTypeDoesNotExist;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.search.AbstractArtifactSearchCriteria;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactSearchCriteria;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.artifact.search.AttributeCriteria;
-import org.eclipse.osee.framework.skynet.core.artifact.search.Operator;
import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager;
import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
@@ -157,7 +157,7 @@ public class TeamWorldSearchItem extends WorldUISearchItem {
teamDefinitionGuids.add(teamDef.getGuid());
}
}
- List<AbstractArtifactSearchCriteria> criteria = new ArrayList<AbstractArtifactSearchCriteria>();
+ List<ArtifactSearchCriteria> criteria = new ArrayList<ArtifactSearchCriteria>();
if (teamDefinitionGuids.isEmpty()) {
criteria.add(new AttributeCriteria(AtsAttributeTypes.TeamDefinition));
@@ -226,7 +226,7 @@ public class TeamWorldSearchItem extends WorldUISearchItem {
}
- public static void addIncludeCompletedCancelledCriteria(List<AbstractArtifactSearchCriteria> criteria, boolean includeCompleted, boolean includeCancelled) throws OseeCoreException {
+ public static void addIncludeCompletedCancelledCriteria(List<ArtifactSearchCriteria> criteria, boolean includeCompleted, boolean includeCancelled) throws OseeCoreException {
try {
if (AttributeTypeManager.getType(AtsAttributeTypes.CurrentStateType) != null) {
if (!includeCancelled && !includeCompleted) {
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/UserWorldSearchItem.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/UserWorldSearchItem.java
index f151a5b57e9..d03e537c603 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/UserWorldSearchItem.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/UserWorldSearchItem.java
@@ -30,6 +30,7 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.artifact.search.QueryOptions;
/**
* @author Donald G. Dunne
@@ -77,7 +78,8 @@ public class UserWorldSearchItem {
// Note: Don't need to do this for Originator, Subscribed or Favorites, cause it does completed canceled in it's own searches
if (options.contains(UserSearchOption.IncludeCancelled) || options.contains(UserSearchOption.IncludeCompleted)) {
searchArts.addAll(WorkflowManager.getAwas(ArtifactQuery.getArtifactListFromAttribute(
- AtsAttributeTypes.State, "%<" + user.getUserId() + ">%", AtsUtil.getAtsBranch())));
+ AtsAttributeTypes.State, "<" + user.getUserId() + ">", AtsUtil.getAtsBranch(),
+ QueryOptions.CONTAINS_MATCH_OPTIONS)));
}
}
diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddRequirementData.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddRequirementData.java
index 4f506d86368..120ae57ed3b 100644
--- a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddRequirementData.java
+++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddRequirementData.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.client.demo.internal;
-import static java.lang.Thread.sleep;
+import static java.lang.Thread.*;
import java.io.File;
import java.net.URL;
import java.util.Collection;
@@ -37,6 +37,7 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.artifact.search.QueryOptions;
import org.eclipse.osee.framework.skynet.core.importing.parsers.IArtifactExtractor;
import org.eclipse.osee.framework.skynet.core.importing.parsers.WordOutlineExtractor;
import org.eclipse.osee.framework.skynet.core.importing.parsers.WordOutlineExtractorDelegate;
@@ -253,7 +254,8 @@ public class AddRequirementData implements IDbInitializationTask {
artifactNameStr, branch.getName());
}
Collection<Artifact> arts =
- ArtifactQuery.getArtifactListFromTypeAndName(artifactType, "%" + artifactNameStr + "%", branch);
+ ArtifactQuery.getArtifactListFromTypeAndName(artifactType, artifactNameStr, branch,
+ QueryOptions.CONTAINS_MATCH_OPTIONS);
if (DEBUG) {
OseeLog.logf(AddRequirementData.class, Level.INFO, "Found [%s] Artifacts", arts.size());
}
diff --git a/plugins/org.eclipse.osee.client.integration.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.client.integration.tests/META-INF/MANIFEST.MF
index a2aa664dc78..dc8a01ff749 100644
--- a/plugins/org.eclipse.osee.client.integration.tests/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.client.integration.tests/META-INF/MANIFEST.MF
@@ -18,6 +18,7 @@ Import-Package: org.eclipse.core.runtime,
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.exception,
org.eclipse.osee.framework.core.model,
+ org.eclipse.osee.framework.core.model.cache,
org.eclipse.osee.framework.core.model.event,
org.eclipse.osee.framework.core.model.type,
org.eclipse.osee.framework.core.operation,
diff --git a/plugins/org.eclipse.osee.client.integration.tests/osee-application-server.xml b/plugins/org.eclipse.osee.client.integration.tests/osee-application-server.xml
index 13fb313ccc7..61d7d5c9a05 100644
--- a/plugins/org.eclipse.osee.client.integration.tests/osee-application-server.xml
+++ b/plugins/org.eclipse.osee.client.integration.tests/osee-application-server.xml
@@ -62,7 +62,7 @@
<forget>
<echo message="Launching Osee Application Server..." />
<!-- Test Should Complete in 30 mins (timeout vale) - currently, they only take ~13 mins -->
- <java taskname="build" failonerror="true" maxmemory="1024m" timeout="1800000" jar="${launcherJarPath}" fork="true">
+ <java taskname="int-test-server" failonerror="true" maxmemory="1024m" timeout="1800000" jar="${launcherJarPath}" fork="true">
<classpath>
<fileset dir="${xserver-home}/plugins" includes="org.eclipse.equinox.launcher_*.jar" />
<pathelement location="${xserver-home}/plugins" />
diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactLoaderTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactLoaderTest.java
index c73183be3a7..27590331acf 100644
--- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactLoaderTest.java
+++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactLoaderTest.java
@@ -10,8 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.client.integration.tests.integration.skynet.core;
-import static org.eclipse.osee.client.demo.DemoChoice.OSEE_CLIENT_DEMO;
-import static org.eclipse.osee.framework.core.enums.DeletionFlag.EXCLUDE_DELETED;
+import static org.eclipse.osee.client.demo.DemoChoice.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
@@ -78,7 +77,7 @@ public class ArtifactLoaderTest {
public void tearDown() throws Exception {
SkynetTransaction transaction = TransactionManager.createTransaction(branch, testInfo.getQualifiedTestName());
List<Artifact> artifacts =
- ArtifactQuery.getArtifactListFromName(testInfo.getQualifiedTestName(), branch, EXCLUDE_DELETED);
+ ArtifactQuery.getArtifactListFromName(testInfo.getQualifiedTestName(), branch, DeletionFlag.EXCLUDE_DELETED);
ArtifactPersistenceManager.deleteArtifactCollection(transaction, false, artifacts);
transaction.execute();
}
@@ -92,7 +91,7 @@ public class ArtifactLoaderTest {
* Another interesting side-effect, is this test also gives a repeatable case for duplicate relation loading. These
* are caught by the SevereLoggingMonitor.
*/
- @Test(timeout = 5000)
+ @Test(timeout = 10000)
public void testThreadSafeLoading() throws Exception {
// Create some software artifacts
SkynetTransaction transaction =
@@ -117,7 +116,7 @@ public class ArtifactLoaderTest {
tasks.add(new LoadArtifacts());
}
- ExecutorService executor = Executors.newFixedThreadPool(7, new LoadThreadFactory());
+ ExecutorService executor = Executors.newFixedThreadPool(TOTAL_THREADS, new LoadThreadFactory());
List<Future<List<Artifact>>> futures = executor.invokeAll(tasks, 81, TimeUnit.SECONDS);
int completed = 0;
int cancelled = 0;
@@ -137,7 +136,8 @@ public class ArtifactLoaderTest {
// Load and check artifacts
artifacts =
- ArtifactQuery.getArtifactListFromName("ArtifactLoaderTest", BranchManager.getCommonBranch(), EXCLUDE_DELETED);
+ ArtifactQuery.getArtifactListFromName("ArtifactLoaderTest", BranchManager.getCommonBranch(),
+ DeletionFlag.EXCLUDE_DELETED);
Assert.assertEquals(NUM_ARTIFACTS, artifacts.size());
for (Artifact artifact : artifacts) {
Assert.assertEquals(ATTRIBUTE_VALUE, artifact.getSoleAttributeValue(CoreAttributeTypes.DefaultMailServer));
@@ -273,7 +273,7 @@ public class ArtifactLoaderTest {
public List<Artifact> call() throws Exception {
List<Artifact> artifacts =
ArtifactQuery.getArtifactListFromName("ArtifactLoaderTest", BranchManager.getCommonBranch(),
- EXCLUDE_DELETED);
+ DeletionFlag.EXCLUDE_DELETED);
if (artifacts.size() != NUM_ARTIFACTS) {
throw new OseeStateException("Should have loaded %d not %d", NUM_ARTIFACTS, artifacts.size());
}
diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java
index 8e0d4e083da..adc75d7909a 100644
--- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java
+++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java
@@ -10,23 +10,27 @@
*******************************************************************************/
package org.eclipse.osee.client.integration.tests.integration.skynet.core;
-import static org.eclipse.osee.client.demo.DemoChoice.OSEE_CLIENT_DEMO;
-import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED;
+import static org.eclipse.osee.client.demo.DemoChoice.*;
+import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Set;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.osee.client.test.framework.OseeClientIntegrationRule;
import org.eclipse.osee.client.test.framework.OseeLogMonitorRule;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.cache.BranchFilter;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.artifact.search.QueryOptions;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
@@ -55,7 +59,8 @@ public class ArtifactQueryTest {
// Should exist with allowDeleted
searchedArtifact =
- ArtifactQuery.getArtifactFromId(newArtifact.getGuid(), BranchManager.getCommonBranch(), INCLUDE_DELETED);
+ ArtifactQuery.getArtifactFromId(newArtifact.getGuid(), BranchManager.getCommonBranch(),
+ DeletionFlag.INCLUDE_DELETED);
Assert.assertNotNull(searchedArtifact);
newArtifact.deleteAndPersist();
@@ -77,7 +82,8 @@ public class ArtifactQueryTest {
// Should still exist with allowDeleted
searchedArtifact =
- ArtifactQuery.getArtifactFromId(newArtifact.getGuid(), BranchManager.getCommonBranch(), INCLUDE_DELETED);
+ ArtifactQuery.getArtifactFromId(newArtifact.getGuid(), BranchManager.getCommonBranch(),
+ DeletionFlag.INCLUDE_DELETED);
Assert.assertNotNull(searchedArtifact);
}
@@ -85,8 +91,11 @@ public class ArtifactQueryTest {
@Test
public void testGetArtifactListFromType() throws OseeCoreException {
// Should exist
- List<Artifact> searchedArtifacts =
- ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.SoftwareRequirement, DeletionFlag.INCLUDE_DELETED);
+ Set<Artifact> searchedArtifacts = new LinkedHashSet<Artifact>();
+ for (IOseeBranch branch : BranchManager.getBranches(new BranchFilter())) {
+ searchedArtifacts.addAll(ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.SoftwareRequirement, branch,
+ DeletionFlag.INCLUDE_DELETED));
+ }
// make sure at least one artifact exists
Assert.assertTrue("No artifacts found", searchedArtifacts.size() > 0);
@@ -127,8 +136,8 @@ public class ArtifactQueryTest {
artifact1.persist("testLargeAttributeIndexing");
Thread.sleep(1000);
List<Artifact> artifacts =
- ArtifactQuery.getArtifactListFromAttributeKeywords(branch, "Wikipedia", false, DeletionFlag.EXCLUDE_DELETED,
- false, CoreAttributeTypes.Name);
+ ArtifactQuery.getArtifactListFromName("Wikipedia", branch, DeletionFlag.EXCLUDE_DELETED,
+ QueryOptions.CONTAINS_MATCH_OPTIONS);
Job job = BranchManager.deleteBranch(branch);
job.join();
Assert.assertEquals(1, artifacts.size());
diff --git a/plugins/org.eclipse.osee.client.parent/pom.xml b/plugins/org.eclipse.osee.client.parent/pom.xml
index c8dbf3a569a..55cee7f20fd 100644
--- a/plugins/org.eclipse.osee.client.parent/pom.xml
+++ b/plugins/org.eclipse.osee.client.parent/pom.xml
@@ -17,6 +17,8 @@
<version>0.11.0-SNAPSHOT</version>
<modules>
+ <module>../../plugins/org.eclipse.osee.orcs.rest.client</module>
+
<module>../../plugins/org.eclipse.osee.framework.access</module>
<module>../../plugins/org.eclipse.osee.framework.access.test</module>
<module>../../plugins/org.eclipse.osee.framework.access.provider</module>
diff --git a/plugins/org.eclipse.osee.client.test.framework/src/org/eclipse/osee/client/test/framework/OseeClientIntegrationRule.java b/plugins/org.eclipse.osee.client.test.framework/src/org/eclipse/osee/client/test/framework/OseeClientIntegrationRule.java
index bc6f0596147..b43b5f24c11 100644
--- a/plugins/org.eclipse.osee.client.test.framework/src/org/eclipse/osee/client/test/framework/OseeClientIntegrationRule.java
+++ b/plugins/org.eclipse.osee.client.test.framework/src/org/eclipse/osee/client/test/framework/OseeClientIntegrationRule.java
@@ -10,8 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.client.test.framework;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import org.eclipse.osee.client.test.framework.internal.AbstractTestRule;
import org.eclipse.osee.client.test.framework.internal.DatabaseInitializer;
import org.eclipse.osee.framework.core.client.ClientSessionManager;
@@ -47,7 +46,7 @@ public final class OseeClientIntegrationRule extends AbstractTestRule {
private static boolean onFirstSuccess = false;
- private boolean originalIsInTest;
+ // private boolean originalIsInTest;
// private boolean popUps;
private final IDbInitChoiceEnum choice;
@@ -79,7 +78,7 @@ public final class OseeClientIntegrationRule extends AbstractTestRule {
if (onFirstSuccess) {
checkNotProductionDataStore();
- originalIsInTest = OseeProperties.isInTest();
+ // originalIsInTest = OseeProperties.isInTest();
OseeProperties.setIsInTest(true);
// popUps = RenderingUtil.arePopupsAllowed();
RenderingUtil.setPopupsAllowed(false);
@@ -97,7 +96,7 @@ public final class OseeClientIntegrationRule extends AbstractTestRule {
*/
@Override
public void onTestFinished(FrameworkMethod method) {
- OseeProperties.setIsInTest(originalIsInTest);
+ // OseeProperties.setIsInTest(originalIsInTest);
// RenderingUtil.setPopupsAllowed(popUps);
}
diff --git a/plugins/org.eclipse.osee.display.presenter/src/org/eclipse/osee/display/presenter/ArtifactProviderImpl.java b/plugins/org.eclipse.osee.display.presenter/src/org/eclipse/osee/display/presenter/ArtifactProviderImpl.java
index 4c8fccbc008..7c3670cc1a2 100644
--- a/plugins/org.eclipse.osee.display.presenter/src/org/eclipse/osee/display/presenter/ArtifactProviderImpl.java
+++ b/plugins/org.eclipse.osee.display.presenter/src/org/eclipse/osee/display/presenter/ArtifactProviderImpl.java
@@ -31,8 +31,12 @@ import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.data.IRelationTypeSide;
import org.eclipse.osee.framework.core.data.ResultSet;
+import org.eclipse.osee.framework.core.enums.CaseType;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
+import org.eclipse.osee.framework.core.enums.TokenOrderType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.framework.core.model.type.RelationType;
@@ -40,11 +44,9 @@ import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
import org.eclipse.osee.orcs.data.GraphReadable;
-import org.eclipse.osee.orcs.search.CaseType;
import org.eclipse.osee.orcs.search.Match;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
-import org.eclipse.osee.orcs.search.StringOperator;
import com.google.common.collect.Lists;
/**
@@ -118,7 +120,8 @@ public class ArtifactProviderImpl implements ArtifactProvider {
} else {
IAttributeType type = params.isNameOnly() ? CoreAttributeTypes.Name : QueryBuilder.ANY_ATTRIBUTE_TYPE;
QueryBuilder builder = getFactory().fromBranch(params.getBranch());
- builder.and(type, StringOperator.TOKENIZED_ANY_ORDER, CaseType.IGNORE_CASE, params.getSearchPhrase());
+ builder.and(type, params.getSearchPhrase(), TokenDelimiterMatch.ANY, CaseType.IGNORE_CASE,
+ TokenOrderType.ANY_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT);
callable = new FilteredResultSetCallable(executorAdmin, filter, builder.createSearchWithMatches());
}
return callable;
diff --git a/plugins/org.eclipse.osee.framework.core.client/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.core.client/META-INF/MANIFEST.MF
index 8885a23285f..a6310825f07 100644
--- a/plugins/org.eclipse.osee.framework.core.client/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.core.client/META-INF/MANIFEST.MF
@@ -12,6 +12,7 @@ Import-Package: org.eclipse.core.runtime,
org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.exception,
+ org.eclipse.osee.framework.core.services,
org.eclipse.osee.framework.core.util,
org.eclipse.osee.framework.database.core,
org.eclipse.osee.framework.jdk.core.util,
@@ -23,4 +24,4 @@ Import-Package: org.eclipse.core.runtime,
Export-Package: org.eclipse.osee.framework.core.client,
org.eclipse.osee.framework.core.client.server,
org.eclipse.osee.framework.core.client.task
-Service-Component: OSGI-INF/client.database.provider.xml
+Service-Component: OSGI-INF/*.xml
diff --git a/plugins/org.eclipse.osee.framework.core.client/OSGI-INF/client.uri.provider.xml b/plugins/org.eclipse.osee.framework.core.client/OSGI-INF/client.uri.provider.xml
new file mode 100644
index 00000000000..ca0646b675d
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.client/OSGI-INF/client.uri.provider.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.osee.framework.core.client.internal.URIProviderImpl">
+ <implementation class="org.eclipse.osee.framework.core.client.internal.URIProviderImpl"/>
+ <service>
+ <provide interface="org.eclipse.osee.framework.core.services.URIProvider"/>
+ </service>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/internal/URIProviderImpl.java b/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/internal/URIProviderImpl.java
new file mode 100644
index 00000000000..135c6def290
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/internal/URIProviderImpl.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.client.internal;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+import org.eclipse.osee.framework.core.client.server.HttpUrlBuilderClient;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.core.services.URIProvider;
+
+/**
+ * @author John Misinco
+ * @author Roberto E. Escobar
+ */
+public class URIProviderImpl implements URIProvider {
+
+ @Override
+ public URI getApplicationServerURI() throws OseeCoreException {
+ URI toReturn = null;
+ try {
+ toReturn = new URI(HttpUrlBuilderClient.getInstance().getApplicationServerPrefix());
+ } catch (URISyntaxException ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ return toReturn;
+ }
+
+ @Override
+ public URI getEncodedURI(String context, Map<String, String> params) throws OseeCoreException {
+ URI toReturn = null;
+ try {
+ toReturn = new URI(HttpUrlBuilderClient.getInstance().getOsgiServletServiceUrl(context, params));
+ } catch (Exception ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ return toReturn;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/URIProvider.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/URIProvider.java
new file mode 100644
index 00000000000..c996d077fd7
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/URIProvider.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.services;
+
+import java.net.URI;
+import java.util.Map;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
+/**
+ * @author John Misinco
+ * @author Roberto E. Escobar
+ */
+public interface URIProvider {
+
+ URI getApplicationServerURI() throws OseeCoreException;
+
+ URI getEncodedURI(String context, Map<String, String> params) throws OseeCoreException;
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/CaseType.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CaseType.java
index 15598ce85e7..b6c8c44add1 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/CaseType.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CaseType.java
@@ -8,17 +8,22 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.search;
+package org.eclipse.osee.framework.core.enums;
/**
* @author Ryan D. Brooks
* @author Roberto E. Escobar
*/
-public enum CaseType {
+public enum CaseType implements QueryOption {
MATCH_CASE,
IGNORE_CASE;
public boolean isCaseSensitive() {
return MATCH_CASE == this;
}
+
+ @Override
+ public void accept(OptionVisitor visitor) {
+ visitor.asCaseType(this);
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/MatchTokenCountType.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/MatchTokenCountType.java
new file mode 100644
index 00000000000..81148d5c26b
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/MatchTokenCountType.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.enums;
+
+/**
+ * @author John Misinco
+ */
+public enum MatchTokenCountType implements QueryOption {
+ MATCH_TOKEN_COUNT,
+ IGNORE_TOKEN_COUNT;
+
+ public boolean isMatchTokenCount() {
+ return this == MATCH_TOKEN_COUNT;
+ }
+
+ @Override
+ public void accept(OptionVisitor visitor) {
+ visitor.asMatchTokenCountType(this);
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/Operator.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/Operator.java
new file mode 100644
index 00000000000..b9a5b438973
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/Operator.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.enums;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public enum Operator {
+ EQUAL("="), // Exact Match as in Strings.equals
+ NOT_EQUAL("<>"), // inverse of exact match - !Strings.equals
+ LESS_THAN("<"),
+ GREATER_THAN(">");
+
+ private String expression;
+
+ private Operator(String expression) {
+ this.expression = expression;
+ }
+
+ public boolean isEquals() {
+ return EQUAL == this;
+ }
+
+ public boolean isNotEquals() {
+ return NOT_EQUAL == this;
+ }
+
+ public boolean isGreaterThanOrLessThan() {
+ return GREATER_THAN == this || LESS_THAN == this;
+ }
+
+ @Override
+ public String toString() {
+ return expression;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/OptionVisitor.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/OptionVisitor.java
new file mode 100644
index 00000000000..9cd0ac0419f
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/OptionVisitor.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.enums;
+
+
+/**
+ * @author John Misinco
+ */
+public interface OptionVisitor {
+
+ void asCaseType(CaseType option);
+
+ void asTokenOrderType(TokenOrderType option);
+
+ void asMatchTokenCountType(MatchTokenCountType option);
+
+ void asTokenDelimiterMatch(TokenDelimiterMatch option);
+}
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/QueryOption.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/QueryOption.java
new file mode 100644
index 00000000000..db3700fca83
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/QueryOption.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.enums;
+
+/**
+ * @author John Misinco
+ */
+public interface QueryOption {
+
+ void accept(OptionVisitor visitor);
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/StringOperator.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/StringOperator.java
index 4314924301f..dafc5191926 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/StringOperator.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/StringOperator.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.search;
+package org.eclipse.osee.framework.core.enums;
/**
* @author Ryan D. Brooks
@@ -17,12 +17,12 @@ package org.eclipse.osee.orcs.search;
public enum StringOperator {
EQUALS(), // Exact Match as in Strings.equals
NOT_EQUALS(), // inverse of exact match - !Strings.equals
- CONTAINS,
- TOKENIZED_ANY_ORDER,
- TOKENIZED_MATCH_ORDER;
+ CONTAINS, // Exact Match as in String.contains
+ TOKENIZED_ANY_ORDER, // tokenized on special chars, then matched in any order in string
+ TOKENIZED_MATCH_ORDER; // tokenized on special chars, then matched in same order in string
public boolean isTokenized() {
- return StringOperator.TOKENIZED_ANY_ORDER == this || StringOperator.TOKENIZED_MATCH_ORDER == this;
+ return this != NOT_EQUALS;
}
}
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/TokenDelimiterMatch.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/TokenDelimiterMatch.java
new file mode 100644
index 00000000000..0a6b42005de
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/TokenDelimiterMatch.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.enums;
+
+import java.util.regex.Pattern;
+
+/**
+ * @author John Misinco
+ */
+public class TokenDelimiterMatch implements QueryOption {
+ public static final TokenDelimiterMatch EXACT = new TokenDelimiterMatch(Pattern.compile(""));
+ public static final TokenDelimiterMatch WHITESPACE = new TokenDelimiterMatch(Pattern.compile("\\s+"));
+ public static final TokenDelimiterMatch ANY = new TokenDelimiterMatch(Pattern.compile("(\\W|_)+"));
+
+ private final Pattern pattern;
+
+ private TokenDelimiterMatch(Pattern pattern) {
+ this.pattern = pattern;
+ }
+
+ public Pattern getPattern() {
+ return pattern;
+ }
+
+ @Override
+ public void accept(OptionVisitor visitor) {
+ visitor.asTokenDelimiterMatch(this);
+ }
+
+ public static TokenDelimiterMatch custom(String regex) {
+ return new TokenDelimiterMatch(Pattern.compile(regex));
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/TokenOrderType.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/TokenOrderType.java
new file mode 100644
index 00000000000..82be63b2d50
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/TokenOrderType.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.enums;
+
+/**
+ * @author John Misinco
+ */
+public enum TokenOrderType implements QueryOption {
+ ANY_ORDER,
+ MATCH_ORDER;
+
+ public boolean isMatchOrder() {
+ return MATCH_ORDER == this;
+ }
+
+ @Override
+ public void accept(OptionVisitor visitor) {
+ visitor.asTokenOrderType(this);
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/Conditions.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/Conditions.java
index a307c4c9409..6bb6fad1a94 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/Conditions.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/Conditions.java
@@ -62,6 +62,13 @@ public final class Conditions {
}
/**
+ * @return false if the parameter is null or empty, otherwise return true
+ */
+ public static boolean hasValues(Collection<?> toCheck) {
+ return toCheck != null && !toCheck.isEmpty();
+ }
+
+ /**
* @return true if all of the parameters are null, otherwise returns false. Also returns true when objects is an
* empty array
*/
diff --git a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SearchEngineServlet.java b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SearchEngineServlet.java
index cf9646a5dcb..f7fad718724 100644
--- a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SearchEngineServlet.java
+++ b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SearchEngineServlet.java
@@ -18,7 +18,10 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.ResultSet;
+import org.eclipse.osee.framework.core.enums.CaseType;
import org.eclipse.osee.framework.core.enums.CoreTranslatorId;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
+import org.eclipse.osee.framework.core.enums.TokenOrderType;
import org.eclipse.osee.framework.core.message.SearchOptions;
import org.eclipse.osee.framework.core.message.SearchRequest;
import org.eclipse.osee.framework.core.message.SearchResponse;
@@ -33,11 +36,9 @@ import org.eclipse.osee.orcs.ApplicationContext;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.search.CaseType;
import org.eclipse.osee.orcs.search.Match;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
-import org.eclipse.osee.orcs.search.StringOperator;
/**
* @author Roberto E. Escobar
@@ -66,8 +67,7 @@ public class SearchEngineServlet extends SecureOseeHttpServlet {
translationService.convert(request.getInputStream(), CoreTranslatorId.SEARCH_REQUEST);
SearchOptions options = searchRequest.getOptions();
- StringOperator operator =
- options.isMatchWordOrder() ? StringOperator.TOKENIZED_MATCH_ORDER : StringOperator.TOKENIZED_ANY_ORDER;
+ TokenOrderType operator = options.isMatchWordOrder() ? TokenOrderType.MATCH_ORDER : TokenOrderType.ANY_ORDER;
CaseType caseType = options.isCaseSensitive() ? CaseType.MATCH_CASE : CaseType.IGNORE_CASE;
QueryFactory factory = orcsApi.getQueryFactory(getContext(request));
@@ -78,7 +78,7 @@ public class SearchEngineServlet extends SecureOseeHttpServlet {
if (attributeTypes.isEmpty()) {
attributeTypes = Collections.singleton(QueryBuilder.ANY_ATTRIBUTE_TYPE);
}
- builder.and(attributeTypes, operator, caseType, searchRequest.getRawSearch());
+ builder.and(attributeTypes, searchRequest.getRawSearch(), TokenDelimiterMatch.ANY, operator, caseType);
BranchCache branchCache = orcsApi.getBranchCache();
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.skynet.core.test/META-INF/MANIFEST.MF
index 0f97aa0dc1b..81e67ccd6f4 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/META-INF/MANIFEST.MF
@@ -7,7 +7,8 @@ Fragment-Host: org.eclipse.osee.framework.skynet.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit,
org.mockito;bundle-version="1.9.0",
- org.hamcrest.core
+ org.hamcrest.core,
+ org.objenesis
Export-Package: org.eclipse.osee.framework.skynet.core,
org.eclipse.osee.framework.skynet.core.rule
Import-Package: org.apache.commons.lang;version="2.4.0",
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/AllSkynetCoreJunitTestSuite.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/AllSkynetCoreJunitTestSuite.java
index d8f0e3f7ee1..8705625a02e 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/AllSkynetCoreJunitTestSuite.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/AllSkynetCoreJunitTestSuite.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactSearchTestSuite;
import org.eclipse.osee.framework.skynet.core.event.EventTestSuite;
import org.eclipse.osee.framework.skynet.core.importing.ImportingSuite;
import org.eclipse.osee.framework.skynet.core.internal.event.InternalEventTestSuite;
@@ -22,6 +23,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
+ ArtifactSearchTestSuite.class,
EventTestSuite.class,
ImportingSuite.class,
InternalEventTestSuite.class,
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactSearchTestSuite.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactSearchTestSuite.java
new file mode 100644
index 00000000000..e47d27bdd22
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactSearchTestSuite.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.skynet.core.artifact.search;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({AttributeCriteriaTest.class, RelationCriteriaTest.class})
+/**
+ * @author John Misinco
+ */
+public class ArtifactSearchTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeCriteriaTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeCriteriaTest.java
new file mode 100644
index 00000000000..49df447bb23
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeCriteriaTest.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.skynet.core.artifact.search;
+
+import static org.mockito.Mockito.*;
+import java.util.Arrays;
+import java.util.List;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.Operator;
+import org.eclipse.osee.framework.core.enums.TokenOrderType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.rest.client.QueryBuilder;
+import org.junit.Test;
+
+/**
+ * @author John Misinco
+ */
+public class AttributeCriteriaTest {
+
+ @Test
+ public void testAddToQueryBuilder() throws OseeCoreException {
+ AttributeCriteria criteria = new AttributeCriteria(CoreAttributeTypes.Active);
+ QueryBuilder builder = mock(QueryBuilder.class);
+ criteria.addToQueryBuilder(builder);
+ verify(builder).andExists(CoreAttributeTypes.Active);
+
+ reset(builder);
+ List<String> values = Arrays.asList("true", "false");
+ criteria = new AttributeCriteria(CoreAttributeTypes.Active, values);
+ criteria.addToQueryBuilder(builder);
+ verify(builder).and(CoreAttributeTypes.Active, Operator.EQUAL, values);
+
+ reset(builder);
+ criteria = new AttributeCriteria(CoreAttributeTypes.Active, "true", Operator.LESS_THAN);
+ criteria.addToQueryBuilder(builder);
+ verify(builder).and(CoreAttributeTypes.Active, Operator.LESS_THAN, "true");
+
+ reset(builder);
+ criteria = new AttributeCriteria(CoreAttributeTypes.Active, "true", TokenOrderType.ANY_ORDER);
+ criteria.addToQueryBuilder(builder);
+ verify(builder).and(CoreAttributeTypes.Active, "true", TokenOrderType.ANY_ORDER);
+
+ reset(builder);
+ criteria = new AttributeCriteria(CoreAttributeTypes.Active, "true");
+ criteria.addToQueryBuilder(builder);
+ verify(builder).and(CoreAttributeTypes.Active, "true", QueryOptions.EXACT_MATCH_OPTIONS);
+
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/search/RelationCriteriaTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/search/RelationCriteriaTest.java
new file mode 100644
index 00000000000..b11fbb8e7b9
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/search/RelationCriteriaTest.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.skynet.core.artifact.search;
+
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
+import org.eclipse.osee.framework.core.data.IRelationTypeSide;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.enums.RelationSide;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.rest.client.QueryBuilder;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+/**
+ * @author John Misinco
+ */
+public class RelationCriteriaTest {
+
+ @Test
+ public void testAddToQueryBuilder() throws OseeCoreException {
+ RelationCriteria criteria = new RelationCriteria(CoreRelationTypes.Allocation__Component);
+ QueryBuilder builder = mock(QueryBuilder.class);
+ criteria.addToQueryBuilder(builder);
+ verify(builder).andExists(CoreRelationTypes.Allocation__Component);
+
+ reset(builder);
+ criteria = new RelationCriteria(4, CoreRelationTypes.Allocation__Component, RelationSide.SIDE_A);
+ criteria.addToQueryBuilder(builder);
+ ArgumentCaptor<IRelationTypeSide> rtsCaptor = ArgumentCaptor.forClass(IRelationTypeSide.class);
+ verify(builder).andRelatedToLocalIds(rtsCaptor.capture(), eq(4));
+ Assert.assertEquals(CoreRelationTypes.Allocation__Component.getGuid(), rtsCaptor.getValue().getGuid());
+ Assert.assertEquals(RelationSide.SIDE_A, rtsCaptor.getValue().getSide());
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF
index be56c6d3a37..952673f681e 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF
@@ -71,7 +71,8 @@ Import-Package: org.apache.commons.lang;version="2.4.0",
org.eclipse.osee.framework.logging,
org.eclipse.osee.framework.messaging.event.res,
org.eclipse.osee.framework.plugin.core,
- org.eclipse.osee.framework.plugin.core.util
+ org.eclipse.osee.framework.plugin.core.util,
+ org.eclipse.osee.orcs.rest.client
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Service-Component: OSGI-INF/*.xml
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java
index 0af92a28fc6..06a38910c3a 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java
@@ -71,16 +71,20 @@ public final class ArtifactLoader {
return new LinkedList<Artifact>(artifacts);
}
- public static List<Artifact> loadArtifacts(Collection<Integer> artIds, IOseeBranch branch, LoadLevel loadLevel, LoadType reload, DeletionFlag allowDeleted) throws OseeCoreException {
+ public static List<Artifact> loadArtifacts(Collection<Integer> artIds, IOseeBranch branch, LoadLevel loadLevel, LoadType reload, DeletionFlag allowDeleted, TransactionRecord transactionId) throws OseeCoreException {
List<Pair<Integer, Integer>> toLoad = new LinkedList<Pair<Integer, Integer>>();
Integer branchId = BranchManager.getBranchId(branch);
for (Integer artId : new HashSet<Integer>(artIds)) {
toLoad.add(new Pair<Integer, Integer>(artId, branchId));
}
- List<Artifact> artifacts = loadSelectedArtifacts(toLoad, loadLevel, reload, allowDeleted, null);
+ List<Artifact> artifacts = loadSelectedArtifacts(toLoad, loadLevel, reload, allowDeleted, transactionId);
return artifacts;
}
+ public static List<Artifact> loadArtifacts(Collection<Integer> artIds, IOseeBranch branch, LoadLevel loadLevel, LoadType reload, DeletionFlag allowDeleted) throws OseeCoreException {
+ return loadArtifacts(artIds, branch, loadLevel, reload, allowDeleted, null);
+ }
+
private static List<Artifact> loadSelectedArtifacts(List<Pair<Integer, Integer>> toLoad, LoadLevel loadLevel, LoadType reload, DeletionFlag allowDeleted, TransactionRecord transactionId) throws OseeCoreException {
Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
if (transactionId == null) {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactTypeManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactTypeManager.java
index ef50949330e..467c3b3e138 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactTypeManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactTypeManager.java
@@ -16,12 +16,15 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.osee.framework.core.data.IArtifactToken;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
@@ -29,6 +32,7 @@ import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.framework.core.exception.OseeTypeDoesNotExist;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.cache.ArtifactTypeCache;
+import org.eclipse.osee.framework.core.model.cache.BranchFilter;
import org.eclipse.osee.framework.core.model.event.DefaultBasicGuidArtifact;
import org.eclipse.osee.framework.core.model.type.ArtifactType;
import org.eclipse.osee.framework.core.services.IOseeCachingService;
@@ -199,8 +203,11 @@ public class ArtifactTypeManager {
public static void purgeArtifactTypesWithCheck(Collection<? extends IArtifactType> purgeArtifactTypes, IArtifactType newArtifactType) throws CoreException {
for (IArtifactType purgeArtifactType : purgeArtifactTypes) {
// find all artifact of this type on all branches and make a unique list for type change (since it is not by branch)
- List<Artifact> artifacts =
- ArtifactQuery.getArtifactListFromType(purgeArtifactType, DeletionFlag.INCLUDE_DELETED);
+ Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
+ for (IOseeBranch branch : BranchManager.getBranches(new BranchFilter())) {
+ artifacts.addAll(ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.SoftwareRequirement, branch,
+ DeletionFlag.INCLUDE_DELETED));
+ }
if (artifacts.size() > 0) {
HashMap<Integer, Artifact> artifactMap = new HashMap<Integer, Artifact>();
for (Artifact artifact : artifacts) {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AbstractArtifactSearchCriteria.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AbstractArtifactSearchCriteria.java
deleted file mode 100644
index 916fd7c6b8f..00000000000
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AbstractArtifactSearchCriteria.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.skynet.core.artifact.search;
-
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-
-/**
- * @author Ryan D. Brooks
- */
-public abstract class AbstractArtifactSearchCriteria {
-
- public abstract void addToTableSql(ArtifactQueryBuilder builder) throws OseeDataStoreException;
-
- public abstract void addToWhereSql(ArtifactQueryBuilder builder) throws OseeCoreException;
-
- public abstract void addJoinArtId(ArtifactQueryBuilder builder, boolean left) throws OseeDataStoreException;
-
- @SuppressWarnings("unused")
- public void cleanUp() throws OseeCoreException {
- // provided for subclass implementation
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
index cb70ff526ac..5f7a0dcb76b 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
@@ -10,10 +10,9 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.artifact.search;
-import static org.eclipse.osee.framework.core.enums.DeletionFlag.EXCLUDE_DELETED;
-import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED;
-import static org.eclipse.osee.framework.core.enums.LoadLevel.FULL;
-import static org.eclipse.osee.framework.skynet.core.artifact.LoadType.INCLUDE_CACHE;
+import static org.eclipse.osee.framework.core.enums.DeletionFlag.*;
+import static org.eclipse.osee.framework.core.enums.LoadLevel.*;
+import static org.eclipse.osee.framework.skynet.core.artifact.LoadType.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -30,6 +29,7 @@ import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.enums.LoadLevel;
+import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist;
import org.eclipse.osee.framework.core.exception.MultipleArtifactsExist;
@@ -270,13 +270,13 @@ public class ArtifactQuery {
return new ArtifactQueryBuilder(Arrays.asList(guidOrHrid), transactionId, allowDeleted, FULL).getOrCheckArtifact(QueryType.CHECK);
}
- public static List<Artifact> getArtifactListFromName(String artifactName, IOseeBranch branch, DeletionFlag allowDeleted) throws OseeCoreException {
+ public static List<Artifact> getArtifactListFromName(String artifactName, IOseeBranch branch, DeletionFlag allowDeleted, QueryOption... options) throws OseeCoreException {
return new ArtifactQueryBuilder(branch, FULL, allowDeleted, new AttributeCriteria(CoreAttributeTypes.Name,
- artifactName)).getArtifacts(30, null);
+ artifactName, options)).getArtifacts(30, null);
}
- public static List<Artifact> getArtifactListFromTypeAndName(IArtifactType artifactType, String artifactName, IOseeBranch branch) throws OseeCoreException {
- return getArtifactListFromTypeAndAttribute(artifactType, CoreAttributeTypes.Name, artifactName, branch);
+ public static List<Artifact> getArtifactListFromTypeAndName(IArtifactType artifactType, String artifactName, IOseeBranch branch, QueryOption... options) throws OseeCoreException {
+ return getArtifactListFromTypeAndAttribute(artifactType, CoreAttributeTypes.Name, artifactName, branch, options);
}
/**
@@ -305,10 +305,6 @@ public class ArtifactQuery {
attributeValue)).getOrCheckArtifact(QueryType.GET);
}
- public static List<Artifact> getArtifactListFromType(IArtifactType artifactTypeToken, DeletionFlag allowDeleted) throws OseeCoreException {
- return getArtifactListFromType(artifactTypeToken, null, allowDeleted);
- }
-
/**
* Does not return any inherited artifacts. Use getArtifactListFromTypeWithInheritence instead.
*
@@ -380,7 +376,7 @@ public class ArtifactQuery {
*
* @return a collection of the artifacts found or an empty collection if none are found
*/
- public static List<Artifact> getArtifactListFromTypeAnd(IArtifactType artifactType, IOseeBranch branch, int artifactCountEstimate, List<AbstractArtifactSearchCriteria> criteria) throws OseeCoreException {
+ public static List<Artifact> getArtifactListFromTypeAnd(IArtifactType artifactType, IOseeBranch branch, int artifactCountEstimate, List<ArtifactSearchCriteria> criteria) throws OseeCoreException {
return new ArtifactQueryBuilder(artifactType, branch, FULL, criteria).getArtifacts(artifactCountEstimate, null);
}
@@ -389,7 +385,7 @@ public class ArtifactQuery {
*
* @return a collection of the artifacts found or an empty collection if none are found
*/
- public static List<Artifact> getArtifactListFromCriteria(IOseeBranch branch, int artifactCountEstimate, List<AbstractArtifactSearchCriteria> criteria) throws OseeCoreException {
+ public static List<Artifact> getArtifactListFromCriteria(IOseeBranch branch, int artifactCountEstimate, List<ArtifactSearchCriteria> criteria) throws OseeCoreException {
return new ArtifactQueryBuilder(branch, FULL, criteria).getArtifacts(artifactCountEstimate, null);
}
@@ -398,7 +394,7 @@ public class ArtifactQuery {
*
* @return a collection of the artifacts found or an empty collection if none are found
*/
- public static List<Artifact> getArtifactListFromCriteria(IOseeBranch branch, int artifactCountEstimate, AbstractArtifactSearchCriteria... criteria) throws OseeCoreException {
+ public static List<Artifact> getArtifactListFromCriteria(IOseeBranch branch, int artifactCountEstimate, ArtifactSearchCriteria... criteria) throws OseeCoreException {
return new ArtifactQueryBuilder(branch, FULL, EXCLUDE_DELETED, criteria).getArtifacts(artifactCountEstimate, null);
}
@@ -427,14 +423,14 @@ public class ArtifactQuery {
*
* @return a collection of the artifacts found or an empty collection if none are found
*/
- public static List<Artifact> getArtifactListFromTypeAndAttribute(IArtifactType artifactType, IAttributeType attributeType, String attributeValue, IOseeBranch branch) throws OseeCoreException {
- return new ArtifactQueryBuilder(artifactType, branch, FULL, new AttributeCriteria(attributeType, attributeValue)).getArtifacts(
- 100, null);
+ public static List<Artifact> getArtifactListFromTypeAndAttribute(IArtifactType artifactType, IAttributeType attributeType, String attributeValue, IOseeBranch branch, QueryOption... options) throws OseeCoreException {
+ return new ArtifactQueryBuilder(artifactType, branch, FULL, new AttributeCriteria(attributeType, attributeValue,
+ options)).getArtifacts(100, null);
}
- public static List<Artifact> getArtifactListFromAttribute(IAttributeType attributeType, String attributeValue, IOseeBranch branch) throws OseeCoreException {
+ public static List<Artifact> getArtifactListFromAttribute(IAttributeType attributeType, String attributeValue, IOseeBranch branch, QueryOption... options) throws OseeCoreException {
return new ArtifactQueryBuilder(branch, FULL, EXCLUDE_DELETED, new AttributeCriteria(attributeType,
- attributeValue)).getArtifacts(300, null);
+ attributeValue, options)).getArtifacts(300, null);
}
/**
@@ -445,15 +441,10 @@ public class ArtifactQuery {
300, null);
}
- private static ArtifactQueryBuilder queryFromTypeAndAttribute(IArtifactType artifactType, IAttributeType attributeType, String attributeValue, IOseeBranch branch) throws OseeCoreException {
+ private static ArtifactQueryBuilder queryFromTypeAndAttribute(IArtifactType artifactType, IAttributeType attributeType, String attributeValue, IOseeBranch branch) {
return new ArtifactQueryBuilder(artifactType, branch, FULL, new AttributeCriteria(attributeType, attributeValue));
}
- public static List<Artifact> getArtifactListFromHistoricalAttributeValue(String attributeValue, IOseeBranch branch) throws OseeCoreException {
- return new ArtifactQueryBuilder(branch, FULL, INCLUDE_DELETED, new AttributeCriteria(null, attributeValue, true)).getArtifacts(
- 30, null);
- }
-
public static List<Artifact> getArtifactListFromTypeAndAttribute(IArtifactType artifactType, IAttributeType attributeType, Collection<String> attributeValues, IOseeBranch branch, int artifactCountEstimate) throws OseeCoreException {
return new ArtifactQueryBuilder(artifactType, branch, FULL, new AttributeCriteria(attributeType, attributeValues)).getArtifacts(
artifactCountEstimate, null);
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java
index b658dfb8748..46c458bf434 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java
@@ -17,70 +17,49 @@ import static org.eclipse.osee.framework.skynet.core.artifact.LoadType.RELOAD_CA
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
-import org.eclipse.osee.framework.core.client.ClientSessionManager;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.enums.LoadLevel;
-import org.eclipse.osee.framework.core.enums.TxChange;
import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist;
import org.eclipse.osee.framework.core.exception.MultipleArtifactsExist;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeWrappedException;
import org.eclipse.osee.framework.core.model.TransactionRecord;
-import org.eclipse.osee.framework.core.services.IdentityService;
-import org.eclipse.osee.framework.database.core.AbstractJoinQuery;
-import org.eclipse.osee.framework.database.core.CharJoinQuery;
-import org.eclipse.osee.framework.database.core.ConnectionHandler;
-import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.database.core.IdJoinQuery;
-import org.eclipse.osee.framework.database.core.JoinUtility;
-import org.eclipse.osee.framework.database.core.OseeSql;
+import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.eclipse.osee.framework.jdk.core.util.HumanReadableId;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactLoader;
-import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.artifact.ISearchConfirmer;
import org.eclipse.osee.framework.skynet.core.artifact.LoadType;
import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil;
+import org.eclipse.osee.orcs.rest.client.OseeClient;
+import org.eclipse.osee.orcs.rest.client.QueryBuilder;
/**
* @author Ryan D. Brooks
*/
public class ArtifactQueryBuilder {
- private final HashMap<String, NextAlias> nextAliases = new HashMap<String, NextAlias>();
- private final StringBuilder sql = new StringBuilder(1000);
- private final List<Object> queryParameters = new ArrayList<Object>();
private List<String> guids;
private List<String> hrids;
private String guidOrHrid;
- private final AbstractArtifactSearchCriteria[] criteria;
+ private final ArtifactSearchCriteria[] criteria;
private final IOseeBranch branch;
private int artifactId;
private Collection<Integer> artifactIds;
private final Collection<? extends IArtifactType> artifactTypes;
private final DeletionFlag allowDeleted;
private final LoadLevel loadLevel;
- private boolean count = false;
private boolean emptyCriteria = false;
- private boolean firstTable = true;
- private final boolean tableOrderForward;
private final TransactionRecord transactionId;
- private AbstractJoinQuery guidJoinQuery;
- private AbstractJoinQuery hridJoinQuery;
- private AbstractJoinQuery idJoinQuery;
- private AbstractJoinQuery idTypeJoinQuery;
/**
* @param allowDeleted set whether deleted artifacts should be included in the resulting artifact list
*/
public ArtifactQueryBuilder(int artId, IOseeBranch branch, DeletionFlag allowDeleted, LoadLevel loadLevel) {
- this(null, artId, null, null, null, branch, null, allowDeleted, loadLevel, true);
+ this(null, artId, null, null, null, branch, null, allowDeleted, loadLevel);
}
/**
@@ -90,73 +69,73 @@ public class ArtifactQueryBuilder {
* @param allowDeleted set whether deleted artifacts should be included in the resulting artifact list
*/
public ArtifactQueryBuilder(Collection<Integer> artifactIds, IOseeBranch branch, DeletionFlag allowDeleted, LoadLevel loadLevel) {
- this(artifactIds, 0, null, null, null, branch, null, allowDeleted, loadLevel, true);
+ this(artifactIds, 0, null, null, null, branch, null, allowDeleted, loadLevel);
emptyCriteria = artifactIds.isEmpty();
}
public ArtifactQueryBuilder(List<String> guidOrHrids, IOseeBranch branch, LoadLevel loadLevel) {
- this(null, 0, guidOrHrids, null, null, branch, null, EXCLUDE_DELETED, loadLevel, true);
+ this(null, 0, guidOrHrids, null, null, branch, null, EXCLUDE_DELETED, loadLevel);
emptyCriteria = guidOrHrids.isEmpty();
}
public ArtifactQueryBuilder(List<String> guidOrHrids, IOseeBranch branch, DeletionFlag allowDeleted, LoadLevel loadLevel) {
- this(null, 0, guidOrHrids, null, null, branch, null, allowDeleted, loadLevel, true);
+ this(null, 0, guidOrHrids, null, null, branch, null, allowDeleted, loadLevel);
emptyCriteria = guidOrHrids.isEmpty();
}
public ArtifactQueryBuilder(List<String> guidOrHrids, TransactionRecord transactionId, DeletionFlag allowDeleted, LoadLevel loadLevel) throws OseeCoreException {
- this(null, 0, guidOrHrids, null, null, transactionId.getBranch(), transactionId, allowDeleted, loadLevel, true);
+ this(null, 0, guidOrHrids, null, null, transactionId.getBranch(), transactionId, allowDeleted, loadLevel);
emptyCriteria = guidOrHrids.isEmpty();
}
public ArtifactQueryBuilder(Collection<Integer> artifactIds, TransactionRecord transactionId, DeletionFlag allowDeleted, LoadLevel loadLevel) throws OseeCoreException {
- this(artifactIds, 0, null, null, null, transactionId.getBranch(), transactionId, allowDeleted, loadLevel, true);
+ this(artifactIds, 0, null, null, null, transactionId.getBranch(), transactionId, allowDeleted, loadLevel);
emptyCriteria = artifactIds.isEmpty();
}
public ArtifactQueryBuilder(int artifactId, TransactionRecord transactionId, DeletionFlag allowDeleted, LoadLevel loadLevel) throws OseeCoreException {
- this(null, artifactId, null, null, null, transactionId.getBranch(), transactionId, allowDeleted, loadLevel, true);
+ this(null, artifactId, null, null, null, transactionId.getBranch(), transactionId, allowDeleted, loadLevel);
}
public ArtifactQueryBuilder(String guidOrHrid, IOseeBranch branch, DeletionFlag allowDeleted, LoadLevel loadLevel) throws OseeCoreException {
- this(null, 0, null, ensureValid(guidOrHrid), null, branch, null, allowDeleted, loadLevel, true);
+ this(null, 0, null, ensureValid(guidOrHrid), null, branch, null, allowDeleted, loadLevel);
}
public ArtifactQueryBuilder(IArtifactType artifactType, IOseeBranch branch, LoadLevel loadLevel, DeletionFlag allowDeleted) {
- this(null, 0, null, null, Arrays.asList(artifactType), branch, null, allowDeleted, loadLevel, true);
+ this(null, 0, null, null, Arrays.asList(artifactType), branch, null, allowDeleted, loadLevel);
}
public ArtifactQueryBuilder(Collection<? extends IArtifactType> artifactTypes, IOseeBranch branch, LoadLevel loadLevel, DeletionFlag allowDeleted) {
- this(null, 0, null, null, artifactTypes, branch, null, allowDeleted, loadLevel, true);
+ this(null, 0, null, null, artifactTypes, branch, null, allowDeleted, loadLevel);
emptyCriteria = artifactTypes.isEmpty();
}
public ArtifactQueryBuilder(IOseeBranch branch, LoadLevel loadLevel, DeletionFlag allowDeleted) {
- this(null, 0, null, null, null, branch, null, allowDeleted, loadLevel, false);
+ this(null, 0, null, null, null, branch, null, allowDeleted, loadLevel);
}
- public ArtifactQueryBuilder(IOseeBranch branch, LoadLevel loadLevel, DeletionFlag allowDeleted, AbstractArtifactSearchCriteria... criteria) {
- this(null, 0, null, null, null, branch, null, allowDeleted, loadLevel, true, criteria);
+ public ArtifactQueryBuilder(IOseeBranch branch, LoadLevel loadLevel, DeletionFlag allowDeleted, ArtifactSearchCriteria... criteria) {
+ this(null, 0, null, null, null, branch, null, allowDeleted, loadLevel, criteria);
emptyCriteria = criteria.length == 0;
}
- public ArtifactQueryBuilder(IOseeBranch branch, LoadLevel loadLevel, List<AbstractArtifactSearchCriteria> criteria) {
- this(null, 0, null, null, null, branch, null, EXCLUDE_DELETED, loadLevel, true, toArray(criteria));
+ public ArtifactQueryBuilder(IOseeBranch branch, LoadLevel loadLevel, List<ArtifactSearchCriteria> criteria) {
+ this(null, 0, null, null, null, branch, null, EXCLUDE_DELETED, loadLevel, toArray(criteria));
emptyCriteria = criteria.isEmpty();
}
- public ArtifactQueryBuilder(IArtifactType artifactType, IOseeBranch branch, LoadLevel loadLevel, AbstractArtifactSearchCriteria... criteria) {
- this(null, 0, null, null, Arrays.asList(artifactType), branch, null, EXCLUDE_DELETED, loadLevel, true, criteria);
+ public ArtifactQueryBuilder(IArtifactType artifactType, IOseeBranch branch, LoadLevel loadLevel, ArtifactSearchCriteria... criteria) {
+ this(null, 0, null, null, Arrays.asList(artifactType), branch, null, EXCLUDE_DELETED, loadLevel, criteria);
emptyCriteria = criteria.length == 0;
}
- public ArtifactQueryBuilder(IArtifactType artifactType, IOseeBranch branch, LoadLevel loadLevel, List<AbstractArtifactSearchCriteria> criteria) {
- this(null, 0, null, null, Arrays.asList(artifactType), branch, null, EXCLUDE_DELETED, loadLevel, true,
+ public ArtifactQueryBuilder(IArtifactType artifactType, IOseeBranch branch, LoadLevel loadLevel, List<ArtifactSearchCriteria> criteria) {
+ this(null, 0, null, null, Arrays.asList(artifactType), branch, null, EXCLUDE_DELETED, loadLevel,
toArray(criteria));
emptyCriteria = criteria.isEmpty();
}
- private ArtifactQueryBuilder(Collection<Integer> artifactIds, int artifactId, List<String> guidOrHrids, String guidOrHrid, Collection<? extends IArtifactType> artifactTypes, IOseeBranch branch, TransactionRecord transactionId, DeletionFlag allowDeleted, LoadLevel loadLevel, boolean tableOrderForward, AbstractArtifactSearchCriteria... criteria) {
+ private ArtifactQueryBuilder(Collection<Integer> artifactIds, int artifactId, List<String> guidOrHrids, String guidOrHrid, Collection<? extends IArtifactType> artifactTypes, IOseeBranch branch, TransactionRecord transactionId, DeletionFlag allowDeleted, LoadLevel loadLevel, ArtifactSearchCriteria... criteria) {
this.artifactTypes = artifactTypes;
this.branch = branch;
this.criteria = criteria;
@@ -164,7 +143,6 @@ public class ArtifactQueryBuilder {
this.allowDeleted = allowDeleted;
this.guidOrHrid = guidOrHrid;
this.artifactId = artifactId;
- this.tableOrderForward = tableOrderForward;
this.transactionId = transactionId;
if (artifactIds != null && !artifactIds.isEmpty()) {
if (artifactIds.size() == 1) {
@@ -190,307 +168,66 @@ public class ArtifactQueryBuilder {
}
}
- nextAliases.put("osee_txs", new NextAlias("txs"));
- nextAliases.put("osee_artifact", new NextAlias("art"));
- nextAliases.put("osee_attribute", new NextAlias("att"));
- nextAliases.put("osee_relation_link", new NextAlias("rel"));
- nextAliases.put("osee_join_char_id", new NextAlias("jch"));
- nextAliases.put("osee_join_id", new NextAlias("jid"));
}
- private static AbstractArtifactSearchCriteria[] toArray(List<AbstractArtifactSearchCriteria> criteria) {
- return criteria.toArray(new AbstractArtifactSearchCriteria[criteria.size()]);
+ private static ArtifactSearchCriteria[] toArray(List<ArtifactSearchCriteria> criteria) {
+ return criteria.toArray(new ArtifactSearchCriteria[criteria.size()]);
}
- private static String ensureValid(String id) throws OseeArgumentException {
- if (id == null) {
- throw new OseeArgumentException("The id can not be null.");
+ private static String ensureValid(String id) throws OseeCoreException {
+ boolean guidCheck = GUID.isValid(id);
+ boolean hridCheck = HumanReadableId.isValid(id);
+ if (!guidCheck && !hridCheck) {
+ throw new OseeArgumentException("Invalid hrid/guid detected [%s]", id);
}
return id;
}
- private String getArtifactSelectSql() throws OseeCoreException {
- // sql.delete(0, sql.length());
- // firstTable = true;
- // queryParameters.clear();
+ private QueryBuilder createOrcsQuery() throws OseeCoreException {
boolean isHistorical = transactionId != null;
- if (count) {
- if (isHistorical) {
- throw new OseeCoreException("Count historical is not supported.");
- } else {
- sql.append("SELECT%s count(%s.art_id) FROM ");
- }
- } else {
- if (isHistorical) {
- sql.append("SELECT%s Max(transaction_id), %s.art_id, %s.branch_id FROM ");
- } else {
- sql.append("SELECT%s %s.art_id, %s.branch_id FROM ");
- }
- }
- if (criteria.length > 0) {
- for (AbstractArtifactSearchCriteria x : criteria) {
- x.addToTableSql(this);
- }
- }
+ OseeClient client = ServiceUtil.getOseeClient();
+ QueryBuilder builder = client.createQueryBuilder(branch);
- String artAlias, txsAlias;
- String jguidAlias = "";
- String jIdAlias = "";
- String jTypeIdAlias = "";
- String jHridAlias = "";
- if (tableOrderForward) {
- if (hasValues(artifactTypes)) {
- jTypeIdAlias = appendAliasedTable("osee_join_id");
- }
- if (hasValues(hrids)) {
- jHridAlias = appendAliasedTable("osee_join_char_id");
- }
- if (hasValues(artifactIds)) {
- jIdAlias = appendAliasedTable("osee_join_id");
- }
- if (hasValues(guids)) {
- jguidAlias = appendAliasedTable("osee_join_char_id");
- }
- artAlias = appendAliasedTable("osee_artifact");
- txsAlias = appendAliasedTable("osee_txs");
- } else {
- txsAlias = appendAliasedTable("osee_txs");
- artAlias = appendAliasedTable("osee_artifact");
- if (hasValues(guids)) {
- jguidAlias = appendAliasedTable("osee_join_char_id");
- }
- if (hasValues(artifactIds)) {
- jIdAlias = appendAliasedTable("osee_join_id");
- }
- if (hasValues(hrids)) {
- jHridAlias = appendAliasedTable("osee_join_char_id");
- }
- if (hasValues(artifactTypes)) {
- jTypeIdAlias = appendAliasedTable("osee_join_id");
- }
+ if (allowDeleted == INCLUDE_DELETED) {
+ builder.includeDeleted();
}
- sql.append("\n");
- sql.append(" WHERE ");
-
- if (artifactId != 0) {
- sql.append(artAlias);
- sql.append(".art_id=? AND ");
- addParameter(artifactId);
+ if (artifactId != 0 || Conditions.hasValues(artifactIds)) {
+ if (Conditions.hasValues(artifactIds)) {
+ builder.andLocalIds(artifactIds);
+ } else if (artifactId != 0) {
+ builder.andLocalId(artifactId);
+ }
}
- if (hasValues(artifactIds)) {
- idJoinQuery = addToIdJoin(artifactIds);
- sql.append(artAlias);
- sql.append(".art_id = ");
- sql.append(jIdAlias);
- sql.append(".id AND ");
- sql.append(jIdAlias);
- sql.append(".query_id = ? AND ");
- addParameter(idJoinQuery.getQueryId());
- }
-
- if (hasValues(artifactTypes)) {
- Set<Integer> artTypeIds = new HashSet<Integer>();
- IdentityService identityService = ServiceUtil.getIdentityService();
- for (IArtifactType artifactType : artifactTypes) {
- artTypeIds.add(identityService.getLocalId(artifactType));
- }
- idTypeJoinQuery = addToIdJoin(artTypeIds);
- sql.append(artAlias);
- sql.append(".art_type_id = ");
- sql.append(jTypeIdAlias);
- sql.append(".id AND ");
- sql.append(jTypeIdAlias);
- sql.append(".query_id = ? AND ");
- addParameter(idTypeJoinQuery.getQueryId());
+ if (Conditions.hasValues(artifactTypes)) {
+ builder.andIsOfType(artifactTypes);
}
if (guidOrHrid != null) {
- if (GUID.isValid(guidOrHrid)) {
- sql.append(artAlias);
- sql.append(".guid = ? AND ");
- } else {
- sql.append(artAlias);
- sql.append(".human_readable_id = ? AND ");
- }
- addParameter(guidOrHrid);
+ builder.andGuidsOrHrids(guidOrHrid);
}
- if (hasValues(guids)) {
- guidJoinQuery = addToGuidJoin(guids);
- sql.append(artAlias);
- sql.append(".guid = ");
- sql.append(jguidAlias);
- sql.append(".id AND ");
- sql.append(jguidAlias);
- sql.append(".query_id = ? AND ");
- addParameter(guidJoinQuery.getQueryId());
+ if (Conditions.hasValues(guids)) {
+ builder.andGuidsOrHrids(guids);
}
- if (hasValues(hrids)) {
- hridJoinQuery = addToGuidJoin(hrids);
- sql.append(artAlias);
- sql.append(".human_readable_id = ");
- sql.append(jHridAlias);
- sql.append(".id AND ");
- sql.append(jHridAlias);
- sql.append(".query_id = ? AND ");
- addParameter(hridJoinQuery.getQueryId());
+ if (Conditions.hasValues(hrids)) {
+ builder.andGuidsOrHrids(hrids);
}
- sql.append("\n");
if (criteria.length > 0) {
- criteria[0].addToWhereSql(this);
- sql.append("\n");
- for (int i = 1; i < criteria.length; i++) {
- AbstractArtifactSearchCriteria leftCriteria = criteria[i - 1];
- AbstractArtifactSearchCriteria rightCriteria = criteria[i];
- leftCriteria.addJoinArtId(this, false);
- sql.append("=");
- rightCriteria.addJoinArtId(this, true);
- sql.append(" AND ");
- rightCriteria.addToWhereSql(this);
- sql.append("\n");
+ for (ArtifactSearchCriteria idx : criteria) {
+ idx.addToQueryBuilder(builder);
}
- criteria[criteria.length - 1].addJoinArtId(this, false);
- sql.append("=");
- sql.append(artAlias);
- sql.append(".art_id AND ");
}
- sql.append(artAlias);
- sql.append(".gamma_id = ");
- sql.append(txsAlias);
- sql.append(".gamma_id AND ");
-
- if (isHistorical) {
- sql.append(txsAlias);
- sql.append(".transaction_id <= ?");
- addParameter(transactionId.getId());
- } else {
- sql.append(txsAlias);
- sql.append(".tx_current");
-
- if (allowDeleted == INCLUDE_DELETED) {
- sql.append(" IN (");
- sql.append(TxChange.CURRENT.getValue());
- sql.append(", ");
- sql.append(TxChange.DELETED.getValue());
- sql.append(")");
- } else {
- sql.append("=");
- sql.append(TxChange.CURRENT.getValue());
- }
- }
-
- addBranchTxSql(txsAlias);
-
if (isHistorical) {
- sql.append(" group by art_id, branch_id ");
+ builder.fromTransaction(transactionId.getId());
}
- List<String> paramList = new ArrayList<String>();
- paramList.add(ClientSessionManager.getSql(OseeSql.QUERY_BUILDER));
- if (count) {
- paramList.add(artAlias);
- } else {
- paramList.add(artAlias);
- paramList.add(txsAlias);
- }
-
- String query = null;
- try {
- query = String.format(sql.toString(), paramList.toArray());
- } catch (Exception ex) {
- StringBuilder builder = new StringBuilder();
- builder.append("Error formatting SQL: [");
- builder.append(sql.toString());
- builder.append("] params:");
- builder.append(paramList);
- throw new OseeWrappedException(builder.toString(), ex);
- }
- return query;
- }
-
- private static boolean hasValues(Collection<?> toCheck) {
- return toCheck != null && !toCheck.isEmpty();
- }
-
- private AbstractJoinQuery addToIdJoin(Collection<Integer> ids) throws OseeCoreException {
- IdJoinQuery idJoinQuery = JoinUtility.createIdJoinQuery();
- for (Integer id : ids) {
- idJoinQuery.add(id);
- }
- idJoinQuery.store();
- return idJoinQuery;
- }
-
- private AbstractJoinQuery addToGuidJoin(Collection<String> ids) throws OseeCoreException {
- CharJoinQuery joinQuery = JoinUtility.createCharJoinQuery(ClientSessionManager.getSessionId());
- for (String id : ids) {
- joinQuery.add(id);
- }
- joinQuery.store();
- return joinQuery;
- }
-
- public void append(String sqlSnippet) {
- sql.append(sqlSnippet);
- }
-
- public void addParameter(Object data) {
- queryParameters.add(data);
- }
-
- public void addTxSql(String txsAlias, boolean historical) throws OseeCoreException {
- if (!historical) {
- addCurrentTxSql(txsAlias);
- }
- addBranchTxSql(txsAlias);
- sql.append(" AND ");
- }
-
- private void addCurrentTxSql(String txsAlias) {
- sql.append(txsAlias);
- sql.append(".tx_current=1 ");
- }
-
- private void addBranchTxSql(String txsAlias) throws OseeCoreException {
- if (branch != null) {
- sql.append(" AND ");
- sql.append(txsAlias);
- sql.append(".branch_id=?");
- addParameter(BranchManager.getBranchId(branch));
- }
- }
-
- public String appendAliasedTable(String table) {
- if (firstTable) {
- firstTable = false;
- } else {
- sql.append(',');
- }
- sql.append(table);
- sql.append(' ');
- String alias = nextAliases.get(table).getNextAlias();
- sql.append(alias);
- return alias;
- }
-
- private static class NextAlias {
- String aliasPrefix;
- int aliasSuffix;
-
- public NextAlias(String aliasPrefix) {
- this.aliasPrefix = aliasPrefix;
- this.aliasSuffix = 1;
- }
-
- public String getNextAlias() {
- return aliasPrefix + aliasSuffix++;
- }
+ return builder;
}
public List<Artifact> getArtifacts(int artifactCountEstimate, ISearchConfirmer confirmer) throws OseeCoreException {
@@ -516,73 +253,35 @@ public class ArtifactQueryBuilder {
return artifacts.iterator().next();
}
- private List<Artifact> internalGetArtifacts(int artifactCountEstimate, ISearchConfirmer confirmer, LoadType reload) throws OseeCoreException {
- if (emptyCriteria) {
- return java.util.Collections.emptyList();
- }
-
+ private List<Artifact> loadArtifactsFromServerIds(LoadType reload) throws OseeCoreException {
+ List<Integer> ids = createOrcsQuery().getResults().getList();
List<Artifact> artifacts =
- ArtifactLoader.getArtifacts(getArtifactSelectSql(), queryParameters.toArray(), artifactCountEstimate,
- loadLevel, reload, confirmer, transactionId, allowDeleted);
- cleanup();
-
+ ArtifactLoader.loadArtifacts(ids, branch, loadLevel, reload, allowDeleted, transactionId);
return artifacts;
}
- private void cleanup() throws OseeCoreException {
- clearCriteria();
- cleanUp(guidJoinQuery);
- cleanUp(hridJoinQuery);
- cleanUp(idJoinQuery);
- cleanUp(idTypeJoinQuery);
- }
-
- private static void cleanUp(AbstractJoinQuery query) throws OseeCoreException {
- if (query != null) {
- query.delete();
- query = null;
+ private List<Artifact> internalGetArtifacts(int artifactCountEstimate, ISearchConfirmer confirmer, LoadType reload) throws OseeCoreException {
+ if (emptyCriteria) {
+ return java.util.Collections.emptyList();
}
- }
- private void clearCriteria() throws OseeCoreException {
- if (this.criteria != null) {
- for (AbstractArtifactSearchCriteria critiri : criteria) {
- critiri.cleanUp();
- }
- }
+ List<Artifact> artifactsFromServerIds = loadArtifactsFromServerIds(reload);
+ return artifactsFromServerIds;
}
public List<Integer> selectArtifacts(int artifactCountEstimate) throws OseeCoreException {
- IOseeStatement chStmt = ConnectionHandler.getStatement();
- List<Integer> artifactIds = new ArrayList<Integer>(artifactCountEstimate);
-
- try {
- chStmt.runPreparedQuery(artifactCountEstimate, getArtifactSelectSql(), queryParameters.toArray());
-
- while (chStmt.next()) {
- artifactIds.add(chStmt.getInt("art_id"));
- }
- } finally {
- chStmt.close();
- }
- cleanup();
- return artifactIds;
+ return createOrcsQuery().getResults().getList();
}
public int countArtifacts() throws OseeCoreException {
if (emptyCriteria) {
return 0;
- }
-
- count = true;
- try {
- return ConnectionHandler.runPreparedQueryFetchInt(0, getArtifactSelectSql(), queryParameters.toArray());
- } finally {
- cleanup();
+ } else {
+ return createOrcsQuery().getCount();
}
}
- public Artifact getOrCheckArtifact(QueryType queryType) throws OseeCoreException {
+ protected Artifact getOrCheckArtifact(QueryType queryType) throws OseeCoreException {
if (emptyCriteria) {
throw new ArtifactDoesNotExist("received an empty list in the criteria for this search");
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/Operator.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactSearchCriteria.java
index 8dc50ac7544..a37110165b0 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/Operator.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactSearchCriteria.java
@@ -10,20 +10,14 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.artifact.search;
-public enum Operator {
- EQUAL("="),
- NOT_EQUAL("<>"),
- LESS_THAN("<"),
- GREATER_THAN(">");
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.rest.client.QueryBuilder;
- private String expression;
+/**
+ * @author Ryan D. Brooks
+ */
+public interface ArtifactSearchCriteria {
- private Operator(String expression) {
- this.expression = expression;
- }
+ void addToQueryBuilder(QueryBuilder builder) throws OseeCoreException;
- @Override
- public String toString() {
- return expression;
- }
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeCriteria.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeCriteria.java
index 37b3e9d653e..26316d0c03d 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeCriteria.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeCriteria.java
@@ -11,46 +11,61 @@
package org.eclipse.osee.framework.skynet.core.artifact.search;
import java.util.Collection;
-import org.eclipse.osee.framework.core.client.ClientSessionManager;
import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.enums.Operator;
+import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.database.core.CharJoinQuery;
-import org.eclipse.osee.framework.database.core.JoinUtility;
-import org.eclipse.osee.framework.jdk.core.util.Collections;
-import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.orcs.rest.client.QueryBuilder;
/**
* @author Ryan D. Brooks
*/
-public class AttributeCriteria extends AbstractArtifactSearchCriteria {
+public class AttributeCriteria implements ArtifactSearchCriteria {
private final IAttributeType attributeType;
private String value;
private Collection<String> values;
- private String txsAlias;
- private String attrAlias;
- private String joinAlias;
- private final boolean historical;
private final Operator operator;
- private CharJoinQuery joinQuery;
+ private final QueryOption[] options;
+
+ public IAttributeType getAttributeType() {
+ return attributeType;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public Collection<String> getValues() {
+ return values;
+ }
+
+ public Operator getOperator() {
+ return operator;
+ }
+
+ public QueryOption[] getOptions() {
+ return options;
+ }
/**
* Constructor for search criteria that finds an attribute of the given type with its current value equal to the
* given value.
*
- * @param value to search; supports % wildcard
+ * @param value to search;
*/
- public AttributeCriteria(IAttributeType attributeType, String value) throws OseeCoreException {
- this(attributeType, value, null, false, Operator.EQUAL);
+ public AttributeCriteria(IAttributeType attributeType, String value, QueryOption... options) {
+ this(attributeType, value, null, Operator.EQUAL, options);
}
/**
* Constructor for search criteria that finds an attribute of the given type and any value (i.e. checks for
* existence)
*/
- public AttributeCriteria(IAttributeType attributeType) throws OseeCoreException {
- this(attributeType, null, null, false, Operator.EQUAL);
+ public AttributeCriteria(IAttributeType attributeType) {
+ this(attributeType, null, null, Operator.EQUAL);
}
/**
@@ -60,15 +75,15 @@ public class AttributeCriteria extends AbstractArtifactSearchCriteria {
* OseeArgumentException values is empty or null
*/
public AttributeCriteria(IAttributeType attributeType, Collection<String> values) throws OseeCoreException {
- this(attributeType, null, validate(values), false, Operator.EQUAL);
+ this(attributeType, null, validate(values), Operator.EQUAL);
}
/**
* Constructor for search criteria that finds an attribute of the given type with its current value relative to the
* given value based on the operator provided.
*/
- public AttributeCriteria(IAttributeType attributeType, String value, Operator operator) throws OseeCoreException {
- this(attributeType, value, null, false, operator);
+ public AttributeCriteria(IAttributeType attributeType, String value, Operator operator) {
+ this(attributeType, value, null, operator);
}
/**
@@ -78,18 +93,7 @@ public class AttributeCriteria extends AbstractArtifactSearchCriteria {
* multiple values.
*/
public AttributeCriteria(IAttributeType attributeType, Collection<String> values, Operator operator) throws OseeCoreException {
- this(attributeType, null, validate(values), false, operator);
- }
-
- /**
- * Constructor for search criteria that finds an attribute of the given type with its current value equal to the
- * given value.
- *
- * @param value to search; supports % wildcard
- * @param historical if true will search on any branch and any attribute revision
- */
- public AttributeCriteria(IAttributeType attributeType, String value, boolean historical) throws OseeCoreException {
- this(attributeType, value, null, historical, Operator.EQUAL);
+ this(attributeType, null, validate(values), operator);
}
private static Collection<String> validate(Collection<String> values) throws OseeArgumentException {
@@ -99,94 +103,25 @@ public class AttributeCriteria extends AbstractArtifactSearchCriteria {
return values;
}
- public AttributeCriteria(IAttributeType attributeType, String value, Collection<String> values, boolean historical, Operator operator) throws OseeCoreException {
+ public AttributeCriteria(IAttributeType attributeType, String value, Collection<String> values, Operator operator, QueryOption... options) {
this.attributeType = attributeType;
if (values == null) {
this.value = value;
- if (value != null && value.contains("%") && (operator != Operator.EQUAL && operator != Operator.NOT_EQUAL)) {
- throw new OseeArgumentException(
- "when value contains %%, one of the following operators must be used: %s, %s", Operator.EQUAL,
- Operator.NOT_EQUAL);
- }
} else {
if (values.size() == 1) {
this.value = values.iterator().next();
} else {
this.values = values;
- joinQuery = JoinUtility.createCharJoinQuery(ClientSessionManager.getSessionId());
- for (String str : values) {
- joinQuery.add(str);
- }
}
}
this.operator = operator;
- this.historical = historical;
- }
- @Override
- public void addToTableSql(ArtifactQueryBuilder builder) {
- if (joinQuery != null && operator == Operator.EQUAL) {
- joinAlias = builder.appendAliasedTable(joinQuery.getJoinTableName());
- }
- attrAlias = builder.appendAliasedTable("osee_attribute");
- txsAlias = builder.appendAliasedTable("osee_txs");
- }
-
- @Override
- public void addToWhereSql(ArtifactQueryBuilder builder) throws OseeCoreException {
- if (attributeType != null) {
- builder.append(attrAlias);
- builder.append(".attr_type_id=? AND ");
- builder.addParameter(ServiceUtil.getIdentityService().getLocalId(attributeType));
- }
- if (value != null) {
- builder.append(attrAlias);
- builder.append(".value");
- if (value.contains("%")) {
- if (operator == Operator.NOT_EQUAL) {
- builder.append(" NOT");
- }
- builder.append(" LIKE ");
- } else {
- builder.append(operator.toString());
- }
- builder.append("? AND ");
- builder.addParameter(value);
- }
-
- if (joinQuery != null) {
- if (operator == Operator.EQUAL) {
- builder.append(attrAlias);
- builder.append(".value = ");
- builder.append(joinAlias);
- builder.append(".id AND ");
- builder.append(joinAlias);
- builder.append(".query_id = ? AND ");
- } else {
- builder.append("NOT EXISTS (SELECT 1 from ");
- builder.append(joinQuery.getJoinTableName());
- builder.append(" WHERE id = ");
- builder.append(attrAlias);
- builder.append(".value AND query_id = ?) AND ");
- }
-
- builder.addParameter(joinQuery.getQueryId());
- joinQuery.store();
+ if (this.value != null && operator == Operator.EQUAL && options.length == 0) {
+ this.options = QueryOptions.EXACT_MATCH_OPTIONS;
+ } else {
+ this.options = options;
}
-
- builder.append(attrAlias);
- builder.append(".gamma_id=");
- builder.append(txsAlias);
- builder.append(".gamma_id AND ");
-
- builder.addTxSql(txsAlias, historical);
- }
-
- @Override
- public void addJoinArtId(ArtifactQueryBuilder builder, boolean left) {
- builder.append(attrAlias);
- builder.append(".art_id");
}
@Override
@@ -204,17 +139,21 @@ public class AttributeCriteria extends AbstractArtifactSearchCriteria {
strB.append(value);
}
- if (joinQuery != null) {
- strB.append(attrAlias);
- strB.append("(" + Collections.toString(",", values) + ")");
- }
return strB.toString();
}
@Override
- public void cleanUp() throws OseeCoreException {
- if (joinQuery != null) {
- joinQuery.delete();
+ public void addToQueryBuilder(QueryBuilder builder) throws OseeCoreException {
+ if (Strings.isValid(getValue())) {
+ if (getOperator() == Operator.EQUAL) {
+ builder.and(getAttributeType(), getValue(), getOptions());
+ } else {
+ builder.and(getAttributeType(), getOperator(), getValue());
+ }
+ } else if (getValues() != null) {
+ builder.and(getAttributeType(), getOperator(), getValues());
+ } else {
+ builder.andExists(getAttributeType());
}
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/QueryOptions.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/QueryOptions.java
new file mode 100644
index 00000000000..9e243b6ea10
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/QueryOptions.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.skynet.core.artifact.search;
+
+import org.eclipse.osee.framework.core.enums.CaseType;
+import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
+import org.eclipse.osee.framework.core.enums.QueryOption;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
+import org.eclipse.osee.framework.core.enums.TokenOrderType;
+
+/**
+ * @author John Misinco
+ */
+public final class QueryOptions {
+
+ public static final QueryOption[] EXACT_MATCH_OPTIONS = {
+ CaseType.MATCH_CASE,
+ TokenOrderType.MATCH_ORDER,
+ TokenDelimiterMatch.EXACT,
+ MatchTokenCountType.MATCH_TOKEN_COUNT};
+
+ public static final QueryOption[] CONTAINS_MATCH_OPTIONS = {
+ CaseType.IGNORE_CASE,
+ TokenOrderType.MATCH_ORDER,
+ TokenDelimiterMatch.ANY,
+ MatchTokenCountType.IGNORE_TOKEN_COUNT};
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/RelationCriteria.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/RelationCriteria.java
index 245cdd4d26f..e8ab7bce395 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/RelationCriteria.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/RelationCriteria.java
@@ -12,19 +12,18 @@ package org.eclipse.osee.framework.skynet.core.artifact.search;
import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.data.IRelationTypeSide;
+import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.services.IdentityService;
-import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.orcs.rest.client.QueryBuilder;
/**
* @author Ryan D. Brooks
*/
-public class RelationCriteria extends AbstractArtifactSearchCriteria {
+public class RelationCriteria implements ArtifactSearchCriteria {
private final IRelationType relationType;
private final RelationSide relationSide;
- private String txsAlias;
- private String relAlias;
private final int artifactId;
/**
@@ -47,38 +46,14 @@ public class RelationCriteria extends AbstractArtifactSearchCriteria {
}
@Override
- public void addToTableSql(ArtifactQueryBuilder builder) {
- relAlias = builder.appendAliasedTable("osee_relation_link");
- txsAlias = builder.appendAliasedTable("osee_txs");
- }
-
- @Override
- public void addToWhereSql(ArtifactQueryBuilder builder) throws OseeCoreException {
+ public void addToQueryBuilder(QueryBuilder builder) throws OseeCoreException {
if (artifactId > 0) {
- builder.append(relAlias);
- builder.append(relationSide.isSideA() ? ".b_art_id" : ".a_art_id");
- builder.append("=? AND ");
- builder.addParameter(artifactId);
- }
- if (relationType != null) {
- IdentityService identityService = ServiceUtil.getIdentityService();
- builder.append(relAlias);
- builder.append(".rel_link_type_id=? AND ");
- builder.addParameter(identityService.getLocalId(relationType));
+ IRelationTypeSide rts =
+ TokenFactory.createRelationTypeSide(relationSide, relationType.getGuid(), Strings.EMPTY_STRING);
+ builder.andRelatedToLocalIds(rts, artifactId);
+ } else {
+ builder.andExists(relationType);
}
-
- builder.append(relAlias);
- builder.append(".gamma_id=");
- builder.append(txsAlias);
- builder.append(".gamma_id AND ");
-
- builder.addTxSql(txsAlias, false);
}
- @Override
- public void addJoinArtId(ArtifactQueryBuilder builder, boolean left) {
- boolean useArtA = relationSide == RelationSide.SIDE_A ^ left;
- builder.append(relAlias);
- builder.append(useArtA ? ".a_art_id" : ".b_art_id");
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java
index ee7c7740aba..278e787caf7 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java
@@ -19,6 +19,7 @@ import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.AccessPolicy;
import org.eclipse.osee.framework.skynet.core.attribute.service.AttributeAdapterService;
import org.eclipse.osee.framework.skynet.core.event.OseeEventService;
+import org.eclipse.osee.orcs.rest.client.OseeClient;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -76,6 +77,10 @@ public final class ServiceUtil {
return getService(AttributeAdapterService.class);
}
+ public static OseeClient getOseeClient() throws OseeCoreException {
+ return getService(OseeClient.class);
+ }
+
public static AccessPolicy getAccessPolicy() throws OseeCoreException {
try {
Bundle bundle = Platform.getBundle("org.eclipse.osee.framework.access");
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/search/QueryStatisticsTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/search/QueryStatisticsTest.java
index b8cbccc6698..6bd00271fd9 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/search/QueryStatisticsTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/search/QueryStatisticsTest.java
@@ -14,8 +14,12 @@ import java.util.Collection;
import java.util.Collections;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.enums.CaseType;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
+import org.eclipse.osee.framework.core.enums.TokenOrderType;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Lib;
@@ -23,8 +27,6 @@ import org.eclipse.osee.orcs.core.ds.CriteriaSet;
import org.eclipse.osee.orcs.core.ds.QueryData;
import org.eclipse.osee.orcs.core.ds.QueryOptions;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeyword;
-import org.eclipse.osee.orcs.search.CaseType;
-import org.eclipse.osee.orcs.search.StringOperator;
import org.eclipse.osee.orcs.statistics.QueryStatistics;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -51,8 +53,8 @@ public class QueryStatisticsTest {
private static QueryData createQueryData(IOseeBranch branch, String value) {
QueryData queryData = new QueryData(new CriteriaSet(branch), new QueryOptions());
Collection<? extends IAttributeType> types = Collections.singleton(CoreAttributeTypes.Name);
- queryData.addCriteria(new CriteriaAttributeKeyword(types, value, StringOperator.TOKENIZED_MATCH_ORDER,
- CaseType.MATCH_CASE));
+ queryData.addCriteria(new CriteriaAttributeKeyword(types, value, TokenDelimiterMatch.ANY,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, CaseType.MATCH_CASE));
return queryData;
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaAttributeKeyword.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaAttributeKeyword.java
index 350c189290b..e71e58df52b 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaAttributeKeyword.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaAttributeKeyword.java
@@ -10,14 +10,15 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds.criteria;
+import java.util.Arrays;
import java.util.Collection;
import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.orcs.core.ds.Criteria;
import org.eclipse.osee.orcs.core.ds.QueryOptions;
-import org.eclipse.osee.orcs.search.CaseType;
-import org.eclipse.osee.orcs.search.StringOperator;
/**
* @author Roberto E. Escobar
@@ -26,15 +27,13 @@ public class CriteriaAttributeKeyword extends Criteria<QueryOptions> {
private final Collection<? extends IAttributeType> attributeType;
private final String value;
- private final StringOperator stringOp;
- private final CaseType match;
+ private final QueryOption[] options;
- public CriteriaAttributeKeyword(Collection<? extends IAttributeType> attributeType, String value, StringOperator stringOp, CaseType match) {
+ public CriteriaAttributeKeyword(Collection<? extends IAttributeType> attributeType, String value, QueryOption... options) {
super();
this.attributeType = attributeType;
this.value = value;
- this.stringOp = stringOp;
- this.match = match;
+ this.options = options;
}
public Collection<? extends IAttributeType> getTypes() {
@@ -45,12 +44,8 @@ public class CriteriaAttributeKeyword extends Criteria<QueryOptions> {
return value;
}
- public StringOperator getStringOp() {
- return stringOp;
- }
-
- public CaseType getMatch() {
- return match;
+ public QueryOption[] getOptions() {
+ return options;
}
@Override
@@ -62,7 +57,8 @@ public class CriteriaAttributeKeyword extends Criteria<QueryOptions> {
@Override
public String toString() {
- return "CriteriaAttributeKeyword [attributeType=" + attributeType + ", value=" + value + ", stringOp=" + stringOp + ", match=" + match + "]";
+ return String.format("CriteriaAttributeKeyword [attributeType=%s, value=%s, options=%s]", attributeType, value,
+ Collections.toString(",", Arrays.asList(options)));
}
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaAttributeOther.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaAttributeOther.java
index 9ea366ff91c..a8f210e5368 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaAttributeOther.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaAttributeOther.java
@@ -12,12 +12,12 @@ package org.eclipse.osee.orcs.core.ds.criteria;
import java.util.Collection;
import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.enums.Operator;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.orcs.core.ds.Criteria;
import org.eclipse.osee.orcs.core.ds.QueryOptions;
-import org.eclipse.osee.orcs.search.Operator;
import org.eclipse.osee.orcs.search.QueryBuilder;
/**
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java
index 284bddcffd3..237208c79dd 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java
@@ -110,7 +110,8 @@ public class OrcsApiImpl implements OrcsApi {
loaderFactory = new ArtifactLoaderFactoryImpl(dataStore.getDataLoaderFactory(), builderFactory);
queryModule =
- new QueryModule(logger, dataStore.getQueryEngine(), loaderFactory, cacheService.getAttributeTypeCache());
+ new QueryModule(logger, dataStore.getQueryEngine(), loaderFactory, cacheService.getAttributeTypeCache(),
+ dataStore.getDataLoaderFactory());
indexerModule = new IndexerModule(logger, preferences, executorAdmin, dataStore.getQueryEngineIndexer());
indexerModule.start();
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CallableQueryFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CallableQueryFactory.java
index d245e4f9612..c00f43859bb 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CallableQueryFactory.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CallableQueryFactory.java
@@ -14,15 +14,18 @@ import org.eclipse.osee.executor.admin.CancellableCallable;
import org.eclipse.osee.framework.core.data.ResultSet;
import org.eclipse.osee.framework.core.enums.LoadLevel;
import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
import org.eclipse.osee.orcs.core.ds.QueryData;
import org.eclipse.osee.orcs.core.ds.QueryEngine;
import org.eclipse.osee.orcs.core.internal.ArtifactLoaderFactory;
import org.eclipse.osee.orcs.core.internal.SessionContext;
+import org.eclipse.osee.orcs.core.internal.search.callable.LocalIdSearchCallable;
import org.eclipse.osee.orcs.core.internal.search.callable.SearchCallable;
import org.eclipse.osee.orcs.core.internal.search.callable.SearchCountCallable;
import org.eclipse.osee.orcs.core.internal.search.callable.SearchMatchesCallable;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
+import org.eclipse.osee.orcs.data.HasLocalId;
import org.eclipse.osee.orcs.search.Match;
/**
@@ -34,13 +37,15 @@ public class CallableQueryFactory {
private final QueryEngine queryEngine;
private final ArtifactLoaderFactory objectLoader;
private final QueryCollector collector;
+ private final DataLoaderFactory dataLoader;
- public CallableQueryFactory(Log logger, QueryEngine queryEngine, QueryCollector collector, ArtifactLoaderFactory objectLoader) {
+ public CallableQueryFactory(Log logger, QueryEngine queryEngine, QueryCollector collector, ArtifactLoaderFactory objectLoader, DataLoaderFactory dataLoader) {
super();
this.logger = logger;
this.queryEngine = queryEngine;
this.objectLoader = objectLoader;
this.collector = collector;
+ this.dataLoader = dataLoader;
}
public CancellableCallable<Integer> createCount(SessionContext sessionContext, QueryData queryData) {
@@ -56,4 +61,9 @@ public class CallableQueryFactory {
return new SearchMatchesCallable(logger, queryEngine, collector, objectLoader, sessionContext, LoadLevel.FULL,
queryData);
}
+
+ public CancellableCallable<ResultSet<HasLocalId>> createLocalIdSearch(SessionContext sessionContext, QueryData queryData) {
+ return new LocalIdSearchCallable(logger, queryEngine, collector, objectLoader, dataLoader, sessionContext,
+ queryData);
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CriteriaFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CriteriaFactory.java
index f22f401ba4d..5f73d9dee20 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CriteriaFactory.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CriteriaFactory.java
@@ -17,6 +17,8 @@ import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.data.IRelationTypeSide;
+import org.eclipse.osee.framework.core.enums.Operator;
+import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
import org.eclipse.osee.framework.core.model.type.AttributeType;
@@ -32,10 +34,7 @@ import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeOther;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeTypeExists;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelatedTo;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelationTypeExists;
-import org.eclipse.osee.orcs.search.CaseType;
-import org.eclipse.osee.orcs.search.Operator;
import org.eclipse.osee.orcs.search.QueryBuilder;
-import org.eclipse.osee.orcs.search.StringOperator;
/**
* @author Roberto E. Escobar
@@ -73,9 +72,9 @@ public class CriteriaFactory {
return new CriteriaAttributeOther(attributeType, values, operator);
}
- public Criteria<QueryOptions> createAttributeCriteria(Collection<? extends IAttributeType> attributeTypes, StringOperator operator, CaseType match, String value) throws OseeCoreException {
+ public Criteria<QueryOptions> createAttributeCriteria(Collection<? extends IAttributeType> attributeTypes, String value, QueryOption... options) throws OseeCoreException {
Collection<? extends IAttributeType> toReturn = checkForAnyType(attributeTypes);
- return new CriteriaAttributeKeyword(toReturn, value, operator, match);
+ return new CriteriaAttributeKeyword(toReturn, value, options);
}
public Criteria<QueryOptions> createArtifactTypeCriteria(Collection<? extends IArtifactType> artifactTypes) throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryBuilderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryBuilderImpl.java
index 691b88f92f6..062766366be 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryBuilderImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryBuilderImpl.java
@@ -23,6 +23,8 @@ import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.data.IRelationTypeSide;
import org.eclipse.osee.framework.core.data.ResultSet;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.Operator;
+import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.framework.core.util.Conditions;
@@ -36,11 +38,8 @@ import org.eclipse.osee.orcs.core.internal.SessionContext;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
import org.eclipse.osee.orcs.data.HasLocalId;
-import org.eclipse.osee.orcs.search.CaseType;
import org.eclipse.osee.orcs.search.Match;
-import org.eclipse.osee.orcs.search.Operator;
import org.eclipse.osee.orcs.search.QueryBuilder;
-import org.eclipse.osee.orcs.search.StringOperator;
/**
* @author Roberto E. Escobar
@@ -255,15 +254,15 @@ public class QueryBuilderImpl implements QueryBuilder {
}
@Override
- public QueryBuilder and(IAttributeType attributeType, StringOperator operator, CaseType match, String value) throws OseeCoreException {
+ public QueryBuilder and(IAttributeType attributeType, String value, QueryOption... options) throws OseeCoreException {
Criteria<QueryOptions> criteria =
- criteriaFactory.createAttributeCriteria(Collections.singleton(attributeType), operator, match, value);
+ criteriaFactory.createAttributeCriteria(Collections.singleton(attributeType), value, options);
return addAndCheck(getQueryData(), criteria);
}
@Override
- public QueryBuilder and(Collection<? extends IAttributeType> attributeTypes, StringOperator operator, CaseType match, String value) throws OseeCoreException {
- Criteria<QueryOptions> criteria = criteriaFactory.createAttributeCriteria(attributeTypes, operator, match, value);
+ public QueryBuilder and(Collection<? extends IAttributeType> attributeTypes, String value, QueryOption... options) throws OseeCoreException {
+ Criteria<QueryOptions> criteria = criteriaFactory.createAttributeCriteria(attributeTypes, value, options);
return addAndCheck(getQueryData(), criteria);
}
@@ -355,8 +354,14 @@ public class QueryBuilderImpl implements QueryBuilder {
}
@Override
- public CancellableCallable<Integer> createCount() throws OseeCoreException {
- return queryFactory.createCount(sessionContext, checkAndCloneQueryData());
+ public ResultSet<HasLocalId> getResultsAsLocalIds() throws OseeCoreException {
+ ResultSet<HasLocalId> result = null;
+ try {
+ result = createSearchResultsAsLocalIds().call();
+ } catch (Exception ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ return result;
}
@Override
@@ -369,6 +374,11 @@ public class QueryBuilderImpl implements QueryBuilder {
return queryFactory.createSearchWithMatches(sessionContext, checkAndCloneQueryData());
}
+ @Override
+ public CancellableCallable<ResultSet<HasLocalId>> createSearchResultsAsLocalIds() throws OseeCoreException {
+ return queryFactory.createLocalIdSearch(sessionContext, checkAndCloneQueryData());
+ }
+
private QueryData checkAndCloneQueryData() throws OseeCoreException {
QueryData queryData = getQueryData().clone();
CriteriaSet criteriaSet = queryData.getCriteriaSet();
@@ -377,4 +387,9 @@ public class QueryBuilderImpl implements QueryBuilder {
}
return queryData;
}
+
+ @Override
+ public CancellableCallable<Integer> createCount() throws OseeCoreException {
+ return queryFactory.createCount(sessionContext, checkAndCloneQueryData());
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java
index 0b529a78368..8a448b4e0d2 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.core.internal.search;
import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
import org.eclipse.osee.orcs.core.ds.QueryEngine;
import org.eclipse.osee.orcs.core.internal.ArtifactLoaderFactory;
import org.eclipse.osee.orcs.core.internal.HasStatistics;
@@ -29,10 +30,11 @@ public class QueryModule implements HasStatistics<QueryStatistics> {
private final CriteriaFactory criteriaFctry;
private final CallableQueryFactory callableQueryFactory;
- public QueryModule(Log logger, QueryEngine queryEngine, ArtifactLoaderFactory objectLoader, AttributeTypeCache attributeTypeCache) {
+ public QueryModule(Log logger, QueryEngine queryEngine, ArtifactLoaderFactory objectLoader, AttributeTypeCache attributeTypeCache, DataLoaderFactory dataLoader) {
QueryStatsCollectorImpl queryStatsCollector = new QueryStatsCollectorImpl(statistics);
this.criteriaFctry = new CriteriaFactory(attributeTypeCache);
- this.callableQueryFactory = new CallableQueryFactory(logger, queryEngine, queryStatsCollector, objectLoader);
+ this.callableQueryFactory =
+ new CallableQueryFactory(logger, queryEngine, queryStatsCollector, objectLoader, dataLoader);
}
public QueryFactory createQueryFactory(SessionContext sessionContext) {
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractArtifactSearchCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractArtifactSearchCallable.java
new file mode 100644
index 00000000000..3ed1a864c3e
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractArtifactSearchCallable.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.core.internal.search.callable;
+
+import org.eclipse.osee.framework.core.enums.LoadLevel;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.core.ds.QueryData;
+import org.eclipse.osee.orcs.core.ds.QueryEngine;
+import org.eclipse.osee.orcs.core.internal.ArtifactLoaderFactory;
+import org.eclipse.osee.orcs.core.internal.SessionContext;
+import org.eclipse.osee.orcs.core.internal.search.QueryCollector;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public abstract class AbstractArtifactSearchCallable<T> extends AbstractSearchCallable<T> {
+
+ protected final ArtifactLoaderFactory objectLoader;
+
+ public AbstractArtifactSearchCallable(Log logger, QueryEngine queryEngine, QueryCollector collector, ArtifactLoaderFactory objectLoader, SessionContext sessionContext, LoadLevel loadLevel, QueryData queryData) {
+ super(logger, queryEngine, collector, sessionContext, loadLevel, queryData);
+ this.objectLoader = objectLoader;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractSearchCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractSearchCallable.java
index ad4bd8147e8..4f8fa4fd966 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractSearchCallable.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractSearchCallable.java
@@ -16,7 +16,6 @@ import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.ds.QueryData;
import org.eclipse.osee.orcs.core.ds.QueryEngine;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoaderFactory;
import org.eclipse.osee.orcs.core.internal.SessionContext;
import org.eclipse.osee.orcs.core.internal.search.QueryCollector;
@@ -27,19 +26,16 @@ public abstract class AbstractSearchCallable<T> extends CancellableCallable<T> {
protected final Log logger;
protected final QueryEngine queryEngine;
- protected final ArtifactLoaderFactory objectLoader;
-
protected final SessionContext sessionContext;
protected final LoadLevel loadLevel;
protected final QueryData queryData;
private final QueryCollector collector;
- public AbstractSearchCallable(Log logger, QueryEngine queryEngine, QueryCollector collector, ArtifactLoaderFactory objectLoader, SessionContext sessionContext, LoadLevel loadLevel, QueryData queryData) {
+ public AbstractSearchCallable(Log logger, QueryEngine queryEngine, QueryCollector collector, SessionContext sessionContext, LoadLevel loadLevel, QueryData queryData) {
super();
this.logger = logger;
this.queryEngine = queryEngine;
this.collector = collector;
- this.objectLoader = objectLoader;
this.sessionContext = sessionContext;
this.loadLevel = loadLevel;
this.queryData = queryData;
@@ -85,4 +81,5 @@ public abstract class AbstractSearchCallable<T> extends CancellableCallable<T> {
protected abstract int getCount(T results) throws Exception;
protected abstract T innerCall() throws Exception;
+
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/LocalIdSearchCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/LocalIdSearchCallable.java
new file mode 100644
index 00000000000..02b2108e26f
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/LocalIdSearchCallable.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.core.internal.search.callable;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.osee.framework.core.data.ResultSet;
+import org.eclipse.osee.framework.core.data.ResultSetList;
+import org.eclipse.osee.framework.core.enums.LoadLevel;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.core.ds.ArtifactBuilder;
+import org.eclipse.osee.orcs.core.ds.ArtifactData;
+import org.eclipse.osee.orcs.core.ds.ArtifactDataHandler;
+import org.eclipse.osee.orcs.core.ds.AttributeData;
+import org.eclipse.osee.orcs.core.ds.AttributeDataHandler;
+import org.eclipse.osee.orcs.core.ds.DataLoader;
+import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
+import org.eclipse.osee.orcs.core.ds.QueryContext;
+import org.eclipse.osee.orcs.core.ds.QueryData;
+import org.eclipse.osee.orcs.core.ds.QueryEngine;
+import org.eclipse.osee.orcs.core.ds.QueryPostProcessor;
+import org.eclipse.osee.orcs.core.ds.RelationData;
+import org.eclipse.osee.orcs.core.ds.RelationDataHandler;
+import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeyword;
+import org.eclipse.osee.orcs.core.internal.ArtifactLoader;
+import org.eclipse.osee.orcs.core.internal.ArtifactLoaderFactory;
+import org.eclipse.osee.orcs.core.internal.SessionContext;
+import org.eclipse.osee.orcs.core.internal.search.QueryCollector;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.data.AttributeReadable;
+import org.eclipse.osee.orcs.data.HasLocalId;
+import org.eclipse.osee.orcs.search.Match;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class LocalIdSearchCallable extends AbstractSearchCallable<ResultSet<HasLocalId>> {
+
+ private final ArtifactLoaderFactory objectLoader;
+ private final DataLoaderFactory dataLoaderFactory;
+
+ public LocalIdSearchCallable(Log logger, QueryEngine queryEngine, QueryCollector collector, ArtifactLoaderFactory objectLoader, DataLoaderFactory dataLoaderFactory, SessionContext sessionContext, QueryData queryData) {
+ super(logger, queryEngine, collector, sessionContext, null, queryData);
+ this.dataLoaderFactory = dataLoaderFactory;
+ this.objectLoader = objectLoader;
+ }
+
+ @Override
+ protected int getCount(ResultSet<HasLocalId> results) throws Exception {
+ return results.getList().size();
+ }
+
+ @Override
+ protected ResultSet<HasLocalId> innerCall() throws Exception {
+ QueryContext queryContext = queryEngine.create(sessionContext.getSessionId(), queryData);
+
+ checkForCancelled();
+
+ boolean requiresAttributeScan =
+ queryData.hasCriteriaType(CriteriaAttributeKeyword.class) && !queryContext.getPostProcessors().isEmpty();
+
+ List<HasLocalId> results = new ArrayList<HasLocalId>();
+ if (requiresAttributeScan) {
+ ArtifactLoader loader = objectLoader.fromQueryContext(sessionContext, queryContext);
+ loader.setLoadLevel(loadLevel);
+ loader.includeDeleted(queryData.getOptions().areDeletedIncluded());
+ loader.fromTransaction(queryData.getOptions().getFromTransaction());
+ checkForCancelled();
+
+ List<ArtifactReadable> artifacts = loader.load(this);
+
+ checkForCancelled();
+
+ if (!queryContext.getPostProcessors().isEmpty()) {
+ for (QueryPostProcessor processor : queryContext.getPostProcessors()) {
+ processor.setItemsToProcess(artifacts);
+ checkForCancelled();
+ List<Match<ArtifactReadable, AttributeReadable<?>>> matches = processor.call();
+ for (Match<ArtifactReadable, AttributeReadable<?>> match : matches) {
+ results.add(match.getItem());
+ checkForCancelled();
+ }
+ }
+ } else {
+ results.addAll(artifacts);
+ }
+ } else {
+ DataLoader loader = dataLoaderFactory.fromQueryContext(queryContext);
+ loader.setLoadLevel(LoadLevel.SHALLOW);
+ loader.includeDeleted(queryData.getOptions().areDeletedIncluded());
+ loader.fromTransaction(queryData.getOptions().getFromTransaction());
+ loader.load(this, new AdapterBuidler(results));
+ }
+ checkForCancelled();
+ return new ResultSetList<HasLocalId>(results);
+ }
+
+ private static final class AdapterBuidler implements ArtifactBuilder {
+
+ private final Collection<HasLocalId> results;
+
+ public AdapterBuidler(Collection<HasLocalId> results) {
+ super();
+ this.results = results;
+ }
+
+ @Override
+ public ArtifactDataHandler createArtifactDataHandler() {
+ return new ArtifactDataHandler() {
+
+ @Override
+ public void onData(ArtifactData data) {
+ results.add(data);
+ }
+ };
+ }
+
+ @Override
+ public RelationDataHandler createRelationDataHandler() {
+ return new RelationDataHandler() {
+
+ @Override
+ public void onData(RelationData data) {
+ //
+ }
+ };
+ }
+
+ @Override
+ public AttributeDataHandler createAttributeDataHandler() {
+ return new AttributeDataHandler() {
+
+ @Override
+ public void onData(AttributeData data) {
+ //
+ }
+ };
+ }
+
+ @Override
+ public List<ArtifactReadable> getArtifacts() {
+ return null;
+ }
+
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCallable.java
index 4cb33158ecd..a483832abb9 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCallable.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCallable.java
@@ -31,7 +31,7 @@ import org.eclipse.osee.orcs.search.Match;
/**
* @author Roberto E. Escobar
*/
-public class SearchCallable extends AbstractSearchCallable<ResultSet<ArtifactReadable>> {
+public class SearchCallable extends AbstractArtifactSearchCallable<ResultSet<ArtifactReadable>> {
private QueryContext queryContext;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCountCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCountCallable.java
index 2a5b3d9538f..9c67b83641e 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCountCallable.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCountCallable.java
@@ -30,7 +30,7 @@ import org.eclipse.osee.orcs.search.Match;
/**
* @author Roberto E. Escobar
*/
-public class SearchCountCallable extends AbstractSearchCallable<Integer> {
+public class SearchCountCallable extends AbstractArtifactSearchCallable<Integer> {
private QueryContext queryContext;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchMatchesCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchMatchesCallable.java
index d332b0a8820..62b4cdd6929 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchMatchesCallable.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchMatchesCallable.java
@@ -33,7 +33,7 @@ import org.eclipse.osee.orcs.search.Match;
/**
* @author Roberto E. Escobar
*/
-public class SearchMatchesCallable extends AbstractSearchCallable<ResultSet<Match<ArtifactReadable, AttributeReadable<?>>>> {
+public class SearchMatchesCallable extends AbstractArtifactSearchCallable<ResultSet<Match<ArtifactReadable, AttributeReadable<?>>>> {
private Collection<QueryPostProcessor> processors;
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImplTest.java
index b3305f48ec2..ca7aa763305 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImplTest.java
@@ -10,15 +10,20 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.search;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.eclipse.osee.executor.admin.ExecutorAdmin;
+import org.eclipse.osee.framework.core.enums.CaseType;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
+import org.eclipse.osee.framework.core.enums.Operator;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
+import org.eclipse.osee.framework.core.enums.TokenOrderType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
@@ -47,9 +52,6 @@ import org.eclipse.osee.orcs.db.internal.SqlProvider;
import org.eclipse.osee.orcs.db.internal.search.tagger.TaggingEngine;
import org.eclipse.osee.orcs.db.internal.sql.OseeSql;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandlerFactory;
-import org.eclipse.osee.orcs.search.CaseType;
-import org.eclipse.osee.orcs.search.Operator;
-import org.eclipse.osee.orcs.search.StringOperator;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -76,8 +78,8 @@ public class QueryEngineImplTest {
CoreRelationTypes.Default_Hierarchical__Child);
private static final Criteria<?> ATTRIBUTE_KEYWORD = new CriteriaAttributeKeyword(Arrays.asList(
- CoreAttributeTypes.Name, CoreAttributeTypes.WordTemplateContent), "hello1_two_three",
- StringOperator.TOKENIZED_MATCH_ORDER, CaseType.IGNORE_CASE);
+ CoreAttributeTypes.Name, CoreAttributeTypes.WordTemplateContent), "hello1_two_three", TokenDelimiterMatch.ANY,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, CaseType.MATCH_CASE);
private static final Criteria<?> RELATED_TO = new CriteriaRelatedTo(CoreRelationTypes.Default_Hierarchical__Child,
Arrays.asList(45, 61));
@@ -176,7 +178,7 @@ public class QueryEngineImplTest {
@Test
public void testCountHistorical() throws Exception {
String expected = "SELECT count(xTable.art_id) FROM (\n" + //
- " SELECT/*+ ordered */ max(txs1.transaction_id), art1.art_id, txs1.branch_id\n" + //
+ " SELECT/*+ ordered */ max(txs1.transaction_id) as transaction_id, art1.art_id, txs1.branch_id\n" + //
" FROM \n" + //
"osee_artifact art1, osee_txs txs1\n" + //
" WHERE \n" + //
@@ -286,7 +288,7 @@ public class QueryEngineImplTest {
@Test
public void testQueryHistorical() throws OseeCoreException {
String expected =
- "SELECT/*+ ordered */ max(txs1.transaction_id), art1.art_id, txs1.branch_id\n" + //
+ "SELECT/*+ ordered */ max(txs1.transaction_id) as transaction_id, art1.art_id, txs1.branch_id\n" + //
" FROM \n" + //
"osee_join_id jid1, osee_artifact art1, osee_txs txs1, osee_join_char_id jch1, osee_artifact art2, osee_txs txs2, osee_join_char_id jch2, osee_artifact art3, osee_txs txs3\n" + //
" WHERE \n" + //
@@ -707,7 +709,7 @@ public class QueryEngineImplTest {
@Test
public void testCountAllArtifactsFromBranchHistorical() throws OseeCoreException {
String expected = "SELECT count(xTable.art_id) FROM (\n" + //
- " SELECT/*+ ordered */ max(txs1.transaction_id), art1.art_id, txs1.branch_id\n" + //
+ " SELECT/*+ ordered */ max(txs1.transaction_id) as transaction_id, art1.art_id, txs1.branch_id\n" + //
" FROM \n" + //
"osee_artifact art1, osee_txs txs1\n" + //
" WHERE \n" + //
@@ -760,15 +762,16 @@ public class QueryEngineImplTest {
@Test
public void testQueryAllArtifactsFromBranchHistorical() throws OseeCoreException {
- String expected = "SELECT/*+ ordered */ max(txs1.transaction_id), art1.art_id, txs1.branch_id\n" + //
- " FROM \n" + //
- "osee_artifact art1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "art1.gamma_id = txs1.gamma_id AND txs1.transaction_id <= ?\n" + //
- " AND \n" + //
- "txs1.tx_current IN (1, 0) AND txs1.branch_id = ?\n" + //
- " GROUP BY art1.art_id, txs1.branch_id\n" + //
- " ORDER BY art1.art_id, txs1.branch_id";
+ String expected =
+ "SELECT/*+ ordered */ max(txs1.transaction_id) as transaction_id, art1.art_id, txs1.branch_id\n" + //
+ " FROM \n" + //
+ "osee_artifact art1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "art1.gamma_id = txs1.gamma_id AND txs1.transaction_id <= ?\n" + //
+ " AND \n" + //
+ "txs1.tx_current IN (1, 0) AND txs1.branch_id = ?\n" + //
+ " GROUP BY art1.art_id, txs1.branch_id\n" + //
+ " ORDER BY art1.art_id, txs1.branch_id";
queryData.getOptions().setFromTransaction(EXPECTED_TX_ID);
queryData.addCriteria(ALL_ARTIFACTS);
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlHandlerFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlHandlerFactoryImplTest.java
index c7859a94927..025564df5cc 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlHandlerFactoryImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlHandlerFactoryImplTest.java
@@ -97,7 +97,7 @@ public class QuerySqlHandlerFactoryImplTest {
criteria.add(new CriteriaRelationTypeExists(null));
criteria.add(new CriteriaAttributeTypeExists(null));
criteria.add(new CriteriaAttributeOther(null, null, null));
- criteria.add(new CriteriaAttributeKeyword(null, null, null, null));
+ criteria.add(new CriteriaAttributeKeyword(null, null, null, null, null, null));
criteria.add(new CriteriaRelatedTo(null, null));
criteria.add(new CriteriaAllArtifacts());
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcherTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcherTest.java
new file mode 100644
index 00000000000..ed592dc3552
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcherTest.java
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.db.internal.search.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.osee.framework.core.enums.CaseType;
+import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
+import org.eclipse.osee.framework.core.enums.TokenOrderType;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
+import org.eclipse.osee.orcs.db.internal.search.SearchAsserts;
+import org.eclipse.osee.orcs.db.internal.search.tagger.StreamMatcher;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * @author John Misinco
+ */
+@RunWith(Parameterized.class)
+public class SecondPassMatcherTest {
+
+ private final String toSearch;
+ private final String data;
+ private final List<MatchLocation> expected;
+ private final CaseType caseType;
+ private final boolean findAllMatchLocations;
+ private final StreamMatcher matcher;
+ private final TokenDelimiterMatch delimiter;
+ private final TokenOrderType order;
+ private final MatchTokenCountType countType;
+
+ public SecondPassMatcherTest(StreamMatcher matcher, String data, String toSearch, CaseType caseType, TokenDelimiterMatch delimiter, TokenOrderType order, MatchTokenCountType countType, boolean findAllMatchLocations, List<MatchLocation> expected) {
+ this.toSearch = toSearch;
+ this.data = data;
+ this.caseType = caseType;
+ this.delimiter = delimiter;
+ this.order = order;
+ this.findAllMatchLocations = findAllMatchLocations;
+ this.countType = countType;
+ this.expected = expected;
+ this.matcher = matcher;
+ }
+
+ @Test
+ public void testWordOrderMatcher() throws UnsupportedEncodingException {
+ InputStream inputStream = toStream(data);
+ List<MatchLocation> actual =
+ matcher.findInStream(inputStream, toSearch, findAllMatchLocations, caseType, order, countType, delimiter);
+ SearchAsserts.assertEquals(expected, actual);
+ }
+
+ @Parameters
+ public static Collection<Object[]> data() {
+ List<Object[]> data = new ArrayList<Object[]>();
+
+ StreamMatcher matcher = MatcherFactory.createMatcher();
+
+ // MATCH_ORDER tests
+ addTest(data, matcher, "THIS", "THIS", CaseType.MATCH_CASE, TokenDelimiterMatch.EXACT,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, false, getLocs(1, 4));
+ addTest(data, matcher, "THIS", "this", CaseType.MATCH_CASE, TokenDelimiterMatch.EXACT,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, false, getLocs());
+ addTest(data, matcher, "THIS", "this", CaseType.IGNORE_CASE, TokenDelimiterMatch.EXACT,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, false, getLocs(1, 4));
+ addTest(data, matcher, "THIS bot", "this", CaseType.IGNORE_CASE, TokenDelimiterMatch.EXACT,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, false, getLocs());
+ addTest(data, matcher, "What does this mean", "this", CaseType.MATCH_CASE, TokenDelimiterMatch.EXACT,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, false, getLocs(12, 15));
+ addTest(data, matcher, "What does this mean", "what does", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.WHITESPACE, TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, false,
+ getLocs(1, 11));
+ addTest(data, matcher, "What does this mean", "what does", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.WHITESPACE, TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, false,
+ getLocs());
+ addTest(data, matcher, "What does", "what does", CaseType.IGNORE_CASE, TokenDelimiterMatch.WHITESPACE,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, false, getLocs(1, 13));
+ addTest(data, matcher, "What->does] this mean", "what does this", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.custom("(->|\\s|])+"), TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT,
+ false, getLocs(1, 16));
+ addTest(data, matcher, "What->does] this mean", "what does this", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.custom("(->|\\s|])+"), TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT,
+ false, getLocs());
+ addTest(data, matcher, "What->does] .this. mean", "What does tHis", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.ANY, TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, false,
+ getLocs(1, 17));
+ addTest(data, matcher, "does does does", "does does", CaseType.IGNORE_CASE, TokenDelimiterMatch.WHITESPACE,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, false, getLocs());
+ addTest(data, matcher, " does does does", "does does", CaseType.IGNORE_CASE, TokenDelimiterMatch.WHITESPACE,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, false, getLocs(4, 12));
+ addTest(data, matcher, " (Selected) -> [.SELECTED_STRING_ID] Selected -> ", "SELECTED_STRING_ID",
+ CaseType.IGNORE_CASE, TokenDelimiterMatch.ANY, TokenOrderType.MATCH_ORDER,
+ MatchTokenCountType.IGNORE_TOKEN_COUNT, false, getLocs(18, 35));
+ addTest(data, matcher, " (Selected) -> [.SELECTED_STRING_ID] Selected -> ", "SELECTED_STRING_ID",
+ CaseType.MATCH_CASE, TokenDelimiterMatch.ANY, TokenOrderType.MATCH_ORDER,
+ MatchTokenCountType.IGNORE_TOKEN_COUNT, false, getLocs(18, 35));
+ addTest(data, matcher, " (Selected) -> [.SELECTED_STRING_IWRONG SELECTED_STRING_ID_TWO] Selected -> ",
+ "SELECTED_STRING_ID", CaseType.MATCH_CASE, TokenDelimiterMatch.ANY, TokenOrderType.MATCH_ORDER,
+ MatchTokenCountType.IGNORE_TOKEN_COUNT, false, getLocs(41, 58));
+ addTest(data, matcher, " (Selected) -> [.SELECTED_STRING_IWRONG SELECTED_STRING_ID_TWO] Selected -> ",
+ "SELECTED_STRING_ID", CaseType.IGNORE_CASE, TokenDelimiterMatch.ANY, TokenOrderType.MATCH_ORDER,
+ MatchTokenCountType.IGNORE_TOKEN_COUNT, false, getLocs(41, 58));
+ addTest(data, matcher, " (Selected) -> [.SELECTED_STRING_IWRONG SELECTED_STRING_\nID_TWO] Selected -> ",
+ "SELECTED_STRING_ID", CaseType.IGNORE_CASE, TokenDelimiterMatch.ANY, TokenOrderType.MATCH_ORDER,
+ MatchTokenCountType.IGNORE_TOKEN_COUNT, false, getLocs(41, 59));
+
+ addTest(data, matcher, "THIS", "THIS", CaseType.MATCH_CASE, TokenDelimiterMatch.EXACT,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, true, getLocs(1, 4));
+ addTest(data, matcher, "THIS", "this", CaseType.MATCH_CASE, TokenDelimiterMatch.EXACT,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, true, getLocs());
+ addTest(data, matcher, "THIS", "this", CaseType.IGNORE_CASE, TokenDelimiterMatch.EXACT,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, true, getLocs(1, 4));
+ addTest(data, matcher, "THIS bot", "this", CaseType.IGNORE_CASE, TokenDelimiterMatch.EXACT,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, true, getLocs());
+ addTest(data, matcher, "What does this mean", "this", CaseType.MATCH_CASE, TokenDelimiterMatch.EXACT,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, true, getLocs(12, 15));
+ addTest(data, matcher, "What does this mean", "what does", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.WHITESPACE, TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, true,
+ getLocs(1, 11));
+ addTest(data, matcher, "What does this mean", "what does", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.WHITESPACE, TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, true,
+ getLocs());
+ addTest(data, matcher, "What does", "what does", CaseType.IGNORE_CASE, TokenDelimiterMatch.WHITESPACE,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, true, getLocs(1, 13));
+ addTest(data, matcher, "What->does] this mean", "what does this", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.custom("(->|\\s|])+"), TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT,
+ true, getLocs(1, 16));
+ addTest(data, matcher, "What->does] this mean", "what does this", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.custom("(->|\\s|])+"), TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT,
+ true, getLocs());
+ addTest(data, matcher, "What->does] .this. mean", "What does tHis", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.ANY, TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, true,
+ getLocs(1, 17));
+ addTest(data, matcher, "does does does", "does does", CaseType.IGNORE_CASE, TokenDelimiterMatch.WHITESPACE,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, true, getLocs());
+ addTest(data, matcher, " does does does", "does does", CaseType.IGNORE_CASE, TokenDelimiterMatch.WHITESPACE,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, true, getLocs(4, 12));
+ addTest(data, matcher, " (Selected) -> [.SELECTED_STRING_ID] Selected -> ", "SELECTED_STRING_ID",
+ CaseType.IGNORE_CASE, TokenDelimiterMatch.ANY, TokenOrderType.MATCH_ORDER,
+ MatchTokenCountType.IGNORE_TOKEN_COUNT, true, getLocs(18, 35));
+ addTest(data, matcher, " (Selected) -> [.SELECTED_STRING_ID] Selected -> ", "SELECTED_STRING_ID",
+ CaseType.MATCH_CASE, TokenDelimiterMatch.ANY, TokenOrderType.MATCH_ORDER,
+ MatchTokenCountType.IGNORE_TOKEN_COUNT, true, getLocs(18, 35));
+ addTest(data, matcher, " (Selected) -> [.SELECTED_STRING_IWRONG SELECTED_STRING_ID_TWO] Selected -> ",
+ "SELECTED_STRING_ID", CaseType.MATCH_CASE, TokenDelimiterMatch.ANY, TokenOrderType.MATCH_ORDER,
+ MatchTokenCountType.IGNORE_TOKEN_COUNT, true, getLocs(41, 58));
+ addTest(data, matcher, " (Selected) -> [.SELECTED_STRING_IWRONG SELECTED_STRING_ID_TWO] Selected -> ",
+ "SELECTED_STRING_ID", CaseType.IGNORE_CASE, TokenDelimiterMatch.ANY, TokenOrderType.MATCH_ORDER,
+ MatchTokenCountType.IGNORE_TOKEN_COUNT, true, getLocs(41, 58));
+ addTest(data, matcher, " (Selected) -> [.SELECTED_STRING_IWRONG SELECTED_STRING_\nID_TWO] Selected -> ",
+ "SELECTED_STRING_ID", CaseType.IGNORE_CASE, TokenDelimiterMatch.ANY, TokenOrderType.MATCH_ORDER,
+ MatchTokenCountType.IGNORE_TOKEN_COUNT, true, getLocs(41, 59));
+
+ // ANY_ORDER tests
+ addTest(data, matcher, "each token should match", "should token match each", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.WHITESPACE, TokenOrderType.ANY_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, false,
+ getLocs(1, 4, 6, 10, 12, 17, 19, 23));
+ addTest(data, matcher, "each token should match extra token", "should token match each", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.WHITESPACE, TokenOrderType.ANY_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, false,
+ getLocs(1, 4, 6, 10, 12, 17, 19, 23));
+ addTest(data, matcher, "each token should match extra token", "should token match each", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.WHITESPACE, TokenOrderType.ANY_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, false,
+ getLocs());
+ addTest(data, matcher, "each token should match ToKen", "should token match each", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.WHITESPACE, TokenOrderType.ANY_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, true,
+ getLocs(1, 4, 6, 10, 12, 17, 19, 23, 27, 31));
+ addTest(data, matcher, "each each should extra token", "should token match each", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.ANY, TokenOrderType.ANY_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, false, getLocs());
+
+ addTest(data, matcher, "each token should match", "should token match each", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.WHITESPACE, TokenOrderType.ANY_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, true,
+ getLocs(1, 4, 6, 10, 12, 17, 19, 23));
+ addTest(data, matcher, "each token should match extra token", "should token match each", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.WHITESPACE, TokenOrderType.ANY_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, true,
+ getLocs(1, 4, 6, 10, 12, 17, 19, 23, 31, 35));
+ addTest(data, matcher, "each token should match extra token", "should token match each", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.WHITESPACE, TokenOrderType.ANY_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, true,
+ getLocs());
+ addTest(data, matcher, "each each should extra token", "should token match each", CaseType.IGNORE_CASE,
+ TokenDelimiterMatch.ANY, TokenOrderType.ANY_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, true, getLocs());
+
+ addTest(data, matcher, "Robot API", "Robot", CaseType.MATCH_CASE, TokenDelimiterMatch.ANY,
+ TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, true, getLocs(1, 5));
+
+ return data;
+ }
+
+ private static void addTest(Collection<Object[]> testData, StreamMatcher matcher, String data, String toSearch, CaseType caseType, TokenDelimiterMatch delimiter, TokenOrderType order, MatchTokenCountType countType, boolean findAllMatchLocations, List<MatchLocation> expectedLocs) {
+ testData.add(new Object[] {
+ matcher,
+ data,
+ toSearch,
+ caseType,
+ delimiter,
+ order,
+ countType,
+ findAllMatchLocations,
+ expectedLocs});
+ }
+
+ private static List<MatchLocation> getLocs(int... data) {
+ return SearchAsserts.asLocations(data);
+ }
+
+ private InputStream toStream(String value) throws UnsupportedEncodingException {
+ return new ByteArrayInputStream(value.getBytes("utf-8"));
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/UtilityTestSuite.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/UtilityTestSuite.java
index 87c53909886..893835fd203 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/UtilityTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/UtilityTestSuite.java
@@ -17,7 +17,7 @@ import org.junit.runners.Suite;
* @author Roberto E. Escobar
*/
@RunWith(Suite.class)
-@Suite.SuiteClasses({WordOrderMatcherTest.class, WordsUtilTest.class})
+@Suite.SuiteClasses({SecondPassMatcherTest.class, WordsUtilTest.class})
public class UtilityTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcherTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcherTest.java
deleted file mode 100644
index 8e6c80667d3..00000000000
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcherTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.search.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
-import org.eclipse.osee.orcs.db.internal.search.SearchAsserts;
-import org.eclipse.osee.orcs.search.CaseType;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * Test Case for {@link WordOrderMatcher}
- *
- * @author Roberto E. Escobar
- */
-@RunWith(Parameterized.class)
-public class WordOrderMatcherTest {
-
- private final String toSearch;
- private final String data;
- private final List<MatchLocation> expected;
- private final CaseType caseType;
- private final boolean findAllMatchLocations;
- private final WordOrderMatcher matcher;
-
- public WordOrderMatcherTest(String data, String toSearch, CaseType caseType, boolean findAllMatchLocations, List<MatchLocation> expected) {
- super();
- this.toSearch = toSearch;
- this.data = data;
- this.caseType = caseType;
- this.findAllMatchLocations = findAllMatchLocations;
- this.expected = expected;
- this.matcher = new WordOrderMatcher();
- }
-
- @Test
- public void testWordOrderMatcher() throws UnsupportedEncodingException, OseeCoreException {
- InputStream inputStream = toStream(data);
- List<MatchLocation> actual = matcher.findInStream(inputStream, toSearch, caseType, findAllMatchLocations);
- SearchAsserts.assertEquals(expected, actual);
- }
-
- @Parameters
- public static Collection<Object[]> data() {
- List<Object[]> data = new ArrayList<Object[]>();
- addTest(data, "Why is this here again.", "THIS", CaseType.IGNORE_CASE, false, getLocs(8, 11));
- addTest(data, "Why is this here again.", "THIS", CaseType.MATCH_CASE, false, getLocs());
- addTest(data, "Why is this here this again.", "THIS", CaseType.IGNORE_CASE, false, getLocs(8, 11));
- addTest(data, "Why is this here this again.", "THIS", CaseType.IGNORE_CASE, true, getLocs(8, 11, 18, 21));
- addTest(data, "hello #@!@$$%'- again.", "hello again", CaseType.IGNORE_CASE, false, getLocs(1, 21));
- addTest(data, "hello word again.", "hello again", CaseType.IGNORE_CASE, false, getLocs());
- addTest(data, " (Selected) -> [.SELECTED_STRING_ID] Selected -> ", "SELECTED_STRING_ID",
- CaseType.IGNORE_CASE, false, getLocs(18, 35));
- addTest(data, " (Selected) -> [.SELECTED_STRING_ID] Selected -> ", "SELECTED_STRING_ID",
- CaseType.MATCH_CASE, false, getLocs(18, 35));
- addTest(data, " (Selected) -> [.SELECTED_STRING_IWRONG SELECTED_STRING_ID_TWO] Selected -> ",
- "SELECTED_STRING_ID", CaseType.MATCH_CASE, false, getLocs(41, 58));
- addTest(data, " (Selected) -> [.SELECTED_STRING_IWRONG SELECTED_STRING_ID_TWO] Selected -> ",
- "SELECTED_STRING_ID", CaseType.IGNORE_CASE, false, getLocs(41, 58));
- addTest(data, " (Selected) -> [.SELECTED_STRING_IWRONG SELECTED_STRING_\nID_TWO] Selected -> ",
- "SELECTED_STRING_ID", CaseType.IGNORE_CASE, false, getLocs(41, 59));
- return data;
- }
-
- private static void addTest(Collection<Object[]> testData, String data, String toSearch, CaseType caseType, boolean findAllMatchLocations, List<MatchLocation> expectedLocs) {
- testData.add(new Object[] {data, toSearch, caseType, findAllMatchLocations, expectedLocs});
- }
-
- private static List<MatchLocation> getLocs(int... data) {
- return SearchAsserts.asLocations(data);
- }
-
- private InputStream toStream(String value) throws UnsupportedEncodingException {
- return new ByteArrayInputStream(value.getBytes("utf-8"));
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryModuleFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryModuleFactory.java
index 6bb60bc12cd..9e738133094 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryModuleFactory.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryModuleFactory.java
@@ -53,10 +53,15 @@ import org.eclipse.osee.orcs.db.internal.search.indexer.QueryEngineIndexerImpl;
import org.eclipse.osee.orcs.db.internal.search.indexer.QueueToAttributeLoader;
import org.eclipse.osee.orcs.db.internal.search.indexer.data.QueueToAttributeLoaderImpl;
import org.eclipse.osee.orcs.db.internal.search.language.EnglishLanguage;
+import org.eclipse.osee.orcs.db.internal.search.tagger.DefaultAttributeTagger;
+import org.eclipse.osee.orcs.db.internal.search.tagger.StreamMatcher;
import org.eclipse.osee.orcs.db.internal.search.tagger.TagEncoder;
import org.eclipse.osee.orcs.db.internal.search.tagger.TagProcessor;
+import org.eclipse.osee.orcs.db.internal.search.tagger.Tagger;
import org.eclipse.osee.orcs.db.internal.search.tagger.TaggingEngine;
+import org.eclipse.osee.orcs.db.internal.search.tagger.XmlAttributeTagger;
import org.eclipse.osee.orcs.db.internal.search.util.DataPostProcessorFactoryImpl;
+import org.eclipse.osee.orcs.db.internal.search.util.MatcherFactory;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandler;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandlerFactory;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandlerFactoryImpl;
@@ -104,7 +109,13 @@ public class QueryModuleFactory {
protected TaggingEngine createTaggingEngine(AttributeTypeCache attributeTypeCache) {
TagProcessor tagProcessor = new TagProcessor(new EnglishLanguage(logger), new TagEncoder());
- return new TaggingEngine(tagProcessor, attributeTypeCache);
+ Map<String, Tagger> taggers = new HashMap<String, Tagger>();
+
+ StreamMatcher matcher = MatcherFactory.createMatcher();
+ taggers.put("DefaultAttributeTaggerProvider", new DefaultAttributeTagger(tagProcessor, matcher));
+ taggers.put("XmlAttributeTaggerProvider", new XmlAttributeTagger(tagProcessor, matcher));
+
+ return new TaggingEngine(taggers, tagProcessor, attributeTypeCache);
}
protected QueryEngineImpl createQueryEngine(IOseeDatabaseService dbService, SqlHandlerFactory handlerFactory, SqlProvider sqlProvider, BranchCache branchCache) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlWriter.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlWriter.java
index d1841eb77fb..bea56ebf552 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlWriter.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlWriter.java
@@ -40,7 +40,7 @@ public class QuerySqlWriter extends AbstractSqlWriter<QueryOptions> {
write("SELECT%s ", getSqlHint());
if (getOptions().isHistorical()) {
- write("max(%s.transaction_id), %s.art_id, %s.branch_id", txAlias, artAlias, txAlias);
+ write("max(%s.transaction_id) as transaction_id, %s.art_id, %s.branch_id", txAlias, artAlias, txAlias);
} else {
write("%s.art_id, %s.branch_id", artAlias, txAlias);
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeOtherSqlHandler.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeOtherSqlHandler.java
index 8f17d78dc44..1839db070fd 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeOtherSqlHandler.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeOtherSqlHandler.java
@@ -13,6 +13,7 @@ package org.eclipse.osee.orcs.db.internal.search.handlers;
import java.util.Collection;
import java.util.List;
import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.enums.Operator;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.database.core.AbstractJoinQuery;
import org.eclipse.osee.orcs.core.ds.QueryOptions;
@@ -20,7 +21,6 @@ import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeOther;
import org.eclipse.osee.orcs.db.internal.sql.AbstractSqlWriter;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandler;
import org.eclipse.osee.orcs.db.internal.sql.TableEnum;
-import org.eclipse.osee.orcs.search.Operator;
/**
* @author Roberto E. Escobar
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTokenSqlHandler.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTokenSqlHandler.java
index e13a9fa5256..4b9354da082 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTokenSqlHandler.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTokenSqlHandler.java
@@ -84,17 +84,15 @@ public class AttributeTokenSqlHandler extends SqlHandler<CriteriaAttributeKeywor
public void addTables(AbstractSqlWriter<QueryOptions> writer) throws OseeCoreException {
types = criteria.getTypes();
- if (criteria.getStringOp().isTokenized()) {
- codedTags = new ArrayList<Long>();
- tokenize(criteria.getValue(), codedTags);
+ codedTags = new ArrayList<Long>();
+ tokenize(criteria.getValue(), codedTags);
Conditions.checkExpressionFailOnTrue(codedTags.size() > MAX_TOKEN_SIZE,
"Parsed tokens for [%s] is greater than [%d]", criteria.getValue(), MAX_TOKEN_SIZE);
- tagAliases = new ArrayList<String>();
- for (int index = 0; index < codedTags.size(); index++) {
- tagAliases.add(writer.addTable(TableEnum.SEARCH_TAGS_TABLE));
- }
+ tagAliases = new ArrayList<String>();
+ for (int index = 0; index < codedTags.size(); index++) {
+ tagAliases.add(writer.addTable(TableEnum.SEARCH_TAGS_TABLE));
}
attrAlias = writer.addTable(TableEnum.ATTRIBUTE_TABLE);
if (types.size() > 1) {
@@ -141,47 +139,35 @@ public class AttributeTokenSqlHandler extends SqlHandler<CriteriaAttributeKeywor
DataPostProcessor<?> processor = getDataPostProcessorFactory().createPostProcessor(criteria, writer.getOptions());
writer.addPostProcessor(processor);
- if (criteria.getStringOp().isTokenized()) {
writer.writeAndLn();
- int size = tagAliases.size();
- for (int index = 0; index < size; index++) {
- String tagAlias = tagAliases.get(index);
- Long tag = codedTags.get(index);
+ int size = tagAliases.size();
+ for (int index = 0; index < size; index++) {
+ String tagAlias = tagAliases.get(index);
+ Long tag = codedTags.get(index);
- writer.write(tagAlias);
- writer.write(".coded_tag_id = ?");
- writer.addParameter(tag);
+ writer.write(tagAlias);
+ writer.write(".coded_tag_id = ?");
+ writer.addParameter(tag);
- if (index + 1 < size) {
- writer.write(" AND ");
- }
+ if (index + 1 < size) {
+ writer.write(" AND ");
}
- if (size > 1) {
+ }
+ if (size > 1) {
writer.writeAndLn();
- for (int index = 1; index < size; index++) {
- String tagAlias1 = tagAliases.get(index - 1);
- String tagAlias2 = tagAliases.get(index);
-
- writer.write(tagAlias1);
- writer.write(".gamma_id = ");
- writer.write(tagAlias2);
- writer.write(".gamma_id");
- if (index + 1 < size) {
- writer.write(" AND ");
- }
+ for (int index = 1; index < size; index++) {
+ String tagAlias1 = tagAliases.get(index - 1);
+ String tagAlias2 = tagAliases.get(index);
+
+ writer.write(tagAlias1);
+ writer.write(".gamma_id = ");
+ writer.write(tagAlias2);
+ writer.write(".gamma_id");
+ if (index + 1 < size) {
+ writer.write(" AND ");
}
}
- } else {
- // case CONTAINS:
- // case NOT_EQUALS:
- // case EQUALS:
- //
- //
- //
- // CaseType caseType = criteria.getMatch();
- // caseType.isCaseSensitive();
- throw new UnsupportedOperationException();
}
List<String> aliases = writer.getAliases(TableEnum.ARTIFACT_TABLE);
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/BaseAttributeTagger.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/BaseAttributeTagger.java
index 84360328861..0e20e893041 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/BaseAttributeTagger.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/BaseAttributeTagger.java
@@ -16,17 +16,16 @@ import java.io.UnsupportedEncodingException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.db.internal.search.util.WordOrderMatcher;
/**
* @author Roberto E. Escobar
*/
public abstract class BaseAttributeTagger implements Tagger {
- private final WordOrderMatcher matcher;
+ private final StreamMatcher matcher;
private final TagProcessor tagProcessor;
- protected BaseAttributeTagger(TagProcessor tagProcessor, WordOrderMatcher matcher) {
+ protected BaseAttributeTagger(TagProcessor tagProcessor, StreamMatcher matcher) {
super();
this.tagProcessor = tagProcessor;
this.matcher = matcher;
@@ -36,7 +35,7 @@ public abstract class BaseAttributeTagger implements Tagger {
return tagProcessor;
}
- protected WordOrderMatcher getMatcher() {
+ protected StreamMatcher getMatcher() {
return matcher;
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/DefaultAttributeTagger.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/DefaultAttributeTagger.java
index fa7f33f1817..b832ba2f07a 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/DefaultAttributeTagger.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/DefaultAttributeTagger.java
@@ -13,20 +13,19 @@ package org.eclipse.osee.orcs.db.internal.search.tagger;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
+import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.db.internal.search.util.WordOrderMatcher;
-import org.eclipse.osee.orcs.search.CaseType;
/**
* @author Roberto E. Escobar
*/
public class DefaultAttributeTagger extends BaseAttributeTagger {
- public DefaultAttributeTagger(TagProcessor tagProcessor, WordOrderMatcher matcher) {
+ public DefaultAttributeTagger(TagProcessor tagProcessor, StreamMatcher matcher) {
super(tagProcessor, matcher);
}
@@ -42,13 +41,13 @@ public class DefaultAttributeTagger extends BaseAttributeTagger {
}
@Override
- public List<MatchLocation> find(AttributeReadable<?> attribute, String toSearch, CaseType caseType, boolean matchAllLocations) throws OseeCoreException {
+ public List<MatchLocation> find(AttributeReadable<?> attribute, String toSearch, boolean matchAllLocations, QueryOption... options) throws OseeCoreException {
List<MatchLocation> toReturn;
if (Strings.isValid(toSearch)) {
InputStream inputStream = null;
try {
inputStream = getValueAsStream(attribute);
- toReturn = getMatcher().findInStream(inputStream, toSearch, caseType, matchAllLocations);
+ toReturn = getMatcher().findInStream(inputStream, toSearch, matchAllLocations, options);
} finally {
Lib.close(inputStream);
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/StreamMatcher.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/StreamMatcher.java
new file mode 100644
index 00000000000..da6e78e9188
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/StreamMatcher.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.db.internal.search.tagger;
+
+import java.io.InputStream;
+import java.util.List;
+import org.eclipse.osee.framework.core.enums.QueryOption;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface StreamMatcher {
+
+ List<MatchLocation> findInStream(InputStream inputStream, String toSearch, boolean findAllMatchLocations, QueryOption... options);
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/Tagger.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/Tagger.java
index 98c5e16ca10..3afa92bd8b4 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/Tagger.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/Tagger.java
@@ -11,10 +11,10 @@
package org.eclipse.osee.orcs.db.internal.search.tagger;
import java.util.List;
+import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.search.CaseType;
/**
* @author Roberto E. Escobar
@@ -23,6 +23,6 @@ public interface Tagger {
void tagIt(AttributeReadable<?> attribute, TagCollector collector) throws OseeCoreException;
- List<MatchLocation> find(AttributeReadable<?> attribute, String toSearch, CaseType caseType, boolean matchAllLocations) throws OseeCoreException;
+ List<MatchLocation> find(AttributeReadable<?> attribute, String toSearch, boolean matchAllLocations, QueryOption... options) throws OseeCoreException;
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TaggingEngine.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TaggingEngine.java
index c579721e835..bbb2b80dc58 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TaggingEngine.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TaggingEngine.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.search.tagger;
-import java.util.HashMap;
import java.util.Map;
import org.eclipse.osee.framework.core.data.Identity;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
@@ -19,22 +18,20 @@ import org.eclipse.osee.framework.core.model.type.AttributeType;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.orcs.db.internal.search.util.WordOrderMatcher;
/**
* @author Roberto E. Escobar
*/
public class TaggingEngine {
- private final Map<String, Tagger> taggers = new HashMap<String, Tagger>();
+ private final Map<String, Tagger> taggers;
private final AttributeTypeCache attributeTypeCache;
private final TagProcessor tagProcessor;
- public TaggingEngine(TagProcessor tagProcessor, AttributeTypeCache attributeTypeCache) {
+ public TaggingEngine(Map<String, Tagger> taggers, TagProcessor tagProcessor, AttributeTypeCache attributeTypeCache) {
+ this.taggers = taggers;
this.tagProcessor = tagProcessor;
this.attributeTypeCache = attributeTypeCache;
- taggers.put("DefaultAttributeTaggerProvider", new DefaultAttributeTagger(tagProcessor, new WordOrderMatcher()));
- taggers.put("XmlAttributeTaggerProvider", new XmlAttributeTagger(tagProcessor, new WordOrderMatcher()));
}
public TagProcessor getTagProcessor() {
@@ -78,13 +75,4 @@ public class TaggingEngine {
return tagger;
}
- // public void tagIt(ReadableAttribute<?> attribute, TagCollector collector) throws OseeCoreException {
- // Tagger tagger = getTagger(attribute.getAttributeType());
- // tagger.tagIt(attribute, collector);
- // }
- //
- // public List<MatchLocation> find(ReadableAttribute<?> attribute, String toSearch, CaseType caseType, boolean matchAllLocations) throws OseeCoreException {
- // Tagger tagger = getTagger(attribute.getAttributeType());
- // return tagger.find(attribute, toSearch, caseType, matchAllLocations);
- // }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlAttributeTagger.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlAttributeTagger.java
index 705d4cad334..b9aeadf2979 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlAttributeTagger.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlAttributeTagger.java
@@ -13,21 +13,20 @@ package org.eclipse.osee.orcs.db.internal.search.tagger;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
+import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.jdk.core.util.io.xml.XmlTextInputStream;
import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.db.internal.search.util.WordOrderMatcher;
-import org.eclipse.osee.orcs.search.CaseType;
/**
* @author Roberto E. Escobar
*/
public class XmlAttributeTagger extends BaseAttributeTagger {
- public XmlAttributeTagger(TagProcessor tagProcessor, WordOrderMatcher matcher) {
+ public XmlAttributeTagger(TagProcessor tagProcessor, StreamMatcher matcher) {
super(tagProcessor, matcher);
}
@@ -43,13 +42,13 @@ public class XmlAttributeTagger extends BaseAttributeTagger {
}
@Override
- public List<MatchLocation> find(AttributeReadable<?> attribute, String toSearch, CaseType caseType, boolean matchAllLocations) throws OseeCoreException {
+ public List<MatchLocation> find(AttributeReadable<?> attribute, String toSearch, boolean matchAllLocations, QueryOption... options) throws OseeCoreException {
List<MatchLocation> toReturn;
if (Strings.isValid(toSearch)) {
InputStream inputStream = null;
try {
inputStream = new XmlTextInputStream(getValueAsStream(attribute));
- toReturn = getMatcher().findInStream(inputStream, toSearch, caseType, matchAllLocations);
+ toReturn = getMatcher().findInStream(inputStream, toSearch, matchAllLocations, options);
} finally {
Lib.close(inputStream);
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AbstractQueryPostProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AbstractQueryPostProcessor.java
index d0460e14fdd..51d98ce6b32 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AbstractQueryPostProcessor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AbstractQueryPostProcessor.java
@@ -33,7 +33,6 @@ import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeyword;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
import org.eclipse.osee.orcs.db.internal.search.tagger.Tagger;
-import org.eclipse.osee.orcs.search.CaseType;
import org.eclipse.osee.orcs.search.Match;
/**
@@ -53,10 +52,6 @@ public abstract class AbstractQueryPostProcessor extends QueryPostProcessor impl
this.options = options;
}
- protected CaseType getCaseType() {
- return criteria.getMatch();
- }
-
protected Collection<? extends IAttributeType> getTypes() {
return criteria.getTypes();
}
@@ -128,7 +123,7 @@ public abstract class AbstractQueryPostProcessor extends QueryPostProcessor impl
Tagger tagger = getTagger(attribute);
if (tagger != null) {
checkForCancelled();
- List<MatchLocation> locations = tagger.find(attribute, getQuery(), getCaseType(), true);
+ List<MatchLocation> locations = tagger.find(attribute, getQuery(), true, criteria.getOptions());
if (!locations.isEmpty()) {
if (matchedAttributes == null) {
matchedAttributes = new HashMap<AttributeReadable<?>, List<MatchLocation>>();
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AnyTokenOrderProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AnyTokenOrderProcessor.java
new file mode 100644
index 00000000000..0192b894bf8
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AnyTokenOrderProcessor.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.db.internal.search.util;
+
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.MatchResult;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
+import org.eclipse.osee.framework.jdk.core.type.MutableInteger;
+
+/**
+ * @author John Misinco
+ */
+public class AnyTokenOrderProcessor implements TokenOrderProcessor {
+
+ private final TrackingMap trackingSet;
+ private final List<MatchLocation> locations;
+ private int numTokensToMatch = 0;
+
+ public AnyTokenOrderProcessor() {
+ locations = new LinkedList<MatchLocation>();
+ trackingSet = new TrackingMap();
+ }
+
+ @Override
+ public int getTotalTokensToMatch() {
+ return numTokensToMatch;
+ }
+
+ @Override
+ public void acceptTokenToMatch(String token) {
+ trackingSet.add(token);
+ numTokensToMatch++;
+ }
+
+ @Override
+ public boolean processToken(String token, MatchResult match) {
+ if (trackingSet.found(token)) {
+ locations.add(createMatchLocation(match.start(), match.end()));
+ if (trackingSet.areAllFound()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public List<MatchLocation> getLocations() {
+ return locations;
+ }
+
+ @Override
+ public void clearAllLocations() {
+ locations.clear();
+ }
+
+ private MatchLocation createMatchLocation(int start, int end) {
+ return new MatchLocation(start + 1, end);
+ }
+
+ private static final class TrackingMap {
+
+ private final Map<String, MutableInteger> map = new LinkedHashMap<String, MutableInteger>();
+ private int total = 0;
+
+ public void add(String value) {
+ MutableInteger stored = map.get(value);
+ if (stored == null) {
+ map.put(value, new MutableInteger(1));
+ } else {
+ stored.getValueAndInc();
+ }
+ total++;
+ }
+
+ public boolean found(String value) {
+ MutableInteger stored = map.get(value);
+ if (stored != null) {
+ stored.getValueAndInc(-1);
+ if (stored.getValue() > -1) {
+ total--;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public boolean areAllFound() {
+ return total == 0;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/CheckedOptions.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/CheckedOptions.java
new file mode 100644
index 00000000000..610755920f0
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/CheckedOptions.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.db.internal.search.util;
+
+import java.util.regex.Pattern;
+import org.eclipse.osee.framework.core.enums.CaseType;
+import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
+import org.eclipse.osee.framework.core.enums.OptionVisitor;
+import org.eclipse.osee.framework.core.enums.QueryOption;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
+import org.eclipse.osee.framework.core.enums.TokenOrderType;
+
+/**
+ * @author John Misinco
+ */
+public class CheckedOptions implements OptionVisitor {
+
+ private TokenOrderType orderType;
+ private CaseType caseType;
+ private MatchTokenCountType countType;
+ private TokenDelimiterMatch delimiter;
+
+ public CheckedOptions() {
+ initialize();
+ }
+
+ private void initialize() {
+ orderType = TokenOrderType.ANY_ORDER;
+ caseType = CaseType.IGNORE_CASE;
+ countType = MatchTokenCountType.IGNORE_TOKEN_COUNT;
+ delimiter = TokenDelimiterMatch.ANY;
+ }
+
+ public TokenOrderType getOrderType() {
+ return orderType;
+ }
+
+ public CaseType getCaseType() {
+ return caseType;
+ }
+
+ public MatchTokenCountType getCountType() {
+ return countType;
+ }
+
+ public Pattern getDelimiter() {
+ return delimiter.getPattern();
+ }
+
+ public void accept(QueryOption... options) {
+ initialize();
+ for (QueryOption option : options) {
+ option.accept(this);
+ }
+ }
+
+ @Override
+ public void asCaseType(CaseType option) {
+ caseType = option;
+ }
+
+ @Override
+ public void asTokenOrderType(TokenOrderType option) {
+ orderType = option;
+ }
+
+ @Override
+ public void asMatchTokenCountType(MatchTokenCountType option) {
+ countType = option;
+ }
+
+ @Override
+ public void asTokenDelimiterMatch(TokenDelimiterMatch delimiter) {
+ this.delimiter = delimiter;
+ }
+}; \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/DataPostProcessorFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/DataPostProcessorFactoryImpl.java
index 6ea584c1cd4..3ad163bb0c5 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/DataPostProcessorFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/DataPostProcessorFactoryImpl.java
@@ -37,11 +37,11 @@ public class DataPostProcessorFactoryImpl implements DataPostProcessorFactory<Cr
@Override
public DataPostProcessor<?> createPostProcessor(CriteriaAttributeKeyword criteria, QueryOptions options) {
DataPostProcessor<?> processor;
- if (criteria.getStringOp().isTokenized()) {
- processor = new TokenQueryPostProcessor(logger, executorAdmin, taggingEngine, criteria, options);
- } else {
- processor = new AttributeQueryPostProcessor(logger, executorAdmin, taggingEngine, criteria, options);
- }
+ // if (criteria.getStringOp().isTokenized()) {
+ processor = new TokenQueryPostProcessor(logger, executorAdmin, taggingEngine, criteria, options);
+ // } else {
+ // processor = new AttributeQueryPostProcessor(logger, executorAdmin, taggingEngine, criteria, options);
+ // }
return processor;
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/MatchTokenOrderProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/MatchTokenOrderProcessor.java
new file mode 100644
index 00000000000..85f287646c7
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/MatchTokenOrderProcessor.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.db.internal.search.util;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.regex.MatchResult;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
+
+/**
+ * @author John Misinco
+ */
+public class MatchTokenOrderProcessor implements TokenOrderProcessor {
+
+ private final List<MatchLocation> locations;
+ private final List<String> tokensToSearch;
+ private int matchIdx = 0;
+ private int matchStart = -1;
+ private int numTokensToMatch = 0;
+
+ public MatchTokenOrderProcessor() {
+ super();
+ locations = new LinkedList<MatchLocation>();
+ tokensToSearch = new ArrayList<String>();
+ }
+
+ @Override
+ public int getTotalTokensToMatch() {
+ return numTokensToMatch;
+ }
+
+ @Override
+ public void acceptTokenToMatch(String token) {
+ tokensToSearch.add(token);
+ numTokensToMatch++;
+ }
+
+ @Override
+ public boolean processToken(String token, MatchResult match) {
+ if (!tokensToSearch.get(matchIdx).equals(token)) {
+ matchIdx = 0;
+ }
+
+ if (tokensToSearch.get(matchIdx).equals(token)) {
+ if (matchIdx == 0) {
+ matchStart = match.start();
+ }
+ matchIdx++;
+ if (matchIdx == numTokensToMatch) {
+ locations.add(createMatchLocation(matchStart, match.end()));
+ matchIdx = 0;
+ }
+ }
+
+ return !locations.isEmpty();
+ }
+
+ private MatchLocation createMatchLocation(int start, int end) {
+ return new MatchLocation(start + 1, end);
+ }
+
+ @Override
+ public List<MatchLocation> getLocations() {
+ return locations;
+ }
+
+ @Override
+ public void clearAllLocations() {
+ locations.clear();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/MatcherFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/MatcherFactory.java
new file mode 100644
index 00000000000..ea826a5973a
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/MatcherFactory.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.db.internal.search.util;
+
+import org.eclipse.osee.orcs.db.internal.search.tagger.StreamMatcher;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class MatcherFactory {
+
+ private MatcherFactory() {
+ // Static factory
+ }
+
+ public static StreamMatcher createMatcher() {
+ return new SecondPassMatcher(new TokenOrderProcessorFactoryImpl());
+ }
+
+ private static final class TokenOrderProcessorFactoryImpl implements TokenOrderProcessorFactory {
+ @Override
+ public TokenOrderProcessor createTokenProcessor(CheckedOptions options) {
+ return options.getOrderType().isMatchOrder() ? new MatchTokenOrderProcessor() : new AnyTokenOrderProcessor();
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcher.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcher.java
new file mode 100644
index 00000000000..3077a8c072c
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcher.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.db.internal.search.util;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Scanner;
+import java.util.regex.MatchResult;
+import org.eclipse.osee.framework.core.enums.CaseType;
+import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
+import org.eclipse.osee.framework.core.enums.QueryOption;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
+import org.eclipse.osee.orcs.db.internal.search.tagger.StreamMatcher;
+
+/**
+ * @author John Misinco
+ */
+public class SecondPassMatcher implements StreamMatcher {
+
+ private final TokenOrderProcessorFactory processorFactory;
+
+ public SecondPassMatcher(TokenOrderProcessorFactory processorFactory) {
+ this.processorFactory = processorFactory;
+ }
+
+ private String normalizeCase(CaseType caseType, String token) {
+ return caseType.isCaseSensitive() ? token : token.toLowerCase();
+ }
+
+ @Override
+ public List<MatchLocation> findInStream(InputStream inputStream, String toSearch, boolean findAllMatchLocations, QueryOption... options) {
+ CheckedOptions checkedOptions = new CheckedOptions();
+ checkedOptions.accept(options);
+
+ TokenOrderProcessor processor = processorFactory.createTokenProcessor(checkedOptions);
+
+ parseSearchString(processor, toSearch, checkedOptions);
+ searchStream(processor, inputStream, checkedOptions, findAllMatchLocations);
+
+ return processor.getLocations();
+ }
+
+ private void parseSearchString(TokenOrderProcessor processor, String toSearch, CheckedOptions options) {
+ Scanner toSearchScanner = new Scanner(toSearch);
+ try {
+ toSearchScanner.useDelimiter(options.getDelimiter());
+ while (toSearchScanner.hasNext()) {
+ String next = toSearchScanner.next();
+ next = normalizeCase(options.getCaseType(), next);
+ processor.acceptTokenToMatch(next);
+ }
+ } finally {
+ toSearchScanner.close();
+ }
+ }
+
+ private void searchStream(TokenOrderProcessor processor, InputStream inputStream, CheckedOptions options, boolean findAllMatchLocations) {
+ Scanner inputStreamScanner = new Scanner(inputStream);
+ try {
+ inputStreamScanner.useDelimiter(options.getDelimiter());
+ int numTokensProcessed = 0;
+ boolean isProcessorDone = false;
+ while (inputStreamScanner.hasNext()) {
+ ++numTokensProcessed;
+
+ if (numTokensProcessed > processor.getTotalTokensToMatch() && MatchTokenCountType.MATCH_TOKEN_COUNT == options.getCountType()) {
+ processor.getLocations().clear();
+ break;
+ }
+
+ /**
+ * the purpose of this here is to allow one more token to be read after the processor has signaled that it
+ * is complete. the if statement above will catch the case when too many tokens are present.
+ */
+ if (isProcessorDone && !findAllMatchLocations) {
+ break;
+ }
+
+ String next = inputStreamScanner.next();
+ next = normalizeCase(options.getCaseType(), next);
+
+ MatchResult match = inputStreamScanner.match();
+ isProcessorDone = processor.processToken(next, match);
+ }
+
+ // Clear if search did not complete
+ if (!isProcessorDone) {
+ processor.clearAllLocations();
+ }
+ } finally {
+ inputStreamScanner.close();
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenOrderProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenOrderProcessor.java
new file mode 100644
index 00000000000..13266562bc3
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenOrderProcessor.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.db.internal.search.util;
+
+import java.util.List;
+import java.util.regex.MatchResult;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
+
+/**
+ * @author John Misinco
+ */
+public interface TokenOrderProcessor {
+
+ int getTotalTokensToMatch();
+
+ void acceptTokenToMatch(String token);
+
+ /**
+ * Returns true when all match criteria have been met
+ */
+ boolean processToken(String token, MatchResult match);
+
+ List<MatchLocation> getLocations();
+
+ void clearAllLocations();
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenOrderProcessorFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenOrderProcessorFactory.java
new file mode 100644
index 00000000000..4e53e6c3b95
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenOrderProcessorFactory.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.db.internal.search.util;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface TokenOrderProcessorFactory {
+
+ TokenOrderProcessor createTokenProcessor(CheckedOptions options);
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcher.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcher.java
deleted file mode 100644
index d8c372298dc..00000000000
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcher.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.search.util;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
-import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.orcs.search.CaseType;
-
-/**
- * @author Roberto E. Escobar
- */
-public final class WordOrderMatcher {
-
- public WordOrderMatcher() {
- // Utility Class
- }
-
- public List<MatchLocation> findInStream(InputStream inputStream, String toSearch, CaseType caseType, boolean findAllMatchLocations) throws OseeCoreException {
- List<MatchLocation> matchLocations = new ArrayList<MatchLocation>();
- Reader reader = null;
- try {
- boolean matchedAWhitespace = false;
- int savedCharCount = 0;
- reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
- boolean isCaseInsensitive = !caseType.isCaseSensitive();
- char[] charsToSearch = WordsUtil.removeExtraSpacesAndSpecialCharacters(toSearch, isCaseInsensitive);
- int charCount = 0;
- int index = 0;
- int value = 0;
- boolean lastCharacterAddedWasWhiteSpace = false;
- boolean currCharValid = false;
- MatchLocation matchLocation = new MatchLocation();
- reader.mark(charsToSearch.length);
- while (value != -1) {
- value = reader.read();
- charCount++;
- char currChar = (char) value;
- if (isCaseInsensitive) {
- currChar = Character.toLowerCase(currChar);
- }
-
- if (WordsUtil.isPunctuationOrApostrophe(currChar)) {
- currChar = ' ';
- }
-
- if (Character.isWhitespace(currChar)) {
- reader.mark(toSearch.length());
- savedCharCount = charCount;
- if (!lastCharacterAddedWasWhiteSpace) {
- currCharValid = true;
- lastCharacterAddedWasWhiteSpace = true;
- } else {
- currCharValid = false;
- }
- } else {
- currCharValid = true;
- lastCharacterAddedWasWhiteSpace = false;
- }
-
- if (currCharValid) {
- if (charsToSearch[index] != currChar) {
- matchLocation.reset();
- if (matchedAWhitespace) {
- reader.reset();
- charCount = savedCharCount;
- }
- index = 0;
- matchedAWhitespace = false;
- }
-
- if (charsToSearch[index] == currChar) {
- if (currChar == ' ' && index > 0) {
- matchedAWhitespace = true;
- }
- if (index == 0) {
- matchLocation.setStartPosition(charCount);
- }
-
- if (index + 1 < charsToSearch.length) {
- index++;
- } else {
- matchLocation.setEndPosition(charCount);
- matchLocations.add(matchLocation.clone());
- index = 0;
- if (!findAllMatchLocations) {
- break;
- }
- }
- }
- }
- }
- } catch (UnsupportedEncodingException ex) {
- OseeExceptions.wrapAndThrow(ex);
- } catch (IOException ex) {
- OseeExceptions.wrapAndThrow(ex);
- } finally {
- Lib.close(reader);
- }
- return matchLocations;
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.parent/pom.xml b/plugins/org.eclipse.osee.orcs.parent/pom.xml
index 61ea0776607..9b70b261dd0 100644
--- a/plugins/org.eclipse.osee.orcs.parent/pom.xml
+++ b/plugins/org.eclipse.osee.orcs.parent/pom.xml
@@ -37,6 +37,7 @@
<module>../../plugins/org.eclipse.osee.orcs.core.test</module>
<module>../../plugins/org.eclipse.osee.orcs.db</module>
<module>../../plugins/org.eclipse.osee.orcs.db.mock</module>
+ <module>../../plugins/org.eclipse.osee.orcs.rest.model</module>
<module>../../plugins/org.eclipse.osee.orcs.rest</module>
<module>../../plugins/org.eclipse.osee.orcs.rest.test</module>
<module>../../plugins/org.eclipse.osee.framework.h2</module>
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/.classpath b/plugins/org.eclipse.osee.orcs.rest.client/.classpath
new file mode 100644
index 00000000000..ad32c83a788
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/.project b/plugins/org.eclipse.osee.orcs.rest.client/.project
new file mode 100644
index 00000000000..ebca3f3cb12
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.orcs.rest.client</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.rest.client/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..0c3d4b8aaf1
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/META-INF/MANIFEST.MF
@@ -0,0 +1,25 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE ORCS Rest Client (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.orcs.rest.client
+Bundle-Version: 0.11.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Service-Component: OSGI-INF/*.xml
+Import-Package: javax.ws.rs,
+ javax.ws.rs.core,
+ org.apache.commons.lang.time,
+ org.eclipse.core.net.proxy,
+ org.eclipse.osee.framework.core.data,
+ org.eclipse.osee.framework.core.enums,
+ org.eclipse.osee.framework.core.exception,
+ org.eclipse.osee.framework.core.services,
+ org.eclipse.osee.framework.jdk.core.type,
+ org.eclipse.osee.framework.jdk.core.util
+Export-Package: org.eclipse.osee.orcs.rest.client
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.osee.orcs.rest.model,
+ com.sun.jersey,
+ com.sun.jersey.client.apache,
+ javax.servlet
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/OSGI-INF/osee.client.xml b/plugins/org.eclipse.osee.orcs.rest.client/OSGI-INF/osee.client.xml
new file mode 100644
index 00000000000..6e36ac2a963
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/OSGI-INF/osee.client.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" name="org.eclipse.osee.orcs.rest.client.internal.OseeClientImpl">
+ <implementation class="org.eclipse.osee.orcs.rest.client.internal.OseeClientImpl"/>
+ <service>
+ <provide interface="org.eclipse.osee.orcs.rest.client.OseeClient"/>
+ </service>
+ <reference bind="setWebClientProvider" cardinality="1..1" interface="org.eclipse.osee.orcs.rest.client.internal.WebClientProvider" name="WebClientProvider" policy="static"/>
+ <reference bind="setUriProvider" cardinality="1..1" interface="org.eclipse.osee.framework.core.services.URIProvider" name="URIProvider" policy="static"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/OSGI-INF/web.client.provider.xml b/plugins/org.eclipse.osee.orcs.rest.client/OSGI-INF/web.client.provider.xml
new file mode 100644
index 00000000000..80e11e746cf
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/OSGI-INF/web.client.provider.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" name="org.eclipse.osee.orcs.rest.client.internal.WebClientProviderImpl">
+ <implementation class="org.eclipse.osee.orcs.rest.client.internal.WebClientProviderImpl"/>
+ <service>
+ <provide interface="org.eclipse.osee.orcs.rest.client.internal.WebClientProvider"/>
+ </service>
+ <reference bind="setProxyService" cardinality="1..1" interface="org.eclipse.core.net.proxy.IProxyService" name="IProxyService" policy="static"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/build.properties b/plugins/org.eclipse.osee.orcs.rest.client/build.properties
new file mode 100644
index 00000000000..5fc7ab483ae
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/build.properties
@@ -0,0 +1,10 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/
+additional.bundles = org.eclipse.osee.framework.core,\
+ org.eclipse.osee.framework.jdk.core,\
+ org.eclipse.osee.framework.core.model,\
+ org.apache.commons.lang,\
+ javax.ws.rs
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/pom.xml b/plugins/org.eclipse.osee.orcs.rest.client/pom.xml
new file mode 100644
index 00000000000..f0c1bfeb29d
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/pom.xml
@@ -0,0 +1,35 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.osee</groupId>
+ <artifactId>org.eclipse.osee.client.parent</artifactId>
+ <version>0.11.0-SNAPSHOT</version>
+ <relativePath>../../plugins/org.eclipse.osee.client.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.osee.orcs.rest.client</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>OSEE ORCS REST Client (Incubation)</name>
+
+ <build>
+ <!-- workaround for https://issues.sonatype.org/browse/TYCHO-168 -->
+ <resources>
+ <resource>
+ <directory>src</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-source-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java
new file mode 100644
index 00000000000..e1e47b13ddb
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.client;
+
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+
+/**
+ * @author John Misinco
+ */
+public interface OseeClient {
+
+ QueryBuilder createQueryBuilder(IOseeBranch branch);
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/QueryBuilder.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/QueryBuilder.java
new file mode 100644
index 00000000000..6fd98f33bdb
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/QueryBuilder.java
@@ -0,0 +1,196 @@
+package org.eclipse.osee.orcs.rest.client;
+
+import java.util.Collection;
+import org.eclipse.osee.framework.core.data.IArtifactToken;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.data.IRelationTypeSide;
+import org.eclipse.osee.framework.core.data.ResultSet;
+import org.eclipse.osee.framework.core.data.TokenFactory;
+import org.eclipse.osee.framework.core.enums.Operator;
+import org.eclipse.osee.framework.core.enums.QueryOption;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
+/**
+ * @author Ryan D. Brooks
+ * @author Roberto E. Escobar
+ */
+public interface QueryBuilder {
+
+ public static IAttributeType ANY_ATTRIBUTE_TYPE = TokenFactory.createAttributeType(Long.MIN_VALUE,
+ "Any Attribute Type");
+
+ QueryBuilder includeCache();
+
+ QueryBuilder includeCache(boolean enabled);
+
+ boolean isCacheIncluded();
+
+ QueryBuilder includeDeleted();
+
+ QueryBuilder includeDeleted(boolean enabled);
+
+ boolean areDeletedIncluded();
+
+ QueryBuilder includeTypeInheritance();
+
+ QueryBuilder includeTypeInheritance(boolean enabled);
+
+ boolean isTypeInheritanceIncluded();
+
+ QueryBuilder fromTransaction(int transactionId);
+
+ int getFromTransaction();
+
+ QueryBuilder headTransaction();
+
+ boolean isHeadTransaction();
+
+ QueryBuilder excludeCache();
+
+ QueryBuilder excludeDeleted();
+
+ QueryBuilder excludeTypeInheritance();
+
+ /**
+ * Resets query builder to default settings. This also clear all criteria added to original query.
+ */
+ QueryBuilder resetToDefaults();
+
+ /**
+ * Search criteria that finds a given artifact id
+ */
+ QueryBuilder andLocalId(int... artifactId) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds a given artifact ids
+ */
+ QueryBuilder andLocalIds(Collection<Integer> artifactIds) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds a given artifact with guids or hrids
+ */
+ QueryBuilder andGuidsOrHrids(String... ids) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds a given artifact with guids or hrids
+ */
+ QueryBuilder andGuidsOrHrids(Collection<String> ids) throws OseeCoreException;
+
+ /**
+ * Artifacts matching token id(s)
+ */
+ QueryBuilder andIds(IArtifactToken... artifactToken) throws OseeCoreException;
+
+ /**
+ * Artifacts matching token id(s)
+ */
+ QueryBuilder andIds(Collection<? extends IArtifactToken> artifactTokens) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds a given artifact type
+ */
+ QueryBuilder andIsOfType(IArtifactType... artifactType) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds a given artifact types
+ */
+ QueryBuilder andIsOfType(Collection<? extends IArtifactType> artifactType) throws OseeCoreException;
+
+ /**
+ * Search criteria that checks for the existence of an attribute type(s).
+ */
+ QueryBuilder andExists(IAttributeType... attributeType) throws OseeCoreException;
+
+ /**
+ * Search criteria that checks for the existence of an attribute types.
+ */
+ QueryBuilder andExists(Collection<? extends IAttributeType> attributeTypes) throws OseeCoreException;
+
+ /**
+ * Search criteria that follows the relation link ending on the given side
+ *
+ * @param relationType the type to start following the link from
+ */
+ QueryBuilder andExists(IRelationType relationType) throws OseeCoreException;
+
+ /**
+ * Artifact name equals value
+ */
+ QueryBuilder andNameEquals(String artifactName) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds an attribute of the given type with its current value relative to the given value based
+ * on the operator provided.
+ */
+ QueryBuilder and(IAttributeType attributeType, Operator operator, String value) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds an attribute of the given type with its current value exactly equal (or not equal) to
+ * any one of the given literal values. If the list only contains one value, then the search is conducted exactly as
+ * if the single value constructor was called. This search does not support the (* wildcard) for multiple values.
+ */
+ QueryBuilder and(IAttributeType attributeType, Operator operator, Collection<String> values) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds an attribute of the given type with its current value relative to the given value based
+ * on the operator provided.
+ */
+ QueryBuilder and(IAttributeType attributeType, String value, QueryOption... options) throws OseeCoreException;
+
+ /**
+ * Search criteria that finds an attribute of the given type with its current value exactly equal (or not equal) to
+ * any one of the given literal values. If the list only contains one value, then the search is conducted exactly as
+ * if the single value constructor was called. This search does not support the (* wildcard) for multiple values.
+ */
+ QueryBuilder and(Collection<? extends IAttributeType> attributeTypes, String value, QueryOption... options) throws OseeCoreException;
+
+ /**
+ * Search for related artifacts
+ *
+ * @param relationTypeSide the type-side to search on
+ */
+ QueryBuilder andRelatedTo(IRelationTypeSide relationTypeSide, IArtifactToken... artifacts) throws OseeCoreException;
+
+ /**
+ * Search for related artifacts
+ *
+ * @param relationTypeSide the type-side to search on
+ */
+ QueryBuilder andRelatedTo(IRelationTypeSide relationTypeSide, Collection<? extends IArtifactToken> artifacts) throws OseeCoreException;
+
+ /**
+ * Search for related artifacts
+ *
+ * @param relationTypeSide the type-side to search on
+ */
+ QueryBuilder andRelatedToLocalIds(IRelationTypeSide relationTypeSide, int... artifactIds) throws OseeCoreException;
+
+ /**
+ * Search for related artifacts
+ *
+ * @param relationTypeSide the type-side to search on
+ */
+ QueryBuilder andRelatedToLocalIds(IRelationTypeSide relationTypeSide, Collection<Integer> artifactIds) throws OseeCoreException;
+
+ /**
+ * Executes query
+ *
+ * @return artifact search results
+ */
+ public ResultSet<Integer> getResults() throws OseeCoreException;
+
+ /**
+ * Executes query
+ *
+ * @return artifact search results with match locations
+ */
+ // public ResultSet<Match<Artifact, Attribute<?>>> getMatches() throws OseeCoreException;
+
+ /**
+ * Count search results
+ */
+ public int getCount() throws OseeCoreException;
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/Options.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/Options.java
new file mode 100644
index 00000000000..7f69402d6db
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/Options.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.client.internal;
+
+import org.eclipse.osee.framework.core.enums.DeletionFlag;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class Options implements Cloneable {
+ private static final int TRANSACTION_SENTINEL = -1;
+
+ private DeletionFlag includeDeleted;
+ private int transactionId;
+
+ public Options() {
+ super();
+ reset();
+ }
+
+ public void reset() {
+ includeDeleted = DeletionFlag.EXCLUDE_DELETED;
+ transactionId = TRANSACTION_SENTINEL;
+ }
+
+ public boolean areDeletedIncluded() {
+ return includeDeleted.areDeletedAllowed();
+ }
+
+ public void setIncludeDeleted(boolean enabled) {
+ includeDeleted = DeletionFlag.allowDeleted(enabled);
+ }
+
+ public DeletionFlag getIncludeDeleted() {
+ return includeDeleted;
+ }
+
+ public void setFromTransaction(int transactionId) {
+ this.transactionId = transactionId;
+ if (transactionId < -1) {
+ this.transactionId = TRANSACTION_SENTINEL;
+ }
+ }
+
+ public int getFromTransaction() {
+ return transactionId;
+ }
+
+ public void setHeadTransaction() {
+ transactionId = TRANSACTION_SENTINEL;
+ }
+
+ public boolean isHeadTransaction() {
+ return TRANSACTION_SENTINEL == getFromTransaction();
+ }
+
+ public boolean isHistorical() {
+ return !isHeadTransaction();
+ }
+
+ @Override
+ public Options clone() {
+ Options clone = new Options();
+ clone.includeDeleted = this.includeDeleted;
+ clone.transactionId = this.transactionId;
+ return clone;
+ }
+
+ @Override
+ public String toString() {
+ return "Options [includeDeleted=" + includeDeleted + ", transactionId=" + transactionId + "]";
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java
new file mode 100644
index 00000000000..244fd131bf0
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.client.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.services.URIProvider;
+import org.eclipse.osee.orcs.rest.client.OseeClient;
+import org.eclipse.osee.orcs.rest.client.QueryBuilder;
+import org.eclipse.osee.orcs.rest.client.internal.search.PredicateFactory;
+import org.eclipse.osee.orcs.rest.client.internal.search.PredicateFactoryImpl;
+import org.eclipse.osee.orcs.rest.client.internal.search.QueryBuilderImpl;
+import org.eclipse.osee.orcs.rest.client.internal.search.QueryOptions;
+import org.eclipse.osee.orcs.rest.client.internal.search.SearchResultProvider;
+import org.eclipse.osee.orcs.rest.client.internal.search.V1SearchResultProvider;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+
+/**
+ * @author John Misinco
+ * @author Roberto E. Escobar
+ */
+public class OseeClientImpl implements OseeClient {
+
+ private PredicateFactory predicateFactory;
+ private SearchResultProvider searchResultProvider;
+
+ private URIProvider uriProvider;
+ private WebClientProvider clientProvider;
+
+ public void setWebClientProvider(WebClientProvider clientProvider) {
+ this.clientProvider = clientProvider;
+ }
+
+ public void setUriProvider(URIProvider uriProvider) {
+ this.uriProvider = uriProvider;
+ }
+
+ public void start() {
+ predicateFactory = new PredicateFactoryImpl();
+ searchResultProvider = new V1SearchResultProvider(uriProvider, clientProvider);
+ }
+
+ public void stop() {
+ predicateFactory = null;
+ searchResultProvider = null;
+ }
+
+ @Override
+ public QueryBuilder createQueryBuilder(IOseeBranch branch) {
+ QueryOptions options = new QueryOptions();
+ List<Predicate> predicates = new ArrayList<Predicate>();
+ return new QueryBuilderImpl(branch, predicates, options, predicateFactory, searchResultProvider);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/WebClientProvider.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/WebClientProvider.java
new file mode 100644
index 00000000000..027d851c597
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/WebClientProvider.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.client.internal;
+
+import java.net.URI;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import com.sun.jersey.api.client.AsyncWebResource;
+import com.sun.jersey.api.client.WebResource;
+
+/**
+ * @author John Misinco
+ * @author Roberto E. Escobar
+ */
+public interface WebClientProvider {
+
+ WebResource createResource(URI uri) throws OseeCoreException;
+
+ AsyncWebResource createAsyncResource(URI uri) throws OseeCoreException;
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/WebClientProviderImpl.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/WebClientProviderImpl.java
new file mode 100644
index 00000000000..60e8d19e19c
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/WebClientProviderImpl.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.client.internal;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.eclipse.core.net.proxy.IProxyChangeEvent;
+import org.eclipse.core.net.proxy.IProxyChangeListener;
+import org.eclipse.core.net.proxy.IProxyData;
+import org.eclipse.core.net.proxy.IProxyService;
+import com.sun.jersey.api.client.AsyncWebResource;
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.client.apache.ApacheHttpClient;
+import com.sun.jersey.client.apache.config.DefaultApacheHttpClientConfig;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class WebClientProviderImpl implements WebClientProvider {
+
+ private Map<String, IProxyData[]> proxiedData;
+ private IProxyService proxyService;
+ private Client client;
+
+ public void setProxyService(IProxyService proxyService) {
+ this.proxyService = proxyService;
+ }
+
+ public void start() {
+ proxiedData = new ConcurrentHashMap<String, IProxyData[]>();
+ proxyService.addProxyChangeListener(new IProxyChangeListener() {
+ @Override
+ public void proxyInfoChanged(IProxyChangeEvent event) {
+ proxiedData.clear();
+ }
+ });
+ }
+
+ public void stop() {
+ if (proxiedData != null) {
+ proxiedData.clear();
+ }
+ }
+
+ @Override
+ public WebResource createResource(URI uri) {
+ Client client = createClient(uri);
+ return client.resource(uri);
+ }
+
+ @Override
+ public AsyncWebResource createAsyncResource(URI uri) {
+ Client client = createClient(uri);
+ return client.asyncResource(uri);
+ }
+
+ private Client createClient(URI uri) {
+ if (client == null) {
+ DefaultApacheHttpClientConfig clientConfig = new DefaultApacheHttpClientConfig();
+ Map<String, Object> properties = clientConfig.getProperties();
+
+ properties.put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true);
+
+ // configureProxyData(uri, properties);
+ client = ApacheHttpClient.create(clientConfig);
+ }
+ return client;
+ }
+
+ // private void configureProxyData(URI uri, Map<String, Object> properties) {
+ // boolean proxyBypass = OseeProperties.getOseeProxyBypassEnabled();
+ // if (!proxyBypass) {
+ // String key = String.format("%s_%s", uri.getScheme(), uri.getHost());
+ // IProxyData[] datas = proxiedData.get(key);
+ // if (datas == null) {
+ // datas = proxyService.select(uri);
+ // proxiedData.put(key, datas);
+ // }
+ //
+ // for (IProxyData proxyData : datas) {
+ // String type = proxyData.getType();
+ // if (Strings.isValid(type) && type.startsWith("HTTP")) {
+ // String proxyURL =
+ // String.format("%s://%s:%s", type.toLowerCase(), proxyData.getHost(), proxyData.getPort());
+ // properties.put(ApacheHttpClientConfig.PROPERTY_PROXY_URI, proxyURL);
+ // }
+ // }
+ // }
+ // }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/OptionConverter.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/OptionConverter.java
new file mode 100644
index 00000000000..56c99aec32e
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/OptionConverter.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.client.internal.search;
+
+import java.util.LinkedList;
+import java.util.List;
+import org.eclipse.osee.framework.core.enums.CaseType;
+import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
+import org.eclipse.osee.framework.core.enums.OptionVisitor;
+import org.eclipse.osee.framework.core.enums.QueryOption;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
+import org.eclipse.osee.framework.core.enums.TokenOrderType;
+import org.eclipse.osee.orcs.rest.client.internal.search.PredicateFactoryImpl.RestSearchOptions;
+import org.eclipse.osee.orcs.rest.model.search.SearchFlag;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OptionConverter implements OptionVisitor, RestSearchOptions {
+ private final List<SearchFlag> flags = new LinkedList<SearchFlag>();
+ private String delimiter;
+
+ private StringBuilder buffer;
+
+ public void accept(QueryOption[] options) {
+ reset();
+ for (QueryOption option : options) {
+ option.accept(this);
+ }
+ if (buffer == null) {
+ delimiter = TokenDelimiterMatch.ANY.getPattern().pattern();
+ } else {
+ delimiter = buffer.toString();
+ }
+ }
+
+ private void reset() {
+ flags.clear();
+ buffer = null;
+ }
+
+ @Override
+ public void asCaseType(CaseType option) {
+ if (option.isCaseSensitive()) {
+ flags.add(SearchFlag.MATCH_CASE);
+ }
+ }
+
+ @Override
+ public void asTokenOrderType(TokenOrderType option) {
+ if (option.isMatchOrder()) {
+ flags.add(SearchFlag.MATCH_TOKEN_ORDER);
+ }
+ }
+
+ @Override
+ public void asMatchTokenCountType(MatchTokenCountType option) {
+ if (option.isMatchTokenCount()) {
+ flags.add(SearchFlag.MATCH_TOKEN_COUNT);
+ }
+ }
+
+ @Override
+ public void asTokenDelimiterMatch(TokenDelimiterMatch option) {
+ if (buffer == null) {
+ buffer = new StringBuilder();
+ }
+ buffer.append(option.getPattern().pattern());
+ }
+
+ @Override
+ public List<SearchFlag> getFlags() {
+ return flags;
+ }
+
+ @Override
+ public String getDelimiter() {
+ return delimiter.toString();
+ }
+
+}; \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactory.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactory.java
new file mode 100644
index 00000000000..dc80e16565a
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactory.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.client.internal.search;
+
+import java.util.Collection;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.data.IRelationTypeSide;
+import org.eclipse.osee.framework.core.data.Identity;
+import org.eclipse.osee.framework.core.enums.Operator;
+import org.eclipse.osee.framework.core.enums.QueryOption;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+
+/**
+ * @author John Misinco
+ */
+public interface PredicateFactory {
+
+ Predicate createUuidSearch(Collection<String> ids);
+
+ Predicate createLocalIdsSearch(Collection<Integer> ids);
+
+ Predicate createIdSearch(Collection<? extends Identity<String>> ids);
+
+ Predicate createTypeSearch(Collection<? extends IArtifactType> artifactType);
+
+ Predicate createAttributeTypeSearch(Collection<? extends IAttributeType> attributeTypes, String value, QueryOption... options);
+
+ Predicate createAttributeTypeSearch(Collection<? extends IAttributeType> attributeTypes, Operator operator, Collection<String> values);
+
+ Predicate createAttributeExistsSearch(Collection<? extends IAttributeType> attributeTypes);
+
+ Predicate createRelationExistsSearch(Collection<? extends IRelationType> relationTypes);
+
+ Predicate createRelatedToSearch(IRelationTypeSide relationTypeSide, Collection<?> ids);
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactoryImpl.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactoryImpl.java
new file mode 100644
index 00000000000..fe536c8b63f
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactoryImpl.java
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.client.internal.search;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import org.eclipse.osee.framework.core.data.IArtifactToken;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.data.IRelationTypeSide;
+import org.eclipse.osee.framework.core.data.Identity;
+import org.eclipse.osee.framework.core.enums.Operator;
+import org.eclipse.osee.framework.core.enums.QueryOption;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchFlag;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
+import org.eclipse.osee.orcs.rest.model.search.SearchOp;
+
+/**
+ * @author John Misinco
+ */
+public class PredicateFactoryImpl implements PredicateFactory {
+
+ private final List<String> emptyStringList = Collections.emptyList();
+ private final List<SearchFlag> emptySearchFlagList = Collections.emptyList();
+
+ public static interface RestSearchOptions {
+
+ List<SearchFlag> getFlags();
+
+ String getDelimiter();
+ }
+
+ @Override
+ public Predicate createUuidSearch(Collection<String> ids) {
+ List<String> strIds = new LinkedList<String>(ids);
+ return createIdsSearch(strIds);
+ }
+
+ @Override
+ public Predicate createLocalIdsSearch(Collection<Integer> ids) {
+ List<String> strIds = new LinkedList<String>();
+ for (Integer value : ids) {
+ strIds.add(String.valueOf(value));
+ }
+ return createIdsSearch(strIds);
+ }
+
+ @Override
+ public Predicate createIdSearch(Collection<? extends Identity<String>> ids) {
+ List<String> values = new LinkedList<String>();
+ for (Identity<String> token : ids) {
+ values.add(token.getGuid());
+ }
+ return createIdsSearch(values);
+ }
+
+ private Predicate createIdsSearch(List<String> ids) {
+ return new Predicate(SearchMethod.IDS, emptyStringList, SearchOp.EQUALS, emptySearchFlagList,
+ Strings.EMPTY_STRING, ids);
+ }
+
+ @Override
+ public Predicate createTypeSearch(Collection<? extends IArtifactType> artifactType) {
+ List<String> typeIds = getLongIds(artifactType);
+ return new Predicate(SearchMethod.IS_OF_TYPE, emptyStringList, SearchOp.EQUALS, emptySearchFlagList,
+ Strings.EMPTY_STRING, typeIds);
+ }
+
+ @Override
+ public Predicate createAttributeTypeSearch(Collection<? extends IAttributeType> attributeTypes, String value, QueryOption... options) {
+ List<String> typeIds = getLongIds(attributeTypes);
+ List<String> values = Collections.singletonList(value);
+ RestSearchOptions option = convertToSearchFlags(options);
+ return new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeIds, SearchOp.EQUALS, option.getFlags(),
+ option.getDelimiter(), values);
+ }
+
+ @Override
+ public Predicate createAttributeTypeSearch(Collection<? extends IAttributeType> attributeTypes, Operator operator, Collection<String> values) {
+ List<String> typeIds = getLongIds(attributeTypes);
+ List<String> valuesList = new LinkedList<String>(values);
+ SearchOp op = convertToSearchOp(operator);
+ return new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeIds, op, emptySearchFlagList, Strings.EMPTY_STRING,
+ valuesList);
+ }
+
+ @Override
+ public Predicate createAttributeExistsSearch(Collection<? extends IAttributeType> attributeTypes) {
+ List<String> typeIds = getLongIds(attributeTypes);
+ return new Predicate(SearchMethod.EXISTS_TYPE, Arrays.asList("attrType"), SearchOp.EQUALS, emptySearchFlagList,
+ Strings.EMPTY_STRING, typeIds);
+ }
+
+ @Override
+ public Predicate createRelationExistsSearch(Collection<? extends IRelationType> relationTypes) {
+ List<String> typeIds = getLongIds(relationTypes);
+ return new Predicate(SearchMethod.EXISTS_TYPE, Arrays.asList("relType"), SearchOp.EQUALS, emptySearchFlagList,
+ Strings.EMPTY_STRING, typeIds);
+ }
+
+ @Override
+ public Predicate createRelatedToSearch(IRelationTypeSide relationTypeSide, Collection<?> ids) {
+ List<String> values = new LinkedList<String>();
+ String side = relationTypeSide.getSide().isSideA() ? "A" : "B";
+ for (Object id : ids) {
+ if (id instanceof IArtifactToken) {
+ values.add(((IArtifactToken) id).getGuid());
+ } else if (id instanceof Integer) {
+ values.add(id.toString());
+ }
+ }
+ return new Predicate(SearchMethod.RELATED_TO, Arrays.asList(side + relationTypeSide.getGuid().toString()),
+ SearchOp.EQUALS, emptySearchFlagList, Strings.EMPTY_STRING, values);
+ }
+
+ private List<String> getLongIds(Collection<? extends Identity<Long>> types) {
+ List<String> toReturn = new LinkedList<String>();
+ for (Identity<Long> type : types) {
+ Long value = type.getGuid();
+ toReturn.add(String.valueOf(value));
+ }
+ return toReturn;
+ }
+
+ private SearchOp convertToSearchOp(Operator op) {
+ SearchOp toReturn = SearchOp.EQUALS;
+ switch (op) {
+ case EQUAL:
+ toReturn = SearchOp.EQUALS;
+ break;
+ case GREATER_THAN:
+ toReturn = SearchOp.GREATER_THAN;
+ break;
+ case LESS_THAN:
+ toReturn = SearchOp.LESS_THAN;
+ break;
+ }
+ return toReturn;
+ }
+
+ private RestSearchOptions convertToSearchFlags(QueryOption[] options) {
+ OptionConverter visitor = new OptionConverter();
+ visitor.accept(options);
+ return visitor;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryBuilderImpl.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryBuilderImpl.java
new file mode 100644
index 00000000000..cba27be280a
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryBuilderImpl.java
@@ -0,0 +1,284 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.client.internal.search;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import org.eclipse.osee.framework.core.data.IArtifactToken;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.data.IRelationTypeSide;
+import org.eclipse.osee.framework.core.data.ResultSet;
+import org.eclipse.osee.framework.core.data.ResultSetList;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.Operator;
+import org.eclipse.osee.framework.core.enums.QueryOption;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.rest.client.QueryBuilder;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchResult;
+
+/**
+ * @author John Misinco
+ */
+public class QueryBuilderImpl implements QueryBuilder {
+
+ private final PredicateFactory predicateFactory;
+ private final SearchResultProvider searchResultProvider;
+ private final IOseeBranch branch;
+ private final QueryOptions options;
+ private final List<Predicate> predicates;
+
+ public QueryBuilderImpl(IOseeBranch branch, List<Predicate> predicates, QueryOptions options, PredicateFactory predicateFactory, SearchResultProvider searchResultProvider) {
+ this.branch = branch;
+ this.predicates = predicates;
+ this.options = options;
+ this.predicateFactory = predicateFactory;
+ this.searchResultProvider = searchResultProvider;
+ reset();
+ }
+
+ private void reset() {
+ options.reset();
+ predicates.clear();
+ }
+
+ @Override
+ public QueryBuilder includeCache() {
+ return includeCache(true);
+ }
+
+ @Override
+ public QueryBuilder includeCache(boolean enabled) {
+ options.setIncludeDeleted(enabled);
+ return this;
+ }
+
+ @Override
+ public boolean isCacheIncluded() {
+ return options.isCacheIncluded();
+ }
+
+ @Override
+ public QueryBuilder includeDeleted() {
+ return includeDeleted(true);
+ }
+
+ @Override
+ public QueryBuilder includeDeleted(boolean enabled) {
+ options.setIncludeDeleted(enabled);
+ return this;
+ }
+
+ @Override
+ public boolean areDeletedIncluded() {
+ return options.areDeletedIncluded();
+ }
+
+ @Override
+ public QueryBuilder includeTypeInheritance() {
+ includeTypeInheritance(true);
+ return this;
+ }
+
+ @Override
+ public QueryBuilder includeTypeInheritance(boolean enabled) {
+ options.setIncludeTypeInheritance(enabled);
+ return this;
+ }
+
+ @Override
+ public boolean isTypeInheritanceIncluded() {
+ return options.isTypeInheritanceIncluded();
+ }
+
+ @Override
+ public QueryBuilder fromTransaction(int transactionId) {
+ options.setFromTransaction(transactionId);
+ return this;
+ }
+
+ @Override
+ public int getFromTransaction() {
+ return options.getFromTransaction();
+ }
+
+ @Override
+ public QueryBuilder headTransaction() {
+ options.setHeadTransaction();
+ return this;
+ }
+
+ @Override
+ public boolean isHeadTransaction() {
+ return options.isHeadTransaction();
+ }
+
+ @Override
+ public QueryBuilder excludeCache() {
+ options.setIncludeCache(false);
+ return this;
+ }
+
+ @Override
+ public QueryBuilder excludeDeleted() {
+ return includeDeleted(false);
+ }
+
+ @Override
+ public QueryBuilder excludeTypeInheritance() {
+ includeTypeInheritance(false);
+ return this;
+ }
+
+ @Override
+ public QueryBuilder resetToDefaults() {
+ reset();
+ return this;
+ }
+
+ @Override
+ public QueryBuilder andLocalId(int... artifactId) {
+ Collection<Integer> ids = new LinkedList<Integer>();
+ for (int id : artifactId) {
+ ids.add(id);
+ }
+ return andLocalIds(ids);
+ }
+
+ @Override
+ public QueryBuilder andLocalIds(Collection<Integer> artifactIds) {
+ predicates.add(predicateFactory.createLocalIdsSearch(artifactIds));
+ return this;
+ }
+
+ @Override
+ public QueryBuilder andGuidsOrHrids(String... ids) {
+ return andGuidsOrHrids(Arrays.asList(ids));
+ }
+
+ @Override
+ public QueryBuilder andGuidsOrHrids(Collection<String> ids) {
+ predicates.add(predicateFactory.createUuidSearch(ids));
+ return this;
+ }
+
+ @Override
+ public QueryBuilder andIds(IArtifactToken... artifactToken) {
+ return andIds(Arrays.asList(artifactToken));
+ }
+
+ @Override
+ public QueryBuilder andIds(Collection<? extends IArtifactToken> artifactTokens) {
+ predicates.add(predicateFactory.createIdSearch(artifactTokens));
+ return this;
+ }
+
+ @Override
+ public QueryBuilder andIsOfType(IArtifactType... artifactType) {
+ return andIsOfType(Arrays.asList(artifactType));
+ }
+
+ @Override
+ public QueryBuilder andIsOfType(Collection<? extends IArtifactType> artifactTypes) {
+ predicates.add(predicateFactory.createTypeSearch(artifactTypes));
+ return this;
+ }
+
+ @Override
+ public QueryBuilder andExists(IAttributeType... attributeType) {
+ return andExists(Arrays.asList(attributeType));
+ }
+
+ @Override
+ public QueryBuilder andExists(Collection<? extends IAttributeType> attributeTypes) {
+ predicates.add(predicateFactory.createAttributeExistsSearch(attributeTypes));
+ return this;
+ }
+
+ @Override
+ public QueryBuilder andExists(IRelationType relationType) {
+ predicates.add(predicateFactory.createRelationExistsSearch(Collections.singleton(relationType)));
+ return this;
+ }
+
+ @Override
+ public QueryBuilder andNameEquals(String artifactName) {
+ return and(CoreAttributeTypes.Name, Operator.EQUAL, artifactName);
+ }
+
+ @Override
+ public QueryBuilder and(IAttributeType attributeType, Operator operator, String value) {
+ return and(attributeType, operator, Collections.singleton(value));
+ }
+
+ @Override
+ public QueryBuilder and(IAttributeType attributeType, Operator operator, Collection<String> values) {
+ predicates.add(predicateFactory.createAttributeTypeSearch(Collections.singleton(attributeType), operator, values));
+ return this;
+ }
+
+ @Override
+ public QueryBuilder and(IAttributeType attributeType, String value, QueryOption... options) {
+ return and(Collections.singleton(attributeType), value, options);
+ }
+
+ @Override
+ public QueryBuilder and(Collection<? extends IAttributeType> attributeTypes, String value, QueryOption... options) {
+ predicates.add(predicateFactory.createAttributeTypeSearch(attributeTypes, value, options));
+ return this;
+ }
+
+ @Override
+ public QueryBuilder andRelatedTo(IRelationTypeSide relationTypeSide, IArtifactToken... artifacts) {
+ return andRelatedTo(relationTypeSide, Arrays.asList(artifacts));
+ }
+
+ @Override
+ public QueryBuilder andRelatedTo(IRelationTypeSide relationTypeSide, Collection<? extends IArtifactToken> artifacts) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public QueryBuilder andRelatedToLocalIds(IRelationTypeSide relationTypeSide, int... artifactIds) {
+ Collection<Integer> ids = new LinkedList<Integer>();
+ for (int id : artifactIds) {
+ ids.add(id);
+ }
+ return andRelatedToLocalIds(relationTypeSide, ids);
+ }
+
+ @Override
+ public QueryBuilder andRelatedToLocalIds(IRelationTypeSide relationTypeSide, Collection<Integer> artifactIds) {
+ predicates.add(predicateFactory.createRelatedToSearch(relationTypeSide, artifactIds));
+ return this;
+ }
+
+ @Override
+ public ResultSet<Integer> getResults() throws OseeCoreException {
+ QueryOptions qOptions = options.clone();
+ SearchResult result = searchResultProvider.getSearchResults(branch, predicates, qOptions);
+ List<Integer> ids = result.getIds();
+ return new ResultSetList<Integer>(ids);
+ }
+
+ @Override
+ public int getCount() throws OseeCoreException {
+ QueryOptions qOptions = options.clone();
+ return searchResultProvider.getSearchCount(branch, predicates, qOptions);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryOptions.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryOptions.java
new file mode 100644
index 00000000000..4596eaf326b
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryOptions.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.client.internal.search;
+
+import org.eclipse.osee.orcs.rest.client.internal.Options;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class QueryOptions extends Options {
+
+ private boolean includeCache = true;
+ private boolean includeTypeInheritance = false;
+
+ public QueryOptions() {
+ super();
+ }
+
+ @Override
+ public void reset() {
+ super.reset();
+ includeCache = true;
+ includeTypeInheritance = false;
+ }
+
+ public boolean isCacheIncluded() {
+ return includeCache;
+ }
+
+ public boolean isTypeInheritanceIncluded() {
+ return includeTypeInheritance;
+ }
+
+ public void setIncludeCache(boolean enabled) {
+ includeCache = enabled;
+ }
+
+ public void setIncludeTypeInheritance(boolean enabled) {
+ includeTypeInheritance = enabled;
+ }
+
+ @Override
+ public QueryOptions clone() {
+ QueryOptions clone = new QueryOptions();
+ clone.setIncludeDeleted(this.areDeletedIncluded());
+ clone.setFromTransaction(this.getFromTransaction());
+ clone.includeCache = this.includeCache;
+ clone.includeTypeInheritance = this.includeTypeInheritance;
+ return clone;
+ }
+
+ @Override
+ public String toString() {
+ return "QueryOptions [includeCache=" + includeCache + ", includeTypeInheritance=" + includeTypeInheritance + " [" + super.toString() + "]]";
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/SearchResultProvider.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/SearchResultProvider.java
new file mode 100644
index 00000000000..e5da4857771
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/SearchResultProvider.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.client.internal.search;
+
+import java.util.List;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchResult;
+
+/**
+ * @author John Misinco
+ * @author Roberto E. Escobar
+ */
+public interface SearchResultProvider {
+
+ int getSearchCount(IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException;
+
+ SearchResult getSearchResults(IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException;
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/V1SearchResultProvider.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/V1SearchResultProvider.java
new file mode 100644
index 00000000000..e31c02b8c87
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/V1SearchResultProvider.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.client.internal.search;
+
+import java.net.URI;
+import java.util.List;
+import javax.ws.rs.core.MediaType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.core.services.URIProvider;
+import org.eclipse.osee.orcs.rest.client.internal.WebClientProvider;
+import org.eclipse.osee.orcs.rest.model.search.OutputFormat;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.RequestType;
+import org.eclipse.osee.orcs.rest.model.search.SearchParameters;
+import org.eclipse.osee.orcs.rest.model.search.SearchResult;
+import com.sun.jersey.api.client.WebResource;
+
+/**
+ * @author John Misinco
+ */
+public class V1SearchResultProvider implements SearchResultProvider {
+
+ private final WebClientProvider clientProvider;
+ private final URIProvider uriProvider;
+
+ public V1SearchResultProvider(URIProvider uriProvider, WebClientProvider clientProvider) {
+ super();
+ this.uriProvider = uriProvider;
+ this.clientProvider = clientProvider;
+ }
+
+ @Override
+ public int getSearchCount(IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException {
+ SearchResult result = performSearch(RequestType.COUNT, OutputFormat.XML, branch, predicates, options);
+ return result.getTotal();
+ }
+
+ @Override
+ public SearchResult getSearchResults(IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException {
+ SearchResult result = performSearch(RequestType.IDS, OutputFormat.XML, branch, predicates, options);
+ return result;
+ }
+
+ private SearchResult performSearch(RequestType requestType, OutputFormat outputFormat, IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException {
+ int fromTx = 0;
+ if (options.isHistorical()) {
+ fromTx = options.getFromTransaction();
+ }
+
+ boolean includeTypeInh = false;
+ if (options.isTypeInheritanceIncluded()) {
+ includeTypeInh = true;
+ }
+
+ boolean includeCache = false;
+ if (options.isCacheIncluded()) {
+ includeCache = true;
+ }
+
+ boolean includeDeleted = false;
+ if (options.areDeletedIncluded()) {
+ includeDeleted = true;
+ }
+
+ SearchParameters params =
+ new SearchParameters(branch.getGuid(), predicates, outputFormat.name().toLowerCase(),
+ requestType.name().toLowerCase(), fromTx, includeTypeInh, includeCache, includeDeleted);
+
+ URI uri = uriProvider.getEncodedURI(String.format("oseex/branch/%s/artifact/search/v1", branch.getGuid()), null);
+
+ WebResource resource = clientProvider.createResource(uri);
+ SearchResult searchResult = null;
+ try {
+ searchResult =
+ resource.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON_TYPE).post(
+ SearchResult.class, params);
+ } catch (Exception ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ return searchResult;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/.classpath b/plugins/org.eclipse.osee.orcs.rest.model/.classpath
new file mode 100644
index 00000000000..ad32c83a788
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/.project b/plugins/org.eclipse.osee.orcs.rest.model/.project
new file mode 100644
index 00000000000..3768a078d29
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.orcs.rest.model</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.rest.model/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..9709cf86009
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE ORCS Rest Model (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.orcs.rest.model
+Bundle-Version: 0.11.0.qualifier
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.eclipse.osee.orcs.rest.model,
+ org.eclipse.osee.orcs.rest.model.search
+Import-Package: javax.xml.bind.annotation,
+ org.eclipse.osee.framework.core.exception,
+ org.eclipse.osee.framework.core.util,
+ org.eclipse.osee.framework.jdk.core.util
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.osee.framework.core
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/build.properties b/plugins/org.eclipse.osee.orcs.rest.model/build.properties
new file mode 100644
index 00000000000..e218306d004
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
+additional.bundles = org.eclipse.osee.framework.core,\
+ org.eclipse.osee.framework.jdk.core
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/pom.xml b/plugins/org.eclipse.osee.orcs.rest.model/pom.xml
new file mode 100644
index 00000000000..95be64dae5b
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/pom.xml
@@ -0,0 +1,34 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.osee</groupId>
+ <artifactId>org.eclipse.osee.x.server.parent</artifactId>
+ <version>0.11.0-SNAPSHOT</version>
+ <relativePath>../../plugins/org.eclipse.osee.x.server.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.osee.orcs.rest.model</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>OSEE ORCS Rest Model - (Incubation)</name>
+
+ <build>
+ <!-- workaround for https://issues.sonatype.org/browse/TYCHO-168 -->
+ <resources>
+ <resource>
+ <directory>src</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-source-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Branch.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Branch.java
new file mode 100644
index 00000000000..92ab72b0861
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Branch.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import org.eclipse.osee.framework.core.enums.BranchArchivedState;
+import org.eclipse.osee.framework.core.enums.BranchState;
+import org.eclipse.osee.framework.core.enums.BranchType;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@XmlRootElement
+public class Branch {
+
+ private String uuid;
+ private String name;
+ private BranchType branchType;
+ private BranchState branchState;
+ private BranchArchivedState branchArchivedState;
+ private Transaction baseTransaction;
+ private Transaction sourceTransaction;
+
+ public String getId() {
+ return uuid;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public BranchType getBranchType() {
+ return branchType;
+ }
+
+ public BranchState getBranchState() {
+ return branchState;
+ }
+
+ public BranchArchivedState getArchiveState() {
+ return branchArchivedState;
+ }
+
+ public Transaction getBaseTransaction() {
+ return baseTransaction;
+ }
+
+ public Transaction getSourceTransaction() {
+ return sourceTransaction;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Transaction.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Transaction.java
new file mode 100644
index 00000000000..7ddae90abe6
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Transaction.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.model;
+
+import java.util.Date;
+import javax.xml.bind.annotation.XmlRootElement;
+import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@XmlRootElement
+public class Transaction {
+
+ private String branchUuid;
+ private TransactionDetailsType txType;
+ private String comment;
+ private Date time;
+ private int authorArtId;
+ private int commitArtId;
+
+ public TransactionDetailsType getTxType() {
+ return txType;
+ }
+
+ public void setTxType(TransactionDetailsType txType) {
+ this.txType = txType;
+ }
+
+ public String getBranchId() {
+ return branchUuid;
+ }
+
+ public void setBranchId(String branchUuid) {
+ this.branchUuid = branchUuid;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ public Date getTimeStamp() {
+ return time;
+ }
+
+ public void setTimeStamp(Date time) {
+ this.time = time;
+ }
+
+ public int getAuthor() {
+ return authorArtId;
+ }
+
+ public void setAuthor(int authorArtId) {
+ this.authorArtId = authorArtId;
+ }
+
+ public int getCommit() {
+ return commitArtId;
+ }
+
+ public void setCommit(int commitArtId) {
+ this.commitArtId = commitArtId;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/OutputFormat.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/OutputFormat.java
new file mode 100644
index 00000000000..1f248fa4eba
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/OutputFormat.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.model.search;
+
+/**
+ * @author John R. Misinco
+ */
+public enum OutputFormat {
+ XML
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/Predicate.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/Predicate.java
index cffbb3d8419..e25dff1bbce 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/Predicate.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/Predicate.java
@@ -8,14 +8,11 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.rest.internal.search;
+package org.eclipse.osee.orcs.rest.model.search;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import org.eclipse.osee.framework.jdk.core.util.Collections;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchFlag;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchMethod;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchOp;
/**
* @author John R. Misinco
@@ -28,16 +25,22 @@ public class Predicate {
private SearchOp op;
private List<SearchFlag> flags;
private List<String> values;
+ private String delimiter;
public Predicate() {
}
- public Predicate(SearchMethod type, List<String> typeParameters, SearchOp op, List<SearchFlag> flags, List<String> values) {
+ public Predicate(SearchMethod type, List<String> typeParameters, SearchOp op, List<SearchFlag> flags, String delimiter, List<String> values) {
this.type = type;
this.typeParameters = typeParameters;
this.op = op;
this.flags = flags;
this.values = values;
+ this.delimiter = delimiter;
+ }
+
+ public void setDelimiter(String regex) {
+ this.delimiter = regex;
}
public void setType(SearchMethod type) {
@@ -80,22 +83,15 @@ public class Predicate {
return values;
}
+ public String getDelimiter() {
+ return delimiter;
+ }
+
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("type:[");
- sb.append(type);
- sb.append("],typeParameters:[");
- sb.append(Collections.toString(",", typeParameters));
- sb.append("],");
- sb.append("op:[");
- sb.append(op);
- sb.append("],flags:[");
- sb.append(Collections.toString(",", flags));
- sb.append("],values:[");
- sb.append(Collections.toString(",", values));
- sb.append("]");
- return sb.toString();
+ return String.format("type:[%s],typeParameters:[%s],op[%s],flags[%s],values[%s],delimiter[%s]", type,
+ Collections.toString(",", typeParameters), op, Collections.toString(",", flags),
+ Collections.toString(",", values), delimiter);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/RequestType.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/RequestType.java
new file mode 100644
index 00000000000..c2e031a7d45
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/RequestType.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.model.search;
+
+/**
+ * @author John R. Misinco
+ */
+public enum RequestType {
+ COUNT,
+ IDS;
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchFlag.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchFlag.java
index 9b9ebc8632b..79d7af59f58 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchFlag.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchFlag.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.rest.internal.search.dsl;
+package org.eclipse.osee.orcs.rest.model.search;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.Conditions;
@@ -18,12 +18,9 @@ import org.eclipse.osee.framework.core.util.Conditions;
* @author Roberto E. Escobar
*/
public enum SearchFlag {
- TOKENIZED("t"),
- IGNORE_CASE("i"),
- MATCH_CASE("m"),
- TOKENIZED_ANY("t_any"),
- TOKENIZED_ORDERED("t_ordered"),
- INCLUDE_TYPE_INHERITANCE("iti");
+ MATCH_CASE("mc"),
+ MATCH_TOKEN_COUNT("mtc"),
+ MATCH_TOKEN_ORDER("mto");
private final String token;
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchMethod.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchMethod.java
index 9a516a9f7c2..873dd430dbe 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchMethod.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchMethod.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.rest.internal.search.dsl;
+package org.eclipse.osee.orcs.rest.model.search;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.Conditions;
@@ -21,7 +21,8 @@ public enum SearchMethod {
IDS("ids"),
IS_OF_TYPE("isOfType"),
EXISTS_TYPE("exists"),
- ATTRIBUTE_TYPE("attrType");
+ ATTRIBUTE_TYPE("attrType"),
+ RELATED_TO("related");
private final String token;
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchOp.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchOp.java
index 34d9f533bf2..0dedba0f160 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchOp.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchOp.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.rest.internal.search.dsl;
+package org.eclipse.osee.orcs.rest.model.search;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.Conditions;
@@ -19,10 +19,8 @@ import org.eclipse.osee.framework.core.util.Conditions;
*/
public enum SearchOp {
EQUALS("=="),
- NOT_EQUALS("!="),
LESS_THAN("<"),
- GREATER_THAN(">"),
- IN("in");
+ GREATER_THAN(">");
private final String token;
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchParameters.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchParameters.java
new file mode 100644
index 00000000000..20a1abeb374
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchParameters.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.model.search;
+
+import java.util.List;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+/**
+ * @author John R. Misinco
+ * @author Roberto E. Escobar
+ */
+@XmlRootElement
+public class SearchParameters {
+
+ private String branchUuid;
+ private String alt;
+ private String fields;
+ private int fromTx;
+ private boolean includeTypeInh;
+ private boolean includeCache;
+ private boolean includeDeleted;
+
+ @XmlTransient
+ private List<Predicate> predicates;
+
+ public SearchParameters() {
+ super();
+ }
+
+ public SearchParameters(String branchUuid, List<Predicate> predicates, String alt, String fields, int fromTx, boolean includeTypeInheritance, boolean includeCache, boolean includeDeleted) {
+ super();
+ this.branchUuid = branchUuid;
+ this.predicates = predicates;
+ this.alt = alt;
+ this.fields = fields;
+ this.fromTx = fromTx;
+ this.includeTypeInh = includeTypeInheritance;
+ this.includeCache = includeCache;
+ this.includeDeleted = includeDeleted;
+ }
+
+ public String getBranchUuid() {
+ return branchUuid;
+ }
+
+ @XmlElementWrapper(name = "predicates")
+ @XmlElement(name = "predicate")
+ public List<Predicate> getPredicates() {
+ return predicates;
+ }
+
+ public String getAlt() {
+ return alt;
+ }
+
+ public String getFields() {
+ return fields;
+ }
+
+ public void setBranchUuid(String uuid) {
+ this.branchUuid = uuid;
+ }
+
+ public void setPredicates(List<Predicate> predicates) {
+ this.predicates = predicates;
+ }
+
+ public void setAlt(String alt) {
+ this.alt = alt;
+ }
+
+ public void setFields(String fields) {
+ this.fields = fields;
+ }
+
+ public boolean isIncludeTypeInheritance() {
+ return includeTypeInh;
+ }
+
+ public boolean isIncludeCache() {
+ return includeCache;
+ }
+
+ public boolean isIncludeDeleted() {
+ return includeDeleted;
+ }
+
+ public int getFromTx() {
+ return fromTx;
+ }
+
+ public void setFromTx(int fromTx) {
+ this.fromTx = fromTx;
+ }
+
+ public boolean isIncludeTypeInh() {
+ return includeTypeInh;
+ }
+
+ public void setIncludeTypeInh(boolean includeTypeInh) {
+ this.includeTypeInh = includeTypeInh;
+ }
+
+ public void setIncludeCache(boolean includeCache) {
+ this.includeCache = includeCache;
+ }
+
+ public void setIncludeDeleted(boolean includeDeleted) {
+ this.includeDeleted = includeDeleted;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/SearchResult.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchResult.java
index 4e05edefad6..2a6fc74df29 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/SearchResult.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchResult.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.rest.internal.search;
+package org.eclipse.osee.orcs.rest.model.search;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -23,8 +23,6 @@ import javax.xml.bind.annotation.XmlTransient;
@XmlRootElement
public class SearchResult {
- // All else from out message
-
private int total;
private long searchTime;
private String version;
@@ -32,7 +30,7 @@ public class SearchResult {
private SearchParameters searchParameters;
@XmlTransient
- private List<Predicate> predicates;
+ private List<Integer> ids;
public SearchParameters getSearchParams() {
return searchParameters;
@@ -42,10 +40,6 @@ public class SearchResult {
this.searchParameters = searchParams;
}
- public void setPredicates(List<Predicate> predicates) {
- this.predicates = predicates;
- }
-
public void setVersion(String version) {
this.version = version;
}
@@ -70,14 +64,18 @@ public class SearchResult {
return version;
}
- @XmlElementWrapper(name = "predicates")
- @XmlElement(name = "predicate")
- public List<Predicate> getPredicates() {
- return predicates;
- }
-
public SearchParameters getSearchParameters() {
return searchParameters;
}
+ @XmlElementWrapper(name = "ids")
+ @XmlElement(name = "id")
+ public List<Integer> getIds() {
+ return ids;
+ }
+
+ public void setIds(List<Integer> ids) {
+ this.ids = ids;
+ }
+
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImplTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImplTest.java
index 371dc3522fb..a0a30b98843 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImplTest.java
@@ -15,7 +15,10 @@ import java.util.Random;
import junit.framework.Assert;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.rest.internal.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchFlag;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
+import org.eclipse.osee.orcs.rest.model.search.SearchOp;
import org.junit.Test;
/**
@@ -25,7 +28,7 @@ public class DslTranslatorImplTest {
@Test(expected = OseeArgumentException.class)
public void testBadSearchType() throws OseeCoreException {
- DslTranslatorImpl translator = new DslTranslatorImpl();
+ DslTranslatorImpl_V1 translator = new DslTranslatorImpl_V1();
//test bad search type
String test = "[t:attrTypes&tp:1000000000000070&op:==&v:AtsAdmin]";
@@ -34,7 +37,7 @@ public class DslTranslatorImplTest {
@Test(expected = OseeArgumentException.class)
public void testBadOp() throws OseeCoreException {
- DslTranslatorImpl translator = new DslTranslatorImpl();
+ DslTranslatorImpl_V1 translator = new DslTranslatorImpl_V1();
//test bad op
String test = "[t:attrType&tp:1000000000000070&op:<>&v:AtsAdmin]";
@@ -43,7 +46,7 @@ public class DslTranslatorImplTest {
@Test(expected = OseeArgumentException.class)
public void testBadFlag() throws OseeCoreException {
- DslTranslatorImpl translator = new DslTranslatorImpl();
+ DslTranslatorImpl_V1 translator = new DslTranslatorImpl_V1();
//test bad flags
String test = "[t:attrType&tp:1000000000000070&op:==&f:ti&v:AtsAdmin]";
@@ -123,7 +126,7 @@ public class DslTranslatorImplTest {
@Test
public void testMultiplePredicates() throws OseeCoreException {
- DslTranslatorImpl translator = new DslTranslatorImpl();
+ DslTranslatorImpl_V1 translator = new DslTranslatorImpl_V1();
int size = 5;
String test = getTestQuery(size);
@@ -138,15 +141,38 @@ public class DslTranslatorImplTest {
@Test
public void testAttrTypeSearches() throws OseeCoreException {
- DslTranslatorImpl translator = new DslTranslatorImpl();
-
- String test = "[t:attrType&tp:0x1000000000000070&op:==&f:t,i&v:AtsAdmin]";
- translator.translate(test);
-
- test = "[t:attrType&tp:1000000000000070&op:!=&f:t,i&v:AtsAdmin]";
- translator.translate(test);
-
- test = "[t:attrType&tp:1000000000000070&op:<&f:t,i&v:AtsAdmin]";
- translator.translate(test);
+ DslTranslatorImpl_V1 translator = new DslTranslatorImpl_V1();
+ List<Predicate> predicates;
+
+ String test = "[t:attrType&tp:0x1000000000000070&op:==&v:AtsAdmin]";
+ predicates = translator.translate(test);
+ Assert.assertEquals(1, predicates.size());
+ Predicate predicate = predicates.iterator().next();
+ Assert.assertEquals(SearchMethod.ATTRIBUTE_TYPE, predicate.getType());
+ Assert.assertEquals(SearchOp.EQUALS, predicate.getOp());
+ Assert.assertTrue(predicate.getValues().contains("AtsAdmin"));
+
+ test = "[t:isOfType&tp:1000000000000070&op:>&v:AtsAdmin]";
+ predicates = translator.translate(test);
+ Assert.assertEquals(1, predicates.size());
+ predicate = predicates.iterator().next();
+ Assert.assertEquals(SearchMethod.IS_OF_TYPE, predicate.getType());
+ Assert.assertEquals(SearchOp.GREATER_THAN, predicate.getOp());
+ Assert.assertTrue(predicate.getValues().contains("AtsAdmin"));
+
+ test = "[t:ids&tp:1000000000000070&op:<&v:AtsAdmin&d:'bo'b]''']";
+ test += "&[t:attrType&tp:1000000000000070&op:==&v:TestAdmin&d:'bo'b]'[]&]'']";
+ predicates = translator.translate(test);
+ Assert.assertEquals(2, predicates.size());
+ predicate = predicates.get(0);
+ Assert.assertEquals(SearchMethod.IDS, predicate.getType());
+ Assert.assertEquals(SearchOp.LESS_THAN, predicate.getOp());
+ Assert.assertTrue(predicate.getValues().contains("AtsAdmin"));
+ Assert.assertEquals("bo'b]''", predicate.getDelimiter());
+ predicate = predicates.get(1);
+ Assert.assertEquals(SearchMethod.ATTRIBUTE_TYPE, predicate.getType());
+ Assert.assertEquals(SearchOp.EQUALS, predicate.getOp());
+ Assert.assertTrue(predicate.getValues().contains("TestAdmin"));
+ Assert.assertEquals("bo'b]'[]&]'", predicate.getDelimiter());
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java
index 209fcbc89dd..0a7d09e77c3 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java
@@ -10,110 +10,71 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.internal.search.dsl;
-import java.util.Collection;
-import java.util.Collections;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.Arrays;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-import org.eclipse.osee.framework.core.data.IArtifactType;
+import junit.framework.Assert;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.rest.internal.search.Predicate;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.orcs.rest.internal.search.PredicateHandler;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchDsl.DslTranslator;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
+import org.eclipse.osee.orcs.rest.model.search.SearchOp;
+import org.eclipse.osee.orcs.rest.model.search.SearchParameters;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
-import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
/**
* @author John R. Misinco
*/
public class SearchDslTest {
- private class MockTranslator implements DslTranslator {
- public String rawString;
- private final SearchMethod method;
+ // @formatter:off
+ @Mock private PredicateHandler handler;
+ @Mock private QueryFactory queryFactory;
+ @Mock private QueryBuilder builder;
+ @Captor private ArgumentCaptor<IOseeBranch> fromBranch;
+ // @formatter:on
- public MockTranslator(SearchMethod method) {
- this.method = method;
- }
+ private static final IOseeBranch BRANCH = CoreBranches.COMMON;
+ private SearchQueryBuilder dsl;
- @Override
- public List<Predicate> translate(String rawString) {
- this.rawString = rawString;
- Predicate toReturn = new Predicate(method, null, null, null, null);
- return Collections.singletonList(toReturn);
- }
- }
-
- private class MockPredicateHandler implements PredicateHandler {
- public boolean handleCalled = false;
-
- @Override
- public QueryBuilder handle(QueryBuilder builder, Predicate predicate) {
- handleCalled = true;
- return builder;
- }
- }
-
- private class MockQueryFactory implements QueryFactory {
- public IOseeBranch branch;
-
- @Override
- public QueryBuilder fromBranch(IOseeBranch branch) {
- this.branch = branch;
- return null;
- }
-
- @Override
- public QueryBuilder fromArtifactTypeAllBranches(IArtifactType artifactType) {
- return null;
- }
-
- @Override
- public QueryBuilder fromArtifacts(Collection<? extends ArtifactReadable> artifacts) {
- return null;
- }
- };
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
- @Test
- public void testBuildValidSearchType() throws OseeCoreException {
Map<SearchMethod, PredicateHandler> handlers = new HashMap<SearchMethod, PredicateHandler>();
- MockPredicateHandler handler = new MockPredicateHandler();
handlers.put(SearchMethod.ATTRIBUTE_TYPE, handler);
- MockTranslator translator = new MockTranslator(SearchMethod.ATTRIBUTE_TYPE);
- SearchDsl dsl = new SearchDsl(handlers, translator);
- MockQueryFactory queryFactory = new MockQueryFactory();
-
- IOseeBranch branch = CoreBranches.COMMON;
- String rawQuery = "[t:attrType&tp:1000000000000070&op:==&v:AtsAdmin]";
- dsl.build(queryFactory, branch, rawQuery);
-
- Assert.assertEquals(rawQuery, translator.rawString);
- Assert.assertEquals(branch, queryFactory.branch);
- Assert.assertTrue(handler.handleCalled);
+ dsl = new SearchQueryBuilder(handlers);
}
@Test
- public void testBuildInvalidSearchType() throws OseeCoreException {
- Map<SearchMethod, PredicateHandler> handlers = new HashMap<SearchMethod, PredicateHandler>();
- MockPredicateHandler handler = new MockPredicateHandler();
- handlers.put(SearchMethod.ATTRIBUTE_TYPE, handler);
+ public void testBuildValidSearchType() throws OseeCoreException {
+ when(queryFactory.fromBranch(any(IOseeBranch.class))).thenReturn(builder);
- MockTranslator translator = new MockTranslator(SearchMethod.EXISTS_TYPE);
- SearchDsl dsl = new SearchDsl(handlers, translator);
- MockQueryFactory queryFactory = new MockQueryFactory();
+ Predicate predicate =
+ new Predicate(SearchMethod.ATTRIBUTE_TYPE, Arrays.asList("1000000000000070"), SearchOp.EQUALS, null,
+ Strings.EMPTY_STRING, Arrays.asList("AtsAdmin"));
+ SearchParameters params =
+ new SearchParameters(BRANCH.getGuid(), Arrays.asList(predicate), Strings.EMPTY_STRING, Strings.EMPTY_STRING,
+ 0, false, false, false);
- IOseeBranch branch = CoreBranches.COMMON;
- String rawQuery = "[t:attrType&tp:1000000000000070&op:==&v:AtsAdmin]";
- dsl.build(queryFactory, branch, rawQuery);
+ dsl.build(queryFactory, params);
- Assert.assertEquals(rawQuery, translator.rawString);
- Assert.assertEquals(branch, queryFactory.branch);
- Assert.assertFalse(handler.handleCalled);
+ verify(queryFactory).fromBranch(fromBranch.capture());
+ Assert.assertEquals(BRANCH.getGuid(), fromBranch.getValue().getGuid());
+ verify(handler).handle(builder, predicate);
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandlerTest.java
index 93e1cde28ca..83dbc460faa 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandlerTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandlerTest.java
@@ -10,23 +10,29 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.internal.search.predicate;
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import junit.framework.Assert;
import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.enums.CaseType;
+import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
+import org.eclipse.osee.framework.core.enums.Operator;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
+import org.eclipse.osee.framework.core.enums.TokenOrderType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.rest.internal.search.Predicate;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchFlag;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchMethod;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchOp;
-import org.eclipse.osee.orcs.search.CaseType;
-import org.eclipse.osee.orcs.search.Operator;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchFlag;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
+import org.eclipse.osee.orcs.rest.model.search.SearchOp;
import org.eclipse.osee.orcs.search.QueryBuilder;
-import org.eclipse.osee.orcs.search.StringOperator;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -35,109 +41,57 @@ import org.mockito.MockitoAnnotations;
*/
public class AttributeTypePredicateHandlerTest {
- private class TestAttributeTypePredicateHandler extends AttributeTypePredicateHandler {
-
- StringOperator stringOperator;
- Operator operator;
- CaseType ct;
-
- @Override
- protected QueryBuilder and(QueryBuilder builder, Collection<IAttributeType> attributeTypes, StringOperator operator, CaseType ct, String value) {
- this.stringOperator = operator;
- this.ct = ct;
- return builder;
- }
-
- @Override
- protected QueryBuilder and(QueryBuilder builder, IAttributeType type, Operator operator, List<String> values) {
- this.operator = operator;
- return builder;
- }
-
- }
-
- // @formatter:off
- @Mock private QueryBuilder builder;
- // @formatter:on
+ @Mock
+ private QueryBuilder builder;
+ @Captor
+ private ArgumentCaptor<TokenDelimiterMatch> pattern;
+ @Captor
+ private ArgumentCaptor<Collection<String>> valueCaptor;
@Before
- public void setup() {
+ public void initialize() {
MockitoAnnotations.initMocks(this);
}
@Test
- public void testStringOperatorSelection() throws OseeCoreException {
- TestAttributeTypePredicateHandler handler = new TestAttributeTypePredicateHandler();
- List<String> typeParameters = Collections.singletonList("0x0123");
- List<SearchFlag> flags = Arrays.asList(SearchFlag.TOKENIZED_ANY);
- List<String> values = Collections.singletonList("value");
- Predicate testPredicate =
- new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, values);
- handler.handle(builder, testPredicate);
- Assert.assertEquals(StringOperator.TOKENIZED_ANY_ORDER, handler.stringOperator);
-
- flags = Arrays.asList(SearchFlag.TOKENIZED_ORDERED);
- testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, values);
- handler.handle(builder, testPredicate);
- Assert.assertEquals(StringOperator.TOKENIZED_MATCH_ORDER, handler.stringOperator);
-
- flags = Arrays.asList(SearchFlag.IGNORE_CASE);
- testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, values);
- handler.handle(builder, testPredicate);
- Assert.assertEquals(StringOperator.EQUALS, handler.stringOperator);
-
- testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.NOT_EQUALS, flags, values);
- handler.handle(builder, testPredicate);
- Assert.assertEquals(StringOperator.NOT_EQUALS, handler.stringOperator);
-
- testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.IN, flags, values);
- handler.handle(builder, testPredicate);
- Assert.assertEquals(StringOperator.CONTAINS, handler.stringOperator);
- }
-
- @Test
- public void testCaseTypeSelection() throws OseeCoreException {
- TestAttributeTypePredicateHandler handler = new TestAttributeTypePredicateHandler();
+ public void testStringSearchOptions() throws OseeCoreException {
+ AttributeTypePredicateHandler handler = new AttributeTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("0x0123");
- List<SearchFlag> flags = Arrays.asList(SearchFlag.IGNORE_CASE);
+ List<SearchFlag> flags = Collections.emptyList();
List<String> values = Collections.singletonList("value");
+ String delimiter = "delim";
Predicate testPredicate =
- new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, values);
+ new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, delimiter, values);
handler.handle(builder, testPredicate);
- Assert.assertEquals(CaseType.IGNORE_CASE, handler.ct);
-
- flags = Arrays.asList(SearchFlag.TOKENIZED, SearchFlag.IGNORE_CASE);
- testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, values);
- handler.handle(builder, testPredicate);
- Assert.assertEquals(CaseType.IGNORE_CASE, handler.ct);
-
- flags = Arrays.asList(SearchFlag.TOKENIZED, SearchFlag.MATCH_CASE);
- testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, values);
+ verify(builder).and(anyCollectionOf(IAttributeType.class), eq("value"), pattern.capture(),
+ eq(CaseType.IGNORE_CASE), eq(TokenOrderType.ANY_ORDER), eq(MatchTokenCountType.IGNORE_TOKEN_COUNT));
+ Assert.assertTrue(delimiter.equals(pattern.getValue().getPattern().pattern()));
+
+ reset(builder);
+ flags = Arrays.asList(SearchFlag.values());
+ testPredicate =
+ new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, "delim", values);
handler.handle(builder, testPredicate);
- Assert.assertEquals(CaseType.MATCH_CASE, handler.ct);
+ verify(builder).and(anyCollectionOf(IAttributeType.class), eq("value"), pattern.capture(),
+ eq(CaseType.MATCH_CASE), eq(TokenOrderType.MATCH_ORDER), eq(MatchTokenCountType.MATCH_TOKEN_COUNT));
}
@Test
public void testOperatorSelection() throws OseeCoreException {
- TestAttributeTypePredicateHandler handler = new TestAttributeTypePredicateHandler();
+ AttributeTypePredicateHandler handler = new AttributeTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("0x0123");
List<SearchFlag> flags = Arrays.asList(SearchFlag.MATCH_CASE);
List<String> values = Collections.singletonList("value");
Predicate testPredicate =
- new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, values);
- handler.handle(builder, testPredicate);
- Assert.assertEquals(Operator.EQUAL, handler.operator);
-
- testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.GREATER_THAN, flags, values);
- handler.handle(builder, testPredicate);
- Assert.assertEquals(Operator.GREATER_THAN, handler.operator);
-
- testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.LESS_THAN, flags, values);
+ new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.GREATER_THAN, flags, "", values);
handler.handle(builder, testPredicate);
- Assert.assertEquals(Operator.LESS_THAN, handler.operator);
+ verify(builder).and(any(IAttributeType.class), eq(Operator.GREATER_THAN), valueCaptor.capture());
+ Assert.assertEquals(values, valueCaptor.getValue());
- testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.NOT_EQUALS, flags, values);
+ reset(builder);
+ testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.LESS_THAN, flags, "", values);
handler.handle(builder, testPredicate);
- Assert.assertEquals(Operator.NOT_EQUAL, handler.operator);
+ verify(builder).and(any(IAttributeType.class), eq(Operator.LESS_THAN), valueCaptor.capture());
+ Assert.assertEquals(values, valueCaptor.getValue());
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java
index 0190a25b443..f9b01b5f77d 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java
@@ -10,23 +10,27 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.internal.search.predicate;
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import junit.framework.Assert;
import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.data.IRelationTypeSide;
-import org.eclipse.osee.framework.core.enums.RelationSide;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.rest.internal.search.Predicate;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchFlag;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchMethod;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchOp;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchFlag;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
+import org.eclipse.osee.orcs.rest.model.search.SearchOp;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -35,143 +39,142 @@ import org.mockito.MockitoAnnotations;
*/
public class ExistsTypePredicateHandlerTest {
- private class TestExistsTypePredicateHandler extends ExistsTypePredicateHandler {
+ @Mock
+ private QueryBuilder builder;
- Collection<IRelationTypeSide> relations;
- Collection<IAttributeType> attributeTypes;
-
- @Override
- protected QueryBuilder andRelTypeSideExists(QueryBuilder builder, Collection<IRelationTypeSide> relations) {
- this.relations = relations;
- return builder;
- }
-
- @Override
- protected QueryBuilder andAttrTypesExists(QueryBuilder builder, Collection<IAttributeType> attributeTypes) {
- this.attributeTypes = attributeTypes;
- return builder;
- }
-
- }
-
- // @formatter:off
- @Mock private QueryBuilder builder;
- // @formatter:on
+ @Captor
+ private ArgumentCaptor<IRelationType> relationTypeCaptor;
+ @Captor
+ private ArgumentCaptor<Collection<IAttributeType>> attrTypeSideCaptor;
@Before
- public void setup() {
+ public void initialize() {
MockitoAnnotations.initMocks(this);
}
@Test
- public void testHandleRelationTypeSides() throws OseeCoreException {
- TestExistsTypePredicateHandler handler = new TestExistsTypePredicateHandler();
+ public void testHandleRelationTypeSideA() throws OseeCoreException {
+ ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("relType");
//no flags for exists type
List<SearchFlag> flags = Collections.emptyList();
//for relation type sides, first char must be A or B denoting side, followed by relation type uuid
- String relationValue = "A12345";
+ String relationValue = "12345";
List<String> values = Collections.singletonList(relationValue);
- Predicate testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, values);
+ Predicate testPredicate =
+ new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, null, values);
handler.handle(builder, testPredicate);
+ verify(builder).andExists(relationTypeCaptor.capture());
+ Assert.assertEquals(1, relationTypeCaptor.getAllValues().size());
+ Assert.assertTrue(12345L == relationTypeCaptor.getValue().getGuid());
+ }
- Assert.assertEquals(1, handler.relations.size());
- IRelationTypeSide side = handler.relations.iterator().next();
- Assert.assertEquals(relationValue.substring(1), side.getGuid().toString());
- Assert.assertEquals(RelationSide.SIDE_A, side.getSide());
-
- //test side B
- relationValue = "B12345";
- values = Collections.singletonList(relationValue);
- testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, values);
+ @Test
+ public void testHandleRelationTypeSideB() throws OseeCoreException {
+ ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
+ List<String> typeParameters = Collections.singletonList("relType");
+ //no flags for exists type
+ List<SearchFlag> flags = Collections.emptyList();
+ String relationValue = "12345";
+ List<String> values = Collections.singletonList(relationValue);
+ Predicate testPredicate =
+ new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, null, values);
handler.handle(builder, testPredicate);
- Assert.assertEquals(1, handler.relations.size());
- side = handler.relations.iterator().next();
- Assert.assertEquals(relationValue.substring(1), side.getGuid().toString());
- Assert.assertEquals(RelationSide.SIDE_B, side.getSide());
+ verify(builder).andExists(relationTypeCaptor.capture());
+ Assert.assertEquals(1, relationTypeCaptor.getAllValues().size());
+ Assert.assertTrue(12345L == relationTypeCaptor.getValue().getGuid());
+ }
+ @Test
+ public void testHandleRelationTypeSideMultiples() throws OseeCoreException {
+ ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
+ List<String> typeParameters = Collections.singletonList("relType");
+ //no flags for exists type
+ List<SearchFlag> flags = Collections.emptyList();
//test multiples
- String relationValue1 = "A12345";
- String relationValue2 = "B34567";
- values = Arrays.asList(relationValue1, relationValue2);
- testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, values);
+ String relationValue1 = "12345";
+ String relationValue2 = "34567";
+ List<String> values = Arrays.asList(relationValue1, relationValue2);
+ Predicate testPredicate =
+ new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, null, values);
+
handler.handle(builder, testPredicate);
+ verify(builder, times(2)).andExists(relationTypeCaptor.capture());
+
+ Assert.assertEquals(2, relationTypeCaptor.getAllValues().size());
+ IRelationType type = relationTypeCaptor.getAllValues().get(0);
+ Assert.assertTrue(34567L == type.getGuid());
- Assert.assertEquals(2, handler.relations.size());
- boolean sideAMatched = false, sideBMatched = false;
- for (IRelationTypeSide rts : handler.relations) {
- if (rts.getSide() == RelationSide.SIDE_A) {
- sideAMatched = true;
- Assert.assertEquals(relationValue1.substring(1), rts.getGuid().toString());
- }
- if (rts.getSide() == RelationSide.SIDE_B) {
- sideBMatched = true;
- Assert.assertEquals(relationValue2.substring(1), rts.getGuid().toString());
- }
- }
- Assert.assertTrue(sideAMatched);
- Assert.assertTrue(sideBMatched);
+ type = relationTypeCaptor.getAllValues().get(1);
+ Assert.assertTrue(12345L == type.getGuid());
}
@Test
- public void testHandleAttrType() throws OseeCoreException {
- TestExistsTypePredicateHandler handler = new TestExistsTypePredicateHandler();
+ public void testHandleAttrTypeSingle() throws OseeCoreException {
+ ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("attrType");
//no flags for exists type
List<SearchFlag> flags = Collections.emptyList();
//for relation type sides, first char must be A or B denoting side, followed by relation type uuid
String attrUuid = "12345";
List<String> values = Collections.singletonList(attrUuid);
- Predicate testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, values);
+ Predicate testPredicate =
+ new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, null, values);
handler.handle(builder, testPredicate);
+ verify(builder).andExists(attrTypeSideCaptor.capture());
+ Assert.assertEquals(1, attrTypeSideCaptor.getAllValues().size());
+ List<IAttributeType> attrTypes = new ArrayList<IAttributeType>(attrTypeSideCaptor.getValue());
+ Assert.assertTrue(12345L == attrTypes.get(0).getGuid());
+ }
- Assert.assertEquals(1, handler.attributeTypes.size());
- IAttributeType type = handler.attributeTypes.iterator().next();
- Assert.assertEquals(attrUuid, type.getGuid().toString());
-
- //test multiples
+ @Test
+ public void testHandleAttrTypeMultiple() throws OseeCoreException {
+ ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
+ List<String> typeParameters = Collections.singletonList("attrType");
+ //no flags for exists type
+ List<SearchFlag> flags = Collections.emptyList();
String attrType1 = "12345";
String attrType2 = "34567";
- values = Arrays.asList(attrType1, attrType2);
- testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, values);
+ List<String> values = Arrays.asList(attrType1, attrType2);
+ Predicate testPredicate =
+ new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, "", values);
handler.handle(builder, testPredicate);
- Assert.assertEquals(2, handler.attributeTypes.size());
- boolean attr1Matched = false, attr2Matched = false;
- for (IAttributeType attr : handler.attributeTypes) {
- if (attr.getGuid().toString().equals(attrType1)) {
- attr1Matched = true;
- }
- if (attr.getGuid().toString().equals(attrType2)) {
- attr2Matched = true;
- }
- }
- Assert.assertTrue(attr1Matched);
- Assert.assertTrue(attr2Matched);
+ verify(builder).andExists(attrTypeSideCaptor.capture());
+ Assert.assertEquals(1, attrTypeSideCaptor.getAllValues().size());
+ List<IAttributeType> attrTypes = new ArrayList<IAttributeType>(attrTypeSideCaptor.getValue());
+ Assert.assertTrue(34567L == attrTypes.get(0).getGuid());
+ Assert.assertTrue(12345L == attrTypes.get(1).getGuid());
}
- @Test(expected = OseeArgumentException.class)
+ @Test
public void testHandleBadValues() throws OseeCoreException {
- TestExistsTypePredicateHandler handler = new TestExistsTypePredicateHandler();
+ ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
List<String> typeParameters = Collections.singletonList("attrType");
//no flags for exists type
List<SearchFlag> flags = Collections.emptyList();
- //for relation type sides, first char must be A or B denoting side, followed by relation type uuid
String value = "12A4G";
List<String> values = Collections.singletonList(value);
- Predicate testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, values);
+ Predicate testPredicate =
+ new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, "", values);
handler.handle(builder, testPredicate);
- Assert.assertEquals(0, handler.attributeTypes.size());
+ verify(builder, never()).andExists(anyCollectionOf(IAttributeType.class));
- value = "A12A4G";
+ value = "12A4G";
typeParameters = Collections.singletonList("relType");
values = Collections.singletonList(value);
- testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, values);
+ testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, "", values);
handler.handle(builder, testPredicate);
- Assert.assertEquals(0, handler.relations.size());
+ verify(builder, never()).andExists(any(IRelationTypeSide.class));
+ }
- testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, values);
+ @Test(expected = OseeCoreException.class)
+ public void testBadValuesThrowException() throws OseeCoreException {
+ ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
+ Predicate testPredicate =
+ new Predicate(SearchMethod.ATTRIBUTE_TYPE, Collections.singletonList("relType"), SearchOp.EQUALS, null, "",
+ Collections.singletonList("A12A4G"));
handler.handle(builder, testPredicate);
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IdsPredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IdsPredicateHandlerTest.java
index 703e2e9e412..e752a652fc4 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IdsPredicateHandlerTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IdsPredicateHandlerTest.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.internal.search.predicate;
+import static org.mockito.Mockito.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -17,11 +18,13 @@ import java.util.List;
import junit.framework.Assert;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.rest.internal.search.Predicate;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchMethod;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -30,86 +33,77 @@ import org.mockito.MockitoAnnotations;
*/
public class IdsPredicateHandlerTest {
- private class TestIdsPredicateHandler extends IdsPredicateHandler {
+ @Mock
+ private QueryBuilder builder;
- Collection<String> guids;
- Collection<Integer> rawIds;
-
- @Override
- protected QueryBuilder addGuids(QueryBuilder builder, Collection<String> guids) {
- this.guids = guids;
- return builder;
- }
-
- @Override
- protected QueryBuilder addIds(QueryBuilder builder, Collection<Integer> rawIds) {
- this.rawIds = rawIds;
- return builder;
- }
-
- }
-
- // @formatter:off
- @Mock private QueryBuilder builder;
- // @formatter:on
+ @Captor
+ private ArgumentCaptor<Collection<String>> guidsCaptor;
+ @Captor
+ private ArgumentCaptor<Collection<Integer>> localIdsCaptor;
@Before
- public void setup() {
+ public void initialize() {
MockitoAnnotations.initMocks(this);
}
@Test
- public void testHandle() throws OseeCoreException {
- TestIdsPredicateHandler handler = new TestIdsPredicateHandler();
+ public void testHandleLocalId() throws OseeCoreException {
+ IdsPredicateHandler handler = new IdsPredicateHandler();
//no type params, op, or flags for ids - any passed are ignored
//all digits get treated as artId
String id1 = "12345";
List<String> values = Collections.singletonList(id1);
- Predicate testPredicate = new Predicate(SearchMethod.IDS, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.IDS, null, null, null, null, values);
handler.handle(builder, testPredicate);
+ verify(builder).andLocalIds(localIdsCaptor.capture());
+ Assert.assertEquals(1, localIdsCaptor.getValue().size());
+ Assert.assertTrue(localIdsCaptor.getValue().contains(12345));
+ }
- Assert.assertEquals(1, handler.rawIds.size());
- Assert.assertNull(handler.guids);
- Assert.assertEquals(id1, handler.rawIds.iterator().next().toString());
-
- //if not all digits, treated as guid
- handler = new TestIdsPredicateHandler();
+ @Test
+ public void testHandleGuids() throws OseeCoreException {
+ IdsPredicateHandler handler = new IdsPredicateHandler();
+ // no type params, op, or flags for ids - any passed are ignored
+ // if not all digits, treated as guid
String id2 = "AGUID234";
- values = Collections.singletonList(id2);
- testPredicate = new Predicate(SearchMethod.IDS, null, null, null, values);
+ List<String> values = Collections.singletonList(id2);
+ Predicate testPredicate = new Predicate(SearchMethod.IDS, null, null, null, null, values);
handler.handle(builder, testPredicate);
+ verify(builder).andGuidsOrHrids(guidsCaptor.capture());
+ Assert.assertEquals(1, guidsCaptor.getValue().size());
+ Assert.assertTrue(guidsCaptor.getValue().contains(id2));
+ }
- Assert.assertNull(handler.rawIds);
- Assert.assertEquals(1, handler.guids.size());
- Assert.assertEquals(id2, handler.guids.iterator().next());
-
+ @Test
+ public void testHandleIdsAndGuids() throws OseeCoreException {
//test a rawId and guid
- handler = new TestIdsPredicateHandler();
- values = Arrays.asList(id1, id2);
- testPredicate = new Predicate(SearchMethod.IDS, null, null, null, values);
+ IdsPredicateHandler handler = new IdsPredicateHandler();
+ List<String> values = Arrays.asList("AGUID234", "12345");
+ Predicate testPredicate = new Predicate(SearchMethod.IDS, null, null, null, null, values);
handler.handle(builder, testPredicate);
+ verify(builder).andGuidsOrHrids(guidsCaptor.capture());
+ Assert.assertTrue(guidsCaptor.getValue().contains("AGUID234"));
+ Assert.assertEquals(1, guidsCaptor.getValue().size());
- Assert.assertEquals(1, handler.rawIds.size());
- Assert.assertEquals(1, handler.guids.size());
- Assert.assertEquals(id1, handler.rawIds.iterator().next().toString());
- Assert.assertEquals(id2, handler.guids.iterator().next());
-
+ verify(builder).andLocalIds(localIdsCaptor.capture());
+ Assert.assertEquals(1, localIdsCaptor.getValue().size());
+ Assert.assertTrue(localIdsCaptor.getValue().contains(12345));
}
@Test(expected = OseeArgumentException.class)
public void testHandleBadValues() throws OseeCoreException {
- TestIdsPredicateHandler handler = new TestIdsPredicateHandler();
- Predicate testPredicate = new Predicate(SearchMethod.IDS, null, null, null, null);
+ IdsPredicateHandler handler = new IdsPredicateHandler();
+ Predicate testPredicate = new Predicate(SearchMethod.IDS, null, null, null, null, null);
handler.handle(builder, testPredicate);
}
@Test(expected = OseeArgumentException.class)
public void testBadSearchMethod() throws OseeCoreException {
- TestIdsPredicateHandler handler = new TestIdsPredicateHandler();
+ IdsPredicateHandler handler = new IdsPredicateHandler();
String id1 = "12345";
List<String> values = Collections.singletonList(id1);
- Predicate testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, null, null, null, null, values);
handler.handle(builder, testPredicate);
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandlerTest.java
index f9d06d3130c..1b0060211e9 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandlerTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandlerTest.java
@@ -10,19 +10,23 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.internal.search.predicate;
+import static org.mockito.Mockito.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedList;
import java.util.List;
import junit.framework.Assert;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.rest.internal.search.Predicate;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchMethod;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -31,62 +35,61 @@ import org.mockito.MockitoAnnotations;
*/
public class IsOfTypePredicateHandlerTest {
- private class TestIsOfTypePredicateHandler extends IsOfTypePredicateHandler {
+ @Mock
+ private QueryBuilder builder;
- Collection<IArtifactType> artTypes;
-
- @Override
- protected QueryBuilder andIsOfType(QueryBuilder builder, Collection<IArtifactType> artTypes) {
- this.artTypes = artTypes;
- return builder;
- }
-
- }
-
- // @formatter:off
- @Mock private QueryBuilder builder;
- // @formatter:on
+ @Captor
+ private ArgumentCaptor<Collection<IArtifactType>> artifactTypesCaptor;
@Before
- public void setup() {
+ public void initialize() {
MockitoAnnotations.initMocks(this);
}
@Test
- public void testHandle() throws OseeCoreException {
- TestIsOfTypePredicateHandler handler = new TestIsOfTypePredicateHandler();
+ public void testHandleSingle() throws OseeCoreException {
+ IsOfTypePredicateHandler handler = new IsOfTypePredicateHandler();
//no type params, op, or flags for ids - any passed are ignored
String id1 = "12345";
List<String> values = Collections.singletonList(id1);
- Predicate testPredicate = new Predicate(SearchMethod.IS_OF_TYPE, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.IS_OF_TYPE, null, null, null, null, values);
handler.handle(builder, testPredicate);
+ verify(builder).andIsOfType(artifactTypesCaptor.capture());
+ Assert.assertEquals(1, artifactTypesCaptor.getValue().size());
+ // :-)
+ Assert.assertTrue(artifactTypesCaptor.getValue().iterator().next().getGuid().toString().equals(id1));
+ }
- Assert.assertEquals(1, handler.artTypes.size());
- Assert.assertEquals(id1, handler.artTypes.iterator().next().getGuid().toString());
-
+ @Test
+ public void testHandleMultiple() throws OseeCoreException {
+ IsOfTypePredicateHandler handler = new IsOfTypePredicateHandler();
+ String id1 = "12345";
String id2 = "45678";
- values = Arrays.asList(id1, id2);
+ List<String> values = Arrays.asList(id1, id2);
- testPredicate = new Predicate(SearchMethod.IS_OF_TYPE, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.IS_OF_TYPE, null, null, null, null, values);
handler.handle(builder, testPredicate);
-
- Assert.assertEquals(2, handler.artTypes.size());
+ verify(builder).andIsOfType(artifactTypesCaptor.capture());
+ Assert.assertEquals(2, artifactTypesCaptor.getValue().size());
+ List<IArtifactType> types = new LinkedList<IArtifactType>(artifactTypesCaptor.getValue());
+ Assert.assertEquals(id2, types.get(0).getGuid().toString());
+ Assert.assertEquals(id1, types.get(1).getGuid().toString());
}
@Test(expected = OseeArgumentException.class)
public void testHandleBadValues() throws OseeCoreException {
- TestIsOfTypePredicateHandler handler = new TestIsOfTypePredicateHandler();
- Predicate testPredicate = new Predicate(SearchMethod.IS_OF_TYPE, null, null, null, null);
+ IsOfTypePredicateHandler handler = new IsOfTypePredicateHandler();
+ Predicate testPredicate = new Predicate(SearchMethod.IS_OF_TYPE, null, null, null, null, null);
handler.handle(builder, testPredicate);
}
@Test(expected = OseeArgumentException.class)
public void testBadSearchMethod() throws OseeCoreException {
- TestIsOfTypePredicateHandler handler = new TestIsOfTypePredicateHandler();
+ IsOfTypePredicateHandler handler = new IsOfTypePredicateHandler();
String id1 = "12345";
List<String> values = Collections.singletonList(id1);
- Predicate testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, null, null, null, values);
+ Predicate testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, null, null, null, null, values);
handler.handle(builder, testPredicate);
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandlerTest.java
new file mode 100644
index 00000000000..2ee66d7db08
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandlerTest.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.internal.search.predicate;
+
+import static org.mockito.Mockito.*;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.data.IRelationTypeSide;
+import org.eclipse.osee.framework.core.enums.RelationSide;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchFlag;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
+import org.eclipse.osee.orcs.rest.model.search.SearchOp;
+import org.eclipse.osee.orcs.search.QueryBuilder;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * @author John Misinco
+ */
+public class RelatedToPredicateHandlerTest {
+
+ @Mock
+ private QueryBuilder builder;
+ @Captor
+ private ArgumentCaptor<Collection<Integer>> idsCaptor;
+ @Captor
+ private ArgumentCaptor<IRelationTypeSide> rtsCaptor;
+
+ @Before
+ public void initialize() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testRelatedToLocalIds() throws OseeCoreException {
+ RelatedToPredicateHandler handler = new RelatedToPredicateHandler();
+ List<SearchFlag> emptySearchFlags = Collections.emptyList();
+ Predicate testPredicate =
+ new Predicate(SearchMethod.RELATED_TO, Arrays.asList("A1", "B2"), SearchOp.EQUALS, emptySearchFlags, "",
+ Arrays.asList("4", "5"));
+ handler.handle(builder, testPredicate);
+ verify(builder, times(2)).andRelatedToLocalIds(rtsCaptor.capture(), idsCaptor.capture());
+ List<IRelationTypeSide> rts = rtsCaptor.getAllValues();
+ Assert.assertEquals(2, rts.size());
+ verifyRelationTypeSide(rts.get(0), "A1");
+ verifyRelationTypeSide(rts.get(1), "B2");
+
+ List<Collection<Integer>> ids = idsCaptor.getAllValues();
+ Assert.assertEquals(2, ids.size());
+ ids.containsAll(Arrays.asList(4, 5));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testUnsupportedOperation() throws OseeCoreException {
+ RelatedToPredicateHandler handler = new RelatedToPredicateHandler();
+ List<SearchFlag> emptySearchFlags = Collections.emptyList();
+ Predicate testPredicate =
+ new Predicate(SearchMethod.RELATED_TO, Arrays.asList("A1", "B2"), SearchOp.EQUALS, emptySearchFlags, "",
+ Arrays.asList(GUID.create()));
+ handler.handle(builder, testPredicate);
+ }
+
+ private void verifyRelationTypeSide(IRelationTypeSide rts, String input) {
+ if (input.startsWith("A")) {
+ Assert.assertEquals(RelationSide.SIDE_A, rts.getSide());
+ } else {
+ Assert.assertEquals(RelationSide.SIDE_B, rts.getSide());
+ }
+ Assert.assertTrue(rts.getGuid().equals(Long.parseLong(input.substring(1))));
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
index 516a2f81e09..0c57b80a5b5 100644
--- a/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
@@ -17,5 +17,7 @@ Import-Package: javax.ws.rs,
org.eclipse.osee.framework.jdk.core.util,
org.eclipse.osee.orcs,
org.eclipse.osee.orcs.data,
+ org.eclipse.osee.orcs.rest.model,
+ org.eclipse.osee.orcs.rest.model.search,
org.eclipse.osee.orcs.search
Require-Bundle: org.eclipse.core.runtime
diff --git a/plugins/org.eclipse.osee.orcs.rest/build.properties b/plugins/org.eclipse.osee.orcs.rest/build.properties
index a3ef7214fa9..52a96646f91 100644
--- a/plugins/org.eclipse.osee.orcs.rest/build.properties
+++ b/plugins/org.eclipse.osee.orcs.rest/build.properties
@@ -7,4 +7,5 @@ additional.bundles = org.eclipse.osee.orcs,\
javax.ws.rs,\
org.eclipse.osee.framework.core.model,\
org.eclipse.osee.framework.core,\
- org.eclipse.osee.framework.jdk.core
+ org.eclipse.osee.framework.jdk.core,\
+ org.eclipse.osee.orcs.rest.model
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/ArtifactSearch_V1.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/ArtifactSearch_V1.java
index 81afa7838ac..00b4f41032e 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/ArtifactSearch_V1.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/ArtifactSearch_V1.java
@@ -10,22 +10,24 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.internal.search;
-import java.util.Map;
+import java.util.LinkedList;
+import java.util.List;
+import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
+import javax.ws.rs.POST;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.data.HasLocalId;
import org.eclipse.osee.orcs.rest.internal.OrcsApplication;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.DslTranslatorImpl;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.PredicateHandlerFactory;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchDsl;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchDsl.DslTranslator;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchMethod;
+import org.eclipse.osee.orcs.rest.internal.search.dsl.DslFactory;
+import org.eclipse.osee.orcs.rest.internal.search.dsl.DslTranslator;
+import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchQueryBuilder;
+import org.eclipse.osee.orcs.rest.model.search.SearchParameters;
+import org.eclipse.osee.orcs.rest.model.search.SearchResult;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
@@ -35,15 +37,11 @@ import org.eclipse.osee.orcs.search.QueryFactory;
*/
public class ArtifactSearch_V1 extends ArtifactSearch {
- private final SearchDsl dsl;
+ private final SearchQueryBuilder searchQueryBuilder;
public ArtifactSearch_V1(UriInfo uriInfo, Request request, String branchUuid) {
super(uriInfo, request, branchUuid);
-
- Map<SearchMethod, PredicateHandler> handlers = PredicateHandlerFactory.getHandlers();
- DslTranslator translator = new DslTranslatorImpl();
- // Can have a single instance of this
- dsl = new SearchDsl(handlers, translator);
+ searchQueryBuilder = DslFactory.createQueryBuilder();
}
/**
@@ -102,45 +100,53 @@ public class ArtifactSearch_V1 extends ArtifactSearch {
@GET
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public SearchResult getSearchWithQueryParams(@QueryParam("alt") String alt, @QueryParam("fields") String fields, @QueryParam("q") String rawQuery, @QueryParam("fromTx") int fromTransaction, @QueryParam("inherits") boolean includeTypeInheritance, @QueryParam("cached") boolean includeCache, @QueryParam("includeDeleted") boolean includeDeleted) throws OseeCoreException {
- return search(alt, fields, rawQuery, fromTransaction, includeTypeInheritance, includeCache, includeDeleted);
+ DslTranslator translator = DslFactory.createTranslator();
+ SearchParameters params =
+ new SearchParameters(getBranchUuid(), translator.translate(rawQuery), alt, fields, fromTransaction,
+ includeTypeInheritance, includeCache, includeDeleted);
+ return search(params);
}
- // @GET
- // @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- // public SearchResult getSearchWithMatrixParams(@MatrixParam("alt") String alt, @MatrixParam("fields") String fields, @MatrixParam("q") String rawQuery, @MatrixParam("fromTx") int fromTransaction, @MatrixParam("inherits") boolean includeTypeInheritance, @MatrixParam("cached") boolean includeCache, @MatrixParam("includeDeleted") boolean includeDeleted) throws OseeCoreException {
- // return search(alt, fields, rawQuery, fromTransaction, includeTypeInheritance, includeCache, includeDeleted);
- // }
+ @POST
+ @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ public SearchResult getSearchWithMatrixParams(SearchParameters parameters) throws OseeCoreException {
+ return search(parameters);
+ }
- private SearchResult search(String alt, String fields, String rawQuery, int fromTransaction, boolean includeTypeInheritance, boolean includeCache, boolean includeDeleted) throws OseeCoreException {
+ private SearchResult search(SearchParameters params) throws OseeCoreException {
long startTime = System.currentTimeMillis();
- IOseeBranch branch = TokenFactory.createBranch(getBranchUuid(), "searchBranch");
-
QueryFactory qFactory = OrcsApplication.getOrcsApi().getQueryFactory(null); // Fix this
- QueryBuilder builder = dsl.build(qFactory, branch, rawQuery);
+ QueryBuilder builder = searchQueryBuilder.build(qFactory, params);
- builder.includeCache(includeCache);
- builder.includeTypeInheritance(includeTypeInheritance);
- builder.includeDeleted(includeDeleted);
+ builder.includeCache(params.isIncludeCache());
+ builder.includeTypeInheritance(params.isIncludeTypeInheritance());
+ builder.includeDeleted(params.isIncludeDeleted());
- if (fromTransaction > 0) {
- builder.fromTransaction(fromTransaction);
+ if (params.getFromTx() > 0) {
+ builder.fromTransaction(params.getFromTx());
}
- SearchResult result = new SearchResult();
- SearchParameters params = new SearchParameters(getBranchUuid(), rawQuery, alt, fields);
- result.setPredicates(dsl.getPredicates());
- result.setSearchParams(params);
- if (fields.equals("count")) {
+ SearchResult result;
+ if (params.getFields().equals("count")) {
+ result = new SearchResult();
int total = builder.getCount();
result.setTotal(total);
+ } else if (params.getFields().equals("ids")) {
+ List<Integer> localIds = new LinkedList<Integer>();
+ for (HasLocalId art : builder.getResultsAsLocalIds()) {
+ localIds.add(art.getLocalId());
+ }
+ result = new SearchResult();
+ result.setIds(localIds);
+ result.setTotal(localIds.size());
} else {
- // builder.createSearch();
- // builder.createSearchWithMatches();
throw new UnsupportedOperationException();
}
+ result.setSearchParams(params);
result.setSearchTime(System.currentTimeMillis() - startTime);
return result;
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/PredicateHandler.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/PredicateHandler.java
index 6b25cdbb664..e807620bacb 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/PredicateHandler.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/PredicateHandler.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.orcs.rest.internal.search;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
import org.eclipse.osee.orcs.search.QueryBuilder;
/**
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/SearchParameters.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/SearchParameters.java
deleted file mode 100644
index cdbf24f8cce..00000000000
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/SearchParameters.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.rest.internal.search;
-
-/**
- * @author John R. Misinco
- * @author Roberto E. Escobar
- */
-public class SearchParameters {
-
- private String branchUuid;
- private String query;
- private String alt;
- private String fields;
-
- public SearchParameters() {
-
- }
-
- public SearchParameters(String uuid, String query, String alt, String fields) {
- this.branchUuid = uuid;
- this.query = query;
- this.alt = alt;
- this.fields = fields;
- }
-
- public String getBranchUuid() {
- return branchUuid;
- }
-
- public String getQuery() {
- return query;
- }
-
- public String getAlt() {
- return alt;
- }
-
- public String getFields() {
- return fields;
- }
-
- public void setBranchUuid(String uuid) {
- this.branchUuid = uuid;
- }
-
- public void setQuery(String query) {
- this.query = query;
- }
-
- public void setAlt(String alt) {
- this.alt = alt;
- }
-
- public void setFields(String fields) {
- this.fields = fields;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/PredicateHandlerFactory.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslFactory.java
index 40470116c19..d15fdb73051 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/PredicateHandlerFactory.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslFactory.java
@@ -17,12 +17,27 @@ import org.eclipse.osee.orcs.rest.internal.search.predicate.AttributeTypePredica
import org.eclipse.osee.orcs.rest.internal.search.predicate.ExistsTypePredicateHandler;
import org.eclipse.osee.orcs.rest.internal.search.predicate.IdsPredicateHandler;
import org.eclipse.osee.orcs.rest.internal.search.predicate.IsOfTypePredicateHandler;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
/**
* @author John R. Misinco
* @author Roberto E. Escobar
*/
-public class PredicateHandlerFactory {
+public class DslFactory {
+
+ private static SearchQueryBuilder builder;
+
+ public synchronized static SearchQueryBuilder createQueryBuilder() {
+ if (builder == null) {
+ Map<SearchMethod, PredicateHandler> handlers = DslFactory.getHandlers();
+ builder = new SearchQueryBuilder(handlers);
+ }
+ return builder;
+ }
+
+ public static DslTranslator createTranslator() {
+ return new DslTranslatorImpl_V1();
+ }
public static Map<SearchMethod, PredicateHandler> getHandlers() {
Map<SearchMethod, PredicateHandler> handlers = new HashMap<SearchMethod, PredicateHandler>();
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslator.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslator.java
new file mode 100644
index 00000000000..3232bd67502
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslator.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.internal.search.dsl;
+
+import java.util.List;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+
+/**
+ * @author John R. Misinco
+ */
+public interface DslTranslator {
+
+ List<Predicate> translate(String rawString) throws OseeCoreException;
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImpl.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImpl_V1.java
index 32a424023b5..ae7984191d5 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImpl.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImpl_V1.java
@@ -13,62 +13,70 @@ package org.eclipse.osee.orcs.rest.internal.search.dsl;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
+import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.orcs.rest.internal.search.Predicate;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchDsl.DslTranslator;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchFlag;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
+import org.eclipse.osee.orcs.rest.model.search.SearchOp;
/**
* @author John R. Misinco
* @author Roberto E. Escobar
*/
-public class DslTranslatorImpl implements DslTranslator {
+public class DslTranslatorImpl_V1 implements DslTranslator {
private static final String ARGUMENT_REGEX = ":([^&\\]]+)";
- private static final Pattern queryPattern = Pattern.compile("(\\[[^\\]]+\\])");
+ private static final Pattern queryPattern = Pattern.compile("\\]&\\[");
private static final Pattern typePattern = Pattern.compile("t" + ARGUMENT_REGEX);
private static final Pattern typeParametersPattern = Pattern.compile("tp" + ARGUMENT_REGEX);
private static final Pattern opPattern = Pattern.compile("op" + ARGUMENT_REGEX);
private static final Pattern flagsPattern = Pattern.compile("f" + ARGUMENT_REGEX);
private static final Pattern valuePattern = Pattern.compile("v" + ARGUMENT_REGEX);
+ private static final Pattern delimiterPattern = Pattern.compile("d:'(.+)'");
- private final Matcher queryMatcher, typeMatcher, opMatcher, flagsMatcher, valueMatcher, typeParametersMatcher;
+ private final Matcher typeMatcher, opMatcher, flagsMatcher, valueMatcher, typeParametersMatcher, delimiterMatcher;
+ private Scanner scanner;
- public DslTranslatorImpl() {
- queryMatcher = queryPattern.matcher("");
+ public DslTranslatorImpl_V1() {
typeMatcher = typePattern.matcher("");
opMatcher = opPattern.matcher("");
flagsMatcher = flagsPattern.matcher("");
valueMatcher = valuePattern.matcher("");
typeParametersMatcher = typeParametersPattern.matcher("");
+ delimiterMatcher = delimiterPattern.matcher("");
}
@Override
public List<Predicate> translate(String rawString) throws OseeCoreException {
List<Predicate> predicates = new LinkedList<Predicate>();
- queryMatcher.reset(rawString);
- while (queryMatcher.find()) {
- String queryBlock = queryMatcher.group(1);
+ scanner = new Scanner(rawString);
+ scanner.useDelimiter(queryPattern);
+ while (scanner.hasNext()) {
+ String queryBlock = scanner.next();
typeMatcher.reset(queryBlock);
typeParametersMatcher.reset(queryBlock);
opMatcher.reset(queryBlock);
flagsMatcher.reset(queryBlock);
valueMatcher.reset(queryBlock);
+ delimiterMatcher.reset(queryBlock);
String type = getMatch(typeMatcher);
String typeParams = getMatch(typeParametersMatcher);
String op = getMatch(opMatcher);
String flags = getMatch(flagsMatcher);
String value = getMatch(valueMatcher);
+ String delimiter = getMatch(delimiterMatcher);
- predicates.add(createPredicate(type, typeParams, op, flags, value));
+ predicates.add(createPredicate(type, typeParams, op, flags, delimiter, value));
}
return predicates;
}
- private Predicate createPredicate(String type, String typeParameters, String op, String flags, String value) throws OseeCoreException {
+ private Predicate createPredicate(String type, String typeParameters, String op, String flags, String delimiter, String value) throws OseeCoreException {
SearchMethod searchMethod = SearchMethod.fromString(type);
SearchOp searchOp = SearchOp.fromString(op);
@@ -81,14 +89,14 @@ public class DslTranslatorImpl implements DslTranslator {
List<String> values = Arrays.asList(value.split(",\\s*"));
List<String> typeParams = Arrays.asList(typeParameters.split(",\\s*"));
- return new Predicate(searchMethod, typeParams, searchOp, searchFlags, values);
+ return new Predicate(searchMethod, typeParams, searchOp, searchFlags, delimiter, values);
}
private String getMatch(Matcher m) {
if (m.find()) {
return m.group(1);
}
- return "";
+ return Strings.EMPTY_STRING;
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDsl.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchQueryBuilder.java
index 884a15a728b..e97d74ed782 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDsl.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchQueryBuilder.java
@@ -13,10 +13,13 @@ package org.eclipse.osee.orcs.rest.internal.search.dsl;
import java.util.List;
import java.util.Map;
import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.Conditions;
-import org.eclipse.osee.orcs.rest.internal.search.Predicate;
import org.eclipse.osee.orcs.rest.internal.search.PredicateHandler;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
+import org.eclipse.osee.orcs.rest.model.search.SearchParameters;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
@@ -24,41 +27,30 @@ import org.eclipse.osee.orcs.search.QueryFactory;
* @author John R. Misinco
* @author Roberto E. Escobar
*/
-public class SearchDsl {
-
- public static interface DslTranslator {
-
- List<Predicate> translate(String rawString) throws OseeCoreException;
-
- }
+public class SearchQueryBuilder {
private final Map<SearchMethod, PredicateHandler> handlers;
- private final DslTranslator translator;
- private List<Predicate> predicates;
- public SearchDsl(Map<SearchMethod, PredicateHandler> handlers, DslTranslator translator) {
+ public SearchQueryBuilder(Map<SearchMethod, PredicateHandler> handlers) {
this.handlers = handlers;
- this.translator = translator;
}
- public QueryBuilder build(QueryFactory queryFactory, IOseeBranch branch, String rawQuery) throws OseeCoreException {
+ public QueryBuilder build(QueryFactory queryFactory, SearchParameters params) throws OseeCoreException {
Conditions.checkNotNull(queryFactory, "queryFactory");
- Conditions.checkNotNull(branch, "branch");
- Conditions.checkNotNull(rawQuery, "rawQuery");
- predicates = translator.translate(rawQuery);
- QueryBuilder builder = queryFactory.fromBranch(branch);
- for (Predicate predicate : predicates) {
- SearchMethod method = predicate.getType();
- if (handlers.containsKey(method)) {
+ Conditions.checkNotNull(params, "params");
+ IOseeBranch searchBranch = TokenFactory.createBranch(params.getBranchUuid(), "searchBranch");
+ QueryBuilder builder = queryFactory.fromBranch(searchBranch);
+ List<Predicate> predicates = params.getPredicates();
+ if (predicates != null) {
+ for (Predicate predicate : predicates) {
+ SearchMethod method = predicate.getType();
PredicateHandler handler = handlers.get(method);
- builder = handler.handle(builder, predicate);
+ if (handler != null) {
+ builder = handler.handle(builder, predicate);
+ }
}
}
return builder;
}
- public List<Predicate> getPredicates() {
- return predicates;
- }
-
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandler.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandler.java
index 87c4f8b0d8d..9608d5b67e2 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandler.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandler.java
@@ -14,18 +14,20 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.enums.CaseType;
+import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
+import org.eclipse.osee.framework.core.enums.Operator;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
+import org.eclipse.osee.framework.core.enums.TokenOrderType;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.Conditions;
-import org.eclipse.osee.orcs.rest.internal.search.Predicate;
import org.eclipse.osee.orcs.rest.internal.search.PredicateHandler;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchFlag;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchMethod;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchOp;
-import org.eclipse.osee.orcs.search.CaseType;
-import org.eclipse.osee.orcs.search.Operator;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchFlag;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
+import org.eclipse.osee.orcs.rest.model.search.SearchOp;
import org.eclipse.osee.orcs.search.QueryBuilder;
-import org.eclipse.osee.orcs.search.StringOperator;
/**
* @author John R. Misinco
@@ -42,40 +44,31 @@ public class AttributeTypePredicateHandler implements PredicateHandler {
List<String> typeParameters = predicate.getTypeParameters();
Collection<IAttributeType> attributeTypes = PredicateHandlerUtil.getIAttributeTypes(typeParameters);
SearchOp op = predicate.getOp();
- List<String> values = predicate.getValues();
+ Collection<String> values = predicate.getValues();
Conditions.checkNotNull(values, "values");
- if (isAttributeTokenSearch(op, flags) && !containsAny(Collections.singleton(op), SearchOp.GREATER_THAN,
- SearchOp.LESS_THAN)) {
- StringOperator operator = getStringOperator(op, flags);
- Conditions.checkNotNull(operator, "string operator",
- "Query error - cannot determine string operator from [%s]:[%s]", op, flags);
+ if (!containsAny(Collections.singleton(op), SearchOp.GREATER_THAN, SearchOp.LESS_THAN)) {
CaseType ct = getCaseType(flags);
- for (String value : values) {
- builder = and(builder, attributeTypes, operator, ct, value);
+ TokenOrderType orderType = getTokenOrderType(flags);
+ MatchTokenCountType countType = getMatchTokenCountType(flags);
+ if (values.size() == 1) {
+ builder =
+ builder.and(attributeTypes, values.iterator().next(),
+ TokenDelimiterMatch.custom(predicate.getDelimiter()), ct, orderType, countType);
+ } else {
+ for (IAttributeType type : attributeTypes) {
+ builder = builder.and(type, getOperator(op), values);
+ }
}
} else {
Operator operator = getOperator(op);
for (IAttributeType type : attributeTypes) {
- builder = and(builder, type, operator, values);
+ builder = builder.and(type, operator, values);
}
}
return builder;
}
- protected QueryBuilder and(QueryBuilder builder, Collection<IAttributeType> attributeTypes, StringOperator operator, CaseType ct, String value) throws OseeCoreException {
- return builder.and(attributeTypes, operator, ct, value);
- }
-
- protected QueryBuilder and(QueryBuilder builder, IAttributeType type, Operator operator, List<String> values) throws OseeCoreException {
- return builder.and(type, operator, values);
- }
-
- private boolean isAttributeTokenSearch(SearchOp op, List<SearchFlag> flags) {
- return containsAny(flags, SearchFlag.TOKENIZED, SearchFlag.TOKENIZED_ANY, SearchFlag.TOKENIZED_ORDERED,
- SearchFlag.IGNORE_CASE) || containsAny(Collections.singleton(op), SearchOp.IN);
- }
-
private boolean containsAny(Collection<?> data, Object... values) {
boolean result = false;
for (Object object : values) {
@@ -88,43 +81,24 @@ public class AttributeTypePredicateHandler implements PredicateHandler {
}
private CaseType getCaseType(List<SearchFlag> flags) {
- if (flags.contains(SearchFlag.MATCH_CASE)) {
+ if (flags != null && flags.contains(SearchFlag.MATCH_CASE)) {
return CaseType.MATCH_CASE;
}
return CaseType.IGNORE_CASE;
}
- // EQUALS(), // Exact Match as in Strings.equals
- // NOT_EQUALS(), // inverse of exact match - !Strings.equals
- // CONTAINS,
- // TOKENIZED_ANY_ORDER,
- // TOKENIZED_MATCH_ORDER
-
- private StringOperator getStringOperator(SearchOp op, List<SearchFlag> flags) {
- StringOperator toReturn;
-
- if (flags.contains(SearchFlag.TOKENIZED_ANY)) {
- toReturn = StringOperator.TOKENIZED_ANY_ORDER;
- } else if (flags.contains(SearchFlag.TOKENIZED_ORDERED)) {
- toReturn = StringOperator.TOKENIZED_MATCH_ORDER;
- } else {
- switch (op) {
- case EQUALS:
- toReturn = StringOperator.EQUALS;
- break;
- case NOT_EQUALS:
- toReturn = StringOperator.NOT_EQUALS;
- break;
- case IN:
- toReturn = StringOperator.CONTAINS;
- break;
- default:
- toReturn = null;
- break;
+ private TokenOrderType getTokenOrderType(List<SearchFlag> flags) {
+ if (flags != null && flags.contains(SearchFlag.MATCH_TOKEN_ORDER)) {
+ return TokenOrderType.MATCH_ORDER;
+ }
+ return TokenOrderType.ANY_ORDER;
+ }
- }
+ private MatchTokenCountType getMatchTokenCountType(List<SearchFlag> flags) {
+ if (flags != null && flags.contains(SearchFlag.MATCH_TOKEN_COUNT)) {
+ return MatchTokenCountType.MATCH_TOKEN_COUNT;
}
- return toReturn;
+ return MatchTokenCountType.IGNORE_TOKEN_COUNT;
}
// EQUAL("="), // Exact Match as in Strings.equals
@@ -138,9 +112,6 @@ public class AttributeTypePredicateHandler implements PredicateHandler {
if (op.equals(SearchOp.LESS_THAN)) {
return Operator.LESS_THAN;
}
- if (op.equals(SearchOp.NOT_EQUALS)) {
- return Operator.NOT_EQUAL;
- }
return Operator.EQUAL;
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandler.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandler.java
index 731d9f44c98..04c20b2cdee 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandler.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandler.java
@@ -13,13 +13,13 @@ package org.eclipse.osee.orcs.rest.internal.search.predicate;
import java.util.Collection;
import java.util.List;
import org.eclipse.osee.framework.core.data.IAttributeType;
-import org.eclipse.osee.framework.core.data.IRelationTypeSide;
+import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.Conditions;
-import org.eclipse.osee.orcs.rest.internal.search.Predicate;
import org.eclipse.osee.orcs.rest.internal.search.PredicateHandler;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchMethod;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
import org.eclipse.osee.orcs.search.QueryBuilder;
/**
@@ -34,7 +34,7 @@ public class ExistsTypePredicateHandler implements PredicateHandler {
throw new OseeArgumentException("This predicate handler only supports [%s]", SearchMethod.EXISTS_TYPE);
}
List<String> typeParameters = predicate.getTypeParameters();
- List<String> values = predicate.getValues();
+ Collection<String> values = predicate.getValues();
Conditions.checkNotNull(typeParameters, "typeParameters");
Conditions.checkNotNull(values, "values");
@@ -43,24 +43,17 @@ public class ExistsTypePredicateHandler implements PredicateHandler {
String existsType = typeParameters.get(0);
if ("attrType".equals(existsType)) {
Collection<IAttributeType> attributeTypes = PredicateHandlerUtil.getIAttributeTypes(values);
- builder = andAttrTypesExists(builder, attributeTypes);
+ if (!attributeTypes.isEmpty()) {
+ builder.andExists(attributeTypes);
+ }
} else if ("relType".equals(existsType)) {
- Collection<IRelationTypeSide> relations = PredicateHandlerUtil.getIRelationTypeSides(values);
- builder = andRelTypeSideExists(builder, relations);
+ for (IRelationType rt : PredicateHandlerUtil.getIRelationTypes(values)) {
+ builder.andExists(rt);
+ }
}
}
return builder;
}
- protected QueryBuilder andRelTypeSideExists(QueryBuilder builder, Collection<IRelationTypeSide> relations) throws OseeCoreException {
- for (IRelationTypeSide rts : relations) {
- builder = builder.andExists(rts);
- }
- return builder;
- }
-
- protected QueryBuilder andAttrTypesExists(QueryBuilder builder, Collection<IAttributeType> attributeTypes) throws OseeCoreException {
- return builder.andExists(attributeTypes);
- }
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IdsPredicateHandler.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IdsPredicateHandler.java
index 2794283563a..e5b2001d196 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IdsPredicateHandler.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IdsPredicateHandler.java
@@ -12,13 +12,12 @@ package org.eclipse.osee.orcs.rest.internal.search.predicate;
import java.util.Collection;
import java.util.HashSet;
-import java.util.List;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.Conditions;
-import org.eclipse.osee.orcs.rest.internal.search.Predicate;
import org.eclipse.osee.orcs.rest.internal.search.PredicateHandler;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchMethod;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
import org.eclipse.osee.orcs.search.QueryBuilder;
/**
@@ -32,8 +31,7 @@ public class IdsPredicateHandler implements PredicateHandler {
if (predicate.getType() != SearchMethod.IDS) {
throw new OseeArgumentException("This predicate handler only supports [%s]", SearchMethod.IDS);
}
- QueryBuilder theBuilder = builder;
- List<String> values = predicate.getValues();
+ Collection<String> values = predicate.getValues();
Conditions.checkNotNull(values, "values");
@@ -48,20 +46,13 @@ public class IdsPredicateHandler implements PredicateHandler {
}
if (!guids.isEmpty()) {
- theBuilder = addGuids(builder, guids);
+ builder.andGuidsOrHrids(guids);
}
if (!rawIds.isEmpty()) {
- theBuilder = addIds(builder, rawIds);
+ builder.andLocalIds(rawIds);
}
- return theBuilder;
+ return builder;
}
- protected QueryBuilder addGuids(QueryBuilder builder, Collection<String> guids) throws OseeCoreException {
- return builder.andGuidsOrHrids(guids);
- }
-
- protected QueryBuilder addIds(QueryBuilder builder, Collection<Integer> rawIds) throws OseeCoreException {
- return builder.andLocalIds(rawIds);
- }
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandler.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandler.java
index 13b96179bec..2d04869ed44 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandler.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/IsOfTypePredicateHandler.java
@@ -11,14 +11,13 @@
package org.eclipse.osee.orcs.rest.internal.search.predicate;
import java.util.Collection;
-import java.util.List;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.Conditions;
-import org.eclipse.osee.orcs.rest.internal.search.Predicate;
import org.eclipse.osee.orcs.rest.internal.search.PredicateHandler;
-import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchMethod;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
import org.eclipse.osee.orcs.search.QueryBuilder;
/**
@@ -32,10 +31,12 @@ public class IsOfTypePredicateHandler implements PredicateHandler {
if (predicate.getType() != SearchMethod.IS_OF_TYPE) {
throw new OseeArgumentException("This predicate handler only supports [%s]", SearchMethod.IS_OF_TYPE);
}
- List<String> values = predicate.getValues();
+ Collection<String> values = predicate.getValues();
Conditions.checkNotNull(values, "values");
Collection<IArtifactType> artTypes = PredicateHandlerUtil.getIArtifactTypes(values);
- builder = andIsOfType(builder, artTypes);
+ if (!artTypes.isEmpty()) {
+ builder.andIsOfType(artTypes);
+ }
return builder;
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/PredicateHandlerUtil.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/PredicateHandlerUtil.java
index 289f4d58d42..7baab311f5d 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/PredicateHandlerUtil.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/PredicateHandlerUtil.java
@@ -12,9 +12,9 @@ package org.eclipse.osee.orcs.rest.internal.search.predicate;
import java.util.Collection;
import java.util.HashSet;
-import java.util.List;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.data.IRelationTypeSide;
import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.RelationSide;
@@ -27,7 +27,7 @@ import org.eclipse.osee.framework.core.util.HexUtil;
*/
public class PredicateHandlerUtil {
- public static Collection<IAttributeType> getIAttributeTypes(List<String> types) throws OseeCoreException {
+ public static Collection<IAttributeType> getIAttributeTypes(Collection<String> types) throws OseeCoreException {
Collection<IAttributeType> attrTypes = new HashSet<IAttributeType>();
for (String value : types) {
long uuid = parseUuid(value);
@@ -38,7 +38,7 @@ public class PredicateHandlerUtil {
return attrTypes;
}
- public static Collection<IArtifactType> getIArtifactTypes(List<String> types) throws OseeCoreException {
+ public static Collection<IArtifactType> getIArtifactTypes(Collection<String> types) throws OseeCoreException {
Collection<IArtifactType> artTypes = new HashSet<IArtifactType>();
for (String value : types) {
long uuid = parseUuid(value);
@@ -49,7 +49,18 @@ public class PredicateHandlerUtil {
return artTypes;
}
- public static Collection<IRelationTypeSide> getIRelationTypeSides(List<String> rels) throws OseeCoreException {
+ public static Collection<IRelationType> getIRelationTypes(Collection<String> rels) throws OseeCoreException {
+ Collection<IRelationType> types = new HashSet<IRelationType>();
+ for (String value : rels) {
+ long longUuid = parseUuid(value);
+ if (longUuid != -1L) {
+ types.add(TokenFactory.createRelationType(longUuid, "SearchRelationType"));
+ }
+ }
+ return types;
+ }
+
+ public static Collection<IRelationTypeSide> getIRelationTypeSides(Collection<String> rels) throws OseeCoreException {
Collection<IRelationTypeSide> relSides = new HashSet<IRelationTypeSide>();
for (String value : rels) {
char sideChar = value.charAt(0);
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandler.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandler.java
new file mode 100644
index 00000000000..67113005efb
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandler.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.rest.internal.search.predicate;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import org.eclipse.osee.framework.core.data.IRelationTypeSide;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.eclipse.osee.orcs.rest.internal.search.PredicateHandler;
+import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
+import org.eclipse.osee.orcs.search.QueryBuilder;
+
+/**
+ * @author John Misinco
+ */
+public class RelatedToPredicateHandler implements PredicateHandler {
+
+ @Override
+ public QueryBuilder handle(QueryBuilder builder, Predicate predicate) throws OseeCoreException {
+ if (predicate.getType() != SearchMethod.RELATED_TO) {
+ throw new OseeArgumentException("This predicate handler only supports [%s]", SearchMethod.EXISTS_TYPE);
+ }
+ List<String> typeParameters = predicate.getTypeParameters();
+ Collection<String> values = predicate.getValues();
+
+ Conditions.checkNotNull(typeParameters, "typeParameters");
+ Conditions.checkNotNull(values, "values");
+
+ Collection<IRelationTypeSide> types = PredicateHandlerUtil.getIRelationTypeSides(typeParameters);
+ Collection<Integer> localIds = new LinkedList<Integer>();
+
+ for (String value : values) {
+ if (GUID.isValid(value)) {
+ throw new UnsupportedOperationException();
+ } else {
+ localIds.add(Integer.parseInt(value));
+ }
+ }
+
+ if (!localIds.isEmpty()) {
+ for (IRelationTypeSide rts : types) {
+ builder.andRelatedToLocalIds(rts, localIds);
+ }
+ }
+ return builder;
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsAttributeLoadingTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsAttributeLoadingTest.java
index c08f187be6e..d621a0261f5 100644
--- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsAttributeLoadingTest.java
+++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsAttributeLoadingTest.java
@@ -18,6 +18,7 @@ import junit.framework.Assert;
import org.eclipse.osee.framework.core.data.ResultSet;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.Operator;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
import org.eclipse.osee.orcs.ApplicationContext;
@@ -26,7 +27,6 @@ import org.eclipse.osee.orcs.OrcsIntegrationRule;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.db.mock.OseeDatabase;
import org.eclipse.osee.orcs.db.mock.OsgiService;
-import org.eclipse.osee.orcs.search.Operator;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
import org.junit.Rule;
diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsAttributeSearchTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsAttributeSearchTest.java
index 6d911be16a6..e88590ca22c 100644
--- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsAttributeSearchTest.java
+++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsAttributeSearchTest.java
@@ -15,8 +15,13 @@ import java.util.List;
import java.util.Map;
import junit.framework.Assert;
import org.eclipse.osee.framework.core.data.ResultSet;
+import org.eclipse.osee.framework.core.enums.CaseType;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
+import org.eclipse.osee.framework.core.enums.Operator;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
+import org.eclipse.osee.framework.core.enums.TokenOrderType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
@@ -26,11 +31,8 @@ import org.eclipse.osee.orcs.OrcsIntegrationRule;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.db.mock.OseeDatabase;
import org.eclipse.osee.orcs.db.mock.OsgiService;
-import org.eclipse.osee.orcs.search.CaseType;
-import org.eclipse.osee.orcs.search.Operator;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
-import org.eclipse.osee.orcs.search.StringOperator;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -93,8 +95,8 @@ public class OrcsAttributeSearchTest {
BranchCache branchCache = orcsApi.getBranchCache();
Branch branch = branchCache.getBySoleName("SAW_Bld_1");
QueryBuilder builder =
- queryFactory.fromBranch(branch).and(CoreAttributeTypes.WordTemplateContent,
- StringOperator.TOKENIZED_ANY_ORDER, CaseType.IGNORE_CASE, "commands");
+ queryFactory.fromBranch(branch).and(CoreAttributeTypes.WordTemplateContent, "commands",
+ TokenDelimiterMatch.ANY, TokenOrderType.MATCH_ORDER, CaseType.IGNORE_CASE, MatchTokenCountType.IGNORE_TOKEN_COUNT);
ResultSet<ArtifactReadable> resultSet = builder.getResults();
List<ArtifactReadable> moreArts = resultSet.getList();
diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java
index 4fa7a4ca571..ebab15aae20 100644
--- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java
+++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java
@@ -18,10 +18,13 @@ import java.util.List;
import junit.framework.Assert;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.enums.CaseType;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.enums.Operator;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.orcs.ApplicationContext;
@@ -31,12 +34,9 @@ import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
import org.eclipse.osee.orcs.db.mock.OseeDatabase;
import org.eclipse.osee.orcs.db.mock.OsgiService;
-import org.eclipse.osee.orcs.search.CaseType;
import org.eclipse.osee.orcs.search.Match;
-import org.eclipse.osee.orcs.search.Operator;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
-import org.eclipse.osee.orcs.search.StringOperator;
import org.eclipse.osee.orcs.utility.MatchComparator;
import org.eclipse.osee.orcs.utility.NameComparator;
import org.eclipse.osee.orcs.utility.SortOrder;
@@ -249,7 +249,7 @@ public class OrcsQueryTest {
@Test
public void testQueryAttributeKeyword() throws OseeCoreException {
QueryBuilder builder = factory.fromBranch(TestBranches.SAW_Bld_1);
- builder.and(CoreAttributeTypes.Name, StringOperator.TOKENIZED_ANY_ORDER, CaseType.IGNORE_CASE, "REQUIREMENTS");
+ builder.and(CoreAttributeTypes.Name, "REQUIREMENTS", TokenDelimiterMatch.ANY);
Assert.assertEquals(7, builder.getCount());
List<ArtifactReadable> requirements = builder.getResults().getList();
@@ -284,7 +284,7 @@ public class OrcsQueryTest {
// @formatter:on
QueryBuilder builder1 = factory.fromBranch(TestBranches.SAW_Bld_1);
- builder1.and(CoreAttributeTypes.Name, StringOperator.TOKENIZED_ANY_ORDER, CaseType.MATCH_CASE, "REQUIREMENTS");
+ builder1.and(CoreAttributeTypes.Name, "REQUIREMENTS", TokenDelimiterMatch.ANY, CaseType.MATCH_CASE);
Assert.assertEquals(0, builder1.getCount());
}
diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsRelationLoadingTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsRelationLoadingTest.java
index 3d68accd5b7..209575cc1d5 100644
--- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsRelationLoadingTest.java
+++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsRelationLoadingTest.java
@@ -18,6 +18,7 @@ import org.eclipse.osee.framework.core.data.ResultSet;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.enums.Operator;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.ApplicationContext;
import org.eclipse.osee.orcs.OrcsApi;
@@ -26,7 +27,6 @@ import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.GraphReadable;
import org.eclipse.osee.orcs.db.mock.OseeDatabase;
import org.eclipse.osee.orcs.db.mock.OsgiService;
-import org.eclipse.osee.orcs.search.Operator;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
import org.junit.Assert;
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/ApiTester.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/ApiTester.java
index 6751c2c50e0..0b487566295 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/ApiTester.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/ApiTester.java
@@ -14,6 +14,7 @@ import java.util.List;
import org.eclipse.osee.framework.core.data.ResultSet;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.Operator;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.ApplicationContext;
import org.eclipse.osee.orcs.OrcsApi;
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/QueryBuilder.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/QueryBuilder.java
index 6bf498b44a6..5eccaa56674 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/QueryBuilder.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/QueryBuilder.java
@@ -19,9 +19,12 @@ import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.data.IRelationTypeSide;
import org.eclipse.osee.framework.core.data.ResultSet;
import org.eclipse.osee.framework.core.data.TokenFactory;
+import org.eclipse.osee.framework.core.enums.Operator;
+import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
+import org.eclipse.osee.orcs.data.HasLocalId;
/**
* @author Ryan D. Brooks
@@ -148,14 +151,14 @@ public interface QueryBuilder {
* Search criteria that finds an attribute of the given type with its current value relative to the given value based
* on the operator provided.
*/
- QueryBuilder and(IAttributeType attributeType, StringOperator operator, CaseType match, String value) throws OseeCoreException;
+ QueryBuilder and(IAttributeType attributeType, String value, QueryOption... options) throws OseeCoreException;
/**
* Search criteria that finds an attribute of the given type with its current value exactly equal (or not equal) to
* any one of the given literal values. If the list only contains one value, then the search is conducted exactly as
* if the single value constructor was called. This search does not support the (* wildcard) for multiple values.
*/
- QueryBuilder and(Collection<? extends IAttributeType> attributeTypes, StringOperator operator, CaseType match, String value) throws OseeCoreException;
+ QueryBuilder and(Collection<? extends IAttributeType> attributeTypes, String value, QueryOption... options) throws OseeCoreException;
/**
* Search for related artifacts
@@ -200,6 +203,13 @@ public interface QueryBuilder {
ResultSet<Match<ArtifactReadable, AttributeReadable<?>>> getMatches() throws OseeCoreException;
/**
+ * Executes query
+ *
+ * @return localIds search results
+ */
+ ResultSet<HasLocalId> getResultsAsLocalIds() throws OseeCoreException;
+
+ /**
* Count search results
*/
int getCount() throws OseeCoreException;
@@ -223,4 +233,11 @@ public interface QueryBuilder {
*/
CancellableCallable<ResultSet<Match<ArtifactReadable, AttributeReadable<?>>>> createSearchWithMatches() throws OseeCoreException;
+ /**
+ * Schedule query and find matching locations
+ *
+ * @return localIds search results
+ */
+ CancellableCallable<ResultSet<HasLocalId>> createSearchResultsAsLocalIds() throws OseeCoreException;
+
}

Back to the top