You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@streams.apache.org by steveblackmon <gi...@git.apache.org> on 2015/03/29 23:07:08 UTC

[GitHub] incubator-streams pull request: STREAMS-259

GitHub user steveblackmon opened a pull request:

    https://github.com/apache/incubator-streams/pull/207

    STREAMS-259

    streams-verbs and streams-filters

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/steveblackmon/incubator-streams STREAMS-259

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-streams/pull/207.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #207
    
----
commit 0b2ba6cb6f145605b48a1275299d797cb6375163
Author: sblackmon <sb...@w2odigital.com>
Date:   2014-12-16T16:39:11Z

    streams-verbs and streams-filters

commit 70a58d027b69bfcc8ad44f93c97c4836f2e5ca06
Author: sblackmon <sb...@w2odigital.com>
Date:   2015-01-06T17:04:45Z

    test

commit 083c5ab47522b405babfa6776ec8718324644964
Author: Steve Blackmon (@steveblackmon) <sb...@apache.org>
Date:   2015-03-29T20:37:29Z

    update for changes since branch

commit d00839d1b776a2771fb0885968162aac189e283c
Author: Steve Blackmon (@steveblackmon) <sb...@apache.org>
Date:   2015-03-29T21:00:10Z

    READMEs

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-streams pull request: STREAMS-259

Posted by steveblackmon <gi...@git.apache.org>.
Github user steveblackmon commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/207#discussion_r27531107
  
    --- Diff: streams-components/streams-filters/src/main/java/org/apache/streams/filters/VerbDefinitionKeepFilter.java ---
    @@ -0,0 +1,95 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +package org.apache.streams.filters;
    +
    +import com.google.common.base.Preconditions;
    +import com.google.common.collect.Lists;
    +import org.apache.streams.core.StreamsDatum;
    +import org.apache.streams.core.StreamsProcessor;
    +import org.apache.streams.pojo.json.Activity;
    +import org.apache.streams.verbs.ObjectCombination;
    +import org.apache.streams.verbs.VerbDefinition;
    +import org.apache.streams.verbs.VerbDefinitionResolver;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.*;
    +
    +/**
    + * Checks one or more verb definitions against a stream of Activity documents, and drops any activities
    + * which do not match the filter criteria.
    + */
    +public class VerbDefinitionKeepFilter implements StreamsProcessor {
    +
    +    private static final String STREAMS_ID = "VerbDefinitionKeepFilter";
    +    private static final Logger LOGGER = LoggerFactory.getLogger(VerbDefinitionKeepFilter.class);
    +
    +    protected Set<VerbDefinition> verbDefinitionSet;
    +    protected VerbDefinitionResolver resolver;
    +
    +    public VerbDefinitionKeepFilter() {
    +        // get with reflection
    +    }
    +
    +    public VerbDefinitionKeepFilter(Set<VerbDefinition> verbDefinitionSet) {
    +        this();
    +        this.verbDefinitionSet = verbDefinitionSet;
    +    }
    +
    +    @Override
    +    public List<StreamsDatum> process(StreamsDatum entry) {
    +
    +        List<StreamsDatum> result = Lists.newArrayList();
    +
    +        LOGGER.debug("{} filtering {}", STREAMS_ID, entry.getDocument().getClass());
    +
    +        Activity activity;
    +
    +        Preconditions.checkArgument(entry.getDocument() instanceof Activity);
    +
    +        activity = (Activity) entry.getDocument();
    +
    +        boolean match = false;
    +        for( VerbDefinition verbDefinition : verbDefinitionSet)
    +            if( verbDefinition.getValue() != null &&
    +                verbDefinition.getValue().equals(activity.getVerb()))
    +                for (ObjectCombination objectCombination : verbDefinition.getObjects())
    +                    if (VerbDefinitionResolver.filter(activity, objectCombination) == true)
    +                        match = true;
    --- End diff --
    
    yes.  refactored both filter processors to call new util VerbDefinitionMatchUtil.match


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-streams pull request: STREAMS-259

Posted by mfranklin <gi...@git.apache.org>.
Github user mfranklin commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/207#discussion_r27501388
  
    --- Diff: streams-components/streams-filters/src/main/java/org/apache/streams/filters/VerbDefinitionDropFilter.java ---
    @@ -0,0 +1,96 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +package org.apache.streams.filters;
    +
    +import com.google.common.base.Preconditions;
    +import com.google.common.collect.Lists;
    +import org.apache.streams.core.StreamsDatum;
    +import org.apache.streams.core.StreamsProcessor;
    +import org.apache.streams.pojo.json.Activity;
    +import org.apache.streams.verbs.ObjectCombination;
    +import org.apache.streams.verbs.VerbDefinition;
    +import org.apache.streams.verbs.VerbDefinitionResolver;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.List;
    +import java.util.Set;
    +
    +/**
    + * Checks one or more verb definitions against a stream of Activity documents, and drops any activities
    + * which match the filter criteria.
    + */
    +public class VerbDefinitionDropFilter implements StreamsProcessor {
    +
    +    private static final String STREAMS_ID = "VerbDefinitionDropFilter";
    +    private static final Logger LOGGER = LoggerFactory.getLogger(VerbDefinitionDropFilter.class);
    +
    +    protected Set<VerbDefinition> verbDefinitionSet;
    +    protected VerbDefinitionResolver resolver;
    +
    +    public VerbDefinitionDropFilter() {
    +        // get with reflection
    +    }
    +
    +    public VerbDefinitionDropFilter(Set<VerbDefinition> verbDefinitionSet) {
    +        this();
    +        this.verbDefinitionSet = verbDefinitionSet;
    +    }
    +
    +    @Override
    +    public List<StreamsDatum> process(StreamsDatum entry) {
    +
    +        List<StreamsDatum> result = Lists.newArrayList();
    +
    +        LOGGER.debug("{} filtering {}", STREAMS_ID, entry.getDocument().getClass());
    +
    +        Activity activity;
    +
    +        Preconditions.checkArgument(entry.getDocument() instanceof Activity);
    +
    +        activity = (Activity) entry.getDocument();
    +
    +        boolean match = false;
    +        for( VerbDefinition verbDefinition : verbDefinitionSet)
    +            if( verbDefinition.getValue() != null &&
    +                verbDefinition.getValue().equals(activity.getVerb()))
    +                for (ObjectCombination objectCombination : verbDefinition.getObjects())
    +                    if (VerbDefinitionResolver.filter(activity, objectCombination) == true)
    +                        match = true;
    --- End diff --
    
    don't you want to break on the first match so that you don't have to test any additional values?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-streams pull request: STREAMS-259

Posted by mfranklin <gi...@git.apache.org>.
Github user mfranklin commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/207#discussion_r27500768
  
    --- Diff: streams-components/streams-filters/pom.xml ---
    @@ -0,0 +1,74 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<!--
    +  ~ Licensed to the Apache Software Foundation (ASF) under one
    +  ~ or more contributor license agreements.  See the NOTICE file
    +  ~ distributed with this work for additional information
    +  ~ regarding copyright ownership.  The ASF licenses this file
    +  ~ to you under the Apache License, Version 2.0 (the
    +  ~ "License"); you may not use this file except in compliance
    +  ~
    +  ~   http://www.apache.org/licenses/LICENSE-2.0
    +  ~
    +  ~ Unless required by applicable law or agreed to in writing,
    +  ~ software distributed under the License is distributed on an
    +  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +  ~ KIND, either express or implied.  See the License for the
    +  ~ specific language governing permissions and limitations
    +  ~ under the License.
    +  -->
    +<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/xsd/maven-4.0.0.xsd">
    +    <modelVersion>4.0.0</modelVersion>
    +
    +    <parent>
    +        <groupId>org.apache.streams</groupId>
    +        <artifactId>streams-components</artifactId>
    +        <version>0.2-incubating-SNAPSHOT</version>
    +        <relativePath>../pom.xml</relativePath>
    +    </parent>
    +
    +    <artifactId>streams-filters</artifactId>
    +
    +    <name>streams-filters</name>
    +
    +    <dependencies>
    +
    +        <dependency>
    +            <groupId>org.apache.streams</groupId>
    +            <artifactId>streams-config</artifactId>
    +        </dependency>
    +        <dependency>
    +            <groupId>com.typesafe</groupId>
    +            <artifactId>config</artifactId>
    +        </dependency>
    +        <dependency>
    +            <groupId>org.apache.streams</groupId>
    +            <artifactId>streams-core</artifactId>
    +        </dependency>
    +        <dependency>
    +            <groupId>org.apache.streams</groupId>
    +            <artifactId>streams-pojo</artifactId>
    +        </dependency>
    +        <dependency>
    +            <groupId>org.apache.streams</groupId>
    +            <artifactId>streams-verbs</artifactId>
    +            <version>${project.version}</version>
    --- End diff --
    
    Move the version management to the <dependencyManagement> section


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-streams pull request: STREAMS-259

Posted by mfranklin <gi...@git.apache.org>.
Github user mfranklin commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/207#discussion_r27509719
  
    --- Diff: streams-verbs/pom.xml ---
    @@ -0,0 +1,148 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<!--
    +  ~ Licensed to the Apache Software Foundation (ASF) under one
    +  ~ or more contributor license agreements.  See the NOTICE file
    +  ~ distributed with this work for additional information
    +  ~ regarding copyright ownership.  The ASF licenses this file
    +  ~ to you under the Apache License, Version 2.0 (the
    +  ~ "License"); you may not use this file except in compliance
    +  ~
    +  ~   http://www.apache.org/licenses/LICENSE-2.0
    +  ~
    +  ~ Unless required by applicable law or agreed to in writing,
    +  ~ software distributed under the License is distributed on an
    +  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +  ~ KIND, either express or implied.  See the License for the
    +  ~ specific language governing permissions and limitations
    +  ~ under the License.
    +  -->
    +<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/xsd/maven-4.0.0.xsd">
    +    <modelVersion>4.0.0</modelVersion>
    +
    +    <parent>
    +        <groupId>org.apache.streams</groupId>
    +        <artifactId>streams-project</artifactId>
    +        <version>0.2-incubating-SNAPSHOT</version>
    +        <relativePath>../pom.xml</relativePath>
    +    </parent>
    +
    +    <artifactId>streams-verbs</artifactId>
    +
    +    <name>streams-verbs</name>
    +
    +    <dependencies>
    +
    +        <dependency>
    +            <groupId>org.jsonschema2pojo</groupId>
    +            <artifactId>jsonschema2pojo-core</artifactId>
    +            <type>jar</type>
    +            <scope>compile</scope>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>org.apache.streams</groupId>
    +            <artifactId>streams-pojo</artifactId>
    +            <version>${project.version}</version>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>com.fasterxml.jackson.core</groupId>
    +            <artifactId>jackson-core</artifactId>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>com.fasterxml.jackson.core</groupId>
    +            <artifactId>jackson-databind</artifactId>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>com.fasterxml.jackson.datatype</groupId>
    +            <artifactId>jackson-datatype-joda</artifactId>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>joda-time</groupId>
    +            <artifactId>joda-time</artifactId>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>nz.net.ultraq.jaxb</groupId>
    +            <artifactId>jaxb-utilities</artifactId>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>commons-io</groupId>
    +            <artifactId>commons-io</artifactId>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>com.google.guava</groupId>
    +            <artifactId>guava</artifactId>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>org.antlr</groupId>
    +            <artifactId>stringtemplate</artifactId>
    +            <version>4.0.2</version>
    --- End diff --
    
    `<dependencyManagement>`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-streams pull request: STREAMS-259

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-streams/pull/207


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-streams pull request: STREAMS-259

Posted by mfranklin <gi...@git.apache.org>.
Github user mfranklin commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/207#discussion_r27500936
  
    --- Diff: streams-components/streams-filters/src/main/java/org/apache/streams/filters/VerbDefinitionDropFilter.java ---
    @@ -0,0 +1,96 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +package org.apache.streams.filters;
    +
    +import com.google.common.base.Preconditions;
    +import com.google.common.collect.Lists;
    +import org.apache.streams.core.StreamsDatum;
    +import org.apache.streams.core.StreamsProcessor;
    +import org.apache.streams.pojo.json.Activity;
    +import org.apache.streams.verbs.ObjectCombination;
    +import org.apache.streams.verbs.VerbDefinition;
    +import org.apache.streams.verbs.VerbDefinitionResolver;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.List;
    +import java.util.Set;
    +
    +/**
    + * Checks one or more verb definitions against a stream of Activity documents, and drops any activities
    + * which match the filter criteria.
    + */
    +public class VerbDefinitionDropFilter implements StreamsProcessor {
    +
    +    private static final String STREAMS_ID = "VerbDefinitionDropFilter";
    --- End diff --
    
    Don't you want this to be public?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-streams pull request: STREAMS-259

Posted by steveblackmon <gi...@git.apache.org>.
Github user steveblackmon commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/207#discussion_r27530824
  
    --- Diff: streams-components/streams-filters/pom.xml ---
    @@ -0,0 +1,74 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<!--
    +  ~ Licensed to the Apache Software Foundation (ASF) under one
    +  ~ or more contributor license agreements.  See the NOTICE file
    +  ~ distributed with this work for additional information
    +  ~ regarding copyright ownership.  The ASF licenses this file
    +  ~ to you under the Apache License, Version 2.0 (the
    +  ~ "License"); you may not use this file except in compliance
    +  ~
    +  ~   http://www.apache.org/licenses/LICENSE-2.0
    +  ~
    +  ~ Unless required by applicable law or agreed to in writing,
    +  ~ software distributed under the License is distributed on an
    +  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +  ~ KIND, either express or implied.  See the License for the
    +  ~ specific language governing permissions and limitations
    +  ~ under the License.
    +  -->
    +<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/xsd/maven-4.0.0.xsd">
    +    <modelVersion>4.0.0</modelVersion>
    +
    +    <parent>
    +        <groupId>org.apache.streams</groupId>
    +        <artifactId>streams-components</artifactId>
    +        <version>0.2-incubating-SNAPSHOT</version>
    +        <relativePath>../pom.xml</relativePath>
    +    </parent>
    +
    +    <artifactId>streams-filters</artifactId>
    +
    +    <name>streams-filters</name>
    +
    +    <dependencies>
    +
    +        <dependency>
    +            <groupId>org.apache.streams</groupId>
    +            <artifactId>streams-config</artifactId>
    +        </dependency>
    +        <dependency>
    +            <groupId>com.typesafe</groupId>
    +            <artifactId>config</artifactId>
    +        </dependency>
    +        <dependency>
    +            <groupId>org.apache.streams</groupId>
    +            <artifactId>streams-core</artifactId>
    +        </dependency>
    +        <dependency>
    +            <groupId>org.apache.streams</groupId>
    +            <artifactId>streams-pojo</artifactId>
    +        </dependency>
    +        <dependency>
    +            <groupId>org.apache.streams</groupId>
    +            <artifactId>streams-verbs</artifactId>
    +            <version>${project.version}</version>
    --- End diff --
    
    done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-streams pull request: STREAMS-259

Posted by steveblackmon <gi...@git.apache.org>.
Github user steveblackmon commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/207#discussion_r27530829
  
    --- Diff: streams-components/streams-filters/src/main/java/org/apache/streams/filters/VerbDefinitionDropFilter.java ---
    @@ -0,0 +1,96 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +package org.apache.streams.filters;
    +
    +import com.google.common.base.Preconditions;
    +import com.google.common.collect.Lists;
    +import org.apache.streams.core.StreamsDatum;
    +import org.apache.streams.core.StreamsProcessor;
    +import org.apache.streams.pojo.json.Activity;
    +import org.apache.streams.verbs.ObjectCombination;
    +import org.apache.streams.verbs.VerbDefinition;
    +import org.apache.streams.verbs.VerbDefinitionResolver;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.List;
    +import java.util.Set;
    +
    +/**
    + * Checks one or more verb definitions against a stream of Activity documents, and drops any activities
    + * which match the filter criteria.
    + */
    +public class VerbDefinitionDropFilter implements StreamsProcessor {
    +
    +    private static final String STREAMS_ID = "VerbDefinitionDropFilter";
    --- End diff --
    
    yes. fixed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-streams pull request: STREAMS-259

Posted by mfranklin <gi...@git.apache.org>.
Github user mfranklin commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/207#discussion_r27505660
  
    --- Diff: streams-components/streams-filters/src/main/java/org/apache/streams/filters/VerbDefinitionKeepFilter.java ---
    @@ -0,0 +1,95 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +package org.apache.streams.filters;
    +
    +import com.google.common.base.Preconditions;
    +import com.google.common.collect.Lists;
    +import org.apache.streams.core.StreamsDatum;
    +import org.apache.streams.core.StreamsProcessor;
    +import org.apache.streams.pojo.json.Activity;
    +import org.apache.streams.verbs.ObjectCombination;
    +import org.apache.streams.verbs.VerbDefinition;
    +import org.apache.streams.verbs.VerbDefinitionResolver;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.*;
    +
    +/**
    + * Checks one or more verb definitions against a stream of Activity documents, and drops any activities
    + * which do not match the filter criteria.
    + */
    +public class VerbDefinitionKeepFilter implements StreamsProcessor {
    +
    +    private static final String STREAMS_ID = "VerbDefinitionKeepFilter";
    +    private static final Logger LOGGER = LoggerFactory.getLogger(VerbDefinitionKeepFilter.class);
    +
    +    protected Set<VerbDefinition> verbDefinitionSet;
    +    protected VerbDefinitionResolver resolver;
    +
    +    public VerbDefinitionKeepFilter() {
    +        // get with reflection
    +    }
    +
    +    public VerbDefinitionKeepFilter(Set<VerbDefinition> verbDefinitionSet) {
    +        this();
    +        this.verbDefinitionSet = verbDefinitionSet;
    +    }
    +
    +    @Override
    +    public List<StreamsDatum> process(StreamsDatum entry) {
    +
    +        List<StreamsDatum> result = Lists.newArrayList();
    +
    +        LOGGER.debug("{} filtering {}", STREAMS_ID, entry.getDocument().getClass());
    +
    +        Activity activity;
    +
    +        Preconditions.checkArgument(entry.getDocument() instanceof Activity);
    +
    +        activity = (Activity) entry.getDocument();
    +
    +        boolean match = false;
    +        for( VerbDefinition verbDefinition : verbDefinitionSet)
    +            if( verbDefinition.getValue() != null &&
    +                verbDefinition.getValue().equals(activity.getVerb()))
    +                for (ObjectCombination objectCombination : verbDefinition.getObjects())
    +                    if (VerbDefinitionResolver.filter(activity, objectCombination) == true)
    +                        match = true;
    --- End diff --
    
    same comment as other filter. also can this be abstracted to a utility?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-streams pull request: STREAMS-259

Posted by steveblackmon <gi...@git.apache.org>.
Github user steveblackmon commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/207#discussion_r27531122
  
    --- Diff: streams-verbs/pom.xml ---
    @@ -0,0 +1,148 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<!--
    +  ~ Licensed to the Apache Software Foundation (ASF) under one
    +  ~ or more contributor license agreements.  See the NOTICE file
    +  ~ distributed with this work for additional information
    +  ~ regarding copyright ownership.  The ASF licenses this file
    +  ~ to you under the Apache License, Version 2.0 (the
    +  ~ "License"); you may not use this file except in compliance
    +  ~
    +  ~   http://www.apache.org/licenses/LICENSE-2.0
    +  ~
    +  ~ Unless required by applicable law or agreed to in writing,
    +  ~ software distributed under the License is distributed on an
    +  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +  ~ KIND, either express or implied.  See the License for the
    +  ~ specific language governing permissions and limitations
    +  ~ under the License.
    +  -->
    +<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/xsd/maven-4.0.0.xsd">
    +    <modelVersion>4.0.0</modelVersion>
    +
    +    <parent>
    +        <groupId>org.apache.streams</groupId>
    +        <artifactId>streams-project</artifactId>
    +        <version>0.2-incubating-SNAPSHOT</version>
    +        <relativePath>../pom.xml</relativePath>
    +    </parent>
    +
    +    <artifactId>streams-verbs</artifactId>
    +
    +    <name>streams-verbs</name>
    +
    +    <dependencies>
    +
    +        <dependency>
    +            <groupId>org.jsonschema2pojo</groupId>
    +            <artifactId>jsonschema2pojo-core</artifactId>
    +            <type>jar</type>
    +            <scope>compile</scope>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>org.apache.streams</groupId>
    +            <artifactId>streams-pojo</artifactId>
    +            <version>${project.version}</version>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>com.fasterxml.jackson.core</groupId>
    +            <artifactId>jackson-core</artifactId>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>com.fasterxml.jackson.core</groupId>
    +            <artifactId>jackson-databind</artifactId>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>com.fasterxml.jackson.datatype</groupId>
    +            <artifactId>jackson-datatype-joda</artifactId>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>joda-time</groupId>
    +            <artifactId>joda-time</artifactId>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>nz.net.ultraq.jaxb</groupId>
    +            <artifactId>jaxb-utilities</artifactId>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>commons-io</groupId>
    +            <artifactId>commons-io</artifactId>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>com.google.guava</groupId>
    +            <artifactId>guava</artifactId>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>org.antlr</groupId>
    +            <artifactId>stringtemplate</artifactId>
    +            <version>4.0.2</version>
    --- End diff --
    
    done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-streams pull request: STREAMS-259

Posted by mfranklin <gi...@git.apache.org>.
Github user mfranklin commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/207#discussion_r27509581
  
    --- Diff: streams-verbs/pom.xml ---
    @@ -0,0 +1,148 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<!--
    +  ~ Licensed to the Apache Software Foundation (ASF) under one
    +  ~ or more contributor license agreements.  See the NOTICE file
    +  ~ distributed with this work for additional information
    +  ~ regarding copyright ownership.  The ASF licenses this file
    +  ~ to you under the Apache License, Version 2.0 (the
    +  ~ "License"); you may not use this file except in compliance
    +  ~
    +  ~   http://www.apache.org/licenses/LICENSE-2.0
    +  ~
    +  ~ Unless required by applicable law or agreed to in writing,
    +  ~ software distributed under the License is distributed on an
    +  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +  ~ KIND, either express or implied.  See the License for the
    +  ~ specific language governing permissions and limitations
    +  ~ under the License.
    +  -->
    +<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/xsd/maven-4.0.0.xsd">
    +    <modelVersion>4.0.0</modelVersion>
    +
    +    <parent>
    +        <groupId>org.apache.streams</groupId>
    +        <artifactId>streams-project</artifactId>
    +        <version>0.2-incubating-SNAPSHOT</version>
    +        <relativePath>../pom.xml</relativePath>
    +    </parent>
    +
    +    <artifactId>streams-verbs</artifactId>
    +
    +    <name>streams-verbs</name>
    +
    +    <dependencies>
    +
    +        <dependency>
    +            <groupId>org.jsonschema2pojo</groupId>
    +            <artifactId>jsonschema2pojo-core</artifactId>
    +            <type>jar</type>
    +            <scope>compile</scope>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>org.apache.streams</groupId>
    +            <artifactId>streams-pojo</artifactId>
    +            <version>${project.version}</version>
    --- End diff --
    
    Move to `<dependencyManagement>` section


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-streams pull request: STREAMS-259

Posted by steveblackmon <gi...@git.apache.org>.
Github user steveblackmon commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/207#discussion_r27530837
  
    --- Diff: streams-components/streams-filters/src/main/java/org/apache/streams/filters/VerbDefinitionDropFilter.java ---
    @@ -0,0 +1,96 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +package org.apache.streams.filters;
    +
    +import com.google.common.base.Preconditions;
    +import com.google.common.collect.Lists;
    +import org.apache.streams.core.StreamsDatum;
    +import org.apache.streams.core.StreamsProcessor;
    +import org.apache.streams.pojo.json.Activity;
    +import org.apache.streams.verbs.ObjectCombination;
    +import org.apache.streams.verbs.VerbDefinition;
    +import org.apache.streams.verbs.VerbDefinitionResolver;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.List;
    +import java.util.Set;
    +
    +/**
    + * Checks one or more verb definitions against a stream of Activity documents, and drops any activities
    + * which match the filter criteria.
    + */
    +public class VerbDefinitionDropFilter implements StreamsProcessor {
    +
    +    private static final String STREAMS_ID = "VerbDefinitionDropFilter";
    +    private static final Logger LOGGER = LoggerFactory.getLogger(VerbDefinitionDropFilter.class);
    +
    +    protected Set<VerbDefinition> verbDefinitionSet;
    +    protected VerbDefinitionResolver resolver;
    +
    +    public VerbDefinitionDropFilter() {
    +        // get with reflection
    +    }
    +
    +    public VerbDefinitionDropFilter(Set<VerbDefinition> verbDefinitionSet) {
    +        this();
    +        this.verbDefinitionSet = verbDefinitionSet;
    +    }
    +
    +    @Override
    +    public List<StreamsDatum> process(StreamsDatum entry) {
    +
    +        List<StreamsDatum> result = Lists.newArrayList();
    +
    +        LOGGER.debug("{} filtering {}", STREAMS_ID, entry.getDocument().getClass());
    +
    +        Activity activity;
    +
    +        Preconditions.checkArgument(entry.getDocument() instanceof Activity);
    +
    +        activity = (Activity) entry.getDocument();
    +
    +        boolean match = false;
    +        for( VerbDefinition verbDefinition : verbDefinitionSet)
    +            if( verbDefinition.getValue() != null &&
    +                verbDefinition.getValue().equals(activity.getVerb()))
    +                for (ObjectCombination objectCombination : verbDefinition.getObjects())
    +                    if (VerbDefinitionResolver.filter(activity, objectCombination) == true)
    +                        match = true;
    --- End diff --
    
    yes. fixed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-streams pull request: STREAMS-259

Posted by mfranklin <gi...@git.apache.org>.
Github user mfranklin commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/207#discussion_r27511098
  
    --- Diff: streams-verbs/src/main/java/org/apache/streams/verbs/VerbDefinitionResolver.java ---
    @@ -0,0 +1,112 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +package org.apache.streams.verbs;
    +
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Sets;
    +import org.apache.streams.pojo.json.Activity;
    +import org.apache.streams.pojo.json.ActivityObject;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.*;
    +
    +public class VerbDefinitionResolver {
    +
    +    private static final Logger LOGGER = LoggerFactory.getLogger(VerbDefinitionResolver.class);
    +
    +    protected Set<VerbDefinition> verbDefinitionSet;
    +
    +    public VerbDefinitionResolver() {
    +        // get with reflection
    +    }
    +
    +    public VerbDefinitionResolver(Set<VerbDefinition> verbDefinitionSet) {
    +        this();
    +        this.verbDefinitionSet = verbDefinitionSet;
    +    }
    +
    +    public List<VerbDefinition> matchingVerbDefinitions(Activity activity) {
    +
    +        Set<VerbDefinition> candidates = Sets.newConcurrentHashSet(verbDefinitionSet);
    --- End diff --
    
    This does not clone the individual VerbDefinitions so when you mutate them below, it is changing those definitions for all users of this instance, or any other object that has a reference to the same VerbDefinitions, right?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-streams pull request: STREAMS-259

Posted by steveblackmon <gi...@git.apache.org>.
Github user steveblackmon commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/207#discussion_r27531716
  
    --- Diff: streams-verbs/src/main/java/org/apache/streams/verbs/VerbDefinitionResolver.java ---
    @@ -0,0 +1,112 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +package org.apache.streams.verbs;
    +
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Sets;
    +import org.apache.streams.pojo.json.Activity;
    +import org.apache.streams.pojo.json.ActivityObject;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.*;
    +
    +public class VerbDefinitionResolver {
    +
    +    private static final Logger LOGGER = LoggerFactory.getLogger(VerbDefinitionResolver.class);
    +
    +    protected Set<VerbDefinition> verbDefinitionSet;
    +
    +    public VerbDefinitionResolver() {
    +        // get with reflection
    +    }
    +
    +    public VerbDefinitionResolver(Set<VerbDefinition> verbDefinitionSet) {
    +        this();
    +        this.verbDefinitionSet = verbDefinitionSet;
    +    }
    +
    +    public List<VerbDefinition> matchingVerbDefinitions(Activity activity) {
    +
    +        Set<VerbDefinition> candidates = Sets.newConcurrentHashSet(verbDefinitionSet);
    --- End diff --
    
    good catch.  fixed in latest push.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-streams pull request: STREAMS-259

Posted by steveblackmon <gi...@git.apache.org>.
Github user steveblackmon commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/207#discussion_r27531118
  
    --- Diff: streams-verbs/pom.xml ---
    @@ -0,0 +1,148 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<!--
    +  ~ Licensed to the Apache Software Foundation (ASF) under one
    +  ~ or more contributor license agreements.  See the NOTICE file
    +  ~ distributed with this work for additional information
    +  ~ regarding copyright ownership.  The ASF licenses this file
    +  ~ to you under the Apache License, Version 2.0 (the
    +  ~ "License"); you may not use this file except in compliance
    +  ~
    +  ~   http://www.apache.org/licenses/LICENSE-2.0
    +  ~
    +  ~ Unless required by applicable law or agreed to in writing,
    +  ~ software distributed under the License is distributed on an
    +  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +  ~ KIND, either express or implied.  See the License for the
    +  ~ specific language governing permissions and limitations
    +  ~ under the License.
    +  -->
    +<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/xsd/maven-4.0.0.xsd">
    +    <modelVersion>4.0.0</modelVersion>
    +
    +    <parent>
    +        <groupId>org.apache.streams</groupId>
    +        <artifactId>streams-project</artifactId>
    +        <version>0.2-incubating-SNAPSHOT</version>
    +        <relativePath>../pom.xml</relativePath>
    +    </parent>
    +
    +    <artifactId>streams-verbs</artifactId>
    +
    +    <name>streams-verbs</name>
    +
    +    <dependencies>
    +
    +        <dependency>
    +            <groupId>org.jsonschema2pojo</groupId>
    +            <artifactId>jsonschema2pojo-core</artifactId>
    +            <type>jar</type>
    +            <scope>compile</scope>
    +        </dependency>
    +
    +        <dependency>
    +            <groupId>org.apache.streams</groupId>
    +            <artifactId>streams-pojo</artifactId>
    +            <version>${project.version}</version>
    --- End diff --
    
    done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---