Skip to content

Commit

Permalink
list-view: create event POJOs for list view
Browse files Browse the repository at this point in the history
Add the POJOs that allow to manage a list view with a type defined in an ViewType enumeration. A list view allows to manage artifacts and belongs to an organization.
  • Loading branch information
gdrouet committed Nov 18, 2016
1 parent a680abd commit bea3510
Show file tree
Hide file tree
Showing 7 changed files with 640 additions and 0 deletions.
34 changes: 34 additions & 0 deletions core/java-lib/src/main/java/io/reactivity/core/lib/ViewType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* The MIT License (MIT) Copyright (c) 2016 The reactivity authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


package io.reactivity.core.lib;

/**
* <p>
* Enumeration of core supported types of artifacts views.
* </p>
*
* @author Guillaume DROUET
*/
public enum ViewType {

/**
* A list view.
*/
LIST
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* The MIT License (MIT) Copyright (c) 2016 The reactivity authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


package io.reactivity.core.lib.event;

import io.reactivity.core.lib.ReactivityEntity;

import java.util.List;
import java.util.Map;

/**
* <p>
* A representation of an artifact that is streamed across the Reactivity platform.
* </p>
*
* @author Guillaume DROUET
* @since 0.1.0
*/
public class Artifact extends ReactivityEntity {

/**
* A list of views containing this artifact.
*/
private final List<String> views;

/**
* All categories defined in that artifact.
*/
private final Map<String, Object> categories;

/**
* <p>
* Builds a new instance.
* </p>
*
* @param version the entity version
* @param id the artifact ID
* @param timestamp when the artifact was created
* @param views the views containing the artifact
* @param categories the categories
*/
public Artifact(final String version,
final String id,
final long timestamp,
final List<String> views,
final Map<String, Object> categories) {
super(version, id, timestamp);

this.views = views;
this.categories = categories;
}

/**
* <p>
* Gets the views.
* </p>
*
* @return the artifact views
*/
public List<String> getViews() {
return views;
}

/**
* <p>
* Gets the categories.
* </p>
*
* @return the artifact categories
*/
public Map<String, Object> getCategories() {
return categories;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
* The MIT License (MIT) Copyright (c) 2016 The reactivity authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


package io.reactivity.core.lib.event;

import io.reactivity.core.lib.ReactivityEntity;

/**
* <p>
* A representation of a view allowing to query a set of artifacts from the associated organization.
* </p>
*
* @author Guillaume DROUET
* @since 0.1.0
*/
public class ArtifactView extends ReactivityEntity {

/**
* The organization ID.
*/
private final String organization;

/**
* The view name.
*/
private final String name;

/**
* The period that covers the artifacts.
*/
private final Period period;

/**
* The type of view.
*/
private final String type;

/**
* <p>
* Builds a new instance by copy and a specific period.
* </p>
*
* @param other the view to copy
* @param period the period covering the selected artifacts
*/
public ArtifactView(final ArtifactView other,
final Period period) {
super(other.getVersion(), other.getId(), other.getUpdated());

this.organization = other.getOrganization();
this.name = other.getType();
this.period = period;
this.type = other.getType();
}

/**
* <p>
* Builds a new instance.
* </p>
*
* @param version the entity version
* @param id the view ID
* @param timestamp when the view was created
* @param organization the organization ID
* @param name the view name
* @param period the period covering the selected artifacts
* @param type the view type
*/
public ArtifactView(final String version,
final String id,
final long timestamp,
final String organization,
final String name,
final Period period,
final String type) {
super(version, id, timestamp);

this.organization = organization;
this.name = name;
this.period = period;
this.type = type;
}

/**
* <p>
* Gets the organization ID.
* </p>
*
* @return the view's organization
*/
public String getOrganization() {
return organization;
}

/**
* <p>
* Gets the name.
* </p>
*
* @return the view's name
*/
public String getName() {
return name;
}

/**
* <p>
* Gets the period.
* </p>
*
* @return the view's period
*/
public Period getPeriod() {
return period;
}

/**
* <p>
* Gets the type.
* </p>
*
* @return the view type
*/
public String getType() {
return type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* The MIT License (MIT) Copyright (c) 2016 The reactivity authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


package io.reactivity.core.lib.event;

import io.reactivity.core.lib.ReactivityEntity;

/**
* <p>
* Enumeration of all supported core event types in the {@link Event#event} field.
* </p>
*
* @author Guillaume DROUET
* @since 0.1.0
*/
public enum EventType {

/**
* Read artifact event.
*/
READ_ARTIFACT,

/**
* Read view event.
*/
READ_VIEW,

/**
* Read organization event.
*/
READ_ORGANIZATION;

/**
* <p>
* Builds a new event based on a free event type and a data payload.
* </p>
*
* @param eventType the event type
* @param data the data
* @param <T> the payload type that must be a {@link ReactivityEntity}
* @return the event
*/
public static <T extends ReactivityEntity> Event<T> newEvent(final String eventType, final T data) {
return new Event<>(eventType, data);
}

/**
* <p>
* Creates a new {@link Event} with a type corresponding to this enumeration.
* </p>
*
* @param data the data payload
* @param <T> the payload type that must be a {@link ReactivityEntity}
* @return the event
*/
public <T extends ReactivityEntity> Event<T> newEvent(final T data) {
return newEvent(name(), data);
}
}
Loading

0 comments on commit bea3510

Please sign in to comment.