repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
|---|---|---|---|---|---|---|
leosilvadev/simplebank
|
src/main/java/br/fatea/simplebank/model/jms/messages/PaymentMessage.java
|
// Path: src/main/java/br/fatea/simplebank/soap/payment/v1/PaymentStatus.java
// @XmlType(name = "paymentStatus")
// @XmlEnum
// public enum PaymentStatus {
//
// OPENED,
// CONFIRMED,
// REVERSED,
// CANCELED;
//
// public String value() {
// return name();
// }
//
// public static PaymentStatus fromValue(String v) {
// return valueOf(v);
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/utils/DatetimeUtil.java
// public class DatetimeUtil {
// public static final String PATTERN_SOAP_DATETIME = "yyyy-MM-dd HH:mm:ss";
// private static final Map<String, DateFormat> patterns = new HashMap<String, DateFormat>();
//
// public static String now(String pattern) {
// DateFormat dateFormat = getFormat(pattern);
// return dateFormat.format(new Date());
// }
//
// private static DateFormat getFormat(String pattern) {
// DateFormat dateFormat;
// if (!patterns.containsKey(pattern)) {
// dateFormat = new SimpleDateFormat(pattern);
// patterns.put(pattern, dateFormat);
// }
// dateFormat = patterns.get(pattern);
// return dateFormat;
// }
//
// public static Calendar asCalendar(String date, String pattern) {
// DateFormat dateFormat = getFormat(pattern);
//
// Calendar calendar = Calendar.getInstance();
// try {
// calendar.setTime(dateFormat.parse(date));
// return calendar;
//
// } catch (ParseException e) {
// return null;
//
// }
// }
// }
|
import br.fatea.simplebank.soap.payment.v1.PaymentStatus;
import br.fatea.simplebank.utils.DatetimeUtil;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
|
package br.fatea.simplebank.model.jms.messages;
@JsonTypeName("payment_message")
public class PaymentMessage {
@JsonProperty(required = true)
private String order;
@JsonProperty(required = true)
|
// Path: src/main/java/br/fatea/simplebank/soap/payment/v1/PaymentStatus.java
// @XmlType(name = "paymentStatus")
// @XmlEnum
// public enum PaymentStatus {
//
// OPENED,
// CONFIRMED,
// REVERSED,
// CANCELED;
//
// public String value() {
// return name();
// }
//
// public static PaymentStatus fromValue(String v) {
// return valueOf(v);
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/utils/DatetimeUtil.java
// public class DatetimeUtil {
// public static final String PATTERN_SOAP_DATETIME = "yyyy-MM-dd HH:mm:ss";
// private static final Map<String, DateFormat> patterns = new HashMap<String, DateFormat>();
//
// public static String now(String pattern) {
// DateFormat dateFormat = getFormat(pattern);
// return dateFormat.format(new Date());
// }
//
// private static DateFormat getFormat(String pattern) {
// DateFormat dateFormat;
// if (!patterns.containsKey(pattern)) {
// dateFormat = new SimpleDateFormat(pattern);
// patterns.put(pattern, dateFormat);
// }
// dateFormat = patterns.get(pattern);
// return dateFormat;
// }
//
// public static Calendar asCalendar(String date, String pattern) {
// DateFormat dateFormat = getFormat(pattern);
//
// Calendar calendar = Calendar.getInstance();
// try {
// calendar.setTime(dateFormat.parse(date));
// return calendar;
//
// } catch (ParseException e) {
// return null;
//
// }
// }
// }
// Path: src/main/java/br/fatea/simplebank/model/jms/messages/PaymentMessage.java
import br.fatea.simplebank.soap.payment.v1.PaymentStatus;
import br.fatea.simplebank.utils.DatetimeUtil;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
package br.fatea.simplebank.model.jms.messages;
@JsonTypeName("payment_message")
public class PaymentMessage {
@JsonProperty(required = true)
private String order;
@JsonProperty(required = true)
|
private PaymentStatus status;
|
leosilvadev/simplebank
|
src/main/java/br/fatea/simplebank/model/jms/messages/PaymentMessage.java
|
// Path: src/main/java/br/fatea/simplebank/soap/payment/v1/PaymentStatus.java
// @XmlType(name = "paymentStatus")
// @XmlEnum
// public enum PaymentStatus {
//
// OPENED,
// CONFIRMED,
// REVERSED,
// CANCELED;
//
// public String value() {
// return name();
// }
//
// public static PaymentStatus fromValue(String v) {
// return valueOf(v);
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/utils/DatetimeUtil.java
// public class DatetimeUtil {
// public static final String PATTERN_SOAP_DATETIME = "yyyy-MM-dd HH:mm:ss";
// private static final Map<String, DateFormat> patterns = new HashMap<String, DateFormat>();
//
// public static String now(String pattern) {
// DateFormat dateFormat = getFormat(pattern);
// return dateFormat.format(new Date());
// }
//
// private static DateFormat getFormat(String pattern) {
// DateFormat dateFormat;
// if (!patterns.containsKey(pattern)) {
// dateFormat = new SimpleDateFormat(pattern);
// patterns.put(pattern, dateFormat);
// }
// dateFormat = patterns.get(pattern);
// return dateFormat;
// }
//
// public static Calendar asCalendar(String date, String pattern) {
// DateFormat dateFormat = getFormat(pattern);
//
// Calendar calendar = Calendar.getInstance();
// try {
// calendar.setTime(dateFormat.parse(date));
// return calendar;
//
// } catch (ParseException e) {
// return null;
//
// }
// }
// }
|
import br.fatea.simplebank.soap.payment.v1.PaymentStatus;
import br.fatea.simplebank.utils.DatetimeUtil;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
|
package br.fatea.simplebank.model.jms.messages;
@JsonTypeName("payment_message")
public class PaymentMessage {
@JsonProperty(required = true)
private String order;
@JsonProperty(required = true)
private PaymentStatus status;
@JsonProperty(required = true, value = "generated_datetime")
private String generatedDatetime;
@JsonProperty(required = false, value = "detail")
private String detail;
public PaymentMessage() {
}
public PaymentMessage(String order, PaymentStatus status, String detail) {
super();
this.order = order;
this.status = status;
this.generatedDatetime = detail;
|
// Path: src/main/java/br/fatea/simplebank/soap/payment/v1/PaymentStatus.java
// @XmlType(name = "paymentStatus")
// @XmlEnum
// public enum PaymentStatus {
//
// OPENED,
// CONFIRMED,
// REVERSED,
// CANCELED;
//
// public String value() {
// return name();
// }
//
// public static PaymentStatus fromValue(String v) {
// return valueOf(v);
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/utils/DatetimeUtil.java
// public class DatetimeUtil {
// public static final String PATTERN_SOAP_DATETIME = "yyyy-MM-dd HH:mm:ss";
// private static final Map<String, DateFormat> patterns = new HashMap<String, DateFormat>();
//
// public static String now(String pattern) {
// DateFormat dateFormat = getFormat(pattern);
// return dateFormat.format(new Date());
// }
//
// private static DateFormat getFormat(String pattern) {
// DateFormat dateFormat;
// if (!patterns.containsKey(pattern)) {
// dateFormat = new SimpleDateFormat(pattern);
// patterns.put(pattern, dateFormat);
// }
// dateFormat = patterns.get(pattern);
// return dateFormat;
// }
//
// public static Calendar asCalendar(String date, String pattern) {
// DateFormat dateFormat = getFormat(pattern);
//
// Calendar calendar = Calendar.getInstance();
// try {
// calendar.setTime(dateFormat.parse(date));
// return calendar;
//
// } catch (ParseException e) {
// return null;
//
// }
// }
// }
// Path: src/main/java/br/fatea/simplebank/model/jms/messages/PaymentMessage.java
import br.fatea.simplebank.soap.payment.v1.PaymentStatus;
import br.fatea.simplebank.utils.DatetimeUtil;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
package br.fatea.simplebank.model.jms.messages;
@JsonTypeName("payment_message")
public class PaymentMessage {
@JsonProperty(required = true)
private String order;
@JsonProperty(required = true)
private PaymentStatus status;
@JsonProperty(required = true, value = "generated_datetime")
private String generatedDatetime;
@JsonProperty(required = false, value = "detail")
private String detail;
public PaymentMessage() {
}
public PaymentMessage(String order, PaymentStatus status, String detail) {
super();
this.order = order;
this.status = status;
this.generatedDatetime = detail;
|
this.generatedDatetime = DatetimeUtil.now(DatetimeUtil.PATTERN_SOAP_DATETIME);
|
leosilvadev/simplebank
|
src/main/java/br/fatea/simplebank/model/security/SystemUserDetail.java
|
// Path: src/main/java/br/fatea/simplebank/model/domains/SystemUser.java
// @Entity
// @Table(name = "TBL_SYSTEM_USER")
// public class SystemUser {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "SUS_ID")
// private Long id;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_USERNAME", unique=true)
// private String username;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_PASSWORD")
// private String password;
//
// @Version
// @Column(name = "SUS_VERSION")
// private Integer version;
//
// @ManyToMany(fetch = FetchType.EAGER)
// @JoinTable(name = "TBL_SYSTEM_USER_ROLES", joinColumns = @JoinColumn(name = "SYSTEM_USER", referencedColumnName = "SUS_ID"), inverseJoinColumns = @JoinColumn(name = "SYSTEM_ROLE", referencedColumnName = "SRO_ID"))
// private Set<SystemRole> roles;
//
// @Embedded
// private IntegrationConfig integrationConfig;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Integer getVersion() {
// return version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public Set<SystemRole> getRoles() {
// return roles;
// }
//
// public void setRoles(Set<SystemRole> roles) {
// this.roles = roles;
// }
//
// public IntegrationConfig getIntegrationConfig() {
// return integrationConfig;
// }
//
// public void setIntegrationConfig(IntegrationConfig integrationConfig) {
// this.integrationConfig = integrationConfig;
// }
//
// public void encodePassword(BCryptPasswordEncoder encoder) {
// if(this.password!=null)
// this.password = encoder.encode(password);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result
// + ((username == null) ? 0 : username.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// SystemUser other = (SystemUser) obj;
// if (username == null) {
// if (other.username != null)
// return false;
// } else if (!username.equals(other.username))
// return false;
// return true;
// }
//
// }
|
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import br.fatea.simplebank.model.domains.SystemUser;
|
package br.fatea.simplebank.model.security;
public class SystemUserDetail implements UserDetails {
private static final long serialVersionUID = -5028285189159361408L;
|
// Path: src/main/java/br/fatea/simplebank/model/domains/SystemUser.java
// @Entity
// @Table(name = "TBL_SYSTEM_USER")
// public class SystemUser {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "SUS_ID")
// private Long id;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_USERNAME", unique=true)
// private String username;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_PASSWORD")
// private String password;
//
// @Version
// @Column(name = "SUS_VERSION")
// private Integer version;
//
// @ManyToMany(fetch = FetchType.EAGER)
// @JoinTable(name = "TBL_SYSTEM_USER_ROLES", joinColumns = @JoinColumn(name = "SYSTEM_USER", referencedColumnName = "SUS_ID"), inverseJoinColumns = @JoinColumn(name = "SYSTEM_ROLE", referencedColumnName = "SRO_ID"))
// private Set<SystemRole> roles;
//
// @Embedded
// private IntegrationConfig integrationConfig;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Integer getVersion() {
// return version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public Set<SystemRole> getRoles() {
// return roles;
// }
//
// public void setRoles(Set<SystemRole> roles) {
// this.roles = roles;
// }
//
// public IntegrationConfig getIntegrationConfig() {
// return integrationConfig;
// }
//
// public void setIntegrationConfig(IntegrationConfig integrationConfig) {
// this.integrationConfig = integrationConfig;
// }
//
// public void encodePassword(BCryptPasswordEncoder encoder) {
// if(this.password!=null)
// this.password = encoder.encode(password);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result
// + ((username == null) ? 0 : username.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// SystemUser other = (SystemUser) obj;
// if (username == null) {
// if (other.username != null)
// return false;
// } else if (!username.equals(other.username))
// return false;
// return true;
// }
//
// }
// Path: src/main/java/br/fatea/simplebank/model/security/SystemUserDetail.java
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import br.fatea.simplebank.model.domains.SystemUser;
package br.fatea.simplebank.model.security;
public class SystemUserDetail implements UserDetails {
private static final long serialVersionUID = -5028285189159361408L;
|
private SystemUser systemUser;
|
leosilvadev/simplebank
|
src/main/java/br/fatea/simplebank/config/JMSConfig.java
|
// Path: src/main/java/br/fatea/simplebank/model/jms/converters/PaymentMessageConverter.java
// @Component
// public class PaymentMessageConverter implements MessageConverter {
//
// @Autowired private JSONMapperTemplate jsonMapperTemplate;
//
// @Override
// public Object fromMessage(Message message) throws JMSException, MessageConversionException {
// return jsonMapperTemplate.mapToObject(message, PaymentMessage.class);
// }
//
// @Override
// public Message toMessage(Object object, Session session) throws JMSException, MessageConversionException {
// return jsonMapperTemplate.mapToMessage(object, session);
// }
// }
|
import java.util.UUID;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;
import br.fatea.simplebank.model.jms.converters.PaymentMessageConverter;
|
package br.fatea.simplebank.config;
@Configuration
@EnableScheduling
@PropertySource("classpath:configuration/jms.properties")
public class JMSConfig {
|
// Path: src/main/java/br/fatea/simplebank/model/jms/converters/PaymentMessageConverter.java
// @Component
// public class PaymentMessageConverter implements MessageConverter {
//
// @Autowired private JSONMapperTemplate jsonMapperTemplate;
//
// @Override
// public Object fromMessage(Message message) throws JMSException, MessageConversionException {
// return jsonMapperTemplate.mapToObject(message, PaymentMessage.class);
// }
//
// @Override
// public Message toMessage(Object object, Session session) throws JMSException, MessageConversionException {
// return jsonMapperTemplate.mapToMessage(object, session);
// }
// }
// Path: src/main/java/br/fatea/simplebank/config/JMSConfig.java
import java.util.UUID;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;
import br.fatea.simplebank.model.jms.converters.PaymentMessageConverter;
package br.fatea.simplebank.config;
@Configuration
@EnableScheduling
@PropertySource("classpath:configuration/jms.properties")
public class JMSConfig {
|
@Autowired private PaymentMessageConverter paymentMessageConverter;
|
leosilvadev/simplebank
|
src/main/java/br/fatea/simplebank/model/templates/PaymentJMSTemplate.java
|
// Path: src/main/java/br/fatea/simplebank/model/jms/messages/PaymentMessage.java
// @JsonTypeName("payment_message")
// public class PaymentMessage {
//
// @JsonProperty(required = true)
// private String order;
//
// @JsonProperty(required = true)
// private PaymentStatus status;
//
// @JsonProperty(required = true, value = "generated_datetime")
// private String generatedDatetime;
//
// @JsonProperty(required = false, value = "detail")
// private String detail;
//
// public PaymentMessage() {
// }
//
// public PaymentMessage(String order, PaymentStatus status, String detail) {
// super();
// this.order = order;
// this.status = status;
// this.generatedDatetime = detail;
// this.generatedDatetime = DatetimeUtil.now(DatetimeUtil.PATTERN_SOAP_DATETIME);
// }
//
// public String getOrder() {
// return order;
// }
//
// public void setOrder(String order) {
// this.order = order;
// }
//
// public PaymentStatus getStatus() {
// return status;
// }
//
// public void setStatus(PaymentStatus status) {
// this.status = status;
// }
//
// public String getGeneratedDatetime() {
// return generatedDatetime;
// }
//
// public void setGeneratedDatetime(String generatedDatetime) {
// this.generatedDatetime = generatedDatetime;
// }
//
// public String getDetail() {
// return detail;
// }
//
// public void setDetail(String detail) {
// this.detail = detail;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((order == null) ? 0 : order.hashCode());
// result = prime * result + ((status == null) ? 0 : status.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// PaymentMessage other = (PaymentMessage) obj;
// if (order == null) {
// if (other.order != null)
// return false;
// } else if (!order.equals(other.order))
// return false;
// if (status != other.status)
// return false;
// return true;
// }
//
// }
|
import java.util.HashMap;
import java.util.Map;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;
import br.fatea.simplebank.model.jms.messages.PaymentMessage;
|
package br.fatea.simplebank.model.templates;
@Component
public class PaymentJMSTemplate {
@Autowired private JmsTemplate jmsTemplate;
private Map<String, ActiveMQQueue> queues;
public PaymentJMSTemplate() {
this.queues = new HashMap<>();
}
|
// Path: src/main/java/br/fatea/simplebank/model/jms/messages/PaymentMessage.java
// @JsonTypeName("payment_message")
// public class PaymentMessage {
//
// @JsonProperty(required = true)
// private String order;
//
// @JsonProperty(required = true)
// private PaymentStatus status;
//
// @JsonProperty(required = true, value = "generated_datetime")
// private String generatedDatetime;
//
// @JsonProperty(required = false, value = "detail")
// private String detail;
//
// public PaymentMessage() {
// }
//
// public PaymentMessage(String order, PaymentStatus status, String detail) {
// super();
// this.order = order;
// this.status = status;
// this.generatedDatetime = detail;
// this.generatedDatetime = DatetimeUtil.now(DatetimeUtil.PATTERN_SOAP_DATETIME);
// }
//
// public String getOrder() {
// return order;
// }
//
// public void setOrder(String order) {
// this.order = order;
// }
//
// public PaymentStatus getStatus() {
// return status;
// }
//
// public void setStatus(PaymentStatus status) {
// this.status = status;
// }
//
// public String getGeneratedDatetime() {
// return generatedDatetime;
// }
//
// public void setGeneratedDatetime(String generatedDatetime) {
// this.generatedDatetime = generatedDatetime;
// }
//
// public String getDetail() {
// return detail;
// }
//
// public void setDetail(String detail) {
// this.detail = detail;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((order == null) ? 0 : order.hashCode());
// result = prime * result + ((status == null) ? 0 : status.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// PaymentMessage other = (PaymentMessage) obj;
// if (order == null) {
// if (other.order != null)
// return false;
// } else if (!order.equals(other.order))
// return false;
// if (status != other.status)
// return false;
// return true;
// }
//
// }
// Path: src/main/java/br/fatea/simplebank/model/templates/PaymentJMSTemplate.java
import java.util.HashMap;
import java.util.Map;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;
import br.fatea.simplebank.model.jms.messages.PaymentMessage;
package br.fatea.simplebank.model.templates;
@Component
public class PaymentJMSTemplate {
@Autowired private JmsTemplate jmsTemplate;
private Map<String, ActiveMQQueue> queues;
public PaymentJMSTemplate() {
this.queues = new HashMap<>();
}
|
public void send(PaymentMessage message, String queueName) {
|
leosilvadev/simplebank
|
src/main/java/br/fatea/simplebank/model/jms/converters/PaymentMessageConverter.java
|
// Path: src/main/java/br/fatea/simplebank/model/jms/messages/PaymentMessage.java
// @JsonTypeName("payment_message")
// public class PaymentMessage {
//
// @JsonProperty(required = true)
// private String order;
//
// @JsonProperty(required = true)
// private PaymentStatus status;
//
// @JsonProperty(required = true, value = "generated_datetime")
// private String generatedDatetime;
//
// @JsonProperty(required = false, value = "detail")
// private String detail;
//
// public PaymentMessage() {
// }
//
// public PaymentMessage(String order, PaymentStatus status, String detail) {
// super();
// this.order = order;
// this.status = status;
// this.generatedDatetime = detail;
// this.generatedDatetime = DatetimeUtil.now(DatetimeUtil.PATTERN_SOAP_DATETIME);
// }
//
// public String getOrder() {
// return order;
// }
//
// public void setOrder(String order) {
// this.order = order;
// }
//
// public PaymentStatus getStatus() {
// return status;
// }
//
// public void setStatus(PaymentStatus status) {
// this.status = status;
// }
//
// public String getGeneratedDatetime() {
// return generatedDatetime;
// }
//
// public void setGeneratedDatetime(String generatedDatetime) {
// this.generatedDatetime = generatedDatetime;
// }
//
// public String getDetail() {
// return detail;
// }
//
// public void setDetail(String detail) {
// this.detail = detail;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((order == null) ? 0 : order.hashCode());
// result = prime * result + ((status == null) ? 0 : status.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// PaymentMessage other = (PaymentMessage) obj;
// if (order == null) {
// if (other.order != null)
// return false;
// } else if (!order.equals(other.order))
// return false;
// if (status != other.status)
// return false;
// return true;
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/templates/JSONMapperTemplate.java
// @Component
// public class JSONMapperTemplate {
//
// private ObjectMapper objectMapper;
//
// public JSONMapperTemplate() {
// this.objectMapper = new ObjectMapper();
// }
//
// public <T> T mapToObject(Message message, Class<T> clazz) {
// if (message instanceof TextMessage) {
// TextMessage textMessage = (TextMessage) message;
// try {
// return objectMapper.readValue(textMessage.getText(), clazz);
// } catch (IOException | JMSException e) {
// throw new IllegalArgumentException("Invalid Message");
// }
// } else {
// throw new IllegalArgumentException("Invalid Message. Message must be of type TextMessage");
// }
// }
//
// public Message mapToMessage(Object object, Session session) {
// try {
// return session.createTextMessage(objectMapper.writeValueAsString(object));
//
// } catch (JsonProcessingException | JMSException e) {
// throw new IllegalArgumentException("Invalid Message");
//
// }
// }
// }
|
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.support.converter.MessageConversionException;
import org.springframework.jms.support.converter.MessageConverter;
import org.springframework.stereotype.Component;
import br.fatea.simplebank.model.jms.messages.PaymentMessage;
import br.fatea.simplebank.model.templates.JSONMapperTemplate;
|
package br.fatea.simplebank.model.jms.converters;
@Component
public class PaymentMessageConverter implements MessageConverter {
|
// Path: src/main/java/br/fatea/simplebank/model/jms/messages/PaymentMessage.java
// @JsonTypeName("payment_message")
// public class PaymentMessage {
//
// @JsonProperty(required = true)
// private String order;
//
// @JsonProperty(required = true)
// private PaymentStatus status;
//
// @JsonProperty(required = true, value = "generated_datetime")
// private String generatedDatetime;
//
// @JsonProperty(required = false, value = "detail")
// private String detail;
//
// public PaymentMessage() {
// }
//
// public PaymentMessage(String order, PaymentStatus status, String detail) {
// super();
// this.order = order;
// this.status = status;
// this.generatedDatetime = detail;
// this.generatedDatetime = DatetimeUtil.now(DatetimeUtil.PATTERN_SOAP_DATETIME);
// }
//
// public String getOrder() {
// return order;
// }
//
// public void setOrder(String order) {
// this.order = order;
// }
//
// public PaymentStatus getStatus() {
// return status;
// }
//
// public void setStatus(PaymentStatus status) {
// this.status = status;
// }
//
// public String getGeneratedDatetime() {
// return generatedDatetime;
// }
//
// public void setGeneratedDatetime(String generatedDatetime) {
// this.generatedDatetime = generatedDatetime;
// }
//
// public String getDetail() {
// return detail;
// }
//
// public void setDetail(String detail) {
// this.detail = detail;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((order == null) ? 0 : order.hashCode());
// result = prime * result + ((status == null) ? 0 : status.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// PaymentMessage other = (PaymentMessage) obj;
// if (order == null) {
// if (other.order != null)
// return false;
// } else if (!order.equals(other.order))
// return false;
// if (status != other.status)
// return false;
// return true;
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/templates/JSONMapperTemplate.java
// @Component
// public class JSONMapperTemplate {
//
// private ObjectMapper objectMapper;
//
// public JSONMapperTemplate() {
// this.objectMapper = new ObjectMapper();
// }
//
// public <T> T mapToObject(Message message, Class<T> clazz) {
// if (message instanceof TextMessage) {
// TextMessage textMessage = (TextMessage) message;
// try {
// return objectMapper.readValue(textMessage.getText(), clazz);
// } catch (IOException | JMSException e) {
// throw new IllegalArgumentException("Invalid Message");
// }
// } else {
// throw new IllegalArgumentException("Invalid Message. Message must be of type TextMessage");
// }
// }
//
// public Message mapToMessage(Object object, Session session) {
// try {
// return session.createTextMessage(objectMapper.writeValueAsString(object));
//
// } catch (JsonProcessingException | JMSException e) {
// throw new IllegalArgumentException("Invalid Message");
//
// }
// }
// }
// Path: src/main/java/br/fatea/simplebank/model/jms/converters/PaymentMessageConverter.java
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.support.converter.MessageConversionException;
import org.springframework.jms.support.converter.MessageConverter;
import org.springframework.stereotype.Component;
import br.fatea.simplebank.model.jms.messages.PaymentMessage;
import br.fatea.simplebank.model.templates.JSONMapperTemplate;
package br.fatea.simplebank.model.jms.converters;
@Component
public class PaymentMessageConverter implements MessageConverter {
|
@Autowired private JSONMapperTemplate jsonMapperTemplate;
|
leosilvadev/simplebank
|
src/main/java/br/fatea/simplebank/model/jms/converters/PaymentMessageConverter.java
|
// Path: src/main/java/br/fatea/simplebank/model/jms/messages/PaymentMessage.java
// @JsonTypeName("payment_message")
// public class PaymentMessage {
//
// @JsonProperty(required = true)
// private String order;
//
// @JsonProperty(required = true)
// private PaymentStatus status;
//
// @JsonProperty(required = true, value = "generated_datetime")
// private String generatedDatetime;
//
// @JsonProperty(required = false, value = "detail")
// private String detail;
//
// public PaymentMessage() {
// }
//
// public PaymentMessage(String order, PaymentStatus status, String detail) {
// super();
// this.order = order;
// this.status = status;
// this.generatedDatetime = detail;
// this.generatedDatetime = DatetimeUtil.now(DatetimeUtil.PATTERN_SOAP_DATETIME);
// }
//
// public String getOrder() {
// return order;
// }
//
// public void setOrder(String order) {
// this.order = order;
// }
//
// public PaymentStatus getStatus() {
// return status;
// }
//
// public void setStatus(PaymentStatus status) {
// this.status = status;
// }
//
// public String getGeneratedDatetime() {
// return generatedDatetime;
// }
//
// public void setGeneratedDatetime(String generatedDatetime) {
// this.generatedDatetime = generatedDatetime;
// }
//
// public String getDetail() {
// return detail;
// }
//
// public void setDetail(String detail) {
// this.detail = detail;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((order == null) ? 0 : order.hashCode());
// result = prime * result + ((status == null) ? 0 : status.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// PaymentMessage other = (PaymentMessage) obj;
// if (order == null) {
// if (other.order != null)
// return false;
// } else if (!order.equals(other.order))
// return false;
// if (status != other.status)
// return false;
// return true;
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/templates/JSONMapperTemplate.java
// @Component
// public class JSONMapperTemplate {
//
// private ObjectMapper objectMapper;
//
// public JSONMapperTemplate() {
// this.objectMapper = new ObjectMapper();
// }
//
// public <T> T mapToObject(Message message, Class<T> clazz) {
// if (message instanceof TextMessage) {
// TextMessage textMessage = (TextMessage) message;
// try {
// return objectMapper.readValue(textMessage.getText(), clazz);
// } catch (IOException | JMSException e) {
// throw new IllegalArgumentException("Invalid Message");
// }
// } else {
// throw new IllegalArgumentException("Invalid Message. Message must be of type TextMessage");
// }
// }
//
// public Message mapToMessage(Object object, Session session) {
// try {
// return session.createTextMessage(objectMapper.writeValueAsString(object));
//
// } catch (JsonProcessingException | JMSException e) {
// throw new IllegalArgumentException("Invalid Message");
//
// }
// }
// }
|
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.support.converter.MessageConversionException;
import org.springframework.jms.support.converter.MessageConverter;
import org.springframework.stereotype.Component;
import br.fatea.simplebank.model.jms.messages.PaymentMessage;
import br.fatea.simplebank.model.templates.JSONMapperTemplate;
|
package br.fatea.simplebank.model.jms.converters;
@Component
public class PaymentMessageConverter implements MessageConverter {
@Autowired private JSONMapperTemplate jsonMapperTemplate;
@Override
public Object fromMessage(Message message) throws JMSException, MessageConversionException {
|
// Path: src/main/java/br/fatea/simplebank/model/jms/messages/PaymentMessage.java
// @JsonTypeName("payment_message")
// public class PaymentMessage {
//
// @JsonProperty(required = true)
// private String order;
//
// @JsonProperty(required = true)
// private PaymentStatus status;
//
// @JsonProperty(required = true, value = "generated_datetime")
// private String generatedDatetime;
//
// @JsonProperty(required = false, value = "detail")
// private String detail;
//
// public PaymentMessage() {
// }
//
// public PaymentMessage(String order, PaymentStatus status, String detail) {
// super();
// this.order = order;
// this.status = status;
// this.generatedDatetime = detail;
// this.generatedDatetime = DatetimeUtil.now(DatetimeUtil.PATTERN_SOAP_DATETIME);
// }
//
// public String getOrder() {
// return order;
// }
//
// public void setOrder(String order) {
// this.order = order;
// }
//
// public PaymentStatus getStatus() {
// return status;
// }
//
// public void setStatus(PaymentStatus status) {
// this.status = status;
// }
//
// public String getGeneratedDatetime() {
// return generatedDatetime;
// }
//
// public void setGeneratedDatetime(String generatedDatetime) {
// this.generatedDatetime = generatedDatetime;
// }
//
// public String getDetail() {
// return detail;
// }
//
// public void setDetail(String detail) {
// this.detail = detail;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((order == null) ? 0 : order.hashCode());
// result = prime * result + ((status == null) ? 0 : status.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// PaymentMessage other = (PaymentMessage) obj;
// if (order == null) {
// if (other.order != null)
// return false;
// } else if (!order.equals(other.order))
// return false;
// if (status != other.status)
// return false;
// return true;
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/templates/JSONMapperTemplate.java
// @Component
// public class JSONMapperTemplate {
//
// private ObjectMapper objectMapper;
//
// public JSONMapperTemplate() {
// this.objectMapper = new ObjectMapper();
// }
//
// public <T> T mapToObject(Message message, Class<T> clazz) {
// if (message instanceof TextMessage) {
// TextMessage textMessage = (TextMessage) message;
// try {
// return objectMapper.readValue(textMessage.getText(), clazz);
// } catch (IOException | JMSException e) {
// throw new IllegalArgumentException("Invalid Message");
// }
// } else {
// throw new IllegalArgumentException("Invalid Message. Message must be of type TextMessage");
// }
// }
//
// public Message mapToMessage(Object object, Session session) {
// try {
// return session.createTextMessage(objectMapper.writeValueAsString(object));
//
// } catch (JsonProcessingException | JMSException e) {
// throw new IllegalArgumentException("Invalid Message");
//
// }
// }
// }
// Path: src/main/java/br/fatea/simplebank/model/jms/converters/PaymentMessageConverter.java
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.support.converter.MessageConversionException;
import org.springframework.jms.support.converter.MessageConverter;
import org.springframework.stereotype.Component;
import br.fatea.simplebank.model.jms.messages.PaymentMessage;
import br.fatea.simplebank.model.templates.JSONMapperTemplate;
package br.fatea.simplebank.model.jms.converters;
@Component
public class PaymentMessageConverter implements MessageConverter {
@Autowired private JSONMapperTemplate jsonMapperTemplate;
@Override
public Object fromMessage(Message message) throws JMSException, MessageConversionException {
|
return jsonMapperTemplate.mapToObject(message, PaymentMessage.class);
|
leosilvadev/simplebank
|
src/main/java/br/fatea/simplebank/model/schedulers/PaymentScheduler.java
|
// Path: src/main/java/br/fatea/simplebank/model/services/PaymentService.java
// @Service
// public class PaymentService {
//
// @Autowired private PaymentJMSTemplate paymentJMSTemplate;
// @Autowired private SystemUserRepository systemUserRepository;
// @Autowired private PaymentRepository paymentRepository;
// @Autowired private Converter<PaymentRequest, Payment> converter;
//
// @Transactional
// public void updateStatusPayments(PaymentStatus oldStatus, PaymentStatus newStatus, String detail) {
// List<Payment> payments = paymentRepository.findAllByStatus(oldStatus);
// for(Payment payment : payments) {
// payment.setStatus(newStatus);
// PaymentMessage message = new PaymentMessage(payment.getOrder(), payment.getStatus(), detail);
// paymentJMSTemplate.send(message, payment.getOwner().getIntegrationConfig().getPaymentQueue());
// }
// }
//
// @Transactional
// public PaymentResponse process(PaymentRequest paymentRequest, String username) {
// SystemUser systemUser = systemUserRepository.findOneByUsername(username);
// save(paymentRequest, systemUser);
// return buildResponse(paymentRequest);
// }
//
// private PaymentResponse buildResponse(PaymentRequest paymentRequest) {
// PaymentResponse response = new PaymentResponse();
// response.setOrder(paymentRequest.getOrder());
// response.setStatus(PaymentStatus.OPENED);
// response.setProcessDate(DatetimeUtil.now(DatetimeUtil.PATTERN_SOAP_DATETIME));
// return response;
// }
//
// private void save(PaymentRequest paymentRequest, SystemUser systemUser) {
// Payment payment = converter.asDomain(paymentRequest);
// payment.setOwner(systemUser);
// payment.setStatus(PaymentStatus.OPENED);
// paymentRepository.save(payment);
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/soap/payment/v1/PaymentStatus.java
// @XmlType(name = "paymentStatus")
// @XmlEnum
// public enum PaymentStatus {
//
// OPENED,
// CONFIRMED,
// REVERSED,
// CANCELED;
//
// public String value() {
// return name();
// }
//
// public static PaymentStatus fromValue(String v) {
// return valueOf(v);
// }
//
// }
|
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import br.fatea.simplebank.model.services.PaymentService;
import br.fatea.simplebank.soap.payment.v1.PaymentStatus;
|
package br.fatea.simplebank.model.schedulers;
@Component
public class PaymentScheduler {
|
// Path: src/main/java/br/fatea/simplebank/model/services/PaymentService.java
// @Service
// public class PaymentService {
//
// @Autowired private PaymentJMSTemplate paymentJMSTemplate;
// @Autowired private SystemUserRepository systemUserRepository;
// @Autowired private PaymentRepository paymentRepository;
// @Autowired private Converter<PaymentRequest, Payment> converter;
//
// @Transactional
// public void updateStatusPayments(PaymentStatus oldStatus, PaymentStatus newStatus, String detail) {
// List<Payment> payments = paymentRepository.findAllByStatus(oldStatus);
// for(Payment payment : payments) {
// payment.setStatus(newStatus);
// PaymentMessage message = new PaymentMessage(payment.getOrder(), payment.getStatus(), detail);
// paymentJMSTemplate.send(message, payment.getOwner().getIntegrationConfig().getPaymentQueue());
// }
// }
//
// @Transactional
// public PaymentResponse process(PaymentRequest paymentRequest, String username) {
// SystemUser systemUser = systemUserRepository.findOneByUsername(username);
// save(paymentRequest, systemUser);
// return buildResponse(paymentRequest);
// }
//
// private PaymentResponse buildResponse(PaymentRequest paymentRequest) {
// PaymentResponse response = new PaymentResponse();
// response.setOrder(paymentRequest.getOrder());
// response.setStatus(PaymentStatus.OPENED);
// response.setProcessDate(DatetimeUtil.now(DatetimeUtil.PATTERN_SOAP_DATETIME));
// return response;
// }
//
// private void save(PaymentRequest paymentRequest, SystemUser systemUser) {
// Payment payment = converter.asDomain(paymentRequest);
// payment.setOwner(systemUser);
// payment.setStatus(PaymentStatus.OPENED);
// paymentRepository.save(payment);
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/soap/payment/v1/PaymentStatus.java
// @XmlType(name = "paymentStatus")
// @XmlEnum
// public enum PaymentStatus {
//
// OPENED,
// CONFIRMED,
// REVERSED,
// CANCELED;
//
// public String value() {
// return name();
// }
//
// public static PaymentStatus fromValue(String v) {
// return valueOf(v);
// }
//
// }
// Path: src/main/java/br/fatea/simplebank/model/schedulers/PaymentScheduler.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import br.fatea.simplebank.model.services.PaymentService;
import br.fatea.simplebank.soap.payment.v1.PaymentStatus;
package br.fatea.simplebank.model.schedulers;
@Component
public class PaymentScheduler {
|
@Autowired private PaymentService paymentService;
|
leosilvadev/simplebank
|
src/main/java/br/fatea/simplebank/model/schedulers/PaymentScheduler.java
|
// Path: src/main/java/br/fatea/simplebank/model/services/PaymentService.java
// @Service
// public class PaymentService {
//
// @Autowired private PaymentJMSTemplate paymentJMSTemplate;
// @Autowired private SystemUserRepository systemUserRepository;
// @Autowired private PaymentRepository paymentRepository;
// @Autowired private Converter<PaymentRequest, Payment> converter;
//
// @Transactional
// public void updateStatusPayments(PaymentStatus oldStatus, PaymentStatus newStatus, String detail) {
// List<Payment> payments = paymentRepository.findAllByStatus(oldStatus);
// for(Payment payment : payments) {
// payment.setStatus(newStatus);
// PaymentMessage message = new PaymentMessage(payment.getOrder(), payment.getStatus(), detail);
// paymentJMSTemplate.send(message, payment.getOwner().getIntegrationConfig().getPaymentQueue());
// }
// }
//
// @Transactional
// public PaymentResponse process(PaymentRequest paymentRequest, String username) {
// SystemUser systemUser = systemUserRepository.findOneByUsername(username);
// save(paymentRequest, systemUser);
// return buildResponse(paymentRequest);
// }
//
// private PaymentResponse buildResponse(PaymentRequest paymentRequest) {
// PaymentResponse response = new PaymentResponse();
// response.setOrder(paymentRequest.getOrder());
// response.setStatus(PaymentStatus.OPENED);
// response.setProcessDate(DatetimeUtil.now(DatetimeUtil.PATTERN_SOAP_DATETIME));
// return response;
// }
//
// private void save(PaymentRequest paymentRequest, SystemUser systemUser) {
// Payment payment = converter.asDomain(paymentRequest);
// payment.setOwner(systemUser);
// payment.setStatus(PaymentStatus.OPENED);
// paymentRepository.save(payment);
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/soap/payment/v1/PaymentStatus.java
// @XmlType(name = "paymentStatus")
// @XmlEnum
// public enum PaymentStatus {
//
// OPENED,
// CONFIRMED,
// REVERSED,
// CANCELED;
//
// public String value() {
// return name();
// }
//
// public static PaymentStatus fromValue(String v) {
// return valueOf(v);
// }
//
// }
|
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import br.fatea.simplebank.model.services.PaymentService;
import br.fatea.simplebank.soap.payment.v1.PaymentStatus;
|
package br.fatea.simplebank.model.schedulers;
@Component
public class PaymentScheduler {
@Autowired private PaymentService paymentService;
@Scheduled(fixedDelay = 10 * 1000)
public void confirmPayments(){
|
// Path: src/main/java/br/fatea/simplebank/model/services/PaymentService.java
// @Service
// public class PaymentService {
//
// @Autowired private PaymentJMSTemplate paymentJMSTemplate;
// @Autowired private SystemUserRepository systemUserRepository;
// @Autowired private PaymentRepository paymentRepository;
// @Autowired private Converter<PaymentRequest, Payment> converter;
//
// @Transactional
// public void updateStatusPayments(PaymentStatus oldStatus, PaymentStatus newStatus, String detail) {
// List<Payment> payments = paymentRepository.findAllByStatus(oldStatus);
// for(Payment payment : payments) {
// payment.setStatus(newStatus);
// PaymentMessage message = new PaymentMessage(payment.getOrder(), payment.getStatus(), detail);
// paymentJMSTemplate.send(message, payment.getOwner().getIntegrationConfig().getPaymentQueue());
// }
// }
//
// @Transactional
// public PaymentResponse process(PaymentRequest paymentRequest, String username) {
// SystemUser systemUser = systemUserRepository.findOneByUsername(username);
// save(paymentRequest, systemUser);
// return buildResponse(paymentRequest);
// }
//
// private PaymentResponse buildResponse(PaymentRequest paymentRequest) {
// PaymentResponse response = new PaymentResponse();
// response.setOrder(paymentRequest.getOrder());
// response.setStatus(PaymentStatus.OPENED);
// response.setProcessDate(DatetimeUtil.now(DatetimeUtil.PATTERN_SOAP_DATETIME));
// return response;
// }
//
// private void save(PaymentRequest paymentRequest, SystemUser systemUser) {
// Payment payment = converter.asDomain(paymentRequest);
// payment.setOwner(systemUser);
// payment.setStatus(PaymentStatus.OPENED);
// paymentRepository.save(payment);
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/soap/payment/v1/PaymentStatus.java
// @XmlType(name = "paymentStatus")
// @XmlEnum
// public enum PaymentStatus {
//
// OPENED,
// CONFIRMED,
// REVERSED,
// CANCELED;
//
// public String value() {
// return name();
// }
//
// public static PaymentStatus fromValue(String v) {
// return valueOf(v);
// }
//
// }
// Path: src/main/java/br/fatea/simplebank/model/schedulers/PaymentScheduler.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import br.fatea.simplebank.model.services.PaymentService;
import br.fatea.simplebank.soap.payment.v1.PaymentStatus;
package br.fatea.simplebank.model.schedulers;
@Component
public class PaymentScheduler {
@Autowired private PaymentService paymentService;
@Scheduled(fixedDelay = 10 * 1000)
public void confirmPayments(){
|
paymentService.updateStatusPayments(PaymentStatus.OPENED, PaymentStatus.CONFIRMED, null);
|
leosilvadev/simplebank
|
src/main/java/br/fatea/simplebank/soap/interceptors/ValidationInterceptor.java
|
// Path: src/main/java/br/fatea/simplebank/soap/exceptions/InvalidClientArgumentsException.java
// @SoapFault(faultCode=FaultCode.CLIENT, faultStringOrReason="Invalid Request Parameters")
// public class InvalidClientArgumentsException extends RuntimeException {
//
// private static final long serialVersionUID = -2188675525576989114L;
//
// public InvalidClientArgumentsException(String details) {
// super(details);
// }
//
// }
|
import java.io.IOException;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMResult;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor;
import org.xml.sax.SAXException;
import br.fatea.simplebank.soap.exceptions.InvalidClientArgumentsException;
|
package br.fatea.simplebank.soap.interceptors;
public class ValidationInterceptor extends PayloadValidatingInterceptor {
protected Source getValidationRequestSource(WebServiceMessage request) {
Source source = request.getPayloadSource();
validateSchema(source);
return source;
}
private void validateSchema(Source source) {
SchemaFactory schemaFactory = SchemaFactory.newInstance(getSchemaLanguage());
try {
Schema schema = schemaFactory.newSchema(getSchemas()[0].getFile());
Validator validator = schema.newValidator();
DOMResult result = new DOMResult();
try {
validator.validate(source, result);
} catch (SAXException ex) {
logger.error(ex);
|
// Path: src/main/java/br/fatea/simplebank/soap/exceptions/InvalidClientArgumentsException.java
// @SoapFault(faultCode=FaultCode.CLIENT, faultStringOrReason="Invalid Request Parameters")
// public class InvalidClientArgumentsException extends RuntimeException {
//
// private static final long serialVersionUID = -2188675525576989114L;
//
// public InvalidClientArgumentsException(String details) {
// super(details);
// }
//
// }
// Path: src/main/java/br/fatea/simplebank/soap/interceptors/ValidationInterceptor.java
import java.io.IOException;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMResult;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor;
import org.xml.sax.SAXException;
import br.fatea.simplebank.soap.exceptions.InvalidClientArgumentsException;
package br.fatea.simplebank.soap.interceptors;
public class ValidationInterceptor extends PayloadValidatingInterceptor {
protected Source getValidationRequestSource(WebServiceMessage request) {
Source source = request.getPayloadSource();
validateSchema(source);
return source;
}
private void validateSchema(Source source) {
SchemaFactory schemaFactory = SchemaFactory.newInstance(getSchemaLanguage());
try {
Schema schema = schemaFactory.newSchema(getSchemas()[0].getFile());
Validator validator = schema.newValidator();
DOMResult result = new DOMResult();
try {
validator.validate(source, result);
} catch (SAXException ex) {
logger.error(ex);
|
throw new InvalidClientArgumentsException(ex.getMessage());
|
leosilvadev/simplebank
|
src/main/java/br/fatea/simplebank/model/domains/Payment.java
|
// Path: src/main/java/br/fatea/simplebank/soap/payment/v1/PaymentStatus.java
// @XmlType(name = "paymentStatus")
// @XmlEnum
// public enum PaymentStatus {
//
// OPENED,
// CONFIRMED,
// REVERSED,
// CANCELED;
//
// public String value() {
// return name();
// }
//
// public static PaymentStatus fromValue(String v) {
// return valueOf(v);
// }
//
// }
|
import java.util.Calendar;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import org.hibernate.envers.Audited;
import org.hibernate.envers.RelationTargetAuditMode;
import br.fatea.simplebank.soap.payment.v1.PaymentStatus;
|
package br.fatea.simplebank.model.domains;
@Entity
@Table(name="TBL_PAYMENT")
@Audited(targetAuditMode=RelationTargetAuditMode.NOT_AUDITED)
public class Payment {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="PAY_ID")
private Long id;
@Column(name="PAY_ORDER")
@NotNull
private String order;
@Enumerated(EnumType.STRING)
@Column(name="PAY_STATUS")
@NotNull
|
// Path: src/main/java/br/fatea/simplebank/soap/payment/v1/PaymentStatus.java
// @XmlType(name = "paymentStatus")
// @XmlEnum
// public enum PaymentStatus {
//
// OPENED,
// CONFIRMED,
// REVERSED,
// CANCELED;
//
// public String value() {
// return name();
// }
//
// public static PaymentStatus fromValue(String v) {
// return valueOf(v);
// }
//
// }
// Path: src/main/java/br/fatea/simplebank/model/domains/Payment.java
import java.util.Calendar;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import org.hibernate.envers.Audited;
import org.hibernate.envers.RelationTargetAuditMode;
import br.fatea.simplebank.soap.payment.v1.PaymentStatus;
package br.fatea.simplebank.model.domains;
@Entity
@Table(name="TBL_PAYMENT")
@Audited(targetAuditMode=RelationTargetAuditMode.NOT_AUDITED)
public class Payment {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="PAY_ID")
private Long id;
@Column(name="PAY_ORDER")
@NotNull
private String order;
@Enumerated(EnumType.STRING)
@Column(name="PAY_STATUS")
@NotNull
|
private PaymentStatus status;
|
leosilvadev/simplebank
|
src/main/java/br/fatea/simplebank/controllers/SystemUserController.java
|
// Path: src/main/java/br/fatea/simplebank/model/domains/SystemUser.java
// @Entity
// @Table(name = "TBL_SYSTEM_USER")
// public class SystemUser {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "SUS_ID")
// private Long id;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_USERNAME", unique=true)
// private String username;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_PASSWORD")
// private String password;
//
// @Version
// @Column(name = "SUS_VERSION")
// private Integer version;
//
// @ManyToMany(fetch = FetchType.EAGER)
// @JoinTable(name = "TBL_SYSTEM_USER_ROLES", joinColumns = @JoinColumn(name = "SYSTEM_USER", referencedColumnName = "SUS_ID"), inverseJoinColumns = @JoinColumn(name = "SYSTEM_ROLE", referencedColumnName = "SRO_ID"))
// private Set<SystemRole> roles;
//
// @Embedded
// private IntegrationConfig integrationConfig;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Integer getVersion() {
// return version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public Set<SystemRole> getRoles() {
// return roles;
// }
//
// public void setRoles(Set<SystemRole> roles) {
// this.roles = roles;
// }
//
// public IntegrationConfig getIntegrationConfig() {
// return integrationConfig;
// }
//
// public void setIntegrationConfig(IntegrationConfig integrationConfig) {
// this.integrationConfig = integrationConfig;
// }
//
// public void encodePassword(BCryptPasswordEncoder encoder) {
// if(this.password!=null)
// this.password = encoder.encode(password);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result
// + ((username == null) ? 0 : username.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// SystemUser other = (SystemUser) obj;
// if (username == null) {
// if (other.username != null)
// return false;
// } else if (!username.equals(other.username))
// return false;
// return true;
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/repositories/SystemUserRepository.java
// @Repository
// public interface SystemUserRepository extends CrudRepository<SystemUser, Long> {
//
// SystemUser findOneByUsername(String username);
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/services/SystemUserService.java
// @Service
// @Transactional
// public class SystemUserService {
//
// @Autowired private BCryptPasswordEncoder encoder;
// @Autowired private SystemUserRepository systemUserRepository;
//
// public void save(SystemUser systemUser){
// systemUser.encodePassword(encoder);
// if ( systemUser.getId()==null ) {
// systemUserRepository.save(systemUser);
//
// } else {
// SystemUser persistedUser = systemUserRepository.findOne(systemUser.getId());
// persistedUser.setUsername(systemUser.getUsername());
// persistedUser.setPassword(systemUser.getPassword());
//
// }
// }
//
// }
|
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import br.fatea.simplebank.model.domains.SystemUser;
import br.fatea.simplebank.model.repositories.SystemUserRepository;
import br.fatea.simplebank.model.services.SystemUserService;
|
package br.fatea.simplebank.controllers;
@Controller
@RequestMapping("/users")
public class SystemUserController {
|
// Path: src/main/java/br/fatea/simplebank/model/domains/SystemUser.java
// @Entity
// @Table(name = "TBL_SYSTEM_USER")
// public class SystemUser {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "SUS_ID")
// private Long id;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_USERNAME", unique=true)
// private String username;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_PASSWORD")
// private String password;
//
// @Version
// @Column(name = "SUS_VERSION")
// private Integer version;
//
// @ManyToMany(fetch = FetchType.EAGER)
// @JoinTable(name = "TBL_SYSTEM_USER_ROLES", joinColumns = @JoinColumn(name = "SYSTEM_USER", referencedColumnName = "SUS_ID"), inverseJoinColumns = @JoinColumn(name = "SYSTEM_ROLE", referencedColumnName = "SRO_ID"))
// private Set<SystemRole> roles;
//
// @Embedded
// private IntegrationConfig integrationConfig;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Integer getVersion() {
// return version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public Set<SystemRole> getRoles() {
// return roles;
// }
//
// public void setRoles(Set<SystemRole> roles) {
// this.roles = roles;
// }
//
// public IntegrationConfig getIntegrationConfig() {
// return integrationConfig;
// }
//
// public void setIntegrationConfig(IntegrationConfig integrationConfig) {
// this.integrationConfig = integrationConfig;
// }
//
// public void encodePassword(BCryptPasswordEncoder encoder) {
// if(this.password!=null)
// this.password = encoder.encode(password);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result
// + ((username == null) ? 0 : username.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// SystemUser other = (SystemUser) obj;
// if (username == null) {
// if (other.username != null)
// return false;
// } else if (!username.equals(other.username))
// return false;
// return true;
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/repositories/SystemUserRepository.java
// @Repository
// public interface SystemUserRepository extends CrudRepository<SystemUser, Long> {
//
// SystemUser findOneByUsername(String username);
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/services/SystemUserService.java
// @Service
// @Transactional
// public class SystemUserService {
//
// @Autowired private BCryptPasswordEncoder encoder;
// @Autowired private SystemUserRepository systemUserRepository;
//
// public void save(SystemUser systemUser){
// systemUser.encodePassword(encoder);
// if ( systemUser.getId()==null ) {
// systemUserRepository.save(systemUser);
//
// } else {
// SystemUser persistedUser = systemUserRepository.findOne(systemUser.getId());
// persistedUser.setUsername(systemUser.getUsername());
// persistedUser.setPassword(systemUser.getPassword());
//
// }
// }
//
// }
// Path: src/main/java/br/fatea/simplebank/controllers/SystemUserController.java
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import br.fatea.simplebank.model.domains.SystemUser;
import br.fatea.simplebank.model.repositories.SystemUserRepository;
import br.fatea.simplebank.model.services.SystemUserService;
package br.fatea.simplebank.controllers;
@Controller
@RequestMapping("/users")
public class SystemUserController {
|
@Autowired private SystemUserService systemUserService;
|
leosilvadev/simplebank
|
src/main/java/br/fatea/simplebank/controllers/SystemUserController.java
|
// Path: src/main/java/br/fatea/simplebank/model/domains/SystemUser.java
// @Entity
// @Table(name = "TBL_SYSTEM_USER")
// public class SystemUser {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "SUS_ID")
// private Long id;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_USERNAME", unique=true)
// private String username;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_PASSWORD")
// private String password;
//
// @Version
// @Column(name = "SUS_VERSION")
// private Integer version;
//
// @ManyToMany(fetch = FetchType.EAGER)
// @JoinTable(name = "TBL_SYSTEM_USER_ROLES", joinColumns = @JoinColumn(name = "SYSTEM_USER", referencedColumnName = "SUS_ID"), inverseJoinColumns = @JoinColumn(name = "SYSTEM_ROLE", referencedColumnName = "SRO_ID"))
// private Set<SystemRole> roles;
//
// @Embedded
// private IntegrationConfig integrationConfig;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Integer getVersion() {
// return version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public Set<SystemRole> getRoles() {
// return roles;
// }
//
// public void setRoles(Set<SystemRole> roles) {
// this.roles = roles;
// }
//
// public IntegrationConfig getIntegrationConfig() {
// return integrationConfig;
// }
//
// public void setIntegrationConfig(IntegrationConfig integrationConfig) {
// this.integrationConfig = integrationConfig;
// }
//
// public void encodePassword(BCryptPasswordEncoder encoder) {
// if(this.password!=null)
// this.password = encoder.encode(password);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result
// + ((username == null) ? 0 : username.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// SystemUser other = (SystemUser) obj;
// if (username == null) {
// if (other.username != null)
// return false;
// } else if (!username.equals(other.username))
// return false;
// return true;
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/repositories/SystemUserRepository.java
// @Repository
// public interface SystemUserRepository extends CrudRepository<SystemUser, Long> {
//
// SystemUser findOneByUsername(String username);
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/services/SystemUserService.java
// @Service
// @Transactional
// public class SystemUserService {
//
// @Autowired private BCryptPasswordEncoder encoder;
// @Autowired private SystemUserRepository systemUserRepository;
//
// public void save(SystemUser systemUser){
// systemUser.encodePassword(encoder);
// if ( systemUser.getId()==null ) {
// systemUserRepository.save(systemUser);
//
// } else {
// SystemUser persistedUser = systemUserRepository.findOne(systemUser.getId());
// persistedUser.setUsername(systemUser.getUsername());
// persistedUser.setPassword(systemUser.getPassword());
//
// }
// }
//
// }
|
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import br.fatea.simplebank.model.domains.SystemUser;
import br.fatea.simplebank.model.repositories.SystemUserRepository;
import br.fatea.simplebank.model.services.SystemUserService;
|
package br.fatea.simplebank.controllers;
@Controller
@RequestMapping("/users")
public class SystemUserController {
@Autowired private SystemUserService systemUserService;
|
// Path: src/main/java/br/fatea/simplebank/model/domains/SystemUser.java
// @Entity
// @Table(name = "TBL_SYSTEM_USER")
// public class SystemUser {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "SUS_ID")
// private Long id;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_USERNAME", unique=true)
// private String username;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_PASSWORD")
// private String password;
//
// @Version
// @Column(name = "SUS_VERSION")
// private Integer version;
//
// @ManyToMany(fetch = FetchType.EAGER)
// @JoinTable(name = "TBL_SYSTEM_USER_ROLES", joinColumns = @JoinColumn(name = "SYSTEM_USER", referencedColumnName = "SUS_ID"), inverseJoinColumns = @JoinColumn(name = "SYSTEM_ROLE", referencedColumnName = "SRO_ID"))
// private Set<SystemRole> roles;
//
// @Embedded
// private IntegrationConfig integrationConfig;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Integer getVersion() {
// return version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public Set<SystemRole> getRoles() {
// return roles;
// }
//
// public void setRoles(Set<SystemRole> roles) {
// this.roles = roles;
// }
//
// public IntegrationConfig getIntegrationConfig() {
// return integrationConfig;
// }
//
// public void setIntegrationConfig(IntegrationConfig integrationConfig) {
// this.integrationConfig = integrationConfig;
// }
//
// public void encodePassword(BCryptPasswordEncoder encoder) {
// if(this.password!=null)
// this.password = encoder.encode(password);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result
// + ((username == null) ? 0 : username.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// SystemUser other = (SystemUser) obj;
// if (username == null) {
// if (other.username != null)
// return false;
// } else if (!username.equals(other.username))
// return false;
// return true;
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/repositories/SystemUserRepository.java
// @Repository
// public interface SystemUserRepository extends CrudRepository<SystemUser, Long> {
//
// SystemUser findOneByUsername(String username);
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/services/SystemUserService.java
// @Service
// @Transactional
// public class SystemUserService {
//
// @Autowired private BCryptPasswordEncoder encoder;
// @Autowired private SystemUserRepository systemUserRepository;
//
// public void save(SystemUser systemUser){
// systemUser.encodePassword(encoder);
// if ( systemUser.getId()==null ) {
// systemUserRepository.save(systemUser);
//
// } else {
// SystemUser persistedUser = systemUserRepository.findOne(systemUser.getId());
// persistedUser.setUsername(systemUser.getUsername());
// persistedUser.setPassword(systemUser.getPassword());
//
// }
// }
//
// }
// Path: src/main/java/br/fatea/simplebank/controllers/SystemUserController.java
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import br.fatea.simplebank.model.domains.SystemUser;
import br.fatea.simplebank.model.repositories.SystemUserRepository;
import br.fatea.simplebank.model.services.SystemUserService;
package br.fatea.simplebank.controllers;
@Controller
@RequestMapping("/users")
public class SystemUserController {
@Autowired private SystemUserService systemUserService;
|
@Autowired private SystemUserRepository systemUserRepository;
|
leosilvadev/simplebank
|
src/main/java/br/fatea/simplebank/controllers/SystemUserController.java
|
// Path: src/main/java/br/fatea/simplebank/model/domains/SystemUser.java
// @Entity
// @Table(name = "TBL_SYSTEM_USER")
// public class SystemUser {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "SUS_ID")
// private Long id;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_USERNAME", unique=true)
// private String username;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_PASSWORD")
// private String password;
//
// @Version
// @Column(name = "SUS_VERSION")
// private Integer version;
//
// @ManyToMany(fetch = FetchType.EAGER)
// @JoinTable(name = "TBL_SYSTEM_USER_ROLES", joinColumns = @JoinColumn(name = "SYSTEM_USER", referencedColumnName = "SUS_ID"), inverseJoinColumns = @JoinColumn(name = "SYSTEM_ROLE", referencedColumnName = "SRO_ID"))
// private Set<SystemRole> roles;
//
// @Embedded
// private IntegrationConfig integrationConfig;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Integer getVersion() {
// return version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public Set<SystemRole> getRoles() {
// return roles;
// }
//
// public void setRoles(Set<SystemRole> roles) {
// this.roles = roles;
// }
//
// public IntegrationConfig getIntegrationConfig() {
// return integrationConfig;
// }
//
// public void setIntegrationConfig(IntegrationConfig integrationConfig) {
// this.integrationConfig = integrationConfig;
// }
//
// public void encodePassword(BCryptPasswordEncoder encoder) {
// if(this.password!=null)
// this.password = encoder.encode(password);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result
// + ((username == null) ? 0 : username.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// SystemUser other = (SystemUser) obj;
// if (username == null) {
// if (other.username != null)
// return false;
// } else if (!username.equals(other.username))
// return false;
// return true;
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/repositories/SystemUserRepository.java
// @Repository
// public interface SystemUserRepository extends CrudRepository<SystemUser, Long> {
//
// SystemUser findOneByUsername(String username);
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/services/SystemUserService.java
// @Service
// @Transactional
// public class SystemUserService {
//
// @Autowired private BCryptPasswordEncoder encoder;
// @Autowired private SystemUserRepository systemUserRepository;
//
// public void save(SystemUser systemUser){
// systemUser.encodePassword(encoder);
// if ( systemUser.getId()==null ) {
// systemUserRepository.save(systemUser);
//
// } else {
// SystemUser persistedUser = systemUserRepository.findOne(systemUser.getId());
// persistedUser.setUsername(systemUser.getUsername());
// persistedUser.setPassword(systemUser.getPassword());
//
// }
// }
//
// }
|
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import br.fatea.simplebank.model.domains.SystemUser;
import br.fatea.simplebank.model.repositories.SystemUserRepository;
import br.fatea.simplebank.model.services.SystemUserService;
|
package br.fatea.simplebank.controllers;
@Controller
@RequestMapping("/users")
public class SystemUserController {
@Autowired private SystemUserService systemUserService;
@Autowired private SystemUserRepository systemUserRepository;
@RequestMapping(method=RequestMethod.GET)
public String list(Model model){
model.addAttribute("users", systemUserRepository.findAll());
|
// Path: src/main/java/br/fatea/simplebank/model/domains/SystemUser.java
// @Entity
// @Table(name = "TBL_SYSTEM_USER")
// public class SystemUser {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "SUS_ID")
// private Long id;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_USERNAME", unique=true)
// private String username;
//
// @NotNull
// @NotEmpty
// @Column(name = "SUS_PASSWORD")
// private String password;
//
// @Version
// @Column(name = "SUS_VERSION")
// private Integer version;
//
// @ManyToMany(fetch = FetchType.EAGER)
// @JoinTable(name = "TBL_SYSTEM_USER_ROLES", joinColumns = @JoinColumn(name = "SYSTEM_USER", referencedColumnName = "SUS_ID"), inverseJoinColumns = @JoinColumn(name = "SYSTEM_ROLE", referencedColumnName = "SRO_ID"))
// private Set<SystemRole> roles;
//
// @Embedded
// private IntegrationConfig integrationConfig;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public Integer getVersion() {
// return version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public Set<SystemRole> getRoles() {
// return roles;
// }
//
// public void setRoles(Set<SystemRole> roles) {
// this.roles = roles;
// }
//
// public IntegrationConfig getIntegrationConfig() {
// return integrationConfig;
// }
//
// public void setIntegrationConfig(IntegrationConfig integrationConfig) {
// this.integrationConfig = integrationConfig;
// }
//
// public void encodePassword(BCryptPasswordEncoder encoder) {
// if(this.password!=null)
// this.password = encoder.encode(password);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result
// + ((username == null) ? 0 : username.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// SystemUser other = (SystemUser) obj;
// if (username == null) {
// if (other.username != null)
// return false;
// } else if (!username.equals(other.username))
// return false;
// return true;
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/repositories/SystemUserRepository.java
// @Repository
// public interface SystemUserRepository extends CrudRepository<SystemUser, Long> {
//
// SystemUser findOneByUsername(String username);
//
// }
//
// Path: src/main/java/br/fatea/simplebank/model/services/SystemUserService.java
// @Service
// @Transactional
// public class SystemUserService {
//
// @Autowired private BCryptPasswordEncoder encoder;
// @Autowired private SystemUserRepository systemUserRepository;
//
// public void save(SystemUser systemUser){
// systemUser.encodePassword(encoder);
// if ( systemUser.getId()==null ) {
// systemUserRepository.save(systemUser);
//
// } else {
// SystemUser persistedUser = systemUserRepository.findOne(systemUser.getId());
// persistedUser.setUsername(systemUser.getUsername());
// persistedUser.setPassword(systemUser.getPassword());
//
// }
// }
//
// }
// Path: src/main/java/br/fatea/simplebank/controllers/SystemUserController.java
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import br.fatea.simplebank.model.domains.SystemUser;
import br.fatea.simplebank.model.repositories.SystemUserRepository;
import br.fatea.simplebank.model.services.SystemUserService;
package br.fatea.simplebank.controllers;
@Controller
@RequestMapping("/users")
public class SystemUserController {
@Autowired private SystemUserService systemUserService;
@Autowired private SystemUserRepository systemUserRepository;
@RequestMapping(method=RequestMethod.GET)
public String list(Model model){
model.addAttribute("users", systemUserRepository.findAll());
|
model.addAttribute("systemUser", new SystemUser());
|
leosilvadev/simplebank
|
src/main/java/br/fatea/simplebank/model/repositories/PaymentRepository.java
|
// Path: src/main/java/br/fatea/simplebank/model/domains/Payment.java
// @Entity
// @Table(name="TBL_PAYMENT")
// @Audited(targetAuditMode=RelationTargetAuditMode.NOT_AUDITED)
// public class Payment {
//
// @Id
// @GeneratedValue(strategy=GenerationType.IDENTITY)
// @Column(name="PAY_ID")
// private Long id;
//
// @Column(name="PAY_ORDER")
// @NotNull
// private String order;
//
// @Enumerated(EnumType.STRING)
// @Column(name="PAY_STATUS")
// @NotNull
// private PaymentStatus status;
//
// @Column(name="PAY_REG_DATE")
// @NotNull
// private Calendar registrationDate;
//
// @ManyToOne(optional=false, cascade={CascadeType.PERSIST, CascadeType.MERGE})
// @JoinColumn(name="CRC_ID")
// private CreditCard creditCard;
//
// @ManyToOne(optional=false, cascade={CascadeType.PERSIST, CascadeType.MERGE})
// @JoinColumn(name="SUS_ID")
// private SystemUser owner;
//
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getOrder() {
// return order;
// }
//
// public void setOrder(String order) {
// this.order = order;
// }
//
// public PaymentStatus getStatus() {
// return status;
// }
//
// public void setStatus(PaymentStatus status) {
// this.status = status;
// }
//
// public Calendar getRegistrationDate() {
// return registrationDate;
// }
//
// public void setRegistrationDate(Calendar registrationDate) {
// this.registrationDate = registrationDate;
// }
//
// public CreditCard getCreditCard() {
// return creditCard;
// }
//
// public void setCreditCard(CreditCard creditCard) {
// this.creditCard = creditCard;
// }
//
// public SystemUser getOwner() {
// return owner;
// }
//
// public void setOwner(SystemUser owner) {
// this.owner = owner;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((order == null) ? 0 : order.hashCode());
// result = prime * result + ((owner == null) ? 0 : owner.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Payment other = (Payment) obj;
// if (order == null) {
// if (other.order != null)
// return false;
// } else if (!order.equals(other.order))
// return false;
// if (owner == null) {
// if (other.owner != null)
// return false;
// } else if (!owner.equals(other.owner))
// return false;
// return true;
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/soap/payment/v1/PaymentStatus.java
// @XmlType(name = "paymentStatus")
// @XmlEnum
// public enum PaymentStatus {
//
// OPENED,
// CONFIRMED,
// REVERSED,
// CANCELED;
//
// public String value() {
// return name();
// }
//
// public static PaymentStatus fromValue(String v) {
// return valueOf(v);
// }
//
// }
|
import java.util.List;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import br.fatea.simplebank.model.domains.Payment;
import br.fatea.simplebank.soap.payment.v1.PaymentStatus;
|
package br.fatea.simplebank.model.repositories;
@Repository
public interface PaymentRepository extends CrudRepository<Payment, Long> {
|
// Path: src/main/java/br/fatea/simplebank/model/domains/Payment.java
// @Entity
// @Table(name="TBL_PAYMENT")
// @Audited(targetAuditMode=RelationTargetAuditMode.NOT_AUDITED)
// public class Payment {
//
// @Id
// @GeneratedValue(strategy=GenerationType.IDENTITY)
// @Column(name="PAY_ID")
// private Long id;
//
// @Column(name="PAY_ORDER")
// @NotNull
// private String order;
//
// @Enumerated(EnumType.STRING)
// @Column(name="PAY_STATUS")
// @NotNull
// private PaymentStatus status;
//
// @Column(name="PAY_REG_DATE")
// @NotNull
// private Calendar registrationDate;
//
// @ManyToOne(optional=false, cascade={CascadeType.PERSIST, CascadeType.MERGE})
// @JoinColumn(name="CRC_ID")
// private CreditCard creditCard;
//
// @ManyToOne(optional=false, cascade={CascadeType.PERSIST, CascadeType.MERGE})
// @JoinColumn(name="SUS_ID")
// private SystemUser owner;
//
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getOrder() {
// return order;
// }
//
// public void setOrder(String order) {
// this.order = order;
// }
//
// public PaymentStatus getStatus() {
// return status;
// }
//
// public void setStatus(PaymentStatus status) {
// this.status = status;
// }
//
// public Calendar getRegistrationDate() {
// return registrationDate;
// }
//
// public void setRegistrationDate(Calendar registrationDate) {
// this.registrationDate = registrationDate;
// }
//
// public CreditCard getCreditCard() {
// return creditCard;
// }
//
// public void setCreditCard(CreditCard creditCard) {
// this.creditCard = creditCard;
// }
//
// public SystemUser getOwner() {
// return owner;
// }
//
// public void setOwner(SystemUser owner) {
// this.owner = owner;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((order == null) ? 0 : order.hashCode());
// result = prime * result + ((owner == null) ? 0 : owner.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Payment other = (Payment) obj;
// if (order == null) {
// if (other.order != null)
// return false;
// } else if (!order.equals(other.order))
// return false;
// if (owner == null) {
// if (other.owner != null)
// return false;
// } else if (!owner.equals(other.owner))
// return false;
// return true;
// }
//
// }
//
// Path: src/main/java/br/fatea/simplebank/soap/payment/v1/PaymentStatus.java
// @XmlType(name = "paymentStatus")
// @XmlEnum
// public enum PaymentStatus {
//
// OPENED,
// CONFIRMED,
// REVERSED,
// CANCELED;
//
// public String value() {
// return name();
// }
//
// public static PaymentStatus fromValue(String v) {
// return valueOf(v);
// }
//
// }
// Path: src/main/java/br/fatea/simplebank/model/repositories/PaymentRepository.java
import java.util.List;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import br.fatea.simplebank.model.domains.Payment;
import br.fatea.simplebank.soap.payment.v1.PaymentStatus;
package br.fatea.simplebank.model.repositories;
@Repository
public interface PaymentRepository extends CrudRepository<Payment, Long> {
|
public List<Payment> findAllByStatus(PaymentStatus status);
|
technology16/pgsqlblocks
|
src/main/java/ru/taximaxim/pgsqlblocks/modules/db/model/DBStatus.java
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/utils/Images.java
// public enum Images {
//
// ADD_DATABASE("images/db_add_16.png"),
// DELETE_DATABASE("images/db_del_16.png"),
// EDIT_DATABASE("images/db_edit_16.png"),
// CONNECT_DATABASE("images/db_connect_16.png"),
// DISCONNECT_DATABASE("images/db_disconnect_16.png"),
// UPDATE("images/update_16.png"),
// AUTOUPDATE("images/autoupdate_16.png"),
// VIEW_ONLY_BLOCKED("images/db_ob_16.png"),
// EXPORT_BLOCKS("images/save_16.png"),
// IMPORT_BLOCKS("images/document_open_16.png"),
// SETTINGS("images/settings.png"),
// FILTER("images/filter.png"),
// CANCEL_UPDATE("images/cancel_update_16.png"),
// BLOCKED("images/block-16x16.gif"),
// UNBLOCKED("images/unblock-16x16.gif"),
// DECORATOR_BLOCKED("images/locker_8.png"),
// DECORATOR_UPDATE("images/update_8.png"),
// CONN_DISABLED("images/db_f_16.png"),
// CONN_CONNECTED("images/db_t_16.png"),
// CONN_ERROR("images/db_e_16.png"),
// CONN_UPDATE("images/on_update_16.png"),
// PROC_WORKING("images/nb_16.png"),
// PROC_BLOCKING("images/locker_16.png"),
// PROC_BLOCKED("images/blocked_16.png"),
// SHOW_LOG_PANEL("images/log_show_16.png"),
// HIDE_LOG_PANEL("images/log_hide_16.png"),
// BLOCKS_JOURNAL_FOLDER("images/blocks_journal_folder_16.png"),
// FOLDER("images/folder_16.png"),
// TABLE("images/table_16.png");
//
// private String location;
//
// private Images(String location) {
// this.location = location;
// }
//
// public String getImageAddr() {
// return location;
// }
// }
|
import ru.taximaxim.pgsqlblocks.utils.Images;
|
/*
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.pgsqlblocks.modules.db.model;
public enum DBStatus {
DISABLED,
CONNECTED,
CONNECTION_ERROR,
UPDATE;
/**
* Получение иконки в зависимости от состояния
*/
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/utils/Images.java
// public enum Images {
//
// ADD_DATABASE("images/db_add_16.png"),
// DELETE_DATABASE("images/db_del_16.png"),
// EDIT_DATABASE("images/db_edit_16.png"),
// CONNECT_DATABASE("images/db_connect_16.png"),
// DISCONNECT_DATABASE("images/db_disconnect_16.png"),
// UPDATE("images/update_16.png"),
// AUTOUPDATE("images/autoupdate_16.png"),
// VIEW_ONLY_BLOCKED("images/db_ob_16.png"),
// EXPORT_BLOCKS("images/save_16.png"),
// IMPORT_BLOCKS("images/document_open_16.png"),
// SETTINGS("images/settings.png"),
// FILTER("images/filter.png"),
// CANCEL_UPDATE("images/cancel_update_16.png"),
// BLOCKED("images/block-16x16.gif"),
// UNBLOCKED("images/unblock-16x16.gif"),
// DECORATOR_BLOCKED("images/locker_8.png"),
// DECORATOR_UPDATE("images/update_8.png"),
// CONN_DISABLED("images/db_f_16.png"),
// CONN_CONNECTED("images/db_t_16.png"),
// CONN_ERROR("images/db_e_16.png"),
// CONN_UPDATE("images/on_update_16.png"),
// PROC_WORKING("images/nb_16.png"),
// PROC_BLOCKING("images/locker_16.png"),
// PROC_BLOCKED("images/blocked_16.png"),
// SHOW_LOG_PANEL("images/log_show_16.png"),
// HIDE_LOG_PANEL("images/log_hide_16.png"),
// BLOCKS_JOURNAL_FOLDER("images/blocks_journal_folder_16.png"),
// FOLDER("images/folder_16.png"),
// TABLE("images/table_16.png");
//
// private String location;
//
// private Images(String location) {
// this.location = location;
// }
//
// public String getImageAddr() {
// return location;
// }
// }
// Path: src/main/java/ru/taximaxim/pgsqlblocks/modules/db/model/DBStatus.java
import ru.taximaxim.pgsqlblocks.utils.Images;
/*
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.pgsqlblocks.modules.db.model;
public enum DBStatus {
DISABLED,
CONNECTED,
CONNECTION_ERROR,
UPDATE;
/**
* Получение иконки в зависимости от состояния
*/
|
public Images getStatusImage() {
|
technology16/pgsqlblocks
|
src/main/java/ru/taximaxim/treeviewer/filter/FilterComposite.java
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/utils/Columns.java
// public enum Columns {
//
// PID("pid"),
// BACKEND_TYPE("backend_type"),
// BLOCK_CREATE_DATE("block_start_date"),
// BLOCK_END_DATE("block_end_date"),
// BLOCKED_COUNT("num_of_blocked_processes"),
// APPLICATION_NAME("application"),
// DATABASE_NAME("db_name"),
// USER_NAME("user_name"),
// CLIENT("client"),
// BACKEND_START("backend_start"),
// QUERY_START("query_start"),
// XACT_START("xact_start"),
// DURATION("duration"),
// STATE("state"),
// STATE_CHANGE("state_change"),
// BLOCKED("blocked_by"),
// LOCK_TYPE("lock_type"),
// RELATION("relation"),
// SLOW_QUERY("slow_query"),
// QUERY("query");
//
// private final String columnName;
//
// Columns(String columnName) {
// this.columnName = columnName;
// }
//
// public String getColumnName() {
// return columnName;
// }
// }
//
// Path: src/main/java/ru/taximaxim/treeviewer/models/DataSource.java
// public abstract class DataSource<T extends IObject> implements ITableLabelProvider, ITreeContentProvider {
//
// protected List<ILabelProviderListener> listeners = new ArrayList<>();
//
// public abstract List<Columns> getColumns();
//
// public abstract Set<Columns> getColumnsToFilter();
//
// public abstract ResourceBundle getResourceBundle();
//
// public abstract String getRowText(Object element, Columns column);
//
// public abstract int compare(Object e1, Object e2, Columns column);
//
// public String getLocalizeString(String name) {
// if (getResourceBundle() == null || !getResourceBundle().containsKey(name)) {
// return name;
// }
//
// return getResourceBundle().getString(name);
// }
//
// @Override
// public String getColumnText(Object element, int columnIndex) {
// return getRowText(element, getColumns().get(columnIndex));
// }
//
// @Override
// public void dispose() {
//
// }
//
// @Override
// public boolean isLabelProperty(Object element, String property) {
// return false;
// }
//
// @Override
// public void addListener(ILabelProviderListener listener) {
// listeners.add(listener);
// }
//
// @Override
// public void removeListener(ILabelProviderListener listener) {
// listeners.remove(listener);
// }
// }
|
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import ru.taximaxim.pgsqlblocks.utils.Columns;
import ru.taximaxim.treeviewer.models.DataSource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ResourceBundle;
import java.util.Set;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
|
/*-
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 - 2018 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.treeviewer.filter;
/**
* GUI of Filters
*/
public class FilterComposite extends Composite {
private final Set<Columns> filterList;
private final ResourceBundle innerResourceBundle;
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/utils/Columns.java
// public enum Columns {
//
// PID("pid"),
// BACKEND_TYPE("backend_type"),
// BLOCK_CREATE_DATE("block_start_date"),
// BLOCK_END_DATE("block_end_date"),
// BLOCKED_COUNT("num_of_blocked_processes"),
// APPLICATION_NAME("application"),
// DATABASE_NAME("db_name"),
// USER_NAME("user_name"),
// CLIENT("client"),
// BACKEND_START("backend_start"),
// QUERY_START("query_start"),
// XACT_START("xact_start"),
// DURATION("duration"),
// STATE("state"),
// STATE_CHANGE("state_change"),
// BLOCKED("blocked_by"),
// LOCK_TYPE("lock_type"),
// RELATION("relation"),
// SLOW_QUERY("slow_query"),
// QUERY("query");
//
// private final String columnName;
//
// Columns(String columnName) {
// this.columnName = columnName;
// }
//
// public String getColumnName() {
// return columnName;
// }
// }
//
// Path: src/main/java/ru/taximaxim/treeviewer/models/DataSource.java
// public abstract class DataSource<T extends IObject> implements ITableLabelProvider, ITreeContentProvider {
//
// protected List<ILabelProviderListener> listeners = new ArrayList<>();
//
// public abstract List<Columns> getColumns();
//
// public abstract Set<Columns> getColumnsToFilter();
//
// public abstract ResourceBundle getResourceBundle();
//
// public abstract String getRowText(Object element, Columns column);
//
// public abstract int compare(Object e1, Object e2, Columns column);
//
// public String getLocalizeString(String name) {
// if (getResourceBundle() == null || !getResourceBundle().containsKey(name)) {
// return name;
// }
//
// return getResourceBundle().getString(name);
// }
//
// @Override
// public String getColumnText(Object element, int columnIndex) {
// return getRowText(element, getColumns().get(columnIndex));
// }
//
// @Override
// public void dispose() {
//
// }
//
// @Override
// public boolean isLabelProperty(Object element, String property) {
// return false;
// }
//
// @Override
// public void addListener(ILabelProviderListener listener) {
// listeners.add(listener);
// }
//
// @Override
// public void removeListener(ILabelProviderListener listener) {
// listeners.remove(listener);
// }
// }
// Path: src/main/java/ru/taximaxim/treeviewer/filter/FilterComposite.java
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import ru.taximaxim.pgsqlblocks.utils.Columns;
import ru.taximaxim.treeviewer.models.DataSource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ResourceBundle;
import java.util.Set;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
/*-
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 - 2018 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.treeviewer.filter;
/**
* GUI of Filters
*/
public class FilterComposite extends Composite {
private final Set<Columns> filterList;
private final ResourceBundle innerResourceBundle;
|
private final DataSource<?> dataSource;
|
technology16/pgsqlblocks
|
src/main/java/ru/taximaxim/pgsqlblocks/xmlstore/ColumnLayoutsXmlStore.java
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/utils/ColumnLayout.java
// public class ColumnLayout {
//
// private final int order;
// private final Columns column;
// private final Integer width;
//
// public ColumnLayout(int order, Columns column, Integer width) {
// this.order = order;
// this.column = column;
// this.width = width;
// }
//
// public int getOrder() {
// return order;
// }
//
// public Columns getColumn() {
// return column;
// }
//
// public Integer getWidth() {
// return width;
// }
// }
//
// Path: src/main/java/ru/taximaxim/pgsqlblocks/utils/Columns.java
// public enum Columns {
//
// PID("pid"),
// BACKEND_TYPE("backend_type"),
// BLOCK_CREATE_DATE("block_start_date"),
// BLOCK_END_DATE("block_end_date"),
// BLOCKED_COUNT("num_of_blocked_processes"),
// APPLICATION_NAME("application"),
// DATABASE_NAME("db_name"),
// USER_NAME("user_name"),
// CLIENT("client"),
// BACKEND_START("backend_start"),
// QUERY_START("query_start"),
// XACT_START("xact_start"),
// DURATION("duration"),
// STATE("state"),
// STATE_CHANGE("state_change"),
// BLOCKED("blocked_by"),
// LOCK_TYPE("lock_type"),
// RELATION("relation"),
// SLOW_QUERY("slow_query"),
// QUERY("query");
//
// private final String columnName;
//
// Columns(String columnName) {
// this.columnName = columnName;
// }
//
// public String getColumnName() {
// return columnName;
// }
// }
//
// Path: src/main/java/ru/taximaxim/pgsqlblocks/utils/PathBuilder.java
// public final class PathBuilder {
//
// private static final Logger LOG = LogManager.getLogger(PathBuilder.class);
//
// private static PathBuilder instance;
//
// private Path path;
//
// private PathBuilder() {
// try {
// String os = System.getProperty("os.name").toLowerCase();
// if (os.contains("win")) {
// path = Paths.get(System.getProperty("user.home"), "pgSqlBlocks");
// Files.createDirectories(path);
// Files.setAttribute(path, "dos:hidden", Boolean.TRUE, LinkOption.NOFOLLOW_LINKS);
// } else {
// path = Paths.get(System.getProperty("user.home"), ".pgSqlBlocks");
// Files.createDirectories(path);
// }
// } catch (IOException e) {
// LOG.error(String.format("Ошибка создания директории %s: %s", path, e.getMessage()));
// }
// }
//
// public static PathBuilder getInstance() {
// if(instance == null) {
// instance = new PathBuilder();
// }
// return instance;
// }
//
// public Path getBlocksJournalsDir() {
// Path blocksJournalsDir = path.resolve("blocksJournals");
// if (!blocksJournalsDir.toFile().exists()) {
// try {
// Files.createDirectory(blocksJournalsDir);
// } catch (IOException e) {
// LOG.error(String.format("Ошибка создания директории %s: %s", blocksJournalsDir, e.getMessage()));
// }
// }
// return blocksJournalsDir;
// }
//
// public Path getServersPath() {
// return path.resolve("servers.xml");
// }
//
// public Path getColumnsPath() {
// return path.resolve("columns");
// }
//
// // TODO разные конфиги log4j.propertires для разных ОС
// Path getPropertiesPath() {
// Path propPath = path.resolve("pgsqlblocks.properties");
// if (!propPath.toFile().exists()) {
// try {
// Files.createFile(propPath);
// } catch (IOException e) {
// LOG.error(String.format("Ошибка создания файла %s: %s", propPath, e.getMessage()));
// }
// }
// return propPath;
// }
// }
|
import java.nio.file.Path;
import java.util.List;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import ru.taximaxim.pgsqlblocks.utils.ColumnLayout;
import ru.taximaxim.pgsqlblocks.utils.Columns;
import ru.taximaxim.pgsqlblocks.utils.PathBuilder;
|
/*-
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 - 2018 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.pgsqlblocks.xmlstore;
public class ColumnLayoutsXmlStore extends XmlStore<ColumnLayout> {
private static final String ROOT_TAG = "columns";
private static final String COLUMN = "column";
private static final String COLUMN_ORDER = "column_order";
private static final String COLUMN_NAME = "column_name";
private static final String COLUMN_SIZE = "column_size";
private final String fileName;
public ColumnLayoutsXmlStore(String fileName) {
super(ROOT_TAG);
this.fileName = fileName;
}
@Override
protected Path getXmlFile() {
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/utils/ColumnLayout.java
// public class ColumnLayout {
//
// private final int order;
// private final Columns column;
// private final Integer width;
//
// public ColumnLayout(int order, Columns column, Integer width) {
// this.order = order;
// this.column = column;
// this.width = width;
// }
//
// public int getOrder() {
// return order;
// }
//
// public Columns getColumn() {
// return column;
// }
//
// public Integer getWidth() {
// return width;
// }
// }
//
// Path: src/main/java/ru/taximaxim/pgsqlblocks/utils/Columns.java
// public enum Columns {
//
// PID("pid"),
// BACKEND_TYPE("backend_type"),
// BLOCK_CREATE_DATE("block_start_date"),
// BLOCK_END_DATE("block_end_date"),
// BLOCKED_COUNT("num_of_blocked_processes"),
// APPLICATION_NAME("application"),
// DATABASE_NAME("db_name"),
// USER_NAME("user_name"),
// CLIENT("client"),
// BACKEND_START("backend_start"),
// QUERY_START("query_start"),
// XACT_START("xact_start"),
// DURATION("duration"),
// STATE("state"),
// STATE_CHANGE("state_change"),
// BLOCKED("blocked_by"),
// LOCK_TYPE("lock_type"),
// RELATION("relation"),
// SLOW_QUERY("slow_query"),
// QUERY("query");
//
// private final String columnName;
//
// Columns(String columnName) {
// this.columnName = columnName;
// }
//
// public String getColumnName() {
// return columnName;
// }
// }
//
// Path: src/main/java/ru/taximaxim/pgsqlblocks/utils/PathBuilder.java
// public final class PathBuilder {
//
// private static final Logger LOG = LogManager.getLogger(PathBuilder.class);
//
// private static PathBuilder instance;
//
// private Path path;
//
// private PathBuilder() {
// try {
// String os = System.getProperty("os.name").toLowerCase();
// if (os.contains("win")) {
// path = Paths.get(System.getProperty("user.home"), "pgSqlBlocks");
// Files.createDirectories(path);
// Files.setAttribute(path, "dos:hidden", Boolean.TRUE, LinkOption.NOFOLLOW_LINKS);
// } else {
// path = Paths.get(System.getProperty("user.home"), ".pgSqlBlocks");
// Files.createDirectories(path);
// }
// } catch (IOException e) {
// LOG.error(String.format("Ошибка создания директории %s: %s", path, e.getMessage()));
// }
// }
//
// public static PathBuilder getInstance() {
// if(instance == null) {
// instance = new PathBuilder();
// }
// return instance;
// }
//
// public Path getBlocksJournalsDir() {
// Path blocksJournalsDir = path.resolve("blocksJournals");
// if (!blocksJournalsDir.toFile().exists()) {
// try {
// Files.createDirectory(blocksJournalsDir);
// } catch (IOException e) {
// LOG.error(String.format("Ошибка создания директории %s: %s", blocksJournalsDir, e.getMessage()));
// }
// }
// return blocksJournalsDir;
// }
//
// public Path getServersPath() {
// return path.resolve("servers.xml");
// }
//
// public Path getColumnsPath() {
// return path.resolve("columns");
// }
//
// // TODO разные конфиги log4j.propertires для разных ОС
// Path getPropertiesPath() {
// Path propPath = path.resolve("pgsqlblocks.properties");
// if (!propPath.toFile().exists()) {
// try {
// Files.createFile(propPath);
// } catch (IOException e) {
// LOG.error(String.format("Ошибка создания файла %s: %s", propPath, e.getMessage()));
// }
// }
// return propPath;
// }
// }
// Path: src/main/java/ru/taximaxim/pgsqlblocks/xmlstore/ColumnLayoutsXmlStore.java
import java.nio.file.Path;
import java.util.List;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import ru.taximaxim.pgsqlblocks.utils.ColumnLayout;
import ru.taximaxim.pgsqlblocks.utils.Columns;
import ru.taximaxim.pgsqlblocks.utils.PathBuilder;
/*-
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 - 2018 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.pgsqlblocks.xmlstore;
public class ColumnLayoutsXmlStore extends XmlStore<ColumnLayout> {
private static final String ROOT_TAG = "columns";
private static final String COLUMN = "column";
private static final String COLUMN_ORDER = "column_order";
private static final String COLUMN_NAME = "column_name";
private static final String COLUMN_SIZE = "column_size";
private final String fileName;
public ColumnLayoutsXmlStore(String fileName) {
super(ROOT_TAG);
this.fileName = fileName;
}
@Override
protected Path getXmlFile() {
|
return PathBuilder.getInstance().getColumnsPath().resolve(fileName);
|
technology16/pgsqlblocks
|
src/main/java/ru/taximaxim/pgsqlblocks/dialogs/PasswordDialog.java
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/common/models/DBModel.java
// public class DBModel {
//
// private final String name;
// private final String host;
// private final String port;
// private final String databaseName;
// private final String user;
// private final String password;
// private final boolean readBackendType;
// private final boolean enabled;
//
// public DBModel(String name, String host, String port, String databaseName,
// String user, String password, boolean readBackendType, boolean enabled) {
// this.name = name;
// this.host = host;
// this.port = port;
// this.databaseName = databaseName;
// this.user = user;
// this.password = password;
// this.readBackendType = readBackendType;
// this.enabled = enabled;
// }
//
// public String getName() {
// return name;
// }
//
// public String getHost() {
// return host;
// }
//
// public String getPort() {
// return port;
// }
//
// public boolean isReadBackendType() {
// return readBackendType;
// }
//
// public String getDatabaseName() {
// return databaseName;
// }
//
// public String getUser() {
// return user;
// }
//
// public String getPassword() {
// return password;
// }
//
// public boolean hasPassword() {
// return !password.isEmpty();
// }
//
// public boolean isEnabled() {
// return enabled;
// }
//
// public DBModel copy() {
// return new DBModel(this.name, this.host, this.port, this.databaseName,
// this.user, this.password, this.readBackendType, this.enabled);
// }
//
// @Override
// public String toString() {
// return "DBModel{" +
// "name='" + name + '\'' +
// ", host='" + host + '\'' +
// ", port='" + port + '\'' +
// ", databaseName='" + databaseName + '\'' +
// ", user='" + user + '\'' +
// ", password='" + password + '\'' +
// ", readBackendType='" + readBackendType + '\'' +
// ", enabled=" + enabled +
// '}';
// }
//
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
//
// if (!(obj instanceof DBModel)) {
// return false;
// }
//
// DBModel other = (DBModel) obj;
// return Objects.equals(databaseName, other.databaseName)
// && enabled == other.enabled && Objects.equals(host, other.host)
// && Objects.equals(name, other.name)
// && Objects.equals(password, other.password)
// && Objects.equals(port, other.port)
// && readBackendType == other.readBackendType
// && Objects.equals(user, other.user);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((databaseName == null) ? 0 : databaseName.hashCode());
// result = prime * result + (enabled ? 1231 : 1237);
// result = prime * result + ((host == null) ? 0 : host.hashCode());
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + ((password == null) ? 0 : password.hashCode());
// result = prime * result + ((port == null) ? 0 : port.hashCode());
// result = prime * result + (readBackendType ? 1231 : 1237);
// result = prime * result + ((user == null) ? 0 : user.hashCode());
// return result;
// }
//
// }
|
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import ru.taximaxim.pgsqlblocks.common.models.DBModel;
import java.text.MessageFormat;
import java.util.ResourceBundle;
|
/*-
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 - 2018 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.pgsqlblocks.dialogs;
/**
* Dialog for password for database
*/
public class PasswordDialog extends Dialog {
private ResourceBundle resourceBundle;
private String password;
private Text passwordText;
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/common/models/DBModel.java
// public class DBModel {
//
// private final String name;
// private final String host;
// private final String port;
// private final String databaseName;
// private final String user;
// private final String password;
// private final boolean readBackendType;
// private final boolean enabled;
//
// public DBModel(String name, String host, String port, String databaseName,
// String user, String password, boolean readBackendType, boolean enabled) {
// this.name = name;
// this.host = host;
// this.port = port;
// this.databaseName = databaseName;
// this.user = user;
// this.password = password;
// this.readBackendType = readBackendType;
// this.enabled = enabled;
// }
//
// public String getName() {
// return name;
// }
//
// public String getHost() {
// return host;
// }
//
// public String getPort() {
// return port;
// }
//
// public boolean isReadBackendType() {
// return readBackendType;
// }
//
// public String getDatabaseName() {
// return databaseName;
// }
//
// public String getUser() {
// return user;
// }
//
// public String getPassword() {
// return password;
// }
//
// public boolean hasPassword() {
// return !password.isEmpty();
// }
//
// public boolean isEnabled() {
// return enabled;
// }
//
// public DBModel copy() {
// return new DBModel(this.name, this.host, this.port, this.databaseName,
// this.user, this.password, this.readBackendType, this.enabled);
// }
//
// @Override
// public String toString() {
// return "DBModel{" +
// "name='" + name + '\'' +
// ", host='" + host + '\'' +
// ", port='" + port + '\'' +
// ", databaseName='" + databaseName + '\'' +
// ", user='" + user + '\'' +
// ", password='" + password + '\'' +
// ", readBackendType='" + readBackendType + '\'' +
// ", enabled=" + enabled +
// '}';
// }
//
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
//
// if (!(obj instanceof DBModel)) {
// return false;
// }
//
// DBModel other = (DBModel) obj;
// return Objects.equals(databaseName, other.databaseName)
// && enabled == other.enabled && Objects.equals(host, other.host)
// && Objects.equals(name, other.name)
// && Objects.equals(password, other.password)
// && Objects.equals(port, other.port)
// && readBackendType == other.readBackendType
// && Objects.equals(user, other.user);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((databaseName == null) ? 0 : databaseName.hashCode());
// result = prime * result + (enabled ? 1231 : 1237);
// result = prime * result + ((host == null) ? 0 : host.hashCode());
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + ((password == null) ? 0 : password.hashCode());
// result = prime * result + ((port == null) ? 0 : port.hashCode());
// result = prime * result + (readBackendType ? 1231 : 1237);
// result = prime * result + ((user == null) ? 0 : user.hashCode());
// return result;
// }
//
// }
// Path: src/main/java/ru/taximaxim/pgsqlblocks/dialogs/PasswordDialog.java
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import ru.taximaxim.pgsqlblocks.common.models.DBModel;
import java.text.MessageFormat;
import java.util.ResourceBundle;
/*-
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 - 2018 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.pgsqlblocks.dialogs;
/**
* Dialog for password for database
*/
public class PasswordDialog extends Dialog {
private ResourceBundle resourceBundle;
private String password;
private Text passwordText;
|
private DBModel model;
|
technology16/pgsqlblocks
|
src/main/java/ru/taximaxim/pgsqlblocks/common/ui/DBProcessInfoView.java
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/common/models/DBProcess.java
// public class DBProcess implements IObject {
//
// private List<DBProcess> parents = new ArrayList<>();
// private List<DBProcess> children = new ArrayList<>();
//
// private final Set<DBBlock> blocks = new HashSet<>();
//
// private final int pid;
// private final String state;
// private final String backendType;
// private final Date stateChange; //изменено
// private final DBProcessQuery query;
// private final DBProcessQueryCaller queryCaller;
//
// private DBProcessStatus status = DBProcessStatus.WORKING;
//
// public DBProcess(int pid, String backendType, DBProcessQueryCaller queryCaller, String state, Date stateChange, DBProcessQuery query) {
// this.pid = pid;
// this.backendType = backendType;
// this.queryCaller = queryCaller;
// this.state = state;
// this.stateChange = stateChange;
// this.query = query;
// }
//
// public void addBlock(DBBlock block) {
// blocks.add(block);
// }
//
// public List<DBProcess> getParents() {
// return parents;
// }
//
// public void addChild(DBProcess process) {
// children.add(process);
// }
//
// public void addParent(DBProcess parentProcess) {
// this.parents.add(parentProcess);
// }
//
// public boolean hasParent() {
// return !parents.isEmpty();
// }
//
// public DBProcessStatus getStatus() {
// return status;
// }
//
// public void setStatus(DBProcessStatus status) {
// this.status = status;
// }
//
// public Set<DBBlock> getBlocks() {
// return blocks;
// }
//
// public String getBlocksPidsString() {
// return blocks.stream()
// .map(b -> String.valueOf(b.getBlockingPid()))
// .collect(Collectors.joining(","));
// }
//
// public String getBlocksLocktypesString() {
// return blocks.stream()
// .map(DBBlock::getLocktype)
// .distinct()
// .collect(Collectors.joining(","));
// }
//
// public String getBlocksRelationsString() {
// return blocks.stream()
// .map(DBBlock::getRelation)
// .filter(r -> r != null && !r.isEmpty())
// .distinct()
// .collect(Collectors.joining(","));
// }
//
// public int getPid() {
// return pid;
// }
//
// public String getBackendType() {
// return backendType;
// }
//
// public String getState() {
// return state;
// }
//
// public Date getStateChange() {
// return stateChange;
// }
//
// public DBProcessQuery getQuery() {
// return query;
// }
//
// public DBProcessQueryCaller getQueryCaller() {
// return queryCaller;
// }
//
// @Override
// public List<DBProcess> getChildren() {
// return children;
// }
//
// @Override
// public boolean hasChildren() {
// return !children.isEmpty();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof DBProcess)) return false;
//
// DBProcess process = (DBProcess) o;
//
// return pid == process.pid;
// }
//
// @Override
// public int hashCode() {
// return pid;
// }
//
// @Override
// public String toString() {
// return "DBProcess{" +
// "parents=" + parents +
// ", children=" + children.size() +
// ", blocks=" + blocks +
// ", pid=" + pid +
// ", state='" + state + '\'' +
// ", stateChange=" + stateChange +
// ", query=" + query +
// ", queryCaller=" + queryCaller +
// ", status=" + status +
// '}';
// }
// }
|
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import ru.taximaxim.pgsqlblocks.common.models.DBProcess;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
|
buttonBar.setLayout(layout);
buttonBar.setLayoutData(btnData);
Button cancelProcessButton = new Button(buttonBar, SWT.PUSH);
cancelProcessButton.setText(resourceBundle.getString("cancel_process"));
cancelProcessButton.setToolTipText("pg_cancel_backend");
cancelProcessButton.addListener(SWT.Selection, event -> {
listeners.forEach(DBProcessInfoViewListener::dbProcessInfoViewCancelProcessButtonClicked);
});
Button terminateProcessButton = new Button(buttonBar, SWT.PUSH);
terminateProcessButton.setText(resourceBundle.getString("kill_process"));
terminateProcessButton.setToolTipText("pg_terminate_backend");
terminateProcessButton.addListener(SWT.Selection, event -> {
listeners.forEach(DBProcessInfoViewListener::dbProcessInfoViewTerminateProcessButtonClicked);
});
processInfoText = new Text(this, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
GridData textLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
textLayoutData.heightHint = 200;
processInfoText.setLayoutData(textLayoutData);
}
public void hideToolBar() {
this.buttonBar.setVisible(false);
GridData layoutData = (GridData) this.buttonBar.getLayoutData();
layoutData.exclude = true;
this.layout();
}
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/common/models/DBProcess.java
// public class DBProcess implements IObject {
//
// private List<DBProcess> parents = new ArrayList<>();
// private List<DBProcess> children = new ArrayList<>();
//
// private final Set<DBBlock> blocks = new HashSet<>();
//
// private final int pid;
// private final String state;
// private final String backendType;
// private final Date stateChange; //изменено
// private final DBProcessQuery query;
// private final DBProcessQueryCaller queryCaller;
//
// private DBProcessStatus status = DBProcessStatus.WORKING;
//
// public DBProcess(int pid, String backendType, DBProcessQueryCaller queryCaller, String state, Date stateChange, DBProcessQuery query) {
// this.pid = pid;
// this.backendType = backendType;
// this.queryCaller = queryCaller;
// this.state = state;
// this.stateChange = stateChange;
// this.query = query;
// }
//
// public void addBlock(DBBlock block) {
// blocks.add(block);
// }
//
// public List<DBProcess> getParents() {
// return parents;
// }
//
// public void addChild(DBProcess process) {
// children.add(process);
// }
//
// public void addParent(DBProcess parentProcess) {
// this.parents.add(parentProcess);
// }
//
// public boolean hasParent() {
// return !parents.isEmpty();
// }
//
// public DBProcessStatus getStatus() {
// return status;
// }
//
// public void setStatus(DBProcessStatus status) {
// this.status = status;
// }
//
// public Set<DBBlock> getBlocks() {
// return blocks;
// }
//
// public String getBlocksPidsString() {
// return blocks.stream()
// .map(b -> String.valueOf(b.getBlockingPid()))
// .collect(Collectors.joining(","));
// }
//
// public String getBlocksLocktypesString() {
// return blocks.stream()
// .map(DBBlock::getLocktype)
// .distinct()
// .collect(Collectors.joining(","));
// }
//
// public String getBlocksRelationsString() {
// return blocks.stream()
// .map(DBBlock::getRelation)
// .filter(r -> r != null && !r.isEmpty())
// .distinct()
// .collect(Collectors.joining(","));
// }
//
// public int getPid() {
// return pid;
// }
//
// public String getBackendType() {
// return backendType;
// }
//
// public String getState() {
// return state;
// }
//
// public Date getStateChange() {
// return stateChange;
// }
//
// public DBProcessQuery getQuery() {
// return query;
// }
//
// public DBProcessQueryCaller getQueryCaller() {
// return queryCaller;
// }
//
// @Override
// public List<DBProcess> getChildren() {
// return children;
// }
//
// @Override
// public boolean hasChildren() {
// return !children.isEmpty();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof DBProcess)) return false;
//
// DBProcess process = (DBProcess) o;
//
// return pid == process.pid;
// }
//
// @Override
// public int hashCode() {
// return pid;
// }
//
// @Override
// public String toString() {
// return "DBProcess{" +
// "parents=" + parents +
// ", children=" + children.size() +
// ", blocks=" + blocks +
// ", pid=" + pid +
// ", state='" + state + '\'' +
// ", stateChange=" + stateChange +
// ", query=" + query +
// ", queryCaller=" + queryCaller +
// ", status=" + status +
// '}';
// }
// }
// Path: src/main/java/ru/taximaxim/pgsqlblocks/common/ui/DBProcessInfoView.java
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import ru.taximaxim.pgsqlblocks.common.models.DBProcess;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
buttonBar.setLayout(layout);
buttonBar.setLayoutData(btnData);
Button cancelProcessButton = new Button(buttonBar, SWT.PUSH);
cancelProcessButton.setText(resourceBundle.getString("cancel_process"));
cancelProcessButton.setToolTipText("pg_cancel_backend");
cancelProcessButton.addListener(SWT.Selection, event -> {
listeners.forEach(DBProcessInfoViewListener::dbProcessInfoViewCancelProcessButtonClicked);
});
Button terminateProcessButton = new Button(buttonBar, SWT.PUSH);
terminateProcessButton.setText(resourceBundle.getString("kill_process"));
terminateProcessButton.setToolTipText("pg_terminate_backend");
terminateProcessButton.addListener(SWT.Selection, event -> {
listeners.forEach(DBProcessInfoViewListener::dbProcessInfoViewTerminateProcessButtonClicked);
});
processInfoText = new Text(this, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
GridData textLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
textLayoutData.heightHint = 200;
processInfoText.setLayoutData(textLayoutData);
}
public void hideToolBar() {
this.buttonBar.setVisible(false);
GridData layoutData = (GridData) this.buttonBar.getLayoutData();
layoutData.exclude = true;
this.layout();
}
|
public void show(DBProcess process) {
|
technology16/pgsqlblocks
|
src/main/java/ru/taximaxim/treeviewer/models/DataSource.java
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/utils/Columns.java
// public enum Columns {
//
// PID("pid"),
// BACKEND_TYPE("backend_type"),
// BLOCK_CREATE_DATE("block_start_date"),
// BLOCK_END_DATE("block_end_date"),
// BLOCKED_COUNT("num_of_blocked_processes"),
// APPLICATION_NAME("application"),
// DATABASE_NAME("db_name"),
// USER_NAME("user_name"),
// CLIENT("client"),
// BACKEND_START("backend_start"),
// QUERY_START("query_start"),
// XACT_START("xact_start"),
// DURATION("duration"),
// STATE("state"),
// STATE_CHANGE("state_change"),
// BLOCKED("blocked_by"),
// LOCK_TYPE("lock_type"),
// RELATION("relation"),
// SLOW_QUERY("slow_query"),
// QUERY("query");
//
// private final String columnName;
//
// Columns(String columnName) {
// this.columnName = columnName;
// }
//
// public String getColumnName() {
// return columnName;
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import java.util.Set;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import ru.taximaxim.pgsqlblocks.utils.Columns;
|
/*-
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 - 2018 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.treeviewer.models;
/**
* Класс, выполняющий работу с формированием таблиц и данных.<br>
* От него необходимо будет унаследоваться и переопределить методы для получения текста колонок<br><br>
* getElements должен превращать список данных для treeViewerа;<br>
* getChildren должен возвращать список дочерних объектов того же типа;<br>
* getParent должен возвращать родительский объект, если нужно, чаще null;<br>
* hasChildren должен возвращать true если у объекта есть дочерние объекты;<br>
* **********************************************************************<br>
* getColumns возвращает список объектов, где объект колонки имплементит IColumn;<br>
* getColumnImage получить для строки объекта изображение для определенной колонки<br>
* getColumnText получить значение для определенной ячейки. сделать метод getRowText(element, getColumns().get(columnIndex))<br>
* для возможно проходить не по индексу колонки, а по самой колонке<br>
* localizeString позволяет получить строку из resourceBundle
*/
public abstract class DataSource<T extends IObject> implements ITableLabelProvider, ITreeContentProvider {
protected List<ILabelProviderListener> listeners = new ArrayList<>();
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/utils/Columns.java
// public enum Columns {
//
// PID("pid"),
// BACKEND_TYPE("backend_type"),
// BLOCK_CREATE_DATE("block_start_date"),
// BLOCK_END_DATE("block_end_date"),
// BLOCKED_COUNT("num_of_blocked_processes"),
// APPLICATION_NAME("application"),
// DATABASE_NAME("db_name"),
// USER_NAME("user_name"),
// CLIENT("client"),
// BACKEND_START("backend_start"),
// QUERY_START("query_start"),
// XACT_START("xact_start"),
// DURATION("duration"),
// STATE("state"),
// STATE_CHANGE("state_change"),
// BLOCKED("blocked_by"),
// LOCK_TYPE("lock_type"),
// RELATION("relation"),
// SLOW_QUERY("slow_query"),
// QUERY("query");
//
// private final String columnName;
//
// Columns(String columnName) {
// this.columnName = columnName;
// }
//
// public String getColumnName() {
// return columnName;
// }
// }
// Path: src/main/java/ru/taximaxim/treeviewer/models/DataSource.java
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import java.util.Set;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import ru.taximaxim.pgsqlblocks.utils.Columns;
/*-
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 - 2018 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.treeviewer.models;
/**
* Класс, выполняющий работу с формированием таблиц и данных.<br>
* От него необходимо будет унаследоваться и переопределить методы для получения текста колонок<br><br>
* getElements должен превращать список данных для treeViewerа;<br>
* getChildren должен возвращать список дочерних объектов того же типа;<br>
* getParent должен возвращать родительский объект, если нужно, чаще null;<br>
* hasChildren должен возвращать true если у объекта есть дочерние объекты;<br>
* **********************************************************************<br>
* getColumns возвращает список объектов, где объект колонки имплементит IColumn;<br>
* getColumnImage получить для строки объекта изображение для определенной колонки<br>
* getColumnText получить значение для определенной ячейки. сделать метод getRowText(element, getColumns().get(columnIndex))<br>
* для возможно проходить не по индексу колонки, а по самой колонке<br>
* localizeString позволяет получить строку из resourceBundle
*/
public abstract class DataSource<T extends IObject> implements ITableLabelProvider, ITreeContentProvider {
protected List<ILabelProviderListener> listeners = new ArrayList<>();
|
public abstract List<Columns> getColumns();
|
technology16/pgsqlblocks
|
src/main/java/ru/taximaxim/pgsqlblocks/PgSqlBlocks.java
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/modules/application/controller/ApplicationController.java
// public class ApplicationController implements ApplicationViewListener {
//
// private final ApplicationView applicationView;
//
// private final Settings settings = Settings.getInstance();
//
// private ProcessesController processesController;
//
// public ApplicationController() {
// applicationView = new ApplicationView(settings);
// applicationView.setListener(this);
// }
//
// public void launch() {
// applicationView.show();
// }
//
// @Override
// public void applicationViewDidLoad() {
// new LogsView(applicationView.getBottomPanelComposite(), SWT.NONE);
// processesController = new ProcessesController(settings);
// ProcessesView processesView = new ProcessesView(applicationView.getTopPanelComposite(), SWT.NONE);
// processesController.setView(processesView);
// processesController.load();
// }
//
// public ApplicationView getApplicationView() {
// return applicationView;
// }
//
// @Override
// public void applicationViewWillDisappear() {
// processesController.close();
// }
// }
|
import ru.taximaxim.pgsqlblocks.modules.application.controller.ApplicationController;
|
/*
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.pgsqlblocks;
public class PgSqlBlocks {
public static final String APP_NAME = "pgSqlBlocks " + PgSqlBlocks.class.getPackage().getImplementationVersion();
private static PgSqlBlocks instance;
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/modules/application/controller/ApplicationController.java
// public class ApplicationController implements ApplicationViewListener {
//
// private final ApplicationView applicationView;
//
// private final Settings settings = Settings.getInstance();
//
// private ProcessesController processesController;
//
// public ApplicationController() {
// applicationView = new ApplicationView(settings);
// applicationView.setListener(this);
// }
//
// public void launch() {
// applicationView.show();
// }
//
// @Override
// public void applicationViewDidLoad() {
// new LogsView(applicationView.getBottomPanelComposite(), SWT.NONE);
// processesController = new ProcessesController(settings);
// ProcessesView processesView = new ProcessesView(applicationView.getTopPanelComposite(), SWT.NONE);
// processesController.setView(processesView);
// processesController.load();
// }
//
// public ApplicationView getApplicationView() {
// return applicationView;
// }
//
// @Override
// public void applicationViewWillDisappear() {
// processesController.close();
// }
// }
// Path: src/main/java/ru/taximaxim/pgsqlblocks/PgSqlBlocks.java
import ru.taximaxim.pgsqlblocks.modules.application.controller.ApplicationController;
/*
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.pgsqlblocks;
public class PgSqlBlocks {
public static final String APP_NAME = "pgSqlBlocks " + PgSqlBlocks.class.getPackage().getImplementationVersion();
private static PgSqlBlocks instance;
|
private final ApplicationController applicationController;
|
technology16/pgsqlblocks
|
src/main/java/ru/taximaxim/pgsqlblocks/modules/logs/view/LogsView.java
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/ui/UIAppender.java
// @Plugin(name = UIAppender.PLUGIN_NAME, category = Core.CATEGORY_NAME, elementType = Appender.ELEMENT_TYPE, printObject = true)
// public final class UIAppender extends AbstractAppender {
//
// public static final String PLUGIN_NAME = "TextComposite";
//
// private static final List<Listener> LISTENERS = new ArrayList<>();
//
// public static void addListener(Listener e) {
// LISTENERS.add(e);
// }
//
// public static void removeListener(Listener e) {
// LISTENERS.remove(e);
// }
//
// private UIAppender(String name, Layout<?> layout, Filter filter, boolean ignoreExceptions) {
// super(name, filter, layout, ignoreExceptions, Property.EMPTY_ARRAY);
// }
//
// @Override
// public void append(LogEvent event) {
// String text = new String(getLayout().toByteArray(event), StandardCharsets.UTF_8);
// Event ev = new Event();
// ev.data = text;
// for (Listener listener : LISTENERS) {
// listener.handleEvent(ev);
// }
// }
//
// @PluginFactory
// public static UIAppender createAppender(
// @PluginAttribute("name") String name,
// @PluginAttribute("ignoreExceptions") boolean ignoreExceptions,
// @PluginElement("Layout") Layout<?> layout,
// @PluginElement("Filters") Filter filter) {
// if (name == null) {
// LOGGER.error("No name provided for UIAppender");
// return null;
// }
//
// if (layout == null) {
// layout = PatternLayout.createDefaultLayout();
// }
//
// return new UIAppender(name, layout, filter, ignoreExceptions);
// }
// }
|
import ru.taximaxim.pgsqlblocks.ui.UIAppender;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.StyledTextContent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Listener;
|
private final ModifyListener modifyListener = (ModifyEvent e) -> {
if (text.getText().length() > TEXT_LIMIT) {
styledTextContent.replaceTextRange(0, text.getText().length() - TEXT_LIMIT - 1, "");
styledTextContent.replaceTextRange(0, styledTextContent.getLine(0).length(), "");
}
if (autoScrollEnabled) {
text.setTopIndex(text.getLineCount() - 1);
}
};
private final Listener logListener = e -> {
Display display = getDisplay();
if (display != null && !display.isDisposed()) {
display.asyncExec(() -> {
if (text != null && !text.isDisposed()) {
text.append(e.data.toString());
}
});
}
};
public LogsView(Composite parent, int style) {
super(parent, style);
GridLayout layout = new GridLayout();
layout.marginTop = 0;
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
setLayout(layout);
setLayoutData(layoutData);
createContent();
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/ui/UIAppender.java
// @Plugin(name = UIAppender.PLUGIN_NAME, category = Core.CATEGORY_NAME, elementType = Appender.ELEMENT_TYPE, printObject = true)
// public final class UIAppender extends AbstractAppender {
//
// public static final String PLUGIN_NAME = "TextComposite";
//
// private static final List<Listener> LISTENERS = new ArrayList<>();
//
// public static void addListener(Listener e) {
// LISTENERS.add(e);
// }
//
// public static void removeListener(Listener e) {
// LISTENERS.remove(e);
// }
//
// private UIAppender(String name, Layout<?> layout, Filter filter, boolean ignoreExceptions) {
// super(name, filter, layout, ignoreExceptions, Property.EMPTY_ARRAY);
// }
//
// @Override
// public void append(LogEvent event) {
// String text = new String(getLayout().toByteArray(event), StandardCharsets.UTF_8);
// Event ev = new Event();
// ev.data = text;
// for (Listener listener : LISTENERS) {
// listener.handleEvent(ev);
// }
// }
//
// @PluginFactory
// public static UIAppender createAppender(
// @PluginAttribute("name") String name,
// @PluginAttribute("ignoreExceptions") boolean ignoreExceptions,
// @PluginElement("Layout") Layout<?> layout,
// @PluginElement("Filters") Filter filter) {
// if (name == null) {
// LOGGER.error("No name provided for UIAppender");
// return null;
// }
//
// if (layout == null) {
// layout = PatternLayout.createDefaultLayout();
// }
//
// return new UIAppender(name, layout, filter, ignoreExceptions);
// }
// }
// Path: src/main/java/ru/taximaxim/pgsqlblocks/modules/logs/view/LogsView.java
import ru.taximaxim.pgsqlblocks.ui.UIAppender;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.StyledTextContent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Listener;
private final ModifyListener modifyListener = (ModifyEvent e) -> {
if (text.getText().length() > TEXT_LIMIT) {
styledTextContent.replaceTextRange(0, text.getText().length() - TEXT_LIMIT - 1, "");
styledTextContent.replaceTextRange(0, styledTextContent.getLine(0).length(), "");
}
if (autoScrollEnabled) {
text.setTopIndex(text.getLineCount() - 1);
}
};
private final Listener logListener = e -> {
Display display = getDisplay();
if (display != null && !display.isDisposed()) {
display.asyncExec(() -> {
if (text != null && !text.isDisposed()) {
text.append(e.data.toString());
}
});
}
};
public LogsView(Composite parent, int style) {
super(parent, style);
GridLayout layout = new GridLayout();
layout.marginTop = 0;
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
setLayout(layout);
setLayoutData(layoutData);
createContent();
|
UIAppender.addListener(logListener);
|
technology16/pgsqlblocks
|
src/main/java/ru/taximaxim/pgsqlblocks/common/models/DBProcessStatus.java
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/utils/Images.java
// public enum Images {
//
// ADD_DATABASE("images/db_add_16.png"),
// DELETE_DATABASE("images/db_del_16.png"),
// EDIT_DATABASE("images/db_edit_16.png"),
// CONNECT_DATABASE("images/db_connect_16.png"),
// DISCONNECT_DATABASE("images/db_disconnect_16.png"),
// UPDATE("images/update_16.png"),
// AUTOUPDATE("images/autoupdate_16.png"),
// VIEW_ONLY_BLOCKED("images/db_ob_16.png"),
// EXPORT_BLOCKS("images/save_16.png"),
// IMPORT_BLOCKS("images/document_open_16.png"),
// SETTINGS("images/settings.png"),
// FILTER("images/filter.png"),
// CANCEL_UPDATE("images/cancel_update_16.png"),
// BLOCKED("images/block-16x16.gif"),
// UNBLOCKED("images/unblock-16x16.gif"),
// DECORATOR_BLOCKED("images/locker_8.png"),
// DECORATOR_UPDATE("images/update_8.png"),
// CONN_DISABLED("images/db_f_16.png"),
// CONN_CONNECTED("images/db_t_16.png"),
// CONN_ERROR("images/db_e_16.png"),
// CONN_UPDATE("images/on_update_16.png"),
// PROC_WORKING("images/nb_16.png"),
// PROC_BLOCKING("images/locker_16.png"),
// PROC_BLOCKED("images/blocked_16.png"),
// SHOW_LOG_PANEL("images/log_show_16.png"),
// HIDE_LOG_PANEL("images/log_hide_16.png"),
// BLOCKS_JOURNAL_FOLDER("images/blocks_journal_folder_16.png"),
// FOLDER("images/folder_16.png"),
// TABLE("images/table_16.png");
//
// private String location;
//
// private Images(String location) {
// this.location = location;
// }
//
// public String getImageAddr() {
// return location;
// }
// }
|
import ru.taximaxim.pgsqlblocks.utils.Images;
|
/*
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.pgsqlblocks.common.models;
public enum DBProcessStatus {
WORKING("Working"),
BLOCKING("Blocking"),
BLOCKED("Blocked");
private final String descr;
DBProcessStatus(String descr) {
this.descr = descr;
}
public String getDescr() {
return descr;
}
public static DBProcessStatus getInstanceForDescr(String descr) {
if (descr == null || descr.isEmpty()) {
return WORKING;
}
switch (descr) {
case "Working":
return WORKING;
case "Blocking":
return BLOCKING;
case "Blocked":
return BLOCKED;
default:
return WORKING;
}
}
/**
* Получение иконки в зависимости от состояния
*/
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/utils/Images.java
// public enum Images {
//
// ADD_DATABASE("images/db_add_16.png"),
// DELETE_DATABASE("images/db_del_16.png"),
// EDIT_DATABASE("images/db_edit_16.png"),
// CONNECT_DATABASE("images/db_connect_16.png"),
// DISCONNECT_DATABASE("images/db_disconnect_16.png"),
// UPDATE("images/update_16.png"),
// AUTOUPDATE("images/autoupdate_16.png"),
// VIEW_ONLY_BLOCKED("images/db_ob_16.png"),
// EXPORT_BLOCKS("images/save_16.png"),
// IMPORT_BLOCKS("images/document_open_16.png"),
// SETTINGS("images/settings.png"),
// FILTER("images/filter.png"),
// CANCEL_UPDATE("images/cancel_update_16.png"),
// BLOCKED("images/block-16x16.gif"),
// UNBLOCKED("images/unblock-16x16.gif"),
// DECORATOR_BLOCKED("images/locker_8.png"),
// DECORATOR_UPDATE("images/update_8.png"),
// CONN_DISABLED("images/db_f_16.png"),
// CONN_CONNECTED("images/db_t_16.png"),
// CONN_ERROR("images/db_e_16.png"),
// CONN_UPDATE("images/on_update_16.png"),
// PROC_WORKING("images/nb_16.png"),
// PROC_BLOCKING("images/locker_16.png"),
// PROC_BLOCKED("images/blocked_16.png"),
// SHOW_LOG_PANEL("images/log_show_16.png"),
// HIDE_LOG_PANEL("images/log_hide_16.png"),
// BLOCKS_JOURNAL_FOLDER("images/blocks_journal_folder_16.png"),
// FOLDER("images/folder_16.png"),
// TABLE("images/table_16.png");
//
// private String location;
//
// private Images(String location) {
// this.location = location;
// }
//
// public String getImageAddr() {
// return location;
// }
// }
// Path: src/main/java/ru/taximaxim/pgsqlblocks/common/models/DBProcessStatus.java
import ru.taximaxim.pgsqlblocks.utils.Images;
/*
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.pgsqlblocks.common.models;
public enum DBProcessStatus {
WORKING("Working"),
BLOCKING("Blocking"),
BLOCKED("Blocked");
private final String descr;
DBProcessStatus(String descr) {
this.descr = descr;
}
public String getDescr() {
return descr;
}
public static DBProcessStatus getInstanceForDescr(String descr) {
if (descr == null || descr.isEmpty()) {
return WORKING;
}
switch (descr) {
case "Working":
return WORKING;
case "Blocking":
return BLOCKING;
case "Blocked":
return BLOCKED;
default:
return WORKING;
}
}
/**
* Получение иконки в зависимости от состояния
*/
|
public Images getStatusImage() {
|
technology16/pgsqlblocks
|
src/main/java/ru/taximaxim/treeviewer/filter/FilterOperation.java
|
// Path: src/main/java/ru/taximaxim/treeviewer/utils/TriFunction.java
// @FunctionalInterface
// public interface TriFunction<A,B,C,R> {
//
// R apply(A a, B b, C c);
//
// default <V> TriFunction<A, B, C, V> andThen(Function<? super R, ? extends V> after) {
// Objects.requireNonNull(after);
// return (A a, B b, C c) -> after.apply(apply(a, b, c));
// }
// }
|
import ru.taximaxim.treeviewer.utils.TriFunction;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
|
/*-
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 - 2018 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.treeviewer.filter;
/**
* Enum for types of column filters
*/
enum FilterOperation {
NONE("", (o, s, t) -> true),
EQUALS("=", FilterOperation::equalsByType),
NOT_EQUALS("!=", (o, s, t) -> !EQUALS.matchesForType(o, s, t)),
CONTAINS("~", (o, s, t) -> o.toLowerCase().contains(s.toLowerCase())),
GREATER(">", FilterOperation::greater),
GREATER_OR_EQUAL(">=", (o, s, t) -> EQUALS.matchesForType(o, s, t) || GREATER.matchesForType(o, s, t)),
LESS("<", FilterOperation::less),
LESS_OR_EQUAL("<=", (o, s, t) -> EQUALS.matchesForType(o, s, t) || LESS.matchesForType(o, s, t));
private final String conditionText;
|
// Path: src/main/java/ru/taximaxim/treeviewer/utils/TriFunction.java
// @FunctionalInterface
// public interface TriFunction<A,B,C,R> {
//
// R apply(A a, B b, C c);
//
// default <V> TriFunction<A, B, C, V> andThen(Function<? super R, ? extends V> after) {
// Objects.requireNonNull(after);
// return (A a, B b, C c) -> after.apply(apply(a, b, c));
// }
// }
// Path: src/main/java/ru/taximaxim/treeviewer/filter/FilterOperation.java
import ru.taximaxim.treeviewer.utils.TriFunction;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
/*-
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 - 2018 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.treeviewer.filter;
/**
* Enum for types of column filters
*/
enum FilterOperation {
NONE("", (o, s, t) -> true),
EQUALS("=", FilterOperation::equalsByType),
NOT_EQUALS("!=", (o, s, t) -> !EQUALS.matchesForType(o, s, t)),
CONTAINS("~", (o, s, t) -> o.toLowerCase().contains(s.toLowerCase())),
GREATER(">", FilterOperation::greater),
GREATER_OR_EQUAL(">=", (o, s, t) -> EQUALS.matchesForType(o, s, t) || GREATER.matchesForType(o, s, t)),
LESS("<", FilterOperation::less),
LESS_OR_EQUAL("<=", (o, s, t) -> EQUALS.matchesForType(o, s, t) || LESS.matchesForType(o, s, t));
private final String conditionText;
|
private final TriFunction<String, String, ColumnType, Boolean> matcherFunction;
|
technology16/pgsqlblocks
|
src/main/java/ru/taximaxim/pgsqlblocks/dialogs/AddDatabaseDialog.java
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/common/models/DBModel.java
// public class DBModel {
//
// private final String name;
// private final String host;
// private final String port;
// private final String databaseName;
// private final String user;
// private final String password;
// private final boolean readBackendType;
// private final boolean enabled;
//
// public DBModel(String name, String host, String port, String databaseName,
// String user, String password, boolean readBackendType, boolean enabled) {
// this.name = name;
// this.host = host;
// this.port = port;
// this.databaseName = databaseName;
// this.user = user;
// this.password = password;
// this.readBackendType = readBackendType;
// this.enabled = enabled;
// }
//
// public String getName() {
// return name;
// }
//
// public String getHost() {
// return host;
// }
//
// public String getPort() {
// return port;
// }
//
// public boolean isReadBackendType() {
// return readBackendType;
// }
//
// public String getDatabaseName() {
// return databaseName;
// }
//
// public String getUser() {
// return user;
// }
//
// public String getPassword() {
// return password;
// }
//
// public boolean hasPassword() {
// return !password.isEmpty();
// }
//
// public boolean isEnabled() {
// return enabled;
// }
//
// public DBModel copy() {
// return new DBModel(this.name, this.host, this.port, this.databaseName,
// this.user, this.password, this.readBackendType, this.enabled);
// }
//
// @Override
// public String toString() {
// return "DBModel{" +
// "name='" + name + '\'' +
// ", host='" + host + '\'' +
// ", port='" + port + '\'' +
// ", databaseName='" + databaseName + '\'' +
// ", user='" + user + '\'' +
// ", password='" + password + '\'' +
// ", readBackendType='" + readBackendType + '\'' +
// ", enabled=" + enabled +
// '}';
// }
//
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
//
// if (!(obj instanceof DBModel)) {
// return false;
// }
//
// DBModel other = (DBModel) obj;
// return Objects.equals(databaseName, other.databaseName)
// && enabled == other.enabled && Objects.equals(host, other.host)
// && Objects.equals(name, other.name)
// && Objects.equals(password, other.password)
// && Objects.equals(port, other.port)
// && readBackendType == other.readBackendType
// && Objects.equals(user, other.user);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((databaseName == null) ? 0 : databaseName.hashCode());
// result = prime * result + (enabled ? 1231 : 1237);
// result = prime * result + ((host == null) ? 0 : host.hashCode());
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + ((password == null) ? 0 : password.hashCode());
// result = prime * result + ((port == null) ? 0 : port.hashCode());
// result = prime * result + (readBackendType ? 1231 : 1237);
// result = prime * result + ((user == null) ? 0 : user.hashCode());
// return result;
// }
//
// }
|
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import ru.taximaxim.pgsqlblocks.common.models.DBModel;
import java.util.List;
import java.util.ResourceBundle;
|
/*
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.pgsqlblocks.dialogs;
public class AddDatabaseDialog extends Dialog {
private static final String ATTENTION = "attention";
protected final ResourceBundle resourceBundle;
|
// Path: src/main/java/ru/taximaxim/pgsqlblocks/common/models/DBModel.java
// public class DBModel {
//
// private final String name;
// private final String host;
// private final String port;
// private final String databaseName;
// private final String user;
// private final String password;
// private final boolean readBackendType;
// private final boolean enabled;
//
// public DBModel(String name, String host, String port, String databaseName,
// String user, String password, boolean readBackendType, boolean enabled) {
// this.name = name;
// this.host = host;
// this.port = port;
// this.databaseName = databaseName;
// this.user = user;
// this.password = password;
// this.readBackendType = readBackendType;
// this.enabled = enabled;
// }
//
// public String getName() {
// return name;
// }
//
// public String getHost() {
// return host;
// }
//
// public String getPort() {
// return port;
// }
//
// public boolean isReadBackendType() {
// return readBackendType;
// }
//
// public String getDatabaseName() {
// return databaseName;
// }
//
// public String getUser() {
// return user;
// }
//
// public String getPassword() {
// return password;
// }
//
// public boolean hasPassword() {
// return !password.isEmpty();
// }
//
// public boolean isEnabled() {
// return enabled;
// }
//
// public DBModel copy() {
// return new DBModel(this.name, this.host, this.port, this.databaseName,
// this.user, this.password, this.readBackendType, this.enabled);
// }
//
// @Override
// public String toString() {
// return "DBModel{" +
// "name='" + name + '\'' +
// ", host='" + host + '\'' +
// ", port='" + port + '\'' +
// ", databaseName='" + databaseName + '\'' +
// ", user='" + user + '\'' +
// ", password='" + password + '\'' +
// ", readBackendType='" + readBackendType + '\'' +
// ", enabled=" + enabled +
// '}';
// }
//
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
//
// if (!(obj instanceof DBModel)) {
// return false;
// }
//
// DBModel other = (DBModel) obj;
// return Objects.equals(databaseName, other.databaseName)
// && enabled == other.enabled && Objects.equals(host, other.host)
// && Objects.equals(name, other.name)
// && Objects.equals(password, other.password)
// && Objects.equals(port, other.port)
// && readBackendType == other.readBackendType
// && Objects.equals(user, other.user);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((databaseName == null) ? 0 : databaseName.hashCode());
// result = prime * result + (enabled ? 1231 : 1237);
// result = prime * result + ((host == null) ? 0 : host.hashCode());
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + ((password == null) ? 0 : password.hashCode());
// result = prime * result + ((port == null) ? 0 : port.hashCode());
// result = prime * result + (readBackendType ? 1231 : 1237);
// result = prime * result + ((user == null) ? 0 : user.hashCode());
// return result;
// }
//
// }
// Path: src/main/java/ru/taximaxim/pgsqlblocks/dialogs/AddDatabaseDialog.java
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import ru.taximaxim.pgsqlblocks.common.models.DBModel;
import java.util.List;
import java.util.ResourceBundle;
/*
* ========================LICENSE_START=================================
* pgSqlBlocks
* %
* Copyright (C) 2017 "Technology" LLC
* %
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* =========================LICENSE_END==================================
*/
package ru.taximaxim.pgsqlblocks.dialogs;
public class AddDatabaseDialog extends Dialog {
private static final String ATTENTION = "attention";
protected final ResourceBundle resourceBundle;
|
private DBModel createdModel;
|
ottogroup/flink-operator-library
|
src/test/java/com/ottogroup/bi/streaming/testing/JSONFieldContentMatcherTest.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
|
import java.text.SimpleDateFormat;
import org.apache.sling.commons.json.JSONObject;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.hamcrest.StringDescription;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.testing;
/**
* Test case for {@link JSONFieldContentMatcher}
* @author mnxfst
* @since Apr 25, 2016
*/
public class JSONFieldContentMatcherTest {
/**
* Test for {@link JSONFieldContentMatcher#JSONMatcher(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference, org.hamcrest.Matcher)}
* being provided null as input to content reference parameter
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullContentReference() {
new JSONFieldContentMatcher(null, Matchers.is(10));
}
/**
* Test for {@link JSONFieldContentMatcher#JSONMatcher(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference, org.hamcrest.Matcher)}
* being provided a content reference without path information
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullContentRefPath() {
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
// Path: src/test/java/com/ottogroup/bi/streaming/testing/JSONFieldContentMatcherTest.java
import java.text.SimpleDateFormat;
import org.apache.sling.commons.json.JSONObject;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.hamcrest.StringDescription;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.testing;
/**
* Test case for {@link JSONFieldContentMatcher}
* @author mnxfst
* @since Apr 25, 2016
*/
public class JSONFieldContentMatcherTest {
/**
* Test for {@link JSONFieldContentMatcher#JSONMatcher(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference, org.hamcrest.Matcher)}
* being provided null as input to content reference parameter
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullContentReference() {
new JSONFieldContentMatcher(null, Matchers.is(10));
}
/**
* Test for {@link JSONFieldContentMatcher#JSONMatcher(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference, org.hamcrest.Matcher)}
* being provided a content reference without path information
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullContentRefPath() {
|
new JSONFieldContentMatcher(new JsonContentReference(null, JsonContentType.STRING, true), Matchers.is(10));
|
ottogroup/flink-operator-library
|
src/test/java/com/ottogroup/bi/streaming/testing/JSONFieldContentMatcherTest.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
|
import java.text.SimpleDateFormat;
import org.apache.sling.commons.json.JSONObject;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.hamcrest.StringDescription;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.testing;
/**
* Test case for {@link JSONFieldContentMatcher}
* @author mnxfst
* @since Apr 25, 2016
*/
public class JSONFieldContentMatcherTest {
/**
* Test for {@link JSONFieldContentMatcher#JSONMatcher(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference, org.hamcrest.Matcher)}
* being provided null as input to content reference parameter
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullContentReference() {
new JSONFieldContentMatcher(null, Matchers.is(10));
}
/**
* Test for {@link JSONFieldContentMatcher#JSONMatcher(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference, org.hamcrest.Matcher)}
* being provided a content reference without path information
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullContentRefPath() {
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
// Path: src/test/java/com/ottogroup/bi/streaming/testing/JSONFieldContentMatcherTest.java
import java.text.SimpleDateFormat;
import org.apache.sling.commons.json.JSONObject;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.hamcrest.StringDescription;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.testing;
/**
* Test case for {@link JSONFieldContentMatcher}
* @author mnxfst
* @since Apr 25, 2016
*/
public class JSONFieldContentMatcherTest {
/**
* Test for {@link JSONFieldContentMatcher#JSONMatcher(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference, org.hamcrest.Matcher)}
* being provided null as input to content reference parameter
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullContentReference() {
new JSONFieldContentMatcher(null, Matchers.is(10));
}
/**
* Test for {@link JSONFieldContentMatcher#JSONMatcher(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference, org.hamcrest.Matcher)}
* being provided a content reference without path information
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullContentRefPath() {
|
new JSONFieldContentMatcher(new JsonContentReference(null, JsonContentType.STRING, true), Matchers.is(10));
|
ottogroup/flink-operator-library
|
src/test/java/com/ottogroup/bi/streaming/operator/json/partitioning/JsonKeySelectorTest.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
|
import java.util.NoSuchElementException;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.partitioning;
/**
* Test case for {@link JsonKeySelector}
* @author mnxfst
* @since 20.04.2016
*/
public class JsonKeySelectorTest {
/**
* Test case for {@link JsonKeySelector#JSONPartitioningKeySelector(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference)}
* being provided null as input
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullReferenceInput() {
new JsonKeySelector(null);
}
/**
* Test case for {@link JsonKeySelector#JSONPartitioningKeySelector(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference)}
* being provided a reference showing a path value set to null
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullPathInfo() {
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
// Path: src/test/java/com/ottogroup/bi/streaming/operator/json/partitioning/JsonKeySelectorTest.java
import java.util.NoSuchElementException;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.partitioning;
/**
* Test case for {@link JsonKeySelector}
* @author mnxfst
* @since 20.04.2016
*/
public class JsonKeySelectorTest {
/**
* Test case for {@link JsonKeySelector#JSONPartitioningKeySelector(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference)}
* being provided null as input
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullReferenceInput() {
new JsonKeySelector(null);
}
/**
* Test case for {@link JsonKeySelector#JSONPartitioningKeySelector(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference)}
* being provided a reference showing a path value set to null
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullPathInfo() {
|
new JsonKeySelector(new JsonContentReference(null, JsonContentType.STRING));
|
ottogroup/flink-operator-library
|
src/test/java/com/ottogroup/bi/streaming/operator/json/partitioning/JsonKeySelectorTest.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
|
import java.util.NoSuchElementException;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.partitioning;
/**
* Test case for {@link JsonKeySelector}
* @author mnxfst
* @since 20.04.2016
*/
public class JsonKeySelectorTest {
/**
* Test case for {@link JsonKeySelector#JSONPartitioningKeySelector(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference)}
* being provided null as input
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullReferenceInput() {
new JsonKeySelector(null);
}
/**
* Test case for {@link JsonKeySelector#JSONPartitioningKeySelector(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference)}
* being provided a reference showing a path value set to null
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullPathInfo() {
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
// Path: src/test/java/com/ottogroup/bi/streaming/operator/json/partitioning/JsonKeySelectorTest.java
import java.util.NoSuchElementException;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.partitioning;
/**
* Test case for {@link JsonKeySelector}
* @author mnxfst
* @since 20.04.2016
*/
public class JsonKeySelectorTest {
/**
* Test case for {@link JsonKeySelector#JSONPartitioningKeySelector(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference)}
* being provided null as input
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullReferenceInput() {
new JsonKeySelector(null);
}
/**
* Test case for {@link JsonKeySelector#JSONPartitioningKeySelector(com.ottogroup.bi.streaming.operator.json.aggregate.JsonContentReference)}
* being provided a reference showing a path value set to null
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullPathInfo() {
|
new JsonKeySelector(new JsonContentReference(null, JsonContentType.STRING));
|
ottogroup/flink-operator-library
|
src/test/java/com/ottogroup/bi/streaming/operator/json/aggregate/WindowedJsonContentAggregatorTest.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
|
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.flink.api.common.functions.util.ListCollector;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
|
public void testAddRawMessages_withEmptyValueList() throws JSONException {
Assert.assertEquals("{\"raw\":[]}", new WindowedJsonContentAggregator("operator", new AggregatorConfiguration())
.addRawMessages(new JSONObject(), Collections.<JSONObject>emptyList()).toString());
}
/**
* Test case for {@link WindowedJsonContentAggregator#addRawMessages(JSONObject, Iterable)} being provided
* a list with content as input to the value list
*/
@Test
public void testAddRawMessages_withValueList() throws JSONException {
JSONObject o1 = new JSONObject();
o1.put("test", "value");
JSONObject o2 = new JSONObject();
o2.put("key", "tv1");
List<JSONObject> valueList = new ArrayList<>();
valueList.add(o1);
valueList.add(o2);
Assert.assertEquals("{\"raw\":[{\"test\":\"value\"},{\"key\":\"tv1\"}]}", new WindowedJsonContentAggregator("operator", new AggregatorConfiguration())
.addRawMessages(new JSONObject(), valueList).toString());
}
/**
* Test case for {@link WindowedJsonContentAggregator#aggregateValue(java.io.Serializable, java.io.Serializable, com.ottogroup.bi.streaming.operator.json.JsonContentType, ContentAggregator)}
* being provided null as input to 'new value' parameter
*/
@Test
public void testAggregateValue_withNullNewValue() throws Exception {
Assert.assertEquals(Integer.valueOf(1),
(Integer)new WindowedJsonContentAggregator("test", new AggregatorConfiguration()).
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
// Path: src/test/java/com/ottogroup/bi/streaming/operator/json/aggregate/WindowedJsonContentAggregatorTest.java
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.flink.api.common.functions.util.ListCollector;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
public void testAddRawMessages_withEmptyValueList() throws JSONException {
Assert.assertEquals("{\"raw\":[]}", new WindowedJsonContentAggregator("operator", new AggregatorConfiguration())
.addRawMessages(new JSONObject(), Collections.<JSONObject>emptyList()).toString());
}
/**
* Test case for {@link WindowedJsonContentAggregator#addRawMessages(JSONObject, Iterable)} being provided
* a list with content as input to the value list
*/
@Test
public void testAddRawMessages_withValueList() throws JSONException {
JSONObject o1 = new JSONObject();
o1.put("test", "value");
JSONObject o2 = new JSONObject();
o2.put("key", "tv1");
List<JSONObject> valueList = new ArrayList<>();
valueList.add(o1);
valueList.add(o2);
Assert.assertEquals("{\"raw\":[{\"test\":\"value\"},{\"key\":\"tv1\"}]}", new WindowedJsonContentAggregator("operator", new AggregatorConfiguration())
.addRawMessages(new JSONObject(), valueList).toString());
}
/**
* Test case for {@link WindowedJsonContentAggregator#aggregateValue(java.io.Serializable, java.io.Serializable, com.ottogroup.bi.streaming.operator.json.JsonContentType, ContentAggregator)}
* being provided null as input to 'new value' parameter
*/
@Test
public void testAggregateValue_withNullNewValue() throws Exception {
Assert.assertEquals(Integer.valueOf(1),
(Integer)new WindowedJsonContentAggregator("test", new AggregatorConfiguration()).
|
aggregateValue(null, Integer.valueOf(1), JsonContentType.INTEGER, ContentAggregator.SUM));
|
ottogroup/flink-operator-library
|
src/test/java/com/ottogroup/bi/streaming/operator/json/aggregate/WindowedJsonContentAggregatorTest.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
|
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.flink.api.common.functions.util.ListCollector;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
|
* Test case for {@link WindowedJsonContentAggregator#aggregateValue(java.io.Serializable, java.io.Serializable, com.ottogroup.bi.streaming.operator.json.JsonContentType, ContentAggregator)}
* being provided valid values to all parameters
*/
@Test
public void testAggregateValue_withValidValuesAndAVG() throws Exception {
Pair<Integer, Integer> avgValues = new MutablePair<>(Integer.valueOf(10), Integer.valueOf(3));
Assert.assertEquals(new MutablePair<>(Integer.valueOf(12), Integer.valueOf(4)), new WindowedJsonContentAggregator("test", new AggregatorConfiguration()).
aggregateValue(Integer.valueOf(2), avgValues, JsonContentType.INTEGER, ContentAggregator.AVG));
}
/**
* Test case for {@link WindowedJsonContentAggregator#aggregateField(JSONObject, FieldAggregationConfiguration, String, Map)} being
* provided null as input to json document parameter
*/
@Test(expected=JSONException.class)
public void testAggregateField_withNullJSONDocument() throws Exception {
new WindowedJsonContentAggregator("test", new AggregatorConfiguration()).aggregateField(null, new FieldAggregationConfiguration(), "groupByKeyPrefix", new HashMap<String, Serializable>());
}
/**
* Test case for {@link WindowedJsonContentAggregator#aggregateField(JSONObject, FieldAggregationConfiguration, String, Map)} being
* provided valid values
*/
@Test
public void testAggregateField_withValidValuesBOOLEAN() throws Exception {
JSONObject object = new JSONObject("{\"logical\":true, \"double\":\"2.34\", \"int\":10, \"string\":\"test\", \"ts\":\"20160131\"}");
Assert.assertEquals(Integer.valueOf(1), (Integer)new WindowedJsonContentAggregator("test", new AggregatorConfiguration()).aggregateField(
object,
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
// Path: src/test/java/com/ottogroup/bi/streaming/operator/json/aggregate/WindowedJsonContentAggregatorTest.java
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.flink.api.common.functions.util.ListCollector;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
* Test case for {@link WindowedJsonContentAggregator#aggregateValue(java.io.Serializable, java.io.Serializable, com.ottogroup.bi.streaming.operator.json.JsonContentType, ContentAggregator)}
* being provided valid values to all parameters
*/
@Test
public void testAggregateValue_withValidValuesAndAVG() throws Exception {
Pair<Integer, Integer> avgValues = new MutablePair<>(Integer.valueOf(10), Integer.valueOf(3));
Assert.assertEquals(new MutablePair<>(Integer.valueOf(12), Integer.valueOf(4)), new WindowedJsonContentAggregator("test", new AggregatorConfiguration()).
aggregateValue(Integer.valueOf(2), avgValues, JsonContentType.INTEGER, ContentAggregator.AVG));
}
/**
* Test case for {@link WindowedJsonContentAggregator#aggregateField(JSONObject, FieldAggregationConfiguration, String, Map)} being
* provided null as input to json document parameter
*/
@Test(expected=JSONException.class)
public void testAggregateField_withNullJSONDocument() throws Exception {
new WindowedJsonContentAggregator("test", new AggregatorConfiguration()).aggregateField(null, new FieldAggregationConfiguration(), "groupByKeyPrefix", new HashMap<String, Serializable>());
}
/**
* Test case for {@link WindowedJsonContentAggregator#aggregateField(JSONObject, FieldAggregationConfiguration, String, Map)} being
* provided valid values
*/
@Test
public void testAggregateField_withValidValuesBOOLEAN() throws Exception {
JSONObject object = new JSONObject("{\"logical\":true, \"double\":\"2.34\", \"int\":10, \"string\":\"test\", \"ts\":\"20160131\"}");
Assert.assertEquals(Integer.valueOf(1), (Integer)new WindowedJsonContentAggregator("test", new AggregatorConfiguration()).aggregateField(
object,
|
new FieldAggregationConfiguration("output", new JsonContentReference(new String[]{"logical"}, JsonContentType.BOOLEAN)),
|
ottogroup/flink-operator-library
|
src/main/java/com/ottogroup/bi/streaming/operator/json/aggregate/AggregatorConfiguration.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
|
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.aggregate;
/**
* Structure to keep all configuration required for setting up an instance of {@link WindowedJsonContentAggregator}
* @author mnxfst
* @since Jan 21, 2016
*/
public class AggregatorConfiguration implements Serializable {
private static final long serialVersionUID = 7886758725763674809L;
/** name that will be assigned to output element */
private String outputElement = null;
/** pointer towards a number of fields to group the computation results by */
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/aggregate/AggregatorConfiguration.java
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.aggregate;
/**
* Structure to keep all configuration required for setting up an instance of {@link WindowedJsonContentAggregator}
* @author mnxfst
* @since Jan 21, 2016
*/
public class AggregatorConfiguration implements Serializable {
private static final long serialVersionUID = 7886758725763674809L;
/** name that will be assigned to output element */
private String outputElement = null;
/** pointer towards a number of fields to group the computation results by */
|
private List<JsonContentReference> groupByFields = new ArrayList<>();
|
ottogroup/flink-operator-library
|
src/main/java/com/ottogroup/bi/streaming/operator/json/aggregate/AggregatorConfiguration.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
|
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
|
return optionalFields;
}
public void setOptionalFields(Map<String, String> optionalFields) {
this.optionalFields = optionalFields;
}
public String getTimestampPattern() {
return timestampPattern;
}
public void setTimestampPattern(String timestampPattern) {
this.timestampPattern = timestampPattern;
}
public boolean isRaw() {
return raw;
}
public void setRaw(boolean raw) {
this.raw = raw;
}
public static void main(String[] args) throws Exception {
AggregatorConfiguration cfg = new AggregatorConfiguration();
cfg.setOutputElement("output-element");
cfg.setRaw(true);
cfg.setTimestampPattern("yyyy-MM-dd");
cfg.addFieldAggregation(new FieldAggregationConfiguration( "aggregated-field-1",
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/aggregate/AggregatorConfiguration.java
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
return optionalFields;
}
public void setOptionalFields(Map<String, String> optionalFields) {
this.optionalFields = optionalFields;
}
public String getTimestampPattern() {
return timestampPattern;
}
public void setTimestampPattern(String timestampPattern) {
this.timestampPattern = timestampPattern;
}
public boolean isRaw() {
return raw;
}
public void setRaw(boolean raw) {
this.raw = raw;
}
public static void main(String[] args) throws Exception {
AggregatorConfiguration cfg = new AggregatorConfiguration();
cfg.setOutputElement("output-element");
cfg.setRaw(true);
cfg.setTimestampPattern("yyyy-MM-dd");
cfg.addFieldAggregation(new FieldAggregationConfiguration( "aggregated-field-1",
|
new JsonContentReference(new String[]{"path", "to", "field"}, JsonContentType.STRING)));
|
ottogroup/flink-operator-library
|
src/main/java/com/ottogroup/bi/streaming/operator/json/project/ProjectionMapperConfiguration.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
|
import java.io.Serializable;
import org.apache.sling.commons.json.JSONObject;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.project;
/**
* Provides the configuration used by {@link JsonContentProjectionMapper} to project a single field from an
* existing {@link JSONObject} into a newly created instance
* @author mnxfst
* @since Jan 27, 2016
*/
public class ProjectionMapperConfiguration implements Serializable {
private static final long serialVersionUID = 8215744170987684540L;
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/project/ProjectionMapperConfiguration.java
import java.io.Serializable;
import org.apache.sling.commons.json.JSONObject;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.project;
/**
* Provides the configuration used by {@link JsonContentProjectionMapper} to project a single field from an
* existing {@link JSONObject} into a newly created instance
* @author mnxfst
* @since Jan 27, 2016
*/
public class ProjectionMapperConfiguration implements Serializable {
private static final long serialVersionUID = 8215744170987684540L;
|
private JsonContentReference projectField = null;
|
ottogroup/flink-operator-library
|
src/main/java/com/ottogroup/bi/streaming/operator/json/decode/Base64ContentDecoderConfiguration.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
|
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.decode;
/**
* Configuration required for setting up instances of type {@link Base64ContentDecoder}
* @author mnxfst
* @since Mar 23, 2016
*/
public class Base64ContentDecoderConfiguration implements Serializable {
private static final long serialVersionUID = -1006181381054464078L;
/** prefix that must be removed before deflating which is attached to values found in referenced fields */
@JsonProperty(value="noValuePrefix", required=false)
private String noValuePrefix = null;
/** encoding to be applied when converting the deflated value into a string representation */
@JsonProperty(value="encoding", required=false)
private String encoding = "UTF-8";
/** reference to field the base64 encoded content is expected in */
@JsonProperty(value="jsonRef", required=true)
@NotNull
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/decode/Base64ContentDecoderConfiguration.java
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.decode;
/**
* Configuration required for setting up instances of type {@link Base64ContentDecoder}
* @author mnxfst
* @since Mar 23, 2016
*/
public class Base64ContentDecoderConfiguration implements Serializable {
private static final long serialVersionUID = -1006181381054464078L;
/** prefix that must be removed before deflating which is attached to values found in referenced fields */
@JsonProperty(value="noValuePrefix", required=false)
private String noValuePrefix = null;
/** encoding to be applied when converting the deflated value into a string representation */
@JsonProperty(value="encoding", required=false)
private String encoding = "UTF-8";
/** reference to field the base64 encoded content is expected in */
@JsonProperty(value="jsonRef", required=true)
@NotNull
|
private JsonContentReference jsonRef = null;
|
ottogroup/flink-operator-library
|
src/main/java/com/ottogroup/bi/streaming/operator/json/statsd/StatsdMetricConfig.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
|
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.statsd;
/**
* Points to a destination inside statsd/graphite to write a value to. It gives also a hint on the type
* @author mnxfst
* @since Mar 22, 2016
*/
public class StatsdMetricConfig implements Serializable {
private static final long serialVersionUID = -224675879381334473L;
@JsonProperty(value="path", required=true)
@NotNull
@Size(min=1)
private String path = null;
@JsonProperty(value="dynamicPathPrefix", required=false)
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/statsd/StatsdMetricConfig.java
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.statsd;
/**
* Points to a destination inside statsd/graphite to write a value to. It gives also a hint on the type
* @author mnxfst
* @since Mar 22, 2016
*/
public class StatsdMetricConfig implements Serializable {
private static final long serialVersionUID = -224675879381334473L;
@JsonProperty(value="path", required=true)
@NotNull
@Size(min=1)
private String path = null;
@JsonProperty(value="dynamicPathPrefix", required=false)
|
private JsonContentReference dynamicPathPrefix = null;
|
ottogroup/flink-operator-library
|
src/main/java/com/ottogroup/bi/streaming/operator/json/filter/cfg/FieldConditionConfiguration.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
|
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.filter.cfg;
/**
* Provides the configuration for a single content matcher
* @author mnxfst
* @since Apr 26, 2016
*
*/
public class FieldConditionConfiguration implements Serializable {
private static final long serialVersionUID = -5080138507217022078L;
/** reference into json object pointing to field that must be validated */
@NotNull
@JsonProperty(value="contentRef", required=true)
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/filter/cfg/FieldConditionConfiguration.java
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.filter.cfg;
/**
* Provides the configuration for a single content matcher
* @author mnxfst
* @since Apr 26, 2016
*
*/
public class FieldConditionConfiguration implements Serializable {
private static final long serialVersionUID = -5080138507217022078L;
/** reference into json object pointing to field that must be validated */
@NotNull
@JsonProperty(value="contentRef", required=true)
|
private JsonContentReference contentRef = null;
|
ottogroup/flink-operator-library
|
src/test/java/com/ottogroup/bi/streaming/operator/json/project/JsonContentProjectionMapperTest.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
|
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.project;
/**
* Test case for {@link JsonContentProjectionMapper}
* @author mnxfst
* @since Jan 27, 2016
*/
public class JsonContentProjectionMapperTest {
/**
* Test case for {@link JsonContentProjectionMapper#JsonContentProjectionMapper(java.util.List)}
* being provided null as input
*/
@Test
public void testConstructor_withNullInput() {
Assert.assertTrue(new JsonContentProjectionMapper(null).getConfiguration().isEmpty());
}
/**
* Test case for {@link JsonContentProjectionMapper#JsonContentProjectionMapper(java.util.List)}
* being provided an empty list as input
*/
@Test
public void testConstructor_withEmptyList() {
Assert.assertTrue(new JsonContentProjectionMapper(Collections.<ProjectionMapperConfiguration>emptyList()).getConfiguration().isEmpty());
}
/**
* Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
* provided null as input
*/
@Test
public void testMap_withNullInput() throws Exception {
@SuppressWarnings("unchecked")
List<ProjectionMapperConfiguration> cfg = Mockito.mock(List.class);
Mockito.when(cfg.isEmpty()).thenReturn(true);
Assert.assertNull(new JsonContentProjectionMapper(cfg).map(null));
Mockito.verify(cfg, Mockito.times(1)).isEmpty();
}
/**
* Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
* provided a valid object but no configuration
*/
@Test
public void testMap_withValidObjectEmptyConfiguration() throws Exception {
Assert.assertEquals("{}", new JsonContentProjectionMapper(Collections.<ProjectionMapperConfiguration>emptyList()).
map(new JSONObject("{\"key\":\"value\"}")).toString());
}
/**
* Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
* provided a valid object and valid configuration
*/
@Test
public void testMap_withValidObjectValidConfiguration() throws Exception {
String inputJson = "{\"test\":\"value\", \"sub\":{\"key\":\"another-value\"}}";
List<ProjectionMapperConfiguration> cfg = new ArrayList<>();
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
// Path: src/test/java/com/ottogroup/bi/streaming/operator/json/project/JsonContentProjectionMapperTest.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.project;
/**
* Test case for {@link JsonContentProjectionMapper}
* @author mnxfst
* @since Jan 27, 2016
*/
public class JsonContentProjectionMapperTest {
/**
* Test case for {@link JsonContentProjectionMapper#JsonContentProjectionMapper(java.util.List)}
* being provided null as input
*/
@Test
public void testConstructor_withNullInput() {
Assert.assertTrue(new JsonContentProjectionMapper(null).getConfiguration().isEmpty());
}
/**
* Test case for {@link JsonContentProjectionMapper#JsonContentProjectionMapper(java.util.List)}
* being provided an empty list as input
*/
@Test
public void testConstructor_withEmptyList() {
Assert.assertTrue(new JsonContentProjectionMapper(Collections.<ProjectionMapperConfiguration>emptyList()).getConfiguration().isEmpty());
}
/**
* Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
* provided null as input
*/
@Test
public void testMap_withNullInput() throws Exception {
@SuppressWarnings("unchecked")
List<ProjectionMapperConfiguration> cfg = Mockito.mock(List.class);
Mockito.when(cfg.isEmpty()).thenReturn(true);
Assert.assertNull(new JsonContentProjectionMapper(cfg).map(null));
Mockito.verify(cfg, Mockito.times(1)).isEmpty();
}
/**
* Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
* provided a valid object but no configuration
*/
@Test
public void testMap_withValidObjectEmptyConfiguration() throws Exception {
Assert.assertEquals("{}", new JsonContentProjectionMapper(Collections.<ProjectionMapperConfiguration>emptyList()).
map(new JSONObject("{\"key\":\"value\"}")).toString());
}
/**
* Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
* provided a valid object and valid configuration
*/
@Test
public void testMap_withValidObjectValidConfiguration() throws Exception {
String inputJson = "{\"test\":\"value\", \"sub\":{\"key\":\"another-value\"}}";
List<ProjectionMapperConfiguration> cfg = new ArrayList<>();
|
cfg.add(new ProjectionMapperConfiguration(new JsonContentReference(new String[]{"sub","key"}, JsonContentType.STRING, false),
|
ottogroup/flink-operator-library
|
src/test/java/com/ottogroup/bi/streaming/operator/json/project/JsonContentProjectionMapperTest.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
|
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.project;
/**
* Test case for {@link JsonContentProjectionMapper}
* @author mnxfst
* @since Jan 27, 2016
*/
public class JsonContentProjectionMapperTest {
/**
* Test case for {@link JsonContentProjectionMapper#JsonContentProjectionMapper(java.util.List)}
* being provided null as input
*/
@Test
public void testConstructor_withNullInput() {
Assert.assertTrue(new JsonContentProjectionMapper(null).getConfiguration().isEmpty());
}
/**
* Test case for {@link JsonContentProjectionMapper#JsonContentProjectionMapper(java.util.List)}
* being provided an empty list as input
*/
@Test
public void testConstructor_withEmptyList() {
Assert.assertTrue(new JsonContentProjectionMapper(Collections.<ProjectionMapperConfiguration>emptyList()).getConfiguration().isEmpty());
}
/**
* Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
* provided null as input
*/
@Test
public void testMap_withNullInput() throws Exception {
@SuppressWarnings("unchecked")
List<ProjectionMapperConfiguration> cfg = Mockito.mock(List.class);
Mockito.when(cfg.isEmpty()).thenReturn(true);
Assert.assertNull(new JsonContentProjectionMapper(cfg).map(null));
Mockito.verify(cfg, Mockito.times(1)).isEmpty();
}
/**
* Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
* provided a valid object but no configuration
*/
@Test
public void testMap_withValidObjectEmptyConfiguration() throws Exception {
Assert.assertEquals("{}", new JsonContentProjectionMapper(Collections.<ProjectionMapperConfiguration>emptyList()).
map(new JSONObject("{\"key\":\"value\"}")).toString());
}
/**
* Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
* provided a valid object and valid configuration
*/
@Test
public void testMap_withValidObjectValidConfiguration() throws Exception {
String inputJson = "{\"test\":\"value\", \"sub\":{\"key\":\"another-value\"}}";
List<ProjectionMapperConfiguration> cfg = new ArrayList<>();
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
// Path: src/test/java/com/ottogroup/bi/streaming/operator/json/project/JsonContentProjectionMapperTest.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.project;
/**
* Test case for {@link JsonContentProjectionMapper}
* @author mnxfst
* @since Jan 27, 2016
*/
public class JsonContentProjectionMapperTest {
/**
* Test case for {@link JsonContentProjectionMapper#JsonContentProjectionMapper(java.util.List)}
* being provided null as input
*/
@Test
public void testConstructor_withNullInput() {
Assert.assertTrue(new JsonContentProjectionMapper(null).getConfiguration().isEmpty());
}
/**
* Test case for {@link JsonContentProjectionMapper#JsonContentProjectionMapper(java.util.List)}
* being provided an empty list as input
*/
@Test
public void testConstructor_withEmptyList() {
Assert.assertTrue(new JsonContentProjectionMapper(Collections.<ProjectionMapperConfiguration>emptyList()).getConfiguration().isEmpty());
}
/**
* Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
* provided null as input
*/
@Test
public void testMap_withNullInput() throws Exception {
@SuppressWarnings("unchecked")
List<ProjectionMapperConfiguration> cfg = Mockito.mock(List.class);
Mockito.when(cfg.isEmpty()).thenReturn(true);
Assert.assertNull(new JsonContentProjectionMapper(cfg).map(null));
Mockito.verify(cfg, Mockito.times(1)).isEmpty();
}
/**
* Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
* provided a valid object but no configuration
*/
@Test
public void testMap_withValidObjectEmptyConfiguration() throws Exception {
Assert.assertEquals("{}", new JsonContentProjectionMapper(Collections.<ProjectionMapperConfiguration>emptyList()).
map(new JSONObject("{\"key\":\"value\"}")).toString());
}
/**
* Test case for {@link JsonContentProjectionMapper#map(org.apache.sling.commons.json.JSONObject)} being
* provided a valid object and valid configuration
*/
@Test
public void testMap_withValidObjectValidConfiguration() throws Exception {
String inputJson = "{\"test\":\"value\", \"sub\":{\"key\":\"another-value\"}}";
List<ProjectionMapperConfiguration> cfg = new ArrayList<>();
|
cfg.add(new ProjectionMapperConfiguration(new JsonContentReference(new String[]{"sub","key"}, JsonContentType.STRING, false),
|
ottogroup/flink-operator-library
|
src/test/java/com/ottogroup/bi/streaming/operator/json/csv/Json2CsvConverterTest.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
|
import java.util.ArrayList;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.csv;
/**
* Test case for {@link Json2CsvConverter}
* @author mnxfst
* @since Jan 28, 2016
*/
public class Json2CsvConverterTest {
/**
* Test case for {@link Json2CsvConverter#parse(org.apache.sling.commons.json.JSONObject)}
* being provided null as input
*/
@Test
public void testParse_withNullInput() {
Assert.assertTrue(new Json2CsvConverter(new ArrayList<>(), '\t').parse(null).isEmpty());
}
/**
* Test case for {@link Json2CsvConverter#parse(org.apache.sling.commons.json.JSONObject)}
* being provided a valid object but the converter has no export configuration
*/
@Test
public void testParse_withValidObjectButNoExportDefinition() throws Exception {
Assert.assertEquals("", new Json2CsvConverter(new ArrayList<>(), '\t').parse(new JSONObject("{\"test\":\"value\"}")));
}
/**
* Test case for {@link Json2CsvConverter#parse(org.apache.sling.commons.json.JSONObject)}
* being provided a valid object but the converter has an export configuration which references no existing field
*/
@Test
public void testParse_withValidObjectButExportDefinitionRefNoExistingField() throws Exception {
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
// Path: src/test/java/com/ottogroup/bi/streaming/operator/json/csv/Json2CsvConverterTest.java
import java.util.ArrayList;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.csv;
/**
* Test case for {@link Json2CsvConverter}
* @author mnxfst
* @since Jan 28, 2016
*/
public class Json2CsvConverterTest {
/**
* Test case for {@link Json2CsvConverter#parse(org.apache.sling.commons.json.JSONObject)}
* being provided null as input
*/
@Test
public void testParse_withNullInput() {
Assert.assertTrue(new Json2CsvConverter(new ArrayList<>(), '\t').parse(null).isEmpty());
}
/**
* Test case for {@link Json2CsvConverter#parse(org.apache.sling.commons.json.JSONObject)}
* being provided a valid object but the converter has no export configuration
*/
@Test
public void testParse_withValidObjectButNoExportDefinition() throws Exception {
Assert.assertEquals("", new Json2CsvConverter(new ArrayList<>(), '\t').parse(new JSONObject("{\"test\":\"value\"}")));
}
/**
* Test case for {@link Json2CsvConverter#parse(org.apache.sling.commons.json.JSONObject)}
* being provided a valid object but the converter has an export configuration which references no existing field
*/
@Test
public void testParse_withValidObjectButExportDefinitionRefNoExistingField() throws Exception {
|
List<JsonContentReference> refDef = new ArrayList<>();
|
ottogroup/flink-operator-library
|
src/test/java/com/ottogroup/bi/streaming/operator/json/csv/Json2CsvConverterTest.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
|
import java.util.ArrayList;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.csv;
/**
* Test case for {@link Json2CsvConverter}
* @author mnxfst
* @since Jan 28, 2016
*/
public class Json2CsvConverterTest {
/**
* Test case for {@link Json2CsvConverter#parse(org.apache.sling.commons.json.JSONObject)}
* being provided null as input
*/
@Test
public void testParse_withNullInput() {
Assert.assertTrue(new Json2CsvConverter(new ArrayList<>(), '\t').parse(null).isEmpty());
}
/**
* Test case for {@link Json2CsvConverter#parse(org.apache.sling.commons.json.JSONObject)}
* being provided a valid object but the converter has no export configuration
*/
@Test
public void testParse_withValidObjectButNoExportDefinition() throws Exception {
Assert.assertEquals("", new Json2CsvConverter(new ArrayList<>(), '\t').parse(new JSONObject("{\"test\":\"value\"}")));
}
/**
* Test case for {@link Json2CsvConverter#parse(org.apache.sling.commons.json.JSONObject)}
* being provided a valid object but the converter has an export configuration which references no existing field
*/
@Test
public void testParse_withValidObjectButExportDefinitionRefNoExistingField() throws Exception {
List<JsonContentReference> refDef = new ArrayList<>();
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
// Path: src/test/java/com/ottogroup/bi/streaming/operator/json/csv/Json2CsvConverterTest.java
import java.util.ArrayList;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.csv;
/**
* Test case for {@link Json2CsvConverter}
* @author mnxfst
* @since Jan 28, 2016
*/
public class Json2CsvConverterTest {
/**
* Test case for {@link Json2CsvConverter#parse(org.apache.sling.commons.json.JSONObject)}
* being provided null as input
*/
@Test
public void testParse_withNullInput() {
Assert.assertTrue(new Json2CsvConverter(new ArrayList<>(), '\t').parse(null).isEmpty());
}
/**
* Test case for {@link Json2CsvConverter#parse(org.apache.sling.commons.json.JSONObject)}
* being provided a valid object but the converter has no export configuration
*/
@Test
public void testParse_withValidObjectButNoExportDefinition() throws Exception {
Assert.assertEquals("", new Json2CsvConverter(new ArrayList<>(), '\t').parse(new JSONObject("{\"test\":\"value\"}")));
}
/**
* Test case for {@link Json2CsvConverter#parse(org.apache.sling.commons.json.JSONObject)}
* being provided a valid object but the converter has an export configuration which references no existing field
*/
@Test
public void testParse_withValidObjectButExportDefinitionRefNoExistingField() throws Exception {
List<JsonContentReference> refDef = new ArrayList<>();
|
refDef.add(new JsonContentReference(new String[]{"test", "field"}, JsonContentType.STRING));
|
ottogroup/flink-operator-library
|
src/main/java/com/ottogroup/bi/streaming/operator/json/aggregate/FieldAggregationConfiguration.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
|
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.aggregate;
/**
* Provides information on how to aggregate a specific element within a {@link JSONObject}
* @author mnxfst
* @since Jan 21, 2016
*/
public class FieldAggregationConfiguration implements Serializable {
private static final long serialVersionUID = -8937620821459847616L;
/** name that will be assigned to output element */
private String outputElement = null;
/** reference that points towards the field that must be aggregated */
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/aggregate/FieldAggregationConfiguration.java
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.aggregate;
/**
* Provides information on how to aggregate a specific element within a {@link JSONObject}
* @author mnxfst
* @since Jan 21, 2016
*/
public class FieldAggregationConfiguration implements Serializable {
private static final long serialVersionUID = -8937620821459847616L;
/** name that will be assigned to output element */
private String outputElement = null;
/** reference that points towards the field that must be aggregated */
|
private JsonContentReference aggregateField = null;
|
ottogroup/flink-operator-library
|
src/test/java/com/ottogroup/bi/streaming/operator/json/decode/Base64ContentDecoderTest.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
|
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.decode;
/**
* Test case for {@link Base64ContentDecoder}
* @author mnxfst
* @since Mar 23, 2016
*/
public class Base64ContentDecoderTest {
/**
* Test case for {@link Base64ContentDecoder#Base64ContentDeflater(java.util.List)} being provided null as input
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullInput() {
new Base64ContentDecoder(null);
}
/**
* Test case for {@link Base64ContentDecoder#Base64ContentDeflater(java.util.List)} being provided an empty list as input
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withEmptyInput() {
new Base64ContentDecoder(Collections.<Base64ContentDecoderConfiguration>emptyList());
}
/**
* Test case for {@link Base64ContentDecoder#Base64ContentDeflater(java.util.List)} being provided a list holding an empty
* element
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withEmptyListElement() {
List<Base64ContentDecoderConfiguration> refs = new ArrayList<>();
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
// Path: src/test/java/com/ottogroup/bi/streaming/operator/json/decode/Base64ContentDecoderTest.java
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.decode;
/**
* Test case for {@link Base64ContentDecoder}
* @author mnxfst
* @since Mar 23, 2016
*/
public class Base64ContentDecoderTest {
/**
* Test case for {@link Base64ContentDecoder#Base64ContentDeflater(java.util.List)} being provided null as input
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullInput() {
new Base64ContentDecoder(null);
}
/**
* Test case for {@link Base64ContentDecoder#Base64ContentDeflater(java.util.List)} being provided an empty list as input
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withEmptyInput() {
new Base64ContentDecoder(Collections.<Base64ContentDecoderConfiguration>emptyList());
}
/**
* Test case for {@link Base64ContentDecoder#Base64ContentDeflater(java.util.List)} being provided a list holding an empty
* element
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withEmptyListElement() {
List<Base64ContentDecoderConfiguration> refs = new ArrayList<>();
|
refs.add(new Base64ContentDecoderConfiguration(new JsonContentReference(new String[]{"test", "path"}, JsonContentType.INTEGER, false), "", null, false));
|
ottogroup/flink-operator-library
|
src/test/java/com/ottogroup/bi/streaming/operator/json/decode/Base64ContentDecoderTest.java
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
|
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
|
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.decode;
/**
* Test case for {@link Base64ContentDecoder}
* @author mnxfst
* @since Mar 23, 2016
*/
public class Base64ContentDecoderTest {
/**
* Test case for {@link Base64ContentDecoder#Base64ContentDeflater(java.util.List)} being provided null as input
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullInput() {
new Base64ContentDecoder(null);
}
/**
* Test case for {@link Base64ContentDecoder#Base64ContentDeflater(java.util.List)} being provided an empty list as input
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withEmptyInput() {
new Base64ContentDecoder(Collections.<Base64ContentDecoderConfiguration>emptyList());
}
/**
* Test case for {@link Base64ContentDecoder#Base64ContentDeflater(java.util.List)} being provided a list holding an empty
* element
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withEmptyListElement() {
List<Base64ContentDecoderConfiguration> refs = new ArrayList<>();
|
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentReference.java
// public class JsonContentReference implements Serializable {
//
// private static final long serialVersionUID = -5075723737186875253L;
//
// private String[] path = null;
// private JsonContentType contentType = null;
// private String conversionPattern = null;
// /** enforce strict evaluation and require the field to be present */
// private boolean required = false;
//
// public JsonContentReference() {
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType) {
// this(path, contentType, false);
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.required = required;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// }
//
// public JsonContentReference(final String[] path, final JsonContentType contentType, final String conversionPattern, final boolean required) {
// this.path = path;
// this.contentType = contentType;
// this.conversionPattern = conversionPattern;
// this.required = required;
// }
//
// public String[] getPath() {
// return path;
// }
//
// public void setPath(String[] path) {
// this.path = path;
// }
//
// public JsonContentType getContentType() {
// return contentType;
// }
//
// public void setContentType(JsonContentType contentType) {
// this.contentType = contentType;
// }
//
// public String getConversionPattern() {
// return conversionPattern;
// }
//
// public void setConversionPattern(String conversionPattern) {
// this.conversionPattern = conversionPattern;
// }
//
// public boolean isRequired() {
// return required;
// }
//
// public void setRequired(boolean required) {
// this.required = required;
// }
//
//
// }
//
// Path: src/main/java/com/ottogroup/bi/streaming/operator/json/JsonContentType.java
// public enum JsonContentType implements Serializable {
// STRING, INTEGER, DOUBLE, TIMESTAMP, BOOLEAN
// }
// Path: src/test/java/com/ottogroup/bi/streaming/operator/json/decode/Base64ContentDecoderTest.java
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.sling.commons.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import com.ottogroup.bi.streaming.operator.json.JsonContentReference;
import com.ottogroup.bi.streaming.operator.json.JsonContentType;
/**
* Copyright 2016 Otto (GmbH & Co KG)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.ottogroup.bi.streaming.operator.json.decode;
/**
* Test case for {@link Base64ContentDecoder}
* @author mnxfst
* @since Mar 23, 2016
*/
public class Base64ContentDecoderTest {
/**
* Test case for {@link Base64ContentDecoder#Base64ContentDeflater(java.util.List)} being provided null as input
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withNullInput() {
new Base64ContentDecoder(null);
}
/**
* Test case for {@link Base64ContentDecoder#Base64ContentDeflater(java.util.List)} being provided an empty list as input
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withEmptyInput() {
new Base64ContentDecoder(Collections.<Base64ContentDecoderConfiguration>emptyList());
}
/**
* Test case for {@link Base64ContentDecoder#Base64ContentDeflater(java.util.List)} being provided a list holding an empty
* element
*/
@Test(expected=IllegalArgumentException.class)
public void testConstructor_withEmptyListElement() {
List<Base64ContentDecoderConfiguration> refs = new ArrayList<>();
|
refs.add(new Base64ContentDecoderConfiguration(new JsonContentReference(new String[]{"test", "path"}, JsonContentType.INTEGER, false), "", null, false));
|
michaelmarconi/oncue
|
oncue-agent/src/main/java/oncue/agent/UnlimitedCapacityAgent.java
|
// Path: oncue-common/src/main/java/oncue/common/messages/SimpleWorkRequest.java
// public class SimpleWorkRequest extends AbstractWorkRequest {
//
// private static final long serialVersionUID = -9114194566914906613L;
//
// public SimpleWorkRequest(ActorRef agent, Set<String> workerTypes) {
// super(agent, workerTypes);
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder();
// for (String workerType : getWorkerTypes()) {
// builder.append("[" + workerType + "]");
// }
// return "Simple work request for worker types: " + builder.toString();
// }
// }
|
import java.util.Set;
import oncue.common.messages.SimpleWorkRequest;
|
/*******************************************************************************
* Copyright 2013 Michael Marconi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 oncue.agent;
/**
* This agent assumes that its host has unlimited capacity and it will respond
* to every WORK_AVAILABLE message by requesting work.
*
* <b>Use with care</b>, as this agent may run out of resources if you have
* enough jobs!
*/
public class UnlimitedCapacityAgent extends AbstractAgent {
public UnlimitedCapacityAgent(Set<String> workerTypes) {
super(workerTypes);
}
@Override
protected void requestWork() {
|
// Path: oncue-common/src/main/java/oncue/common/messages/SimpleWorkRequest.java
// public class SimpleWorkRequest extends AbstractWorkRequest {
//
// private static final long serialVersionUID = -9114194566914906613L;
//
// public SimpleWorkRequest(ActorRef agent, Set<String> workerTypes) {
// super(agent, workerTypes);
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder();
// for (String workerType : getWorkerTypes()) {
// builder.append("[" + workerType + "]");
// }
// return "Simple work request for worker types: " + builder.toString();
// }
// }
// Path: oncue-agent/src/main/java/oncue/agent/UnlimitedCapacityAgent.java
import java.util.Set;
import oncue.common.messages.SimpleWorkRequest;
/*******************************************************************************
* Copyright 2013 Michael Marconi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 oncue.agent;
/**
* This agent assumes that its host has unlimited capacity and it will respond
* to every WORK_AVAILABLE message by requesting work.
*
* <b>Use with care</b>, as this agent may run out of resources if you have
* enough jobs!
*/
public class UnlimitedCapacityAgent extends AbstractAgent {
public UnlimitedCapacityAgent(Set<String> workerTypes) {
super(workerTypes);
}
@Override
protected void requestWork() {
|
getScheduler().tell(new SimpleWorkRequest(getSelf(), getWorkerTypes()), getSelf());
|
michaelmarconi/oncue
|
oncue-service/app/controllers/Application.java
|
// Path: oncue-service/app/oncue/EventMachine.java
// public class EventMachine extends UntypedActor {
//
// private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
// private static List<WebSocket.Out<JsonNode>> clients = new ArrayList<>();
// private final static ObjectMapper mapper = new ObjectMapper();
// private final Cancellable pinger = getContext()
// .system()
// .scheduler()
// .schedule(Duration.create(500, TimeUnit.MILLISECONDS),
// Duration.create(30000, TimeUnit.MILLISECONDS), getSelf(), "PING",
// getContext().dispatcher());
//
// static {
// mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"));
// mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
// mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
// }
//
// @Override
// public void preStart() {
// super.preStart();
// EventStream eventStream = getContext().system().eventStream();
// eventStream.subscribe(getSelf(), AgentStartedEvent.class);
// eventStream.subscribe(getSelf(), AgentStoppedEvent.class);
// eventStream.subscribe(getSelf(), JobEnqueuedEvent.class);
// eventStream.subscribe(getSelf(), JobProgressEvent.class);
// eventStream.subscribe(getSelf(), JobFailedEvent.class);
// eventStream.subscribe(getSelf(), JobCleanupEvent.class);
// log.info("EventMachine is listening for OnCue events.");
// }
//
// @Override
// public void postStop() {
// pinger.cancel();
// }
//
// public static void addSocket(WebSocket.In<JsonNode> in, final WebSocket.Out<JsonNode> out) {
// clients.add(out);
// in.onClose(new Callback0() {
//
// @Override
// public void invoke() {
// clients.remove(out);
// }
// });
// }
//
// @Override
// public void onReceive(Object message) {
// if ("PING".equals(message)) {
// log.debug("Pinging websocket clients...");
// for (WebSocket.Out<JsonNode> client : clients) {
// client.write(Json.toJson("PING"));
// }
// } else if (message instanceof AgentStartedEvent) {
// AgentStartedEvent agentStarted = (AgentStartedEvent) message;
// for (WebSocket.Out<JsonNode> client : clients) {
// ObjectNode event = constructEvent("agent:started", "agent", agentStarted.getAgent());
// client.write(event);
// }
// } else if (message instanceof AgentStoppedEvent) {
// AgentStoppedEvent agentStopped = (AgentStoppedEvent) message;
// for (WebSocket.Out<JsonNode> client : clients) {
// ObjectNode event = constructEvent("agent:stopped", "agent", agentStopped.getAgent());
// client.write(event);
// }
// } else if (message instanceof JobEnqueuedEvent) {
// JobEnqueuedEvent jobEnqueued = (JobEnqueuedEvent) message;
// for (WebSocket.Out<JsonNode> client : clients) {
// ObjectNode event = constructEvent("job:enqueued", "job", jobEnqueued.getJob().clonePublicView());
// client.write(event);
// }
// } else if (message instanceof JobProgressEvent) {
// JobProgressEvent jobProgress = (JobProgressEvent) message;
// for (WebSocket.Out<JsonNode> client : clients) {
// ObjectNode event = constructEvent("job:progressed", "job", jobProgress.getJob().clonePublicView());
// client.write(event);
// }
// } else if (message instanceof JobFailedEvent) {
// JobFailedEvent jobFailed = (JobFailedEvent) message;
// for (WebSocket.Out<JsonNode> client : clients) {
// ObjectNode event = constructEvent("job:failed", "job", jobFailed.getJob().clonePublicView());
// client.write(event);
// }
// } else if (message instanceof JobCleanupEvent) {
// for (WebSocket.Out<JsonNode> client : clients) {
// ObjectNode event = constructEvent("jobs:cleanup", "jobs", null);
// client.write(event);
// }
// }
// }
//
// /**
// * Construct an event
// *
// * @param eventKey is the composite event key, e.g. 'agent:started'
// * @param subject is the subject of the event, e.g. 'agent'
// * @param payload is the object to serialise
// * @return a JSON object node representing the event
// */
// private ObjectNode constructEvent(String eventKey, String subject, Object payload) {
// ObjectNode eventNode = Json.newObject();
// ObjectNode payloadNode = Json.newObject();
// eventNode.put(eventKey, payloadNode);
// payloadNode.put(subject, mapper.valueToTree(payload));
// return eventNode;
// }
//
// }
|
import oncue.EventMachine;
import org.codehaus.jackson.JsonNode;
import play.mvc.Controller;
import play.mvc.Result;
import play.mvc.WebSocket;
import views.html.index;
|
package controllers;
public class Application extends Controller {
public static Result index() {
return ok(index.render());
}
public static WebSocket<JsonNode> socketHandler() {
return new WebSocket<JsonNode>() {
public void onReady(WebSocket.In<JsonNode> in, WebSocket.Out<JsonNode> out) {
|
// Path: oncue-service/app/oncue/EventMachine.java
// public class EventMachine extends UntypedActor {
//
// private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
// private static List<WebSocket.Out<JsonNode>> clients = new ArrayList<>();
// private final static ObjectMapper mapper = new ObjectMapper();
// private final Cancellable pinger = getContext()
// .system()
// .scheduler()
// .schedule(Duration.create(500, TimeUnit.MILLISECONDS),
// Duration.create(30000, TimeUnit.MILLISECONDS), getSelf(), "PING",
// getContext().dispatcher());
//
// static {
// mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"));
// mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
// mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
// }
//
// @Override
// public void preStart() {
// super.preStart();
// EventStream eventStream = getContext().system().eventStream();
// eventStream.subscribe(getSelf(), AgentStartedEvent.class);
// eventStream.subscribe(getSelf(), AgentStoppedEvent.class);
// eventStream.subscribe(getSelf(), JobEnqueuedEvent.class);
// eventStream.subscribe(getSelf(), JobProgressEvent.class);
// eventStream.subscribe(getSelf(), JobFailedEvent.class);
// eventStream.subscribe(getSelf(), JobCleanupEvent.class);
// log.info("EventMachine is listening for OnCue events.");
// }
//
// @Override
// public void postStop() {
// pinger.cancel();
// }
//
// public static void addSocket(WebSocket.In<JsonNode> in, final WebSocket.Out<JsonNode> out) {
// clients.add(out);
// in.onClose(new Callback0() {
//
// @Override
// public void invoke() {
// clients.remove(out);
// }
// });
// }
//
// @Override
// public void onReceive(Object message) {
// if ("PING".equals(message)) {
// log.debug("Pinging websocket clients...");
// for (WebSocket.Out<JsonNode> client : clients) {
// client.write(Json.toJson("PING"));
// }
// } else if (message instanceof AgentStartedEvent) {
// AgentStartedEvent agentStarted = (AgentStartedEvent) message;
// for (WebSocket.Out<JsonNode> client : clients) {
// ObjectNode event = constructEvent("agent:started", "agent", agentStarted.getAgent());
// client.write(event);
// }
// } else if (message instanceof AgentStoppedEvent) {
// AgentStoppedEvent agentStopped = (AgentStoppedEvent) message;
// for (WebSocket.Out<JsonNode> client : clients) {
// ObjectNode event = constructEvent("agent:stopped", "agent", agentStopped.getAgent());
// client.write(event);
// }
// } else if (message instanceof JobEnqueuedEvent) {
// JobEnqueuedEvent jobEnqueued = (JobEnqueuedEvent) message;
// for (WebSocket.Out<JsonNode> client : clients) {
// ObjectNode event = constructEvent("job:enqueued", "job", jobEnqueued.getJob().clonePublicView());
// client.write(event);
// }
// } else if (message instanceof JobProgressEvent) {
// JobProgressEvent jobProgress = (JobProgressEvent) message;
// for (WebSocket.Out<JsonNode> client : clients) {
// ObjectNode event = constructEvent("job:progressed", "job", jobProgress.getJob().clonePublicView());
// client.write(event);
// }
// } else if (message instanceof JobFailedEvent) {
// JobFailedEvent jobFailed = (JobFailedEvent) message;
// for (WebSocket.Out<JsonNode> client : clients) {
// ObjectNode event = constructEvent("job:failed", "job", jobFailed.getJob().clonePublicView());
// client.write(event);
// }
// } else if (message instanceof JobCleanupEvent) {
// for (WebSocket.Out<JsonNode> client : clients) {
// ObjectNode event = constructEvent("jobs:cleanup", "jobs", null);
// client.write(event);
// }
// }
// }
//
// /**
// * Construct an event
// *
// * @param eventKey is the composite event key, e.g. 'agent:started'
// * @param subject is the subject of the event, e.g. 'agent'
// * @param payload is the object to serialise
// * @return a JSON object node representing the event
// */
// private ObjectNode constructEvent(String eventKey, String subject, Object payload) {
// ObjectNode eventNode = Json.newObject();
// ObjectNode payloadNode = Json.newObject();
// eventNode.put(eventKey, payloadNode);
// payloadNode.put(subject, mapper.valueToTree(payload));
// return eventNode;
// }
//
// }
// Path: oncue-service/app/controllers/Application.java
import oncue.EventMachine;
import org.codehaus.jackson.JsonNode;
import play.mvc.Controller;
import play.mvc.Result;
import play.mvc.WebSocket;
import views.html.index;
package controllers;
public class Application extends Controller {
public static Result index() {
return ok(index.render());
}
public static WebSocket<JsonNode> socketHandler() {
return new WebSocket<JsonNode>() {
public void onReady(WebSocket.In<JsonNode> in, WebSocket.Out<JsonNode> out) {
|
EventMachine.addSocket(in, out);
|
michaelmarconi/oncue
|
oncue-common/src/main/java/oncue/common/events/AgentStartedEvent.java
|
// Path: oncue-common/src/main/java/oncue/common/messages/Agent.java
// public class Agent implements Serializable {
//
// private static final long serialVersionUID = 1597787228823561798L;
// private String id;
// private String url;
//
// public Agent(String url) {
// super();
// this.id = url;
// this.url = url;
// }
//
// public String getId() {
// return id;
// }
//
// public String getUrl() {
// return url;
// }
// }
|
import java.io.Serializable;
import oncue.common.messages.Agent;
|
package oncue.common.events;
/**
* This event is fired when an agent has started and becomes available.
*/
public class AgentStartedEvent implements Serializable {
private static final long serialVersionUID = -4209324707640249480L;
|
// Path: oncue-common/src/main/java/oncue/common/messages/Agent.java
// public class Agent implements Serializable {
//
// private static final long serialVersionUID = 1597787228823561798L;
// private String id;
// private String url;
//
// public Agent(String url) {
// super();
// this.id = url;
// this.url = url;
// }
//
// public String getId() {
// return id;
// }
//
// public String getUrl() {
// return url;
// }
// }
// Path: oncue-common/src/main/java/oncue/common/events/AgentStartedEvent.java
import java.io.Serializable;
import oncue.common.messages.Agent;
package oncue.common.events;
/**
* This event is fired when an agent has started and becomes available.
*/
public class AgentStartedEvent implements Serializable {
private static final long serialVersionUID = -4209324707640249480L;
|
private Agent agent;
|
michaelmarconi/oncue
|
oncue-service/app/oncue/EventMachine.java
|
// Path: oncue-common/src/main/java/oncue/common/events/AgentStartedEvent.java
// public class AgentStartedEvent implements Serializable {
//
// private static final long serialVersionUID = -4209324707640249480L;
// private Agent agent;
//
// public AgentStartedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/AgentStoppedEvent.java
// public class AgentStoppedEvent implements Serializable {
//
// private static final long serialVersionUID = -866097369897591277L;
// private Agent agent;
//
// public AgentStoppedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobCleanupEvent.java
// public class JobCleanupEvent implements Serializable {
//
// private static final long serialVersionUID = 5037062135239309149L;
//
// public JobCleanupEvent() {
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobEnqueuedEvent.java
// public class JobEnqueuedEvent implements Serializable {
//
// private static final long serialVersionUID = 7820441419463038812L;
//
// private Job job;
//
// public JobEnqueuedEvent(Job job) {
// super();
// this.setJob((Job) job.clone());
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobFailedEvent.java
// public class JobFailedEvent implements Serializable {
//
// private static final long serialVersionUID = 604402719393058553L;
// private Job job;
//
// public JobFailedEvent(Job job) {
// super();
// this.job = job;
// }
//
// public Job getJob() {
// return job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobProgressEvent.java
// public class JobProgressEvent implements Serializable {
//
// private static final long serialVersionUID = 7779509571217733670L;
// private Job job;
//
// public JobProgressEvent(Job job) {
// super();
// this.setJob(job);
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
|
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import oncue.common.events.AgentStartedEvent;
import oncue.common.events.AgentStoppedEvent;
import oncue.common.events.JobCleanupEvent;
import oncue.common.events.JobEnqueuedEvent;
import oncue.common.events.JobFailedEvent;
import oncue.common.events.JobProgressEvent;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.node.ObjectNode;
import play.libs.F.Callback0;
import play.libs.Json;
import play.mvc.WebSocket;
import scala.concurrent.duration.Duration;
import akka.actor.Cancellable;
import akka.actor.UntypedActor;
import akka.event.EventStream;
import akka.event.Logging;
import akka.event.LoggingAdapter;
|
package oncue;
public class EventMachine extends UntypedActor {
private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
private static List<WebSocket.Out<JsonNode>> clients = new ArrayList<>();
private final static ObjectMapper mapper = new ObjectMapper();
private final Cancellable pinger = getContext()
.system()
.scheduler()
.schedule(Duration.create(500, TimeUnit.MILLISECONDS),
Duration.create(30000, TimeUnit.MILLISECONDS), getSelf(), "PING",
getContext().dispatcher());
static {
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"));
mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
@Override
public void preStart() {
super.preStart();
EventStream eventStream = getContext().system().eventStream();
|
// Path: oncue-common/src/main/java/oncue/common/events/AgentStartedEvent.java
// public class AgentStartedEvent implements Serializable {
//
// private static final long serialVersionUID = -4209324707640249480L;
// private Agent agent;
//
// public AgentStartedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/AgentStoppedEvent.java
// public class AgentStoppedEvent implements Serializable {
//
// private static final long serialVersionUID = -866097369897591277L;
// private Agent agent;
//
// public AgentStoppedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobCleanupEvent.java
// public class JobCleanupEvent implements Serializable {
//
// private static final long serialVersionUID = 5037062135239309149L;
//
// public JobCleanupEvent() {
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobEnqueuedEvent.java
// public class JobEnqueuedEvent implements Serializable {
//
// private static final long serialVersionUID = 7820441419463038812L;
//
// private Job job;
//
// public JobEnqueuedEvent(Job job) {
// super();
// this.setJob((Job) job.clone());
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobFailedEvent.java
// public class JobFailedEvent implements Serializable {
//
// private static final long serialVersionUID = 604402719393058553L;
// private Job job;
//
// public JobFailedEvent(Job job) {
// super();
// this.job = job;
// }
//
// public Job getJob() {
// return job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobProgressEvent.java
// public class JobProgressEvent implements Serializable {
//
// private static final long serialVersionUID = 7779509571217733670L;
// private Job job;
//
// public JobProgressEvent(Job job) {
// super();
// this.setJob(job);
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
// Path: oncue-service/app/oncue/EventMachine.java
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import oncue.common.events.AgentStartedEvent;
import oncue.common.events.AgentStoppedEvent;
import oncue.common.events.JobCleanupEvent;
import oncue.common.events.JobEnqueuedEvent;
import oncue.common.events.JobFailedEvent;
import oncue.common.events.JobProgressEvent;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.node.ObjectNode;
import play.libs.F.Callback0;
import play.libs.Json;
import play.mvc.WebSocket;
import scala.concurrent.duration.Duration;
import akka.actor.Cancellable;
import akka.actor.UntypedActor;
import akka.event.EventStream;
import akka.event.Logging;
import akka.event.LoggingAdapter;
package oncue;
public class EventMachine extends UntypedActor {
private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
private static List<WebSocket.Out<JsonNode>> clients = new ArrayList<>();
private final static ObjectMapper mapper = new ObjectMapper();
private final Cancellable pinger = getContext()
.system()
.scheduler()
.schedule(Duration.create(500, TimeUnit.MILLISECONDS),
Duration.create(30000, TimeUnit.MILLISECONDS), getSelf(), "PING",
getContext().dispatcher());
static {
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"));
mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
@Override
public void preStart() {
super.preStart();
EventStream eventStream = getContext().system().eventStream();
|
eventStream.subscribe(getSelf(), AgentStartedEvent.class);
|
michaelmarconi/oncue
|
oncue-service/app/oncue/EventMachine.java
|
// Path: oncue-common/src/main/java/oncue/common/events/AgentStartedEvent.java
// public class AgentStartedEvent implements Serializable {
//
// private static final long serialVersionUID = -4209324707640249480L;
// private Agent agent;
//
// public AgentStartedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/AgentStoppedEvent.java
// public class AgentStoppedEvent implements Serializable {
//
// private static final long serialVersionUID = -866097369897591277L;
// private Agent agent;
//
// public AgentStoppedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobCleanupEvent.java
// public class JobCleanupEvent implements Serializable {
//
// private static final long serialVersionUID = 5037062135239309149L;
//
// public JobCleanupEvent() {
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobEnqueuedEvent.java
// public class JobEnqueuedEvent implements Serializable {
//
// private static final long serialVersionUID = 7820441419463038812L;
//
// private Job job;
//
// public JobEnqueuedEvent(Job job) {
// super();
// this.setJob((Job) job.clone());
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobFailedEvent.java
// public class JobFailedEvent implements Serializable {
//
// private static final long serialVersionUID = 604402719393058553L;
// private Job job;
//
// public JobFailedEvent(Job job) {
// super();
// this.job = job;
// }
//
// public Job getJob() {
// return job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobProgressEvent.java
// public class JobProgressEvent implements Serializable {
//
// private static final long serialVersionUID = 7779509571217733670L;
// private Job job;
//
// public JobProgressEvent(Job job) {
// super();
// this.setJob(job);
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
|
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import oncue.common.events.AgentStartedEvent;
import oncue.common.events.AgentStoppedEvent;
import oncue.common.events.JobCleanupEvent;
import oncue.common.events.JobEnqueuedEvent;
import oncue.common.events.JobFailedEvent;
import oncue.common.events.JobProgressEvent;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.node.ObjectNode;
import play.libs.F.Callback0;
import play.libs.Json;
import play.mvc.WebSocket;
import scala.concurrent.duration.Duration;
import akka.actor.Cancellable;
import akka.actor.UntypedActor;
import akka.event.EventStream;
import akka.event.Logging;
import akka.event.LoggingAdapter;
|
package oncue;
public class EventMachine extends UntypedActor {
private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
private static List<WebSocket.Out<JsonNode>> clients = new ArrayList<>();
private final static ObjectMapper mapper = new ObjectMapper();
private final Cancellable pinger = getContext()
.system()
.scheduler()
.schedule(Duration.create(500, TimeUnit.MILLISECONDS),
Duration.create(30000, TimeUnit.MILLISECONDS), getSelf(), "PING",
getContext().dispatcher());
static {
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"));
mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
@Override
public void preStart() {
super.preStart();
EventStream eventStream = getContext().system().eventStream();
eventStream.subscribe(getSelf(), AgentStartedEvent.class);
|
// Path: oncue-common/src/main/java/oncue/common/events/AgentStartedEvent.java
// public class AgentStartedEvent implements Serializable {
//
// private static final long serialVersionUID = -4209324707640249480L;
// private Agent agent;
//
// public AgentStartedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/AgentStoppedEvent.java
// public class AgentStoppedEvent implements Serializable {
//
// private static final long serialVersionUID = -866097369897591277L;
// private Agent agent;
//
// public AgentStoppedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobCleanupEvent.java
// public class JobCleanupEvent implements Serializable {
//
// private static final long serialVersionUID = 5037062135239309149L;
//
// public JobCleanupEvent() {
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobEnqueuedEvent.java
// public class JobEnqueuedEvent implements Serializable {
//
// private static final long serialVersionUID = 7820441419463038812L;
//
// private Job job;
//
// public JobEnqueuedEvent(Job job) {
// super();
// this.setJob((Job) job.clone());
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobFailedEvent.java
// public class JobFailedEvent implements Serializable {
//
// private static final long serialVersionUID = 604402719393058553L;
// private Job job;
//
// public JobFailedEvent(Job job) {
// super();
// this.job = job;
// }
//
// public Job getJob() {
// return job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobProgressEvent.java
// public class JobProgressEvent implements Serializable {
//
// private static final long serialVersionUID = 7779509571217733670L;
// private Job job;
//
// public JobProgressEvent(Job job) {
// super();
// this.setJob(job);
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
// Path: oncue-service/app/oncue/EventMachine.java
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import oncue.common.events.AgentStartedEvent;
import oncue.common.events.AgentStoppedEvent;
import oncue.common.events.JobCleanupEvent;
import oncue.common.events.JobEnqueuedEvent;
import oncue.common.events.JobFailedEvent;
import oncue.common.events.JobProgressEvent;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.node.ObjectNode;
import play.libs.F.Callback0;
import play.libs.Json;
import play.mvc.WebSocket;
import scala.concurrent.duration.Duration;
import akka.actor.Cancellable;
import akka.actor.UntypedActor;
import akka.event.EventStream;
import akka.event.Logging;
import akka.event.LoggingAdapter;
package oncue;
public class EventMachine extends UntypedActor {
private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
private static List<WebSocket.Out<JsonNode>> clients = new ArrayList<>();
private final static ObjectMapper mapper = new ObjectMapper();
private final Cancellable pinger = getContext()
.system()
.scheduler()
.schedule(Duration.create(500, TimeUnit.MILLISECONDS),
Duration.create(30000, TimeUnit.MILLISECONDS), getSelf(), "PING",
getContext().dispatcher());
static {
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"));
mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
@Override
public void preStart() {
super.preStart();
EventStream eventStream = getContext().system().eventStream();
eventStream.subscribe(getSelf(), AgentStartedEvent.class);
|
eventStream.subscribe(getSelf(), AgentStoppedEvent.class);
|
michaelmarconi/oncue
|
oncue-service/app/oncue/EventMachine.java
|
// Path: oncue-common/src/main/java/oncue/common/events/AgentStartedEvent.java
// public class AgentStartedEvent implements Serializable {
//
// private static final long serialVersionUID = -4209324707640249480L;
// private Agent agent;
//
// public AgentStartedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/AgentStoppedEvent.java
// public class AgentStoppedEvent implements Serializable {
//
// private static final long serialVersionUID = -866097369897591277L;
// private Agent agent;
//
// public AgentStoppedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobCleanupEvent.java
// public class JobCleanupEvent implements Serializable {
//
// private static final long serialVersionUID = 5037062135239309149L;
//
// public JobCleanupEvent() {
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobEnqueuedEvent.java
// public class JobEnqueuedEvent implements Serializable {
//
// private static final long serialVersionUID = 7820441419463038812L;
//
// private Job job;
//
// public JobEnqueuedEvent(Job job) {
// super();
// this.setJob((Job) job.clone());
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobFailedEvent.java
// public class JobFailedEvent implements Serializable {
//
// private static final long serialVersionUID = 604402719393058553L;
// private Job job;
//
// public JobFailedEvent(Job job) {
// super();
// this.job = job;
// }
//
// public Job getJob() {
// return job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobProgressEvent.java
// public class JobProgressEvent implements Serializable {
//
// private static final long serialVersionUID = 7779509571217733670L;
// private Job job;
//
// public JobProgressEvent(Job job) {
// super();
// this.setJob(job);
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
|
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import oncue.common.events.AgentStartedEvent;
import oncue.common.events.AgentStoppedEvent;
import oncue.common.events.JobCleanupEvent;
import oncue.common.events.JobEnqueuedEvent;
import oncue.common.events.JobFailedEvent;
import oncue.common.events.JobProgressEvent;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.node.ObjectNode;
import play.libs.F.Callback0;
import play.libs.Json;
import play.mvc.WebSocket;
import scala.concurrent.duration.Duration;
import akka.actor.Cancellable;
import akka.actor.UntypedActor;
import akka.event.EventStream;
import akka.event.Logging;
import akka.event.LoggingAdapter;
|
package oncue;
public class EventMachine extends UntypedActor {
private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
private static List<WebSocket.Out<JsonNode>> clients = new ArrayList<>();
private final static ObjectMapper mapper = new ObjectMapper();
private final Cancellable pinger = getContext()
.system()
.scheduler()
.schedule(Duration.create(500, TimeUnit.MILLISECONDS),
Duration.create(30000, TimeUnit.MILLISECONDS), getSelf(), "PING",
getContext().dispatcher());
static {
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"));
mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
@Override
public void preStart() {
super.preStart();
EventStream eventStream = getContext().system().eventStream();
eventStream.subscribe(getSelf(), AgentStartedEvent.class);
eventStream.subscribe(getSelf(), AgentStoppedEvent.class);
|
// Path: oncue-common/src/main/java/oncue/common/events/AgentStartedEvent.java
// public class AgentStartedEvent implements Serializable {
//
// private static final long serialVersionUID = -4209324707640249480L;
// private Agent agent;
//
// public AgentStartedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/AgentStoppedEvent.java
// public class AgentStoppedEvent implements Serializable {
//
// private static final long serialVersionUID = -866097369897591277L;
// private Agent agent;
//
// public AgentStoppedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobCleanupEvent.java
// public class JobCleanupEvent implements Serializable {
//
// private static final long serialVersionUID = 5037062135239309149L;
//
// public JobCleanupEvent() {
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobEnqueuedEvent.java
// public class JobEnqueuedEvent implements Serializable {
//
// private static final long serialVersionUID = 7820441419463038812L;
//
// private Job job;
//
// public JobEnqueuedEvent(Job job) {
// super();
// this.setJob((Job) job.clone());
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobFailedEvent.java
// public class JobFailedEvent implements Serializable {
//
// private static final long serialVersionUID = 604402719393058553L;
// private Job job;
//
// public JobFailedEvent(Job job) {
// super();
// this.job = job;
// }
//
// public Job getJob() {
// return job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobProgressEvent.java
// public class JobProgressEvent implements Serializable {
//
// private static final long serialVersionUID = 7779509571217733670L;
// private Job job;
//
// public JobProgressEvent(Job job) {
// super();
// this.setJob(job);
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
// Path: oncue-service/app/oncue/EventMachine.java
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import oncue.common.events.AgentStartedEvent;
import oncue.common.events.AgentStoppedEvent;
import oncue.common.events.JobCleanupEvent;
import oncue.common.events.JobEnqueuedEvent;
import oncue.common.events.JobFailedEvent;
import oncue.common.events.JobProgressEvent;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.node.ObjectNode;
import play.libs.F.Callback0;
import play.libs.Json;
import play.mvc.WebSocket;
import scala.concurrent.duration.Duration;
import akka.actor.Cancellable;
import akka.actor.UntypedActor;
import akka.event.EventStream;
import akka.event.Logging;
import akka.event.LoggingAdapter;
package oncue;
public class EventMachine extends UntypedActor {
private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
private static List<WebSocket.Out<JsonNode>> clients = new ArrayList<>();
private final static ObjectMapper mapper = new ObjectMapper();
private final Cancellable pinger = getContext()
.system()
.scheduler()
.schedule(Duration.create(500, TimeUnit.MILLISECONDS),
Duration.create(30000, TimeUnit.MILLISECONDS), getSelf(), "PING",
getContext().dispatcher());
static {
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"));
mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
@Override
public void preStart() {
super.preStart();
EventStream eventStream = getContext().system().eventStream();
eventStream.subscribe(getSelf(), AgentStartedEvent.class);
eventStream.subscribe(getSelf(), AgentStoppedEvent.class);
|
eventStream.subscribe(getSelf(), JobEnqueuedEvent.class);
|
michaelmarconi/oncue
|
oncue-service/app/oncue/EventMachine.java
|
// Path: oncue-common/src/main/java/oncue/common/events/AgentStartedEvent.java
// public class AgentStartedEvent implements Serializable {
//
// private static final long serialVersionUID = -4209324707640249480L;
// private Agent agent;
//
// public AgentStartedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/AgentStoppedEvent.java
// public class AgentStoppedEvent implements Serializable {
//
// private static final long serialVersionUID = -866097369897591277L;
// private Agent agent;
//
// public AgentStoppedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobCleanupEvent.java
// public class JobCleanupEvent implements Serializable {
//
// private static final long serialVersionUID = 5037062135239309149L;
//
// public JobCleanupEvent() {
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobEnqueuedEvent.java
// public class JobEnqueuedEvent implements Serializable {
//
// private static final long serialVersionUID = 7820441419463038812L;
//
// private Job job;
//
// public JobEnqueuedEvent(Job job) {
// super();
// this.setJob((Job) job.clone());
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobFailedEvent.java
// public class JobFailedEvent implements Serializable {
//
// private static final long serialVersionUID = 604402719393058553L;
// private Job job;
//
// public JobFailedEvent(Job job) {
// super();
// this.job = job;
// }
//
// public Job getJob() {
// return job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobProgressEvent.java
// public class JobProgressEvent implements Serializable {
//
// private static final long serialVersionUID = 7779509571217733670L;
// private Job job;
//
// public JobProgressEvent(Job job) {
// super();
// this.setJob(job);
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
|
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import oncue.common.events.AgentStartedEvent;
import oncue.common.events.AgentStoppedEvent;
import oncue.common.events.JobCleanupEvent;
import oncue.common.events.JobEnqueuedEvent;
import oncue.common.events.JobFailedEvent;
import oncue.common.events.JobProgressEvent;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.node.ObjectNode;
import play.libs.F.Callback0;
import play.libs.Json;
import play.mvc.WebSocket;
import scala.concurrent.duration.Duration;
import akka.actor.Cancellable;
import akka.actor.UntypedActor;
import akka.event.EventStream;
import akka.event.Logging;
import akka.event.LoggingAdapter;
|
package oncue;
public class EventMachine extends UntypedActor {
private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
private static List<WebSocket.Out<JsonNode>> clients = new ArrayList<>();
private final static ObjectMapper mapper = new ObjectMapper();
private final Cancellable pinger = getContext()
.system()
.scheduler()
.schedule(Duration.create(500, TimeUnit.MILLISECONDS),
Duration.create(30000, TimeUnit.MILLISECONDS), getSelf(), "PING",
getContext().dispatcher());
static {
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"));
mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
@Override
public void preStart() {
super.preStart();
EventStream eventStream = getContext().system().eventStream();
eventStream.subscribe(getSelf(), AgentStartedEvent.class);
eventStream.subscribe(getSelf(), AgentStoppedEvent.class);
eventStream.subscribe(getSelf(), JobEnqueuedEvent.class);
|
// Path: oncue-common/src/main/java/oncue/common/events/AgentStartedEvent.java
// public class AgentStartedEvent implements Serializable {
//
// private static final long serialVersionUID = -4209324707640249480L;
// private Agent agent;
//
// public AgentStartedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/AgentStoppedEvent.java
// public class AgentStoppedEvent implements Serializable {
//
// private static final long serialVersionUID = -866097369897591277L;
// private Agent agent;
//
// public AgentStoppedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobCleanupEvent.java
// public class JobCleanupEvent implements Serializable {
//
// private static final long serialVersionUID = 5037062135239309149L;
//
// public JobCleanupEvent() {
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobEnqueuedEvent.java
// public class JobEnqueuedEvent implements Serializable {
//
// private static final long serialVersionUID = 7820441419463038812L;
//
// private Job job;
//
// public JobEnqueuedEvent(Job job) {
// super();
// this.setJob((Job) job.clone());
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobFailedEvent.java
// public class JobFailedEvent implements Serializable {
//
// private static final long serialVersionUID = 604402719393058553L;
// private Job job;
//
// public JobFailedEvent(Job job) {
// super();
// this.job = job;
// }
//
// public Job getJob() {
// return job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobProgressEvent.java
// public class JobProgressEvent implements Serializable {
//
// private static final long serialVersionUID = 7779509571217733670L;
// private Job job;
//
// public JobProgressEvent(Job job) {
// super();
// this.setJob(job);
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
// Path: oncue-service/app/oncue/EventMachine.java
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import oncue.common.events.AgentStartedEvent;
import oncue.common.events.AgentStoppedEvent;
import oncue.common.events.JobCleanupEvent;
import oncue.common.events.JobEnqueuedEvent;
import oncue.common.events.JobFailedEvent;
import oncue.common.events.JobProgressEvent;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.node.ObjectNode;
import play.libs.F.Callback0;
import play.libs.Json;
import play.mvc.WebSocket;
import scala.concurrent.duration.Duration;
import akka.actor.Cancellable;
import akka.actor.UntypedActor;
import akka.event.EventStream;
import akka.event.Logging;
import akka.event.LoggingAdapter;
package oncue;
public class EventMachine extends UntypedActor {
private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
private static List<WebSocket.Out<JsonNode>> clients = new ArrayList<>();
private final static ObjectMapper mapper = new ObjectMapper();
private final Cancellable pinger = getContext()
.system()
.scheduler()
.schedule(Duration.create(500, TimeUnit.MILLISECONDS),
Duration.create(30000, TimeUnit.MILLISECONDS), getSelf(), "PING",
getContext().dispatcher());
static {
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"));
mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
@Override
public void preStart() {
super.preStart();
EventStream eventStream = getContext().system().eventStream();
eventStream.subscribe(getSelf(), AgentStartedEvent.class);
eventStream.subscribe(getSelf(), AgentStoppedEvent.class);
eventStream.subscribe(getSelf(), JobEnqueuedEvent.class);
|
eventStream.subscribe(getSelf(), JobProgressEvent.class);
|
michaelmarconi/oncue
|
oncue-service/app/oncue/EventMachine.java
|
// Path: oncue-common/src/main/java/oncue/common/events/AgentStartedEvent.java
// public class AgentStartedEvent implements Serializable {
//
// private static final long serialVersionUID = -4209324707640249480L;
// private Agent agent;
//
// public AgentStartedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/AgentStoppedEvent.java
// public class AgentStoppedEvent implements Serializable {
//
// private static final long serialVersionUID = -866097369897591277L;
// private Agent agent;
//
// public AgentStoppedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobCleanupEvent.java
// public class JobCleanupEvent implements Serializable {
//
// private static final long serialVersionUID = 5037062135239309149L;
//
// public JobCleanupEvent() {
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobEnqueuedEvent.java
// public class JobEnqueuedEvent implements Serializable {
//
// private static final long serialVersionUID = 7820441419463038812L;
//
// private Job job;
//
// public JobEnqueuedEvent(Job job) {
// super();
// this.setJob((Job) job.clone());
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobFailedEvent.java
// public class JobFailedEvent implements Serializable {
//
// private static final long serialVersionUID = 604402719393058553L;
// private Job job;
//
// public JobFailedEvent(Job job) {
// super();
// this.job = job;
// }
//
// public Job getJob() {
// return job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobProgressEvent.java
// public class JobProgressEvent implements Serializable {
//
// private static final long serialVersionUID = 7779509571217733670L;
// private Job job;
//
// public JobProgressEvent(Job job) {
// super();
// this.setJob(job);
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
|
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import oncue.common.events.AgentStartedEvent;
import oncue.common.events.AgentStoppedEvent;
import oncue.common.events.JobCleanupEvent;
import oncue.common.events.JobEnqueuedEvent;
import oncue.common.events.JobFailedEvent;
import oncue.common.events.JobProgressEvent;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.node.ObjectNode;
import play.libs.F.Callback0;
import play.libs.Json;
import play.mvc.WebSocket;
import scala.concurrent.duration.Duration;
import akka.actor.Cancellable;
import akka.actor.UntypedActor;
import akka.event.EventStream;
import akka.event.Logging;
import akka.event.LoggingAdapter;
|
package oncue;
public class EventMachine extends UntypedActor {
private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
private static List<WebSocket.Out<JsonNode>> clients = new ArrayList<>();
private final static ObjectMapper mapper = new ObjectMapper();
private final Cancellable pinger = getContext()
.system()
.scheduler()
.schedule(Duration.create(500, TimeUnit.MILLISECONDS),
Duration.create(30000, TimeUnit.MILLISECONDS), getSelf(), "PING",
getContext().dispatcher());
static {
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"));
mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
@Override
public void preStart() {
super.preStart();
EventStream eventStream = getContext().system().eventStream();
eventStream.subscribe(getSelf(), AgentStartedEvent.class);
eventStream.subscribe(getSelf(), AgentStoppedEvent.class);
eventStream.subscribe(getSelf(), JobEnqueuedEvent.class);
eventStream.subscribe(getSelf(), JobProgressEvent.class);
|
// Path: oncue-common/src/main/java/oncue/common/events/AgentStartedEvent.java
// public class AgentStartedEvent implements Serializable {
//
// private static final long serialVersionUID = -4209324707640249480L;
// private Agent agent;
//
// public AgentStartedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/AgentStoppedEvent.java
// public class AgentStoppedEvent implements Serializable {
//
// private static final long serialVersionUID = -866097369897591277L;
// private Agent agent;
//
// public AgentStoppedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobCleanupEvent.java
// public class JobCleanupEvent implements Serializable {
//
// private static final long serialVersionUID = 5037062135239309149L;
//
// public JobCleanupEvent() {
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobEnqueuedEvent.java
// public class JobEnqueuedEvent implements Serializable {
//
// private static final long serialVersionUID = 7820441419463038812L;
//
// private Job job;
//
// public JobEnqueuedEvent(Job job) {
// super();
// this.setJob((Job) job.clone());
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobFailedEvent.java
// public class JobFailedEvent implements Serializable {
//
// private static final long serialVersionUID = 604402719393058553L;
// private Job job;
//
// public JobFailedEvent(Job job) {
// super();
// this.job = job;
// }
//
// public Job getJob() {
// return job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobProgressEvent.java
// public class JobProgressEvent implements Serializable {
//
// private static final long serialVersionUID = 7779509571217733670L;
// private Job job;
//
// public JobProgressEvent(Job job) {
// super();
// this.setJob(job);
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
// Path: oncue-service/app/oncue/EventMachine.java
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import oncue.common.events.AgentStartedEvent;
import oncue.common.events.AgentStoppedEvent;
import oncue.common.events.JobCleanupEvent;
import oncue.common.events.JobEnqueuedEvent;
import oncue.common.events.JobFailedEvent;
import oncue.common.events.JobProgressEvent;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.node.ObjectNode;
import play.libs.F.Callback0;
import play.libs.Json;
import play.mvc.WebSocket;
import scala.concurrent.duration.Duration;
import akka.actor.Cancellable;
import akka.actor.UntypedActor;
import akka.event.EventStream;
import akka.event.Logging;
import akka.event.LoggingAdapter;
package oncue;
public class EventMachine extends UntypedActor {
private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
private static List<WebSocket.Out<JsonNode>> clients = new ArrayList<>();
private final static ObjectMapper mapper = new ObjectMapper();
private final Cancellable pinger = getContext()
.system()
.scheduler()
.schedule(Duration.create(500, TimeUnit.MILLISECONDS),
Duration.create(30000, TimeUnit.MILLISECONDS), getSelf(), "PING",
getContext().dispatcher());
static {
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"));
mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
@Override
public void preStart() {
super.preStart();
EventStream eventStream = getContext().system().eventStream();
eventStream.subscribe(getSelf(), AgentStartedEvent.class);
eventStream.subscribe(getSelf(), AgentStoppedEvent.class);
eventStream.subscribe(getSelf(), JobEnqueuedEvent.class);
eventStream.subscribe(getSelf(), JobProgressEvent.class);
|
eventStream.subscribe(getSelf(), JobFailedEvent.class);
|
michaelmarconi/oncue
|
oncue-service/app/oncue/EventMachine.java
|
// Path: oncue-common/src/main/java/oncue/common/events/AgentStartedEvent.java
// public class AgentStartedEvent implements Serializable {
//
// private static final long serialVersionUID = -4209324707640249480L;
// private Agent agent;
//
// public AgentStartedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/AgentStoppedEvent.java
// public class AgentStoppedEvent implements Serializable {
//
// private static final long serialVersionUID = -866097369897591277L;
// private Agent agent;
//
// public AgentStoppedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobCleanupEvent.java
// public class JobCleanupEvent implements Serializable {
//
// private static final long serialVersionUID = 5037062135239309149L;
//
// public JobCleanupEvent() {
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobEnqueuedEvent.java
// public class JobEnqueuedEvent implements Serializable {
//
// private static final long serialVersionUID = 7820441419463038812L;
//
// private Job job;
//
// public JobEnqueuedEvent(Job job) {
// super();
// this.setJob((Job) job.clone());
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobFailedEvent.java
// public class JobFailedEvent implements Serializable {
//
// private static final long serialVersionUID = 604402719393058553L;
// private Job job;
//
// public JobFailedEvent(Job job) {
// super();
// this.job = job;
// }
//
// public Job getJob() {
// return job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobProgressEvent.java
// public class JobProgressEvent implements Serializable {
//
// private static final long serialVersionUID = 7779509571217733670L;
// private Job job;
//
// public JobProgressEvent(Job job) {
// super();
// this.setJob(job);
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
|
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import oncue.common.events.AgentStartedEvent;
import oncue.common.events.AgentStoppedEvent;
import oncue.common.events.JobCleanupEvent;
import oncue.common.events.JobEnqueuedEvent;
import oncue.common.events.JobFailedEvent;
import oncue.common.events.JobProgressEvent;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.node.ObjectNode;
import play.libs.F.Callback0;
import play.libs.Json;
import play.mvc.WebSocket;
import scala.concurrent.duration.Duration;
import akka.actor.Cancellable;
import akka.actor.UntypedActor;
import akka.event.EventStream;
import akka.event.Logging;
import akka.event.LoggingAdapter;
|
package oncue;
public class EventMachine extends UntypedActor {
private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
private static List<WebSocket.Out<JsonNode>> clients = new ArrayList<>();
private final static ObjectMapper mapper = new ObjectMapper();
private final Cancellable pinger = getContext()
.system()
.scheduler()
.schedule(Duration.create(500, TimeUnit.MILLISECONDS),
Duration.create(30000, TimeUnit.MILLISECONDS), getSelf(), "PING",
getContext().dispatcher());
static {
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"));
mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
@Override
public void preStart() {
super.preStart();
EventStream eventStream = getContext().system().eventStream();
eventStream.subscribe(getSelf(), AgentStartedEvent.class);
eventStream.subscribe(getSelf(), AgentStoppedEvent.class);
eventStream.subscribe(getSelf(), JobEnqueuedEvent.class);
eventStream.subscribe(getSelf(), JobProgressEvent.class);
eventStream.subscribe(getSelf(), JobFailedEvent.class);
|
// Path: oncue-common/src/main/java/oncue/common/events/AgentStartedEvent.java
// public class AgentStartedEvent implements Serializable {
//
// private static final long serialVersionUID = -4209324707640249480L;
// private Agent agent;
//
// public AgentStartedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/AgentStoppedEvent.java
// public class AgentStoppedEvent implements Serializable {
//
// private static final long serialVersionUID = -866097369897591277L;
// private Agent agent;
//
// public AgentStoppedEvent(Agent agent) {
// this.agent = agent;
// }
//
// public Agent getAgent() {
// return agent;
// }
//
// @Override
// public String toString() {
// return agent.getUrl();
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobCleanupEvent.java
// public class JobCleanupEvent implements Serializable {
//
// private static final long serialVersionUID = 5037062135239309149L;
//
// public JobCleanupEvent() {
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobEnqueuedEvent.java
// public class JobEnqueuedEvent implements Serializable {
//
// private static final long serialVersionUID = 7820441419463038812L;
//
// private Job job;
//
// public JobEnqueuedEvent(Job job) {
// super();
// this.setJob((Job) job.clone());
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobFailedEvent.java
// public class JobFailedEvent implements Serializable {
//
// private static final long serialVersionUID = 604402719393058553L;
// private Job job;
//
// public JobFailedEvent(Job job) {
// super();
// this.job = job;
// }
//
// public Job getJob() {
// return job;
// }
//
// }
//
// Path: oncue-common/src/main/java/oncue/common/events/JobProgressEvent.java
// public class JobProgressEvent implements Serializable {
//
// private static final long serialVersionUID = 7779509571217733670L;
// private Job job;
//
// public JobProgressEvent(Job job) {
// super();
// this.setJob(job);
// }
//
// public Job getJob() {
// return job;
// }
//
// public void setJob(Job job) {
// this.job = job;
// }
//
// }
// Path: oncue-service/app/oncue/EventMachine.java
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import oncue.common.events.AgentStartedEvent;
import oncue.common.events.AgentStoppedEvent;
import oncue.common.events.JobCleanupEvent;
import oncue.common.events.JobEnqueuedEvent;
import oncue.common.events.JobFailedEvent;
import oncue.common.events.JobProgressEvent;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.node.ObjectNode;
import play.libs.F.Callback0;
import play.libs.Json;
import play.mvc.WebSocket;
import scala.concurrent.duration.Duration;
import akka.actor.Cancellable;
import akka.actor.UntypedActor;
import akka.event.EventStream;
import akka.event.Logging;
import akka.event.LoggingAdapter;
package oncue;
public class EventMachine extends UntypedActor {
private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);
private static List<WebSocket.Out<JsonNode>> clients = new ArrayList<>();
private final static ObjectMapper mapper = new ObjectMapper();
private final Cancellable pinger = getContext()
.system()
.scheduler()
.schedule(Duration.create(500, TimeUnit.MILLISECONDS),
Duration.create(30000, TimeUnit.MILLISECONDS), getSelf(), "PING",
getContext().dispatcher());
static {
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"));
mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
@Override
public void preStart() {
super.preStart();
EventStream eventStream = getContext().system().eventStream();
eventStream.subscribe(getSelf(), AgentStartedEvent.class);
eventStream.subscribe(getSelf(), AgentStoppedEvent.class);
eventStream.subscribe(getSelf(), JobEnqueuedEvent.class);
eventStream.subscribe(getSelf(), JobProgressEvent.class);
eventStream.subscribe(getSelf(), JobFailedEvent.class);
|
eventStream.subscribe(getSelf(), JobCleanupEvent.class);
|
michaelmarconi/oncue
|
oncue-agent/src/main/java/oncue/agent/JVMCapacityAgent.java
|
// Path: oncue-common/src/main/java/oncue/common/messages/JVMCapacityWorkRequest.java
// public class JVMCapacityWorkRequest extends AbstractWorkRequest {
//
// private static final long serialVersionUID = -4503173564405936817L;
//
// private long freeMemory;
// private long maxMemory;
// private long totalMemory;
//
// public JVMCapacityWorkRequest(ActorRef agent, Set<String> workerTypes, long freeMemory, long totalMemory,
// long maxMemory) {
// super(agent, workerTypes);
// this.setFreeMemory(freeMemory);
// this.totalMemory = totalMemory;
// this.maxMemory = maxMemory;
// }
//
// public long getFreeMemory() {
// return freeMemory;
// }
//
// public long getMaxMemory() {
// return maxMemory;
// }
//
// public long getTotalMemory() {
// return totalMemory;
// }
//
// public void setFreeMemory(long freeMemory) {
// this.freeMemory = freeMemory;
// }
//
// @Override
// public String toString() {
// return super.toString()
// + String.format(" [freeMem = %s, totalMem = %s, maxMem = %s]", getFreeMemory(), totalMemory, maxMemory);
// }
// }
|
import java.util.Set;
import oncue.common.messages.JVMCapacityWorkRequest;
|
/*******************************************************************************
* Copyright 2013 Michael Marconi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 oncue.agent;
/**
* This agent will report a snapshot of the JVM memory capacity of this node
* when requesting work.
*/
public class JVMCapacityAgent extends AbstractAgent {
// Only used for testing
private long testCapacity;
public JVMCapacityAgent(Set<String> workerTypes) {
super(workerTypes);
}
/**
* This constructor should only be used for testing!
*
* @param testCapacity
* overrides the maximum number of jobs to deal with concurrently
*/
public JVMCapacityAgent(Set<String> workerTypes, long testCapacity) {
super(workerTypes);
this.testCapacity = testCapacity;
}
@Override
protected void requestWork() {
if (testProbe != null) {
getScheduler().tell(
|
// Path: oncue-common/src/main/java/oncue/common/messages/JVMCapacityWorkRequest.java
// public class JVMCapacityWorkRequest extends AbstractWorkRequest {
//
// private static final long serialVersionUID = -4503173564405936817L;
//
// private long freeMemory;
// private long maxMemory;
// private long totalMemory;
//
// public JVMCapacityWorkRequest(ActorRef agent, Set<String> workerTypes, long freeMemory, long totalMemory,
// long maxMemory) {
// super(agent, workerTypes);
// this.setFreeMemory(freeMemory);
// this.totalMemory = totalMemory;
// this.maxMemory = maxMemory;
// }
//
// public long getFreeMemory() {
// return freeMemory;
// }
//
// public long getMaxMemory() {
// return maxMemory;
// }
//
// public long getTotalMemory() {
// return totalMemory;
// }
//
// public void setFreeMemory(long freeMemory) {
// this.freeMemory = freeMemory;
// }
//
// @Override
// public String toString() {
// return super.toString()
// + String.format(" [freeMem = %s, totalMem = %s, maxMem = %s]", getFreeMemory(), totalMemory, maxMemory);
// }
// }
// Path: oncue-agent/src/main/java/oncue/agent/JVMCapacityAgent.java
import java.util.Set;
import oncue.common.messages.JVMCapacityWorkRequest;
/*******************************************************************************
* Copyright 2013 Michael Marconi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 oncue.agent;
/**
* This agent will report a snapshot of the JVM memory capacity of this node
* when requesting work.
*/
public class JVMCapacityAgent extends AbstractAgent {
// Only used for testing
private long testCapacity;
public JVMCapacityAgent(Set<String> workerTypes) {
super(workerTypes);
}
/**
* This constructor should only be used for testing!
*
* @param testCapacity
* overrides the maximum number of jobs to deal with concurrently
*/
public JVMCapacityAgent(Set<String> workerTypes, long testCapacity) {
super(workerTypes);
this.testCapacity = testCapacity;
}
@Override
protected void requestWork() {
if (testProbe != null) {
getScheduler().tell(
|
new JVMCapacityWorkRequest(getSelf(), getWorkerTypes(), testCapacity, testCapacity, testCapacity),
|
michaelmarconi/oncue
|
oncue-common/src/main/java/oncue/common/events/AgentStarted.java
|
// Path: oncue-common/src/main/java/oncue/common/messages/Agent.java
// public class Agent implements Serializable {
//
// private static final long serialVersionUID = 1597787228823561798L;
// private String id;
// private String url;
//
// public Agent(String url) {
// super();
// this.id = url;
// this.url = url;
// }
//
// public String getId() {
// return id;
// }
//
// public String getUrl() {
// return url;
// }
// }
|
import java.io.Serializable;
import oncue.common.messages.Agent;
|
package oncue.common.events;
/**
* This event is fired when an agent has started and becomes available.
*/
public class AgentStarted implements Serializable {
private static final long serialVersionUID = -4209324707640249480L;
|
// Path: oncue-common/src/main/java/oncue/common/messages/Agent.java
// public class Agent implements Serializable {
//
// private static final long serialVersionUID = 1597787228823561798L;
// private String id;
// private String url;
//
// public Agent(String url) {
// super();
// this.id = url;
// this.url = url;
// }
//
// public String getId() {
// return id;
// }
//
// public String getUrl() {
// return url;
// }
// }
// Path: oncue-common/src/main/java/oncue/common/events/AgentStarted.java
import java.io.Serializable;
import oncue.common.messages.Agent;
package oncue.common.events;
/**
* This event is fired when an agent has started and becomes available.
*/
public class AgentStarted implements Serializable {
private static final long serialVersionUID = -4209324707640249480L;
|
private Agent agent;
|
michaelmarconi/oncue
|
oncue-common/src/main/java/oncue/common/events/AgentStoppedEvent.java
|
// Path: oncue-common/src/main/java/oncue/common/messages/Agent.java
// public class Agent implements Serializable {
//
// private static final long serialVersionUID = 1597787228823561798L;
// private String id;
// private String url;
//
// public Agent(String url) {
// super();
// this.id = url;
// this.url = url;
// }
//
// public String getId() {
// return id;
// }
//
// public String getUrl() {
// return url;
// }
// }
|
import java.io.Serializable;
import oncue.common.messages.Agent;
|
package oncue.common.events;
/**
* This event is fired when an agent has stopped and is no longer available.
*/
public class AgentStoppedEvent implements Serializable {
private static final long serialVersionUID = -866097369897591277L;
|
// Path: oncue-common/src/main/java/oncue/common/messages/Agent.java
// public class Agent implements Serializable {
//
// private static final long serialVersionUID = 1597787228823561798L;
// private String id;
// private String url;
//
// public Agent(String url) {
// super();
// this.id = url;
// this.url = url;
// }
//
// public String getId() {
// return id;
// }
//
// public String getUrl() {
// return url;
// }
// }
// Path: oncue-common/src/main/java/oncue/common/events/AgentStoppedEvent.java
import java.io.Serializable;
import oncue.common.messages.Agent;
package oncue.common.events;
/**
* This event is fired when an agent has stopped and is no longer available.
*/
public class AgentStoppedEvent implements Serializable {
private static final long serialVersionUID = -866097369897591277L;
|
private Agent agent;
|
michaelmarconi/oncue
|
oncue-agent/src/main/java/oncue/agent/OnCueAgent.java
|
// Path: oncue-common/src/main/java/oncue/common/settings/Settings.java
// public class Settings implements Extension {
//
// private static final String SCHEDULER_BACKING_STORE_PATH = "scheduler.backing-store.class";
// public final String SCHEDULER_NAME;
// public final String SCHEDULER_PATH;
// public final String SCHEDULER_CLASS;
// public String SCHEDULER_BACKING_STORE_CLASS;
// public final FiniteDuration SCHEDULER_TIMEOUT;
// public final FiniteDuration SCHEDULER_BROADCAST_JOBS_FREQUENCY;
// public final FiniteDuration SCHEDULER_BROADCAST_JOBS_QUIESCENCE_PERIOD;
// public final FiniteDuration SCHEDULER_MONITOR_AGENTS_FREQUENCY;
// public final FiniteDuration SCHEDULER_AGENT_HEARTBEAT_TIMEOUT;
//
// public final FiniteDuration TIMED_JOBS_RETRY_DELAY;
//
// public final String AGENT_NAME;
// public final String AGENT_PATH;
// public final String AGENT_CLASS;
// public final FiniteDuration AGENT_HEARTBEAT_FREQUENCY;
//
// public final List<Map<String, Object>> TIMED_JOBS_TIMETABLE;
//
// @SuppressWarnings("unchecked")
// public Settings(Config config) {
//
// Config oncueConfig = config.getConfig("oncue");
//
// SCHEDULER_NAME = oncueConfig.getString("scheduler.name");
// SCHEDULER_PATH = oncueConfig.getString("scheduler.path");
// SCHEDULER_CLASS = oncueConfig.getString("scheduler.class");
// SCHEDULER_TIMEOUT = Duration
// .create(oncueConfig.getMilliseconds("scheduler.response-timeout"), TimeUnit.MILLISECONDS);
//
// if(oncueConfig.hasPath(SCHEDULER_BACKING_STORE_PATH)) {
// SCHEDULER_BACKING_STORE_CLASS = oncueConfig.getString(SCHEDULER_BACKING_STORE_PATH);
// } else {
// SCHEDULER_BACKING_STORE_CLASS = null;
// }
//
// SCHEDULER_BROADCAST_JOBS_FREQUENCY = Duration.create(
// oncueConfig.getMilliseconds("scheduler.broadcast-jobs-frequency"), TimeUnit.MILLISECONDS);
//
// SCHEDULER_BROADCAST_JOBS_QUIESCENCE_PERIOD = Duration.create(
// oncueConfig.getMilliseconds("scheduler.broadcast-jobs-quiescence-period"), TimeUnit.MILLISECONDS);
//
// SCHEDULER_MONITOR_AGENTS_FREQUENCY = Duration.create(
// oncueConfig.getMilliseconds("scheduler.monitor-agents-frequency"), TimeUnit.MILLISECONDS);
//
// SCHEDULER_AGENT_HEARTBEAT_TIMEOUT = Duration.create(
// oncueConfig.getMilliseconds("scheduler.agent-heartbeat-timeout"), TimeUnit.MILLISECONDS);
//
// AGENT_NAME = oncueConfig.getString("agent.name");
// AGENT_PATH = oncueConfig.getString("agent.path");
// AGENT_CLASS = oncueConfig.getString("agent.class");
// AGENT_HEARTBEAT_FREQUENCY = Duration.create(oncueConfig.getMilliseconds("agent.heartbeat-frequency"),
// TimeUnit.MILLISECONDS);
//
// TIMED_JOBS_RETRY_DELAY = Duration.create(oncueConfig.getMilliseconds("timed-jobs.retry-delay"),
// TimeUnit.MILLISECONDS);
//
// // Timed jobs are optional
// if (oncueConfig.hasPath("timed-jobs.timetable")) {
// TIMED_JOBS_TIMETABLE = (ArrayList<Map<String, Object>>) oncueConfig.getAnyRef("timed-jobs.timetable");
// } else {
// TIMED_JOBS_TIMETABLE = null;
// }
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/settings/SettingsProvider.java
// public class SettingsProvider extends AbstractExtensionId<Settings> implements ExtensionIdProvider {
// public final static SettingsProvider SettingsProvider = new SettingsProvider();
//
// @SuppressWarnings("static-access")
// public SettingsProvider lookup() {
// return SettingsProvider.SettingsProvider;
// }
//
// public Settings createExtension(ExtendedActorSystem system) {
// return new Settings(system.settings().config());
// }
// }
|
import java.util.HashSet;
import java.util.Set;
import oncue.common.settings.Settings;
import oncue.common.settings.SettingsProvider;
import akka.actor.Actor;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActorFactory;
import akka.kernel.Bootable;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
|
package oncue.agent;
public class OnCueAgent implements Bootable {
public static void main(String[] args) {
new OnCueAgent().startup();
}
private ActorSystem system;
@Override
public void shutdown() {
system.shutdown();
}
@SuppressWarnings("serial")
@Override
public void startup() {
Config config = ConfigFactory.load();
system = ActorSystem.create("oncue-agent", config.getConfig("oncue").withFallback(config));
|
// Path: oncue-common/src/main/java/oncue/common/settings/Settings.java
// public class Settings implements Extension {
//
// private static final String SCHEDULER_BACKING_STORE_PATH = "scheduler.backing-store.class";
// public final String SCHEDULER_NAME;
// public final String SCHEDULER_PATH;
// public final String SCHEDULER_CLASS;
// public String SCHEDULER_BACKING_STORE_CLASS;
// public final FiniteDuration SCHEDULER_TIMEOUT;
// public final FiniteDuration SCHEDULER_BROADCAST_JOBS_FREQUENCY;
// public final FiniteDuration SCHEDULER_BROADCAST_JOBS_QUIESCENCE_PERIOD;
// public final FiniteDuration SCHEDULER_MONITOR_AGENTS_FREQUENCY;
// public final FiniteDuration SCHEDULER_AGENT_HEARTBEAT_TIMEOUT;
//
// public final FiniteDuration TIMED_JOBS_RETRY_DELAY;
//
// public final String AGENT_NAME;
// public final String AGENT_PATH;
// public final String AGENT_CLASS;
// public final FiniteDuration AGENT_HEARTBEAT_FREQUENCY;
//
// public final List<Map<String, Object>> TIMED_JOBS_TIMETABLE;
//
// @SuppressWarnings("unchecked")
// public Settings(Config config) {
//
// Config oncueConfig = config.getConfig("oncue");
//
// SCHEDULER_NAME = oncueConfig.getString("scheduler.name");
// SCHEDULER_PATH = oncueConfig.getString("scheduler.path");
// SCHEDULER_CLASS = oncueConfig.getString("scheduler.class");
// SCHEDULER_TIMEOUT = Duration
// .create(oncueConfig.getMilliseconds("scheduler.response-timeout"), TimeUnit.MILLISECONDS);
//
// if(oncueConfig.hasPath(SCHEDULER_BACKING_STORE_PATH)) {
// SCHEDULER_BACKING_STORE_CLASS = oncueConfig.getString(SCHEDULER_BACKING_STORE_PATH);
// } else {
// SCHEDULER_BACKING_STORE_CLASS = null;
// }
//
// SCHEDULER_BROADCAST_JOBS_FREQUENCY = Duration.create(
// oncueConfig.getMilliseconds("scheduler.broadcast-jobs-frequency"), TimeUnit.MILLISECONDS);
//
// SCHEDULER_BROADCAST_JOBS_QUIESCENCE_PERIOD = Duration.create(
// oncueConfig.getMilliseconds("scheduler.broadcast-jobs-quiescence-period"), TimeUnit.MILLISECONDS);
//
// SCHEDULER_MONITOR_AGENTS_FREQUENCY = Duration.create(
// oncueConfig.getMilliseconds("scheduler.monitor-agents-frequency"), TimeUnit.MILLISECONDS);
//
// SCHEDULER_AGENT_HEARTBEAT_TIMEOUT = Duration.create(
// oncueConfig.getMilliseconds("scheduler.agent-heartbeat-timeout"), TimeUnit.MILLISECONDS);
//
// AGENT_NAME = oncueConfig.getString("agent.name");
// AGENT_PATH = oncueConfig.getString("agent.path");
// AGENT_CLASS = oncueConfig.getString("agent.class");
// AGENT_HEARTBEAT_FREQUENCY = Duration.create(oncueConfig.getMilliseconds("agent.heartbeat-frequency"),
// TimeUnit.MILLISECONDS);
//
// TIMED_JOBS_RETRY_DELAY = Duration.create(oncueConfig.getMilliseconds("timed-jobs.retry-delay"),
// TimeUnit.MILLISECONDS);
//
// // Timed jobs are optional
// if (oncueConfig.hasPath("timed-jobs.timetable")) {
// TIMED_JOBS_TIMETABLE = (ArrayList<Map<String, Object>>) oncueConfig.getAnyRef("timed-jobs.timetable");
// } else {
// TIMED_JOBS_TIMETABLE = null;
// }
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/settings/SettingsProvider.java
// public class SettingsProvider extends AbstractExtensionId<Settings> implements ExtensionIdProvider {
// public final static SettingsProvider SettingsProvider = new SettingsProvider();
//
// @SuppressWarnings("static-access")
// public SettingsProvider lookup() {
// return SettingsProvider.SettingsProvider;
// }
//
// public Settings createExtension(ExtendedActorSystem system) {
// return new Settings(system.settings().config());
// }
// }
// Path: oncue-agent/src/main/java/oncue/agent/OnCueAgent.java
import java.util.HashSet;
import java.util.Set;
import oncue.common.settings.Settings;
import oncue.common.settings.SettingsProvider;
import akka.actor.Actor;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActorFactory;
import akka.kernel.Bootable;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
package oncue.agent;
public class OnCueAgent implements Bootable {
public static void main(String[] args) {
new OnCueAgent().startup();
}
private ActorSystem system;
@Override
public void shutdown() {
system.shutdown();
}
@SuppressWarnings("serial")
@Override
public void startup() {
Config config = ConfigFactory.load();
system = ActorSystem.create("oncue-agent", config.getConfig("oncue").withFallback(config));
|
final Settings settings = SettingsProvider.SettingsProvider.get(system);
|
michaelmarconi/oncue
|
oncue-agent/src/main/java/oncue/agent/OnCueAgent.java
|
// Path: oncue-common/src/main/java/oncue/common/settings/Settings.java
// public class Settings implements Extension {
//
// private static final String SCHEDULER_BACKING_STORE_PATH = "scheduler.backing-store.class";
// public final String SCHEDULER_NAME;
// public final String SCHEDULER_PATH;
// public final String SCHEDULER_CLASS;
// public String SCHEDULER_BACKING_STORE_CLASS;
// public final FiniteDuration SCHEDULER_TIMEOUT;
// public final FiniteDuration SCHEDULER_BROADCAST_JOBS_FREQUENCY;
// public final FiniteDuration SCHEDULER_BROADCAST_JOBS_QUIESCENCE_PERIOD;
// public final FiniteDuration SCHEDULER_MONITOR_AGENTS_FREQUENCY;
// public final FiniteDuration SCHEDULER_AGENT_HEARTBEAT_TIMEOUT;
//
// public final FiniteDuration TIMED_JOBS_RETRY_DELAY;
//
// public final String AGENT_NAME;
// public final String AGENT_PATH;
// public final String AGENT_CLASS;
// public final FiniteDuration AGENT_HEARTBEAT_FREQUENCY;
//
// public final List<Map<String, Object>> TIMED_JOBS_TIMETABLE;
//
// @SuppressWarnings("unchecked")
// public Settings(Config config) {
//
// Config oncueConfig = config.getConfig("oncue");
//
// SCHEDULER_NAME = oncueConfig.getString("scheduler.name");
// SCHEDULER_PATH = oncueConfig.getString("scheduler.path");
// SCHEDULER_CLASS = oncueConfig.getString("scheduler.class");
// SCHEDULER_TIMEOUT = Duration
// .create(oncueConfig.getMilliseconds("scheduler.response-timeout"), TimeUnit.MILLISECONDS);
//
// if(oncueConfig.hasPath(SCHEDULER_BACKING_STORE_PATH)) {
// SCHEDULER_BACKING_STORE_CLASS = oncueConfig.getString(SCHEDULER_BACKING_STORE_PATH);
// } else {
// SCHEDULER_BACKING_STORE_CLASS = null;
// }
//
// SCHEDULER_BROADCAST_JOBS_FREQUENCY = Duration.create(
// oncueConfig.getMilliseconds("scheduler.broadcast-jobs-frequency"), TimeUnit.MILLISECONDS);
//
// SCHEDULER_BROADCAST_JOBS_QUIESCENCE_PERIOD = Duration.create(
// oncueConfig.getMilliseconds("scheduler.broadcast-jobs-quiescence-period"), TimeUnit.MILLISECONDS);
//
// SCHEDULER_MONITOR_AGENTS_FREQUENCY = Duration.create(
// oncueConfig.getMilliseconds("scheduler.monitor-agents-frequency"), TimeUnit.MILLISECONDS);
//
// SCHEDULER_AGENT_HEARTBEAT_TIMEOUT = Duration.create(
// oncueConfig.getMilliseconds("scheduler.agent-heartbeat-timeout"), TimeUnit.MILLISECONDS);
//
// AGENT_NAME = oncueConfig.getString("agent.name");
// AGENT_PATH = oncueConfig.getString("agent.path");
// AGENT_CLASS = oncueConfig.getString("agent.class");
// AGENT_HEARTBEAT_FREQUENCY = Duration.create(oncueConfig.getMilliseconds("agent.heartbeat-frequency"),
// TimeUnit.MILLISECONDS);
//
// TIMED_JOBS_RETRY_DELAY = Duration.create(oncueConfig.getMilliseconds("timed-jobs.retry-delay"),
// TimeUnit.MILLISECONDS);
//
// // Timed jobs are optional
// if (oncueConfig.hasPath("timed-jobs.timetable")) {
// TIMED_JOBS_TIMETABLE = (ArrayList<Map<String, Object>>) oncueConfig.getAnyRef("timed-jobs.timetable");
// } else {
// TIMED_JOBS_TIMETABLE = null;
// }
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/settings/SettingsProvider.java
// public class SettingsProvider extends AbstractExtensionId<Settings> implements ExtensionIdProvider {
// public final static SettingsProvider SettingsProvider = new SettingsProvider();
//
// @SuppressWarnings("static-access")
// public SettingsProvider lookup() {
// return SettingsProvider.SettingsProvider;
// }
//
// public Settings createExtension(ExtendedActorSystem system) {
// return new Settings(system.settings().config());
// }
// }
|
import java.util.HashSet;
import java.util.Set;
import oncue.common.settings.Settings;
import oncue.common.settings.SettingsProvider;
import akka.actor.Actor;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActorFactory;
import akka.kernel.Bootable;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
|
package oncue.agent;
public class OnCueAgent implements Bootable {
public static void main(String[] args) {
new OnCueAgent().startup();
}
private ActorSystem system;
@Override
public void shutdown() {
system.shutdown();
}
@SuppressWarnings("serial")
@Override
public void startup() {
Config config = ConfigFactory.load();
system = ActorSystem.create("oncue-agent", config.getConfig("oncue").withFallback(config));
|
// Path: oncue-common/src/main/java/oncue/common/settings/Settings.java
// public class Settings implements Extension {
//
// private static final String SCHEDULER_BACKING_STORE_PATH = "scheduler.backing-store.class";
// public final String SCHEDULER_NAME;
// public final String SCHEDULER_PATH;
// public final String SCHEDULER_CLASS;
// public String SCHEDULER_BACKING_STORE_CLASS;
// public final FiniteDuration SCHEDULER_TIMEOUT;
// public final FiniteDuration SCHEDULER_BROADCAST_JOBS_FREQUENCY;
// public final FiniteDuration SCHEDULER_BROADCAST_JOBS_QUIESCENCE_PERIOD;
// public final FiniteDuration SCHEDULER_MONITOR_AGENTS_FREQUENCY;
// public final FiniteDuration SCHEDULER_AGENT_HEARTBEAT_TIMEOUT;
//
// public final FiniteDuration TIMED_JOBS_RETRY_DELAY;
//
// public final String AGENT_NAME;
// public final String AGENT_PATH;
// public final String AGENT_CLASS;
// public final FiniteDuration AGENT_HEARTBEAT_FREQUENCY;
//
// public final List<Map<String, Object>> TIMED_JOBS_TIMETABLE;
//
// @SuppressWarnings("unchecked")
// public Settings(Config config) {
//
// Config oncueConfig = config.getConfig("oncue");
//
// SCHEDULER_NAME = oncueConfig.getString("scheduler.name");
// SCHEDULER_PATH = oncueConfig.getString("scheduler.path");
// SCHEDULER_CLASS = oncueConfig.getString("scheduler.class");
// SCHEDULER_TIMEOUT = Duration
// .create(oncueConfig.getMilliseconds("scheduler.response-timeout"), TimeUnit.MILLISECONDS);
//
// if(oncueConfig.hasPath(SCHEDULER_BACKING_STORE_PATH)) {
// SCHEDULER_BACKING_STORE_CLASS = oncueConfig.getString(SCHEDULER_BACKING_STORE_PATH);
// } else {
// SCHEDULER_BACKING_STORE_CLASS = null;
// }
//
// SCHEDULER_BROADCAST_JOBS_FREQUENCY = Duration.create(
// oncueConfig.getMilliseconds("scheduler.broadcast-jobs-frequency"), TimeUnit.MILLISECONDS);
//
// SCHEDULER_BROADCAST_JOBS_QUIESCENCE_PERIOD = Duration.create(
// oncueConfig.getMilliseconds("scheduler.broadcast-jobs-quiescence-period"), TimeUnit.MILLISECONDS);
//
// SCHEDULER_MONITOR_AGENTS_FREQUENCY = Duration.create(
// oncueConfig.getMilliseconds("scheduler.monitor-agents-frequency"), TimeUnit.MILLISECONDS);
//
// SCHEDULER_AGENT_HEARTBEAT_TIMEOUT = Duration.create(
// oncueConfig.getMilliseconds("scheduler.agent-heartbeat-timeout"), TimeUnit.MILLISECONDS);
//
// AGENT_NAME = oncueConfig.getString("agent.name");
// AGENT_PATH = oncueConfig.getString("agent.path");
// AGENT_CLASS = oncueConfig.getString("agent.class");
// AGENT_HEARTBEAT_FREQUENCY = Duration.create(oncueConfig.getMilliseconds("agent.heartbeat-frequency"),
// TimeUnit.MILLISECONDS);
//
// TIMED_JOBS_RETRY_DELAY = Duration.create(oncueConfig.getMilliseconds("timed-jobs.retry-delay"),
// TimeUnit.MILLISECONDS);
//
// // Timed jobs are optional
// if (oncueConfig.hasPath("timed-jobs.timetable")) {
// TIMED_JOBS_TIMETABLE = (ArrayList<Map<String, Object>>) oncueConfig.getAnyRef("timed-jobs.timetable");
// } else {
// TIMED_JOBS_TIMETABLE = null;
// }
// }
// }
//
// Path: oncue-common/src/main/java/oncue/common/settings/SettingsProvider.java
// public class SettingsProvider extends AbstractExtensionId<Settings> implements ExtensionIdProvider {
// public final static SettingsProvider SettingsProvider = new SettingsProvider();
//
// @SuppressWarnings("static-access")
// public SettingsProvider lookup() {
// return SettingsProvider.SettingsProvider;
// }
//
// public Settings createExtension(ExtendedActorSystem system) {
// return new Settings(system.settings().config());
// }
// }
// Path: oncue-agent/src/main/java/oncue/agent/OnCueAgent.java
import java.util.HashSet;
import java.util.Set;
import oncue.common.settings.Settings;
import oncue.common.settings.SettingsProvider;
import akka.actor.Actor;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActorFactory;
import akka.kernel.Bootable;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
package oncue.agent;
public class OnCueAgent implements Bootable {
public static void main(String[] args) {
new OnCueAgent().startup();
}
private ActorSystem system;
@Override
public void shutdown() {
system.shutdown();
}
@SuppressWarnings("serial")
@Override
public void startup() {
Config config = ConfigFactory.load();
system = ActorSystem.create("oncue-agent", config.getConfig("oncue").withFallback(config));
|
final Settings settings = SettingsProvider.SettingsProvider.get(system);
|
michaelmarconi/oncue
|
oncue-agent/src/main/java/oncue/agent/ThrottledAgent.java
|
// Path: oncue-common/src/main/java/oncue/common/messages/ThrottledWorkRequest.java
// public class ThrottledWorkRequest extends AbstractWorkRequest {
//
// private static final long serialVersionUID = -6509063237201496945L;
//
// private int maxJobs;
//
// /**
// * @param jobs
// * is the number of jobs the agent can cope with
// */
// public ThrottledWorkRequest(ActorRef agent, Set<String> workerTypes, int jobs) {
// super(agent, workerTypes);
// this.maxJobs = jobs;
// }
//
// public int getMaxJobs() {
// return maxJobs;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder();
// for (String workerType : getWorkerTypes()) {
// builder.append("[" + workerType + "]");
// }
// return "Throttled work request for " + maxJobs + " jobs for worker types: " + builder.toString();
// }
//
// }
|
import java.util.Set;
import oncue.common.messages.ThrottledWorkRequest;
import com.typesafe.config.Config;
|
/*******************************************************************************
* Copyright 2013 Michael Marconi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 oncue.agent;
/**
* This agent will work on the configured maximum number of jobs at any one
* time, before asking for more work.
*/
public class ThrottledAgent extends AbstractAgent {
// The maximum number of concurrent workers
private final Integer MAX_WORKERS;
public ThrottledAgent(Set<String> workerTypes) {
super(workerTypes);
Config config = getContext().system().settings().config();
if (!config.hasPath("oncue.agent.throttled-agent.max-jobs")) {
throw new RuntimeException(
"Configuration is missing the maximum concurrent jobs configuration for the throttled agent.");
}
MAX_WORKERS = config.getInt("oncue.agent.throttled-agent.max-jobs");
log.info("The throttled agent will process a maximum of {} jobs in parallel", MAX_WORKERS);
}
@Override
protected void requestWork() {
/*
* Don't request work if this agent is already dealing with all the jobs
* it can manage
*/
if (jobsInProgress.size() < MAX_WORKERS) {
int jobsToRequest = MAX_WORKERS - jobsInProgress.size();
log.debug("Requesting {} new jobs", jobsToRequest);
|
// Path: oncue-common/src/main/java/oncue/common/messages/ThrottledWorkRequest.java
// public class ThrottledWorkRequest extends AbstractWorkRequest {
//
// private static final long serialVersionUID = -6509063237201496945L;
//
// private int maxJobs;
//
// /**
// * @param jobs
// * is the number of jobs the agent can cope with
// */
// public ThrottledWorkRequest(ActorRef agent, Set<String> workerTypes, int jobs) {
// super(agent, workerTypes);
// this.maxJobs = jobs;
// }
//
// public int getMaxJobs() {
// return maxJobs;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder();
// for (String workerType : getWorkerTypes()) {
// builder.append("[" + workerType + "]");
// }
// return "Throttled work request for " + maxJobs + " jobs for worker types: " + builder.toString();
// }
//
// }
// Path: oncue-agent/src/main/java/oncue/agent/ThrottledAgent.java
import java.util.Set;
import oncue.common.messages.ThrottledWorkRequest;
import com.typesafe.config.Config;
/*******************************************************************************
* Copyright 2013 Michael Marconi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 oncue.agent;
/**
* This agent will work on the configured maximum number of jobs at any one
* time, before asking for more work.
*/
public class ThrottledAgent extends AbstractAgent {
// The maximum number of concurrent workers
private final Integer MAX_WORKERS;
public ThrottledAgent(Set<String> workerTypes) {
super(workerTypes);
Config config = getContext().system().settings().config();
if (!config.hasPath("oncue.agent.throttled-agent.max-jobs")) {
throw new RuntimeException(
"Configuration is missing the maximum concurrent jobs configuration for the throttled agent.");
}
MAX_WORKERS = config.getInt("oncue.agent.throttled-agent.max-jobs");
log.info("The throttled agent will process a maximum of {} jobs in parallel", MAX_WORKERS);
}
@Override
protected void requestWork() {
/*
* Don't request work if this agent is already dealing with all the jobs
* it can manage
*/
if (jobsInProgress.size() < MAX_WORKERS) {
int jobsToRequest = MAX_WORKERS - jobsInProgress.size();
log.debug("Requesting {} new jobs", jobsToRequest);
|
getScheduler().tell(new ThrottledWorkRequest(getSelf(), getWorkerTypes(), jobsToRequest), getSelf());
|
michaelmarconi/oncue
|
oncue-common/src/main/java/oncue/common/events/AgentStopped.java
|
// Path: oncue-common/src/main/java/oncue/common/messages/Agent.java
// public class Agent implements Serializable {
//
// private static final long serialVersionUID = 1597787228823561798L;
// private String id;
// private String url;
//
// public Agent(String url) {
// super();
// this.id = url;
// this.url = url;
// }
//
// public String getId() {
// return id;
// }
//
// public String getUrl() {
// return url;
// }
// }
|
import java.io.Serializable;
import oncue.common.messages.Agent;
|
package oncue.common.events;
/**
* This event is fired when an agent has stopped and is no longer available.
*/
public class AgentStopped implements Serializable {
private static final long serialVersionUID = -866097369897591277L;
|
// Path: oncue-common/src/main/java/oncue/common/messages/Agent.java
// public class Agent implements Serializable {
//
// private static final long serialVersionUID = 1597787228823561798L;
// private String id;
// private String url;
//
// public Agent(String url) {
// super();
// this.id = url;
// this.url = url;
// }
//
// public String getId() {
// return id;
// }
//
// public String getUrl() {
// return url;
// }
// }
// Path: oncue-common/src/main/java/oncue/common/events/AgentStopped.java
import java.io.Serializable;
import oncue.common.messages.Agent;
package oncue.common.events;
/**
* This event is fired when an agent has stopped and is no longer available.
*/
public class AgentStopped implements Serializable {
private static final long serialVersionUID = -866097369897591277L;
|
private Agent agent;
|
jaliss/securesocial
|
samples/java/demo/app/controllers/Application.java
|
// Path: module-code/app/securesocial/core/java/SecureSocial.java
// public class SecureSocial {
// /**
// * The user key
// */
// public static final String USER_KEY = "securesocial.user";
//
// /**
// * The original url key
// */
// public static final String ORIGINAL_URL = "original-url";
//
// /**
// * Returns the current environment.
// */
// public static RuntimeEnvironment env() {
// return (RuntimeEnvironment) Http.Context.current().args.get("securesocial-env");
// }
//
// /**
// * Returns the current user. Invoke this only if you are executing code
// * without a SecuredAction or UserAware action available (eg: using WebSockets). For other cases this
// * should not be needed.
// *
// * @param env the environment
// * @return the current user object or null if there isn't one available
// */
// public static CompletionStage<Object> currentUser(RuntimeEnvironment env) {
// return currentUser(env, HttpExecution.defaultContext());
// }
//
// /**
// * Returns the current user. Invoke this only if you are executing code
// * without a SecuredAction or UserAware action available (eg: using WebSockets). For other cases this
// * should not be needed.
// *
// * @param env the environment
// * @param executor an ExecutionContext
// * @return the current user object or null if there isn't one available
// */
// public static CompletionStage<Object> currentUser(RuntimeEnvironment env, ExecutionContext executor) {
// RequestHeader requestHeader = Http.Context.current()._requestHeader();
// if (requestHeader == null || env == null) {
// return CompletableFuture.completedFuture(null);
// } else {
// scala.concurrent.Future<Option<Object>> scalaFuture = SecureSocial$.MODULE$.currentUser(requestHeader, env, executor);
// return toJava(scalaFuture).thenApply(userOption -> userOption.isDefined() ? userOption.get() : null);
// }
// }
// }
|
import java.util.concurrent.CompletionStage;
import java.util.function.Function;
import com.google.inject.Inject;
import play.Logger;
import play.libs.F;
import play.mvc.Controller;
import play.mvc.Result;
import securesocial.core.BasicProfile;
import securesocial.core.RuntimeEnvironment;
import securesocial.core.java.SecureSocial;
import securesocial.core.java.SecuredAction;
import securesocial.core.java.UserAwareAction;
import service.DemoUser;
import views.html.index;
import views.html.linkResult;
|
/**
* Copyright 2012-214 Jorge Aliss (jaliss at gmail dot com) - twitter: @jaliss
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 controllers;
/**
* A sample controller
*/
public class Application extends Controller {
public static Logger.ALogger logger = Logger.of("application.controllers.Application");
private RuntimeEnvironment env;
/**
* A constructor needed to get a hold of the environment instance.
* This could be injected using a DI framework instead too.
*
* @param env
*/
@Inject()
public Application (RuntimeEnvironment env) {
this.env = env;
}
/**
* This action only gets called if the user is logged in.
*
* @return
*/
@SecuredAction
public Result index() {
if(logger.isDebugEnabled()){
logger.debug("access granted to index");
}
|
// Path: module-code/app/securesocial/core/java/SecureSocial.java
// public class SecureSocial {
// /**
// * The user key
// */
// public static final String USER_KEY = "securesocial.user";
//
// /**
// * The original url key
// */
// public static final String ORIGINAL_URL = "original-url";
//
// /**
// * Returns the current environment.
// */
// public static RuntimeEnvironment env() {
// return (RuntimeEnvironment) Http.Context.current().args.get("securesocial-env");
// }
//
// /**
// * Returns the current user. Invoke this only if you are executing code
// * without a SecuredAction or UserAware action available (eg: using WebSockets). For other cases this
// * should not be needed.
// *
// * @param env the environment
// * @return the current user object or null if there isn't one available
// */
// public static CompletionStage<Object> currentUser(RuntimeEnvironment env) {
// return currentUser(env, HttpExecution.defaultContext());
// }
//
// /**
// * Returns the current user. Invoke this only if you are executing code
// * without a SecuredAction or UserAware action available (eg: using WebSockets). For other cases this
// * should not be needed.
// *
// * @param env the environment
// * @param executor an ExecutionContext
// * @return the current user object or null if there isn't one available
// */
// public static CompletionStage<Object> currentUser(RuntimeEnvironment env, ExecutionContext executor) {
// RequestHeader requestHeader = Http.Context.current()._requestHeader();
// if (requestHeader == null || env == null) {
// return CompletableFuture.completedFuture(null);
// } else {
// scala.concurrent.Future<Option<Object>> scalaFuture = SecureSocial$.MODULE$.currentUser(requestHeader, env, executor);
// return toJava(scalaFuture).thenApply(userOption -> userOption.isDefined() ? userOption.get() : null);
// }
// }
// }
// Path: samples/java/demo/app/controllers/Application.java
import java.util.concurrent.CompletionStage;
import java.util.function.Function;
import com.google.inject.Inject;
import play.Logger;
import play.libs.F;
import play.mvc.Controller;
import play.mvc.Result;
import securesocial.core.BasicProfile;
import securesocial.core.RuntimeEnvironment;
import securesocial.core.java.SecureSocial;
import securesocial.core.java.SecuredAction;
import securesocial.core.java.UserAwareAction;
import service.DemoUser;
import views.html.index;
import views.html.linkResult;
/**
* Copyright 2012-214 Jorge Aliss (jaliss at gmail dot com) - twitter: @jaliss
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 controllers;
/**
* A sample controller
*/
public class Application extends Controller {
public static Logger.ALogger logger = Logger.of("application.controllers.Application");
private RuntimeEnvironment env;
/**
* A constructor needed to get a hold of the environment instance.
* This could be injected using a DI framework instead too.
*
* @param env
*/
@Inject()
public Application (RuntimeEnvironment env) {
this.env = env;
}
/**
* This action only gets called if the user is logged in.
*
* @return
*/
@SecuredAction
public Result index() {
if(logger.isDebugEnabled()){
logger.debug("access granted to index");
}
|
DemoUser user = (DemoUser) ctx().args.get(SecureSocial.USER_KEY);
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/adapter/render/xcWeekRender.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractRender.java
// public abstract class AbstractRender{
//
// public abstract<T extends AbstractViewHolder> T getReusableComponent();
// public abstract void bindData(int position);
//
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractRenderAdapter.java
// public abstract class AbstractRenderAdapter<T> extends RecyclerView.Adapter<AbstractViewHolder> {
//
// public static final int RENDER_TYPE_HEADER = 110 << 1;
// public static final int RENDER_TYPE_NORMAL = 110 << 2;
// public List<T> mDataset;
//
// public onItemClickListener mOnItemClickListener;
// public onItemFunctionClickListener mOnItemFunctionClickListener;
//
// private View mHeaderView;
// public boolean mIsSectionHeadShown;
//
// @Override
// public int getItemViewType(int position) {
// if (position == 0 && mHeaderView != null) {
// return RENDER_TYPE_HEADER;
// }
// return RENDER_TYPE_NORMAL;
// }
//
// @TargetApi(4)
// public AbstractViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
// switch (viewType) {
// case RENDER_TYPE_HEADER: {
// HeaderRender head = new HeaderRender(mHeaderView);
// AbstractViewHolder headHolder = head.getReusableComponent();
// headHolder.itemView.setTag(android.support.design.R.id.list_item, head);
// return headHolder;
// }
// default:
// return null;
// }
// }
//
// @Override
// public int getItemCount() {
// return hasHeaderView() ? mDataset.size() + 1 : mDataset.size();
// }
//
// public void replace(List<T> data) {
// this.mDataset = data;
// notifyDataSetChanged();
// }
//
// public void replace(List<T> data, boolean isSectionHeadShown) {
// this.mDataset = data;
// this.mIsSectionHeadShown = isSectionHeadShown;
// notifyDataSetChanged();
// }
//
// public void remove(T data) {
// this.mDataset.remove(data);
// notifyDataSetChanged();
// }
//
// public void addAll(List<T> data) {
// this.mDataset.addAll(data);
// notifyDataSetChanged();
// }
//
// public List<T> getList() {
// return this.mDataset;
// }
//
// public int getRealPosition(int position) {
// return hasHeaderView() && position != 0 ? position - 1 : position;
// }
//
// public T getItem(int position) {
// return mDataset.get(getRealPosition(position));
// }
//
//
// public boolean hasHeaderView() {
// return mHeaderView != null;
// }
//
// public void setHeaderView(View view) {
// mHeaderView = view;
// }
//
// public void setOnItemClickListener(onItemClickListener l) {
// mOnItemClickListener = l;
// }
//
// public void setOnItemFunctionClickListener(onItemFunctionClickListener l) {
// mOnItemFunctionClickListener = l;
// }
//
// public interface onItemClickListener {
// void onItemClick(View view, int postion);
// }
//
// public interface onItemFunctionClickListener {
// void onClick(View view, int postion, int type);
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractViewHolder.java
// public abstract class AbstractViewHolder extends RecyclerView.ViewHolder{
//
// public AbstractViewHolder(View itemView) {
// super(itemView);
// }
//
// }
|
import android.view.View;
import android.widget.TextView;
import com.huijimuhe.commonlayout.adapter.base.AbstractRender;
import com.huijimuhe.commonlayout.adapter.base.AbstractRenderAdapter;
import com.huijimuhe.commonlayout.adapter.base.AbstractViewHolder;
|
package com.huijimuhe.commonlayout.adapter.render;
/**
* Copyright (C) 2016 Huijimuhe Technologies. All rights reserved.
* <p/>
* Contact: 20903213@qq.com Zengweizhou
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 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.
*/
public class xcWeekRender extends AbstractRender {
private ViewHolder mHolder;
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractRender.java
// public abstract class AbstractRender{
//
// public abstract<T extends AbstractViewHolder> T getReusableComponent();
// public abstract void bindData(int position);
//
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractRenderAdapter.java
// public abstract class AbstractRenderAdapter<T> extends RecyclerView.Adapter<AbstractViewHolder> {
//
// public static final int RENDER_TYPE_HEADER = 110 << 1;
// public static final int RENDER_TYPE_NORMAL = 110 << 2;
// public List<T> mDataset;
//
// public onItemClickListener mOnItemClickListener;
// public onItemFunctionClickListener mOnItemFunctionClickListener;
//
// private View mHeaderView;
// public boolean mIsSectionHeadShown;
//
// @Override
// public int getItemViewType(int position) {
// if (position == 0 && mHeaderView != null) {
// return RENDER_TYPE_HEADER;
// }
// return RENDER_TYPE_NORMAL;
// }
//
// @TargetApi(4)
// public AbstractViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
// switch (viewType) {
// case RENDER_TYPE_HEADER: {
// HeaderRender head = new HeaderRender(mHeaderView);
// AbstractViewHolder headHolder = head.getReusableComponent();
// headHolder.itemView.setTag(android.support.design.R.id.list_item, head);
// return headHolder;
// }
// default:
// return null;
// }
// }
//
// @Override
// public int getItemCount() {
// return hasHeaderView() ? mDataset.size() + 1 : mDataset.size();
// }
//
// public void replace(List<T> data) {
// this.mDataset = data;
// notifyDataSetChanged();
// }
//
// public void replace(List<T> data, boolean isSectionHeadShown) {
// this.mDataset = data;
// this.mIsSectionHeadShown = isSectionHeadShown;
// notifyDataSetChanged();
// }
//
// public void remove(T data) {
// this.mDataset.remove(data);
// notifyDataSetChanged();
// }
//
// public void addAll(List<T> data) {
// this.mDataset.addAll(data);
// notifyDataSetChanged();
// }
//
// public List<T> getList() {
// return this.mDataset;
// }
//
// public int getRealPosition(int position) {
// return hasHeaderView() && position != 0 ? position - 1 : position;
// }
//
// public T getItem(int position) {
// return mDataset.get(getRealPosition(position));
// }
//
//
// public boolean hasHeaderView() {
// return mHeaderView != null;
// }
//
// public void setHeaderView(View view) {
// mHeaderView = view;
// }
//
// public void setOnItemClickListener(onItemClickListener l) {
// mOnItemClickListener = l;
// }
//
// public void setOnItemFunctionClickListener(onItemFunctionClickListener l) {
// mOnItemFunctionClickListener = l;
// }
//
// public interface onItemClickListener {
// void onItemClick(View view, int postion);
// }
//
// public interface onItemFunctionClickListener {
// void onClick(View view, int postion, int type);
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractViewHolder.java
// public abstract class AbstractViewHolder extends RecyclerView.ViewHolder{
//
// public AbstractViewHolder(View itemView) {
// super(itemView);
// }
//
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/adapter/render/xcWeekRender.java
import android.view.View;
import android.widget.TextView;
import com.huijimuhe.commonlayout.adapter.base.AbstractRender;
import com.huijimuhe.commonlayout.adapter.base.AbstractRenderAdapter;
import com.huijimuhe.commonlayout.adapter.base.AbstractViewHolder;
package com.huijimuhe.commonlayout.adapter.render;
/**
* Copyright (C) 2016 Huijimuhe Technologies. All rights reserved.
* <p/>
* Contact: 20903213@qq.com Zengweizhou
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 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.
*/
public class xcWeekRender extends AbstractRender {
private ViewHolder mHolder;
|
private AbstractRenderAdapter mAdapter;
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/adapter/render/xcWeekRender.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractRender.java
// public abstract class AbstractRender{
//
// public abstract<T extends AbstractViewHolder> T getReusableComponent();
// public abstract void bindData(int position);
//
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractRenderAdapter.java
// public abstract class AbstractRenderAdapter<T> extends RecyclerView.Adapter<AbstractViewHolder> {
//
// public static final int RENDER_TYPE_HEADER = 110 << 1;
// public static final int RENDER_TYPE_NORMAL = 110 << 2;
// public List<T> mDataset;
//
// public onItemClickListener mOnItemClickListener;
// public onItemFunctionClickListener mOnItemFunctionClickListener;
//
// private View mHeaderView;
// public boolean mIsSectionHeadShown;
//
// @Override
// public int getItemViewType(int position) {
// if (position == 0 && mHeaderView != null) {
// return RENDER_TYPE_HEADER;
// }
// return RENDER_TYPE_NORMAL;
// }
//
// @TargetApi(4)
// public AbstractViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
// switch (viewType) {
// case RENDER_TYPE_HEADER: {
// HeaderRender head = new HeaderRender(mHeaderView);
// AbstractViewHolder headHolder = head.getReusableComponent();
// headHolder.itemView.setTag(android.support.design.R.id.list_item, head);
// return headHolder;
// }
// default:
// return null;
// }
// }
//
// @Override
// public int getItemCount() {
// return hasHeaderView() ? mDataset.size() + 1 : mDataset.size();
// }
//
// public void replace(List<T> data) {
// this.mDataset = data;
// notifyDataSetChanged();
// }
//
// public void replace(List<T> data, boolean isSectionHeadShown) {
// this.mDataset = data;
// this.mIsSectionHeadShown = isSectionHeadShown;
// notifyDataSetChanged();
// }
//
// public void remove(T data) {
// this.mDataset.remove(data);
// notifyDataSetChanged();
// }
//
// public void addAll(List<T> data) {
// this.mDataset.addAll(data);
// notifyDataSetChanged();
// }
//
// public List<T> getList() {
// return this.mDataset;
// }
//
// public int getRealPosition(int position) {
// return hasHeaderView() && position != 0 ? position - 1 : position;
// }
//
// public T getItem(int position) {
// return mDataset.get(getRealPosition(position));
// }
//
//
// public boolean hasHeaderView() {
// return mHeaderView != null;
// }
//
// public void setHeaderView(View view) {
// mHeaderView = view;
// }
//
// public void setOnItemClickListener(onItemClickListener l) {
// mOnItemClickListener = l;
// }
//
// public void setOnItemFunctionClickListener(onItemFunctionClickListener l) {
// mOnItemFunctionClickListener = l;
// }
//
// public interface onItemClickListener {
// void onItemClick(View view, int postion);
// }
//
// public interface onItemFunctionClickListener {
// void onClick(View view, int postion, int type);
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractViewHolder.java
// public abstract class AbstractViewHolder extends RecyclerView.ViewHolder{
//
// public AbstractViewHolder(View itemView) {
// super(itemView);
// }
//
// }
|
import android.view.View;
import android.widget.TextView;
import com.huijimuhe.commonlayout.adapter.base.AbstractRender;
import com.huijimuhe.commonlayout.adapter.base.AbstractRenderAdapter;
import com.huijimuhe.commonlayout.adapter.base.AbstractViewHolder;
|
package com.huijimuhe.commonlayout.adapter.render;
/**
* Copyright (C) 2016 Huijimuhe Technologies. All rights reserved.
* <p/>
* Contact: 20903213@qq.com Zengweizhou
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 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.
*/
public class xcWeekRender extends AbstractRender {
private ViewHolder mHolder;
private AbstractRenderAdapter mAdapter;
@Override
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractRender.java
// public abstract class AbstractRender{
//
// public abstract<T extends AbstractViewHolder> T getReusableComponent();
// public abstract void bindData(int position);
//
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractRenderAdapter.java
// public abstract class AbstractRenderAdapter<T> extends RecyclerView.Adapter<AbstractViewHolder> {
//
// public static final int RENDER_TYPE_HEADER = 110 << 1;
// public static final int RENDER_TYPE_NORMAL = 110 << 2;
// public List<T> mDataset;
//
// public onItemClickListener mOnItemClickListener;
// public onItemFunctionClickListener mOnItemFunctionClickListener;
//
// private View mHeaderView;
// public boolean mIsSectionHeadShown;
//
// @Override
// public int getItemViewType(int position) {
// if (position == 0 && mHeaderView != null) {
// return RENDER_TYPE_HEADER;
// }
// return RENDER_TYPE_NORMAL;
// }
//
// @TargetApi(4)
// public AbstractViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
// switch (viewType) {
// case RENDER_TYPE_HEADER: {
// HeaderRender head = new HeaderRender(mHeaderView);
// AbstractViewHolder headHolder = head.getReusableComponent();
// headHolder.itemView.setTag(android.support.design.R.id.list_item, head);
// return headHolder;
// }
// default:
// return null;
// }
// }
//
// @Override
// public int getItemCount() {
// return hasHeaderView() ? mDataset.size() + 1 : mDataset.size();
// }
//
// public void replace(List<T> data) {
// this.mDataset = data;
// notifyDataSetChanged();
// }
//
// public void replace(List<T> data, boolean isSectionHeadShown) {
// this.mDataset = data;
// this.mIsSectionHeadShown = isSectionHeadShown;
// notifyDataSetChanged();
// }
//
// public void remove(T data) {
// this.mDataset.remove(data);
// notifyDataSetChanged();
// }
//
// public void addAll(List<T> data) {
// this.mDataset.addAll(data);
// notifyDataSetChanged();
// }
//
// public List<T> getList() {
// return this.mDataset;
// }
//
// public int getRealPosition(int position) {
// return hasHeaderView() && position != 0 ? position - 1 : position;
// }
//
// public T getItem(int position) {
// return mDataset.get(getRealPosition(position));
// }
//
//
// public boolean hasHeaderView() {
// return mHeaderView != null;
// }
//
// public void setHeaderView(View view) {
// mHeaderView = view;
// }
//
// public void setOnItemClickListener(onItemClickListener l) {
// mOnItemClickListener = l;
// }
//
// public void setOnItemFunctionClickListener(onItemFunctionClickListener l) {
// mOnItemFunctionClickListener = l;
// }
//
// public interface onItemClickListener {
// void onItemClick(View view, int postion);
// }
//
// public interface onItemFunctionClickListener {
// void onClick(View view, int postion, int type);
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractViewHolder.java
// public abstract class AbstractViewHolder extends RecyclerView.ViewHolder{
//
// public AbstractViewHolder(View itemView) {
// super(itemView);
// }
//
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/adapter/render/xcWeekRender.java
import android.view.View;
import android.widget.TextView;
import com.huijimuhe.commonlayout.adapter.base.AbstractRender;
import com.huijimuhe.commonlayout.adapter.base.AbstractRenderAdapter;
import com.huijimuhe.commonlayout.adapter.base.AbstractViewHolder;
package com.huijimuhe.commonlayout.adapter.render;
/**
* Copyright (C) 2016 Huijimuhe Technologies. All rights reserved.
* <p/>
* Contact: 20903213@qq.com Zengweizhou
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 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.
*/
public class xcWeekRender extends AbstractRender {
private ViewHolder mHolder;
private AbstractRenderAdapter mAdapter;
@Override
|
public AbstractViewHolder getReusableComponent() {
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/widget/BannerView.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcBanner.java
// public class xcBanner {
//
// /**
// * id : 1249
// * type : 2
// * title : 钢琴体验券免费送
// * desc : 星空琴行-渠道(吴春威)
// * image : http://ww4.sinaimg.cn/large/6ef77e5ejw3f51u8t8xjtj20hs08c0vc.jpg
// * start_time : 2016-06-22 14:35:28
// * url : http://www.51xiancheng.com/article/40634
// * article_id : 40634
// */
//
// private int id;
// private int type;
// private String title;
// private String desc;
// private String image;
// private String start_time;
// private String url;
// private int article_id;
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDesc(String desc) {
// this.desc = desc;
// }
//
// public void setImage(String image) {
// this.image = image;
// }
//
// public void setStart_time(String start_time) {
// this.start_time = start_time;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public void setArticle_id(int article_id) {
// this.article_id = article_id;
// }
//
// public int getId() {
// return id;
// }
//
// public int getType() {
// return type;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getDesc() {
// return desc;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getStart_time() {
// return start_time;
// }
//
// public String getUrl() {
// return url;
// }
//
// public int getArticle_id() {
// return article_id;
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.huijimuhe.commonlayout.data.xc.xcBanner;
import java.util.ArrayList;
import java.util.List;
import cn.bingoogolapple.bgabanner.BGABanner;
|
package com.huijimuhe.commonlayout.widget;
/**
* Copyright (C) 2016 Huijimuhe Technologies. All rights reserved.
* <p/>
* Contact: 20903213@qq.com Zengweizhou
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 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.
*/
public class BannerView extends BGABanner {
private BannerClickListener l;
private Context mContext;
public BannerView(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
}
public BannerView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mContext = context;
}
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcBanner.java
// public class xcBanner {
//
// /**
// * id : 1249
// * type : 2
// * title : 钢琴体验券免费送
// * desc : 星空琴行-渠道(吴春威)
// * image : http://ww4.sinaimg.cn/large/6ef77e5ejw3f51u8t8xjtj20hs08c0vc.jpg
// * start_time : 2016-06-22 14:35:28
// * url : http://www.51xiancheng.com/article/40634
// * article_id : 40634
// */
//
// private int id;
// private int type;
// private String title;
// private String desc;
// private String image;
// private String start_time;
// private String url;
// private int article_id;
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDesc(String desc) {
// this.desc = desc;
// }
//
// public void setImage(String image) {
// this.image = image;
// }
//
// public void setStart_time(String start_time) {
// this.start_time = start_time;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public void setArticle_id(int article_id) {
// this.article_id = article_id;
// }
//
// public int getId() {
// return id;
// }
//
// public int getType() {
// return type;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getDesc() {
// return desc;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getStart_time() {
// return start_time;
// }
//
// public String getUrl() {
// return url;
// }
//
// public int getArticle_id() {
// return article_id;
// }
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/widget/BannerView.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.huijimuhe.commonlayout.data.xc.xcBanner;
import java.util.ArrayList;
import java.util.List;
import cn.bingoogolapple.bgabanner.BGABanner;
package com.huijimuhe.commonlayout.widget;
/**
* Copyright (C) 2016 Huijimuhe Technologies. All rights reserved.
* <p/>
* Contact: 20903213@qq.com Zengweizhou
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 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.
*/
public class BannerView extends BGABanner {
private BannerClickListener l;
private Context mContext;
public BannerView(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
}
public BannerView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mContext = context;
}
|
public void initBanners(List<xcBanner> banners) {
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/xc/detail/xcDetailActivity.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/AppContext.java
// public class AppContext extends Application {
// private static AppContext INSTANCE=null;
//
// @Override
// public void onCreate() {
// super.onCreate();
// INSTANCE=this;
// }
//
// public static AppContext getInstance(){return INSTANCE;}
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/xcDetailRepository.java
// public class xcDetailRepository {
//
// public void load(Context context, final IxcDataSource.DetailLoadCallBack callback) {
// String dummy = readDummy(context);
// try {
// callback.onSuccess(new Gson().fromJson(dummy, xcDetailResponse.class));
// } catch (Exception e) {
// callback.onError("dd");
// }
// }
//
// public void loadBody(Context context) {
// String Result = "";
// try {
// InputStreamReader inputReader = new InputStreamReader(context.getAssets().open("xc_body_dummy.txt"));
// BufferedReader bufReader = new BufferedReader(inputReader);
// String line = "";
// while ((line = bufReader.readLine()) != null) {
// Result += line;
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// List<xcArticleSection> body = new Gson().fromJson(Result, new TypeToken<List<xcArticleSection>>() {
// }.getType());
//
// int count=body.size();
// }
//
// private String readDummy(Context context) {
// try {
// InputStreamReader inputReader = new InputStreamReader(context.getAssets().open("xc_detail_dummy.txt"));
// BufferedReader bufReader = new BufferedReader(inputReader);
// String line="";
// String Result="";
// while((line = bufReader.readLine()) != null) {
// Result += line;
// }
// return Result;
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/xc/xcDetailContract.java
// public class xcDetailContract {
//
// public interface View extends BaseView<Presenter> {
// void showContainer(xcDetailResponse response);
// }
//
// public interface Presenter extends BasePresenter {
// void load(Context context);
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/xc/xcDetailPresenter.java
// public class xcDetailPresenter implements xcDetailContract.Presenter {
//
// private xcDetailRepository mRepo;
// private xcDetailContract.View mView;
//
// public xcDetailPresenter(xcDetailContract.View view, xcDetailRepository repo) {
// this.mView = view;
// this.mRepo = repo;
// }
//
// @Override
// public void start() {
// }
//
// @Override
// public void load(Context context) {
// mRepo.load(context, new IxcDataSource.DetailLoadCallBack() {
// @Override
// public void onSuccess(xcDetailResponse response) {
// mView.showContainer(response);
// }
//
// @Override
// public void onError(String msg) {
// mView.showError();
// }
// });
// }
//
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/utils/ToastUtils.java
// public class ToastUtils {
//
// private ToastUtils() {
// throw new AssertionError();
// }
//
// public static void show(Context context, int resId) {
// show(context, context.getResources().getText(resId), Toast.LENGTH_SHORT);
// }
//
// public static void show(Context context, int resId, int duration) {
// show(context, context.getResources().getText(resId), duration);
// }
//
// public static void show(Context context, CharSequence text) {
// Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
// }
//
// public static void show(Context context, CharSequence text, int duration) {
// Toast.makeText(context, text, duration).show();
// }
//
// public static void show(Context context, int resId, Object... args) {
// show(context,
// String.format(context.getResources().getString(resId), args),
// Toast.LENGTH_SHORT);
// }
//
// public static void show(Context context, String format, Object... args) {
// show(context, String.format(format, args), Toast.LENGTH_SHORT);
// }
//
// public static void show(Context context, int resId, int duration,
// Object... args) {
// show(context,
// String.format(context.getResources().getString(resId), args),
// duration);
// }
//
// public static void show(Context context, String format, int duration,
// Object... args) {
// show(context, String.format(format, args), duration);
// }
// }
|
import android.content.Intent;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.huijimuhe.commonlayout.AppContext;
import com.huijimuhe.commonlayout.R;
import com.huijimuhe.commonlayout.data.xc.source.xcDetailRepository;
import com.huijimuhe.commonlayout.data.xc.xcDetailResponse;
import com.huijimuhe.commonlayout.presenter.xc.xcDetailContract;
import com.huijimuhe.commonlayout.presenter.xc.xcDetailPresenter;
import com.huijimuhe.commonlayout.utils.ToastUtils;
|
package com.huijimuhe.commonlayout.xc.detail;
public class xcDetailActivity extends AppCompatActivity implements xcDetailContract.View {
private static final String TAG_LOADING = "loading";
private static final String TAG_CONTAINER = "container";
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/AppContext.java
// public class AppContext extends Application {
// private static AppContext INSTANCE=null;
//
// @Override
// public void onCreate() {
// super.onCreate();
// INSTANCE=this;
// }
//
// public static AppContext getInstance(){return INSTANCE;}
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/xcDetailRepository.java
// public class xcDetailRepository {
//
// public void load(Context context, final IxcDataSource.DetailLoadCallBack callback) {
// String dummy = readDummy(context);
// try {
// callback.onSuccess(new Gson().fromJson(dummy, xcDetailResponse.class));
// } catch (Exception e) {
// callback.onError("dd");
// }
// }
//
// public void loadBody(Context context) {
// String Result = "";
// try {
// InputStreamReader inputReader = new InputStreamReader(context.getAssets().open("xc_body_dummy.txt"));
// BufferedReader bufReader = new BufferedReader(inputReader);
// String line = "";
// while ((line = bufReader.readLine()) != null) {
// Result += line;
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// List<xcArticleSection> body = new Gson().fromJson(Result, new TypeToken<List<xcArticleSection>>() {
// }.getType());
//
// int count=body.size();
// }
//
// private String readDummy(Context context) {
// try {
// InputStreamReader inputReader = new InputStreamReader(context.getAssets().open("xc_detail_dummy.txt"));
// BufferedReader bufReader = new BufferedReader(inputReader);
// String line="";
// String Result="";
// while((line = bufReader.readLine()) != null) {
// Result += line;
// }
// return Result;
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/xc/xcDetailContract.java
// public class xcDetailContract {
//
// public interface View extends BaseView<Presenter> {
// void showContainer(xcDetailResponse response);
// }
//
// public interface Presenter extends BasePresenter {
// void load(Context context);
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/xc/xcDetailPresenter.java
// public class xcDetailPresenter implements xcDetailContract.Presenter {
//
// private xcDetailRepository mRepo;
// private xcDetailContract.View mView;
//
// public xcDetailPresenter(xcDetailContract.View view, xcDetailRepository repo) {
// this.mView = view;
// this.mRepo = repo;
// }
//
// @Override
// public void start() {
// }
//
// @Override
// public void load(Context context) {
// mRepo.load(context, new IxcDataSource.DetailLoadCallBack() {
// @Override
// public void onSuccess(xcDetailResponse response) {
// mView.showContainer(response);
// }
//
// @Override
// public void onError(String msg) {
// mView.showError();
// }
// });
// }
//
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/utils/ToastUtils.java
// public class ToastUtils {
//
// private ToastUtils() {
// throw new AssertionError();
// }
//
// public static void show(Context context, int resId) {
// show(context, context.getResources().getText(resId), Toast.LENGTH_SHORT);
// }
//
// public static void show(Context context, int resId, int duration) {
// show(context, context.getResources().getText(resId), duration);
// }
//
// public static void show(Context context, CharSequence text) {
// Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
// }
//
// public static void show(Context context, CharSequence text, int duration) {
// Toast.makeText(context, text, duration).show();
// }
//
// public static void show(Context context, int resId, Object... args) {
// show(context,
// String.format(context.getResources().getString(resId), args),
// Toast.LENGTH_SHORT);
// }
//
// public static void show(Context context, String format, Object... args) {
// show(context, String.format(format, args), Toast.LENGTH_SHORT);
// }
//
// public static void show(Context context, int resId, int duration,
// Object... args) {
// show(context,
// String.format(context.getResources().getString(resId), args),
// duration);
// }
//
// public static void show(Context context, String format, int duration,
// Object... args) {
// show(context, String.format(format, args), duration);
// }
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/xc/detail/xcDetailActivity.java
import android.content.Intent;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.huijimuhe.commonlayout.AppContext;
import com.huijimuhe.commonlayout.R;
import com.huijimuhe.commonlayout.data.xc.source.xcDetailRepository;
import com.huijimuhe.commonlayout.data.xc.xcDetailResponse;
import com.huijimuhe.commonlayout.presenter.xc.xcDetailContract;
import com.huijimuhe.commonlayout.presenter.xc.xcDetailPresenter;
import com.huijimuhe.commonlayout.utils.ToastUtils;
package com.huijimuhe.commonlayout.xc.detail;
public class xcDetailActivity extends AppCompatActivity implements xcDetailContract.View {
private static final String TAG_LOADING = "loading";
private static final String TAG_CONTAINER = "container";
|
private xcDetailPresenter mPresenter;
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/xc/detail/xcDetailActivity.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/AppContext.java
// public class AppContext extends Application {
// private static AppContext INSTANCE=null;
//
// @Override
// public void onCreate() {
// super.onCreate();
// INSTANCE=this;
// }
//
// public static AppContext getInstance(){return INSTANCE;}
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/xcDetailRepository.java
// public class xcDetailRepository {
//
// public void load(Context context, final IxcDataSource.DetailLoadCallBack callback) {
// String dummy = readDummy(context);
// try {
// callback.onSuccess(new Gson().fromJson(dummy, xcDetailResponse.class));
// } catch (Exception e) {
// callback.onError("dd");
// }
// }
//
// public void loadBody(Context context) {
// String Result = "";
// try {
// InputStreamReader inputReader = new InputStreamReader(context.getAssets().open("xc_body_dummy.txt"));
// BufferedReader bufReader = new BufferedReader(inputReader);
// String line = "";
// while ((line = bufReader.readLine()) != null) {
// Result += line;
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// List<xcArticleSection> body = new Gson().fromJson(Result, new TypeToken<List<xcArticleSection>>() {
// }.getType());
//
// int count=body.size();
// }
//
// private String readDummy(Context context) {
// try {
// InputStreamReader inputReader = new InputStreamReader(context.getAssets().open("xc_detail_dummy.txt"));
// BufferedReader bufReader = new BufferedReader(inputReader);
// String line="";
// String Result="";
// while((line = bufReader.readLine()) != null) {
// Result += line;
// }
// return Result;
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/xc/xcDetailContract.java
// public class xcDetailContract {
//
// public interface View extends BaseView<Presenter> {
// void showContainer(xcDetailResponse response);
// }
//
// public interface Presenter extends BasePresenter {
// void load(Context context);
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/xc/xcDetailPresenter.java
// public class xcDetailPresenter implements xcDetailContract.Presenter {
//
// private xcDetailRepository mRepo;
// private xcDetailContract.View mView;
//
// public xcDetailPresenter(xcDetailContract.View view, xcDetailRepository repo) {
// this.mView = view;
// this.mRepo = repo;
// }
//
// @Override
// public void start() {
// }
//
// @Override
// public void load(Context context) {
// mRepo.load(context, new IxcDataSource.DetailLoadCallBack() {
// @Override
// public void onSuccess(xcDetailResponse response) {
// mView.showContainer(response);
// }
//
// @Override
// public void onError(String msg) {
// mView.showError();
// }
// });
// }
//
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/utils/ToastUtils.java
// public class ToastUtils {
//
// private ToastUtils() {
// throw new AssertionError();
// }
//
// public static void show(Context context, int resId) {
// show(context, context.getResources().getText(resId), Toast.LENGTH_SHORT);
// }
//
// public static void show(Context context, int resId, int duration) {
// show(context, context.getResources().getText(resId), duration);
// }
//
// public static void show(Context context, CharSequence text) {
// Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
// }
//
// public static void show(Context context, CharSequence text, int duration) {
// Toast.makeText(context, text, duration).show();
// }
//
// public static void show(Context context, int resId, Object... args) {
// show(context,
// String.format(context.getResources().getString(resId), args),
// Toast.LENGTH_SHORT);
// }
//
// public static void show(Context context, String format, Object... args) {
// show(context, String.format(format, args), Toast.LENGTH_SHORT);
// }
//
// public static void show(Context context, int resId, int duration,
// Object... args) {
// show(context,
// String.format(context.getResources().getString(resId), args),
// duration);
// }
//
// public static void show(Context context, String format, int duration,
// Object... args) {
// show(context, String.format(format, args), duration);
// }
// }
|
import android.content.Intent;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.huijimuhe.commonlayout.AppContext;
import com.huijimuhe.commonlayout.R;
import com.huijimuhe.commonlayout.data.xc.source.xcDetailRepository;
import com.huijimuhe.commonlayout.data.xc.xcDetailResponse;
import com.huijimuhe.commonlayout.presenter.xc.xcDetailContract;
import com.huijimuhe.commonlayout.presenter.xc.xcDetailPresenter;
import com.huijimuhe.commonlayout.utils.ToastUtils;
|
package com.huijimuhe.commonlayout.xc.detail;
public class xcDetailActivity extends AppCompatActivity implements xcDetailContract.View {
private static final String TAG_LOADING = "loading";
private static final String TAG_CONTAINER = "container";
private xcDetailPresenter mPresenter;
public static Intent newIntent() {
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/AppContext.java
// public class AppContext extends Application {
// private static AppContext INSTANCE=null;
//
// @Override
// public void onCreate() {
// super.onCreate();
// INSTANCE=this;
// }
//
// public static AppContext getInstance(){return INSTANCE;}
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/xcDetailRepository.java
// public class xcDetailRepository {
//
// public void load(Context context, final IxcDataSource.DetailLoadCallBack callback) {
// String dummy = readDummy(context);
// try {
// callback.onSuccess(new Gson().fromJson(dummy, xcDetailResponse.class));
// } catch (Exception e) {
// callback.onError("dd");
// }
// }
//
// public void loadBody(Context context) {
// String Result = "";
// try {
// InputStreamReader inputReader = new InputStreamReader(context.getAssets().open("xc_body_dummy.txt"));
// BufferedReader bufReader = new BufferedReader(inputReader);
// String line = "";
// while ((line = bufReader.readLine()) != null) {
// Result += line;
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// List<xcArticleSection> body = new Gson().fromJson(Result, new TypeToken<List<xcArticleSection>>() {
// }.getType());
//
// int count=body.size();
// }
//
// private String readDummy(Context context) {
// try {
// InputStreamReader inputReader = new InputStreamReader(context.getAssets().open("xc_detail_dummy.txt"));
// BufferedReader bufReader = new BufferedReader(inputReader);
// String line="";
// String Result="";
// while((line = bufReader.readLine()) != null) {
// Result += line;
// }
// return Result;
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/xc/xcDetailContract.java
// public class xcDetailContract {
//
// public interface View extends BaseView<Presenter> {
// void showContainer(xcDetailResponse response);
// }
//
// public interface Presenter extends BasePresenter {
// void load(Context context);
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/xc/xcDetailPresenter.java
// public class xcDetailPresenter implements xcDetailContract.Presenter {
//
// private xcDetailRepository mRepo;
// private xcDetailContract.View mView;
//
// public xcDetailPresenter(xcDetailContract.View view, xcDetailRepository repo) {
// this.mView = view;
// this.mRepo = repo;
// }
//
// @Override
// public void start() {
// }
//
// @Override
// public void load(Context context) {
// mRepo.load(context, new IxcDataSource.DetailLoadCallBack() {
// @Override
// public void onSuccess(xcDetailResponse response) {
// mView.showContainer(response);
// }
//
// @Override
// public void onError(String msg) {
// mView.showError();
// }
// });
// }
//
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/utils/ToastUtils.java
// public class ToastUtils {
//
// private ToastUtils() {
// throw new AssertionError();
// }
//
// public static void show(Context context, int resId) {
// show(context, context.getResources().getText(resId), Toast.LENGTH_SHORT);
// }
//
// public static void show(Context context, int resId, int duration) {
// show(context, context.getResources().getText(resId), duration);
// }
//
// public static void show(Context context, CharSequence text) {
// Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
// }
//
// public static void show(Context context, CharSequence text, int duration) {
// Toast.makeText(context, text, duration).show();
// }
//
// public static void show(Context context, int resId, Object... args) {
// show(context,
// String.format(context.getResources().getString(resId), args),
// Toast.LENGTH_SHORT);
// }
//
// public static void show(Context context, String format, Object... args) {
// show(context, String.format(format, args), Toast.LENGTH_SHORT);
// }
//
// public static void show(Context context, int resId, int duration,
// Object... args) {
// show(context,
// String.format(context.getResources().getString(resId), args),
// duration);
// }
//
// public static void show(Context context, String format, int duration,
// Object... args) {
// show(context, String.format(format, args), duration);
// }
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/xc/detail/xcDetailActivity.java
import android.content.Intent;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.huijimuhe.commonlayout.AppContext;
import com.huijimuhe.commonlayout.R;
import com.huijimuhe.commonlayout.data.xc.source.xcDetailRepository;
import com.huijimuhe.commonlayout.data.xc.xcDetailResponse;
import com.huijimuhe.commonlayout.presenter.xc.xcDetailContract;
import com.huijimuhe.commonlayout.presenter.xc.xcDetailPresenter;
import com.huijimuhe.commonlayout.utils.ToastUtils;
package com.huijimuhe.commonlayout.xc.detail;
public class xcDetailActivity extends AppCompatActivity implements xcDetailContract.View {
private static final String TAG_LOADING = "loading";
private static final String TAG_CONTAINER = "container";
private xcDetailPresenter mPresenter;
public static Intent newIntent() {
|
Intent intent = new Intent(AppContext.getInstance(),
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/utils/MarketUtils.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/AppContext.java
// public class AppContext extends Application {
// private static AppContext INSTANCE=null;
//
// @Override
// public void onCreate() {
// super.onCreate();
// INSTANCE=this;
// }
//
// public static AppContext getInstance(){return INSTANCE;}
// }
|
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.text.TextUtils;
import com.huijimuhe.commonlayout.AppContext;
import java.util.ArrayList;
import java.util.List;
|
}
if (TextUtils.isEmpty(installPkg))
continue;
if (installPkg.equals(checkPkg)) {
empty.add(installPkg);
break;
}
}
}
return empty;
}
/**
* 启动到app详情界面
*
* @param appPkg
* App的包名
* @param marketPkg
* 应用商店包名 ,如果为""则由系统弹出应用商店列表供用户选择,否则调转到目标市场的应用详情界面,某些应用商店可能会失败
*/
public static void launchAppDetail(String appPkg, String marketPkg) {
try {
if (TextUtils.isEmpty(appPkg))
return;
Uri uri = Uri.parse("market://details?id=" + appPkg);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
if (!TextUtils.isEmpty(marketPkg))
intent.setPackage(marketPkg);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/AppContext.java
// public class AppContext extends Application {
// private static AppContext INSTANCE=null;
//
// @Override
// public void onCreate() {
// super.onCreate();
// INSTANCE=this;
// }
//
// public static AppContext getInstance(){return INSTANCE;}
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/utils/MarketUtils.java
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.text.TextUtils;
import com.huijimuhe.commonlayout.AppContext;
import java.util.ArrayList;
import java.util.List;
}
if (TextUtils.isEmpty(installPkg))
continue;
if (installPkg.equals(checkPkg)) {
empty.add(installPkg);
break;
}
}
}
return empty;
}
/**
* 启动到app详情界面
*
* @param appPkg
* App的包名
* @param marketPkg
* 应用商店包名 ,如果为""则由系统弹出应用商店列表供用户选择,否则调转到目标市场的应用详情界面,某些应用商店可能会失败
*/
public static void launchAppDetail(String appPkg, String marketPkg) {
try {
if (TextUtils.isEmpty(appPkg))
return;
Uri uri = Uri.parse("market://details?id=" + appPkg);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
if (!TextUtils.isEmpty(marketPkg))
intent.setPackage(marketPkg);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
AppContext.getInstance().startActivity(intent);
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/xc/xcDetailPresenter.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/IxcDataSource.java
// public interface IxcDataSource {
//
// interface JxListLoadCallBack {
// void onSuccess(xcJxResponse response);
//
// void onError(String msg);
// }
//
// interface FxListLoadCallBack {
// void onSuccess(xcFxResponse response);
//
// void onError(String msg);
// }
//
// interface FeedListLoadCallBack {
// void onSuccess(xcFeedResponse response);
//
// void onError(String msg);
// }
// interface DetailLoadCallBack {
// void onSuccess(xcDetailResponse response);
//
// void onError(String msg);
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/xcDetailRepository.java
// public class xcDetailRepository {
//
// public void load(Context context, final IxcDataSource.DetailLoadCallBack callback) {
// String dummy = readDummy(context);
// try {
// callback.onSuccess(new Gson().fromJson(dummy, xcDetailResponse.class));
// } catch (Exception e) {
// callback.onError("dd");
// }
// }
//
// public void loadBody(Context context) {
// String Result = "";
// try {
// InputStreamReader inputReader = new InputStreamReader(context.getAssets().open("xc_body_dummy.txt"));
// BufferedReader bufReader = new BufferedReader(inputReader);
// String line = "";
// while ((line = bufReader.readLine()) != null) {
// Result += line;
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// List<xcArticleSection> body = new Gson().fromJson(Result, new TypeToken<List<xcArticleSection>>() {
// }.getType());
//
// int count=body.size();
// }
//
// private String readDummy(Context context) {
// try {
// InputStreamReader inputReader = new InputStreamReader(context.getAssets().open("xc_detail_dummy.txt"));
// BufferedReader bufReader = new BufferedReader(inputReader);
// String line="";
// String Result="";
// while((line = bufReader.readLine()) != null) {
// Result += line;
// }
// return Result;
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
// }
|
import android.content.Context;
import com.huijimuhe.commonlayout.data.xc.source.IxcDataSource;
import com.huijimuhe.commonlayout.data.xc.source.xcDetailRepository;
import com.huijimuhe.commonlayout.data.xc.xcDetailResponse;
|
package com.huijimuhe.commonlayout.presenter.xc;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public class xcDetailPresenter implements xcDetailContract.Presenter {
private xcDetailRepository mRepo;
private xcDetailContract.View mView;
public xcDetailPresenter(xcDetailContract.View view, xcDetailRepository repo) {
this.mView = view;
this.mRepo = repo;
}
@Override
public void start() {
}
@Override
public void load(Context context) {
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/IxcDataSource.java
// public interface IxcDataSource {
//
// interface JxListLoadCallBack {
// void onSuccess(xcJxResponse response);
//
// void onError(String msg);
// }
//
// interface FxListLoadCallBack {
// void onSuccess(xcFxResponse response);
//
// void onError(String msg);
// }
//
// interface FeedListLoadCallBack {
// void onSuccess(xcFeedResponse response);
//
// void onError(String msg);
// }
// interface DetailLoadCallBack {
// void onSuccess(xcDetailResponse response);
//
// void onError(String msg);
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/xcDetailRepository.java
// public class xcDetailRepository {
//
// public void load(Context context, final IxcDataSource.DetailLoadCallBack callback) {
// String dummy = readDummy(context);
// try {
// callback.onSuccess(new Gson().fromJson(dummy, xcDetailResponse.class));
// } catch (Exception e) {
// callback.onError("dd");
// }
// }
//
// public void loadBody(Context context) {
// String Result = "";
// try {
// InputStreamReader inputReader = new InputStreamReader(context.getAssets().open("xc_body_dummy.txt"));
// BufferedReader bufReader = new BufferedReader(inputReader);
// String line = "";
// while ((line = bufReader.readLine()) != null) {
// Result += line;
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// List<xcArticleSection> body = new Gson().fromJson(Result, new TypeToken<List<xcArticleSection>>() {
// }.getType());
//
// int count=body.size();
// }
//
// private String readDummy(Context context) {
// try {
// InputStreamReader inputReader = new InputStreamReader(context.getAssets().open("xc_detail_dummy.txt"));
// BufferedReader bufReader = new BufferedReader(inputReader);
// String line="";
// String Result="";
// while((line = bufReader.readLine()) != null) {
// Result += line;
// }
// return Result;
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/xc/xcDetailPresenter.java
import android.content.Context;
import com.huijimuhe.commonlayout.data.xc.source.IxcDataSource;
import com.huijimuhe.commonlayout.data.xc.source.xcDetailRepository;
import com.huijimuhe.commonlayout.data.xc.xcDetailResponse;
package com.huijimuhe.commonlayout.presenter.xc;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public class xcDetailPresenter implements xcDetailContract.Presenter {
private xcDetailRepository mRepo;
private xcDetailContract.View mView;
public xcDetailPresenter(xcDetailContract.View view, xcDetailRepository repo) {
this.mView = view;
this.mRepo = repo;
}
@Override
public void start() {
}
@Override
public void load(Context context) {
|
mRepo.load(context, new IxcDataSource.DetailLoadCallBack() {
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractRenderAdapter.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/render/HeaderRender.java
// public class HeaderRender extends AbstractRender {
// private ViewHolder mHolder;
//
// public HeaderRender(View parent) {
// this.mHolder = new ViewHolder(parent);
// }
//
//
// @Override
// public void bindData(int position) {
// }
//
// @Override
// public AbstractViewHolder getReusableComponent() {
// return this.mHolder;
// }
//
// public class ViewHolder extends AbstractViewHolder {
// public ViewHolder(View v) {
// super(v);
// }
// }
// }
|
import android.annotation.TargetApi;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import com.huijimuhe.commonlayout.adapter.render.HeaderRender;
import java.util.List;
|
package com.huijimuhe.commonlayout.adapter.base;
public abstract class AbstractRenderAdapter<T> extends RecyclerView.Adapter<AbstractViewHolder> {
public static final int RENDER_TYPE_HEADER = 110 << 1;
public static final int RENDER_TYPE_NORMAL = 110 << 2;
public List<T> mDataset;
public onItemClickListener mOnItemClickListener;
public onItemFunctionClickListener mOnItemFunctionClickListener;
private View mHeaderView;
public boolean mIsSectionHeadShown;
@Override
public int getItemViewType(int position) {
if (position == 0 && mHeaderView != null) {
return RENDER_TYPE_HEADER;
}
return RENDER_TYPE_NORMAL;
}
@TargetApi(4)
public AbstractViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
switch (viewType) {
case RENDER_TYPE_HEADER: {
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/render/HeaderRender.java
// public class HeaderRender extends AbstractRender {
// private ViewHolder mHolder;
//
// public HeaderRender(View parent) {
// this.mHolder = new ViewHolder(parent);
// }
//
//
// @Override
// public void bindData(int position) {
// }
//
// @Override
// public AbstractViewHolder getReusableComponent() {
// return this.mHolder;
// }
//
// public class ViewHolder extends AbstractViewHolder {
// public ViewHolder(View v) {
// super(v);
// }
// }
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractRenderAdapter.java
import android.annotation.TargetApi;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import com.huijimuhe.commonlayout.adapter.render.HeaderRender;
import java.util.List;
package com.huijimuhe.commonlayout.adapter.base;
public abstract class AbstractRenderAdapter<T> extends RecyclerView.Adapter<AbstractViewHolder> {
public static final int RENDER_TYPE_HEADER = 110 << 1;
public static final int RENDER_TYPE_NORMAL = 110 << 2;
public List<T> mDataset;
public onItemClickListener mOnItemClickListener;
public onItemFunctionClickListener mOnItemFunctionClickListener;
private View mHeaderView;
public boolean mIsSectionHeadShown;
@Override
public int getItemViewType(int position) {
if (position == 0 && mHeaderView != null) {
return RENDER_TYPE_HEADER;
}
return RENDER_TYPE_NORMAL;
}
@TargetApi(4)
public AbstractViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
switch (viewType) {
case RENDER_TYPE_HEADER: {
|
HeaderRender head = new HeaderRender(mHeaderView);
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/IxcDataSource.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFeedResponse.java
// public class xcFeedResponse {
//
// private List<xcFeed> contents;
//
// public List<xcFeed> getContents() {
// return contents;
// }
//
// public void setContents(List<xcFeed> contents) {
// this.contents = contents;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFxResponse.java
// public class xcFxResponse {
//
// private List<xcFeature> features;
//
// public List<xcFeature> getFeatures() {
// return features;
// }
//
// public void setFeatures(List<xcFeature> features) {
// this.features = features;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcJxResponse.java
// public class xcJxResponse {
//
// private List<xcBanner> ads_top;
// private List<xcSale> sales;
// private List<xcArticle> week_praise;
// private List<xcArticleGroup> subjects;
// private List<xcArticle> foods;
// private List<xcArticle> plays;
//
// public List<xcBanner> getAds_top() {
// return ads_top;
// }
//
// public void setAds_top(List<xcBanner> ads_top) {
// this.ads_top = ads_top;
// }
//
// public List<xcSale> getSales() {
// return sales;
// }
//
// public void setSales(List<xcSale> sales) {
// this.sales = sales;
// }
//
// public List<xcArticle> getWeek_praise() {
// return week_praise;
// }
//
// public void setWeek_praise(List<xcArticle> week_praise) {
// this.week_praise = week_praise;
// }
//
// public List<xcArticleGroup> getSubjects() {
// return subjects;
// }
//
// public void setSubjects(List<xcArticleGroup> subjects) {
// this.subjects = subjects;
// }
//
// public List<xcArticle> getFoods() {
// return foods;
// }
//
// public void setFoods(List<xcArticle> foods) {
// this.foods = foods;
// }
//
// public List<xcArticle> getPlays() {
// return plays;
// }
//
// public void setPlays(List<xcArticle> plays) {
// this.plays = plays;
// }
// }
|
import com.huijimuhe.commonlayout.data.xc.xcDetailResponse;
import com.huijimuhe.commonlayout.data.xc.xcFeedResponse;
import com.huijimuhe.commonlayout.data.xc.xcFxResponse;
import com.huijimuhe.commonlayout.data.xc.xcJxResponse;
|
package com.huijimuhe.commonlayout.data.xc.source;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public interface IxcDataSource {
interface JxListLoadCallBack {
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFeedResponse.java
// public class xcFeedResponse {
//
// private List<xcFeed> contents;
//
// public List<xcFeed> getContents() {
// return contents;
// }
//
// public void setContents(List<xcFeed> contents) {
// this.contents = contents;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFxResponse.java
// public class xcFxResponse {
//
// private List<xcFeature> features;
//
// public List<xcFeature> getFeatures() {
// return features;
// }
//
// public void setFeatures(List<xcFeature> features) {
// this.features = features;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcJxResponse.java
// public class xcJxResponse {
//
// private List<xcBanner> ads_top;
// private List<xcSale> sales;
// private List<xcArticle> week_praise;
// private List<xcArticleGroup> subjects;
// private List<xcArticle> foods;
// private List<xcArticle> plays;
//
// public List<xcBanner> getAds_top() {
// return ads_top;
// }
//
// public void setAds_top(List<xcBanner> ads_top) {
// this.ads_top = ads_top;
// }
//
// public List<xcSale> getSales() {
// return sales;
// }
//
// public void setSales(List<xcSale> sales) {
// this.sales = sales;
// }
//
// public List<xcArticle> getWeek_praise() {
// return week_praise;
// }
//
// public void setWeek_praise(List<xcArticle> week_praise) {
// this.week_praise = week_praise;
// }
//
// public List<xcArticleGroup> getSubjects() {
// return subjects;
// }
//
// public void setSubjects(List<xcArticleGroup> subjects) {
// this.subjects = subjects;
// }
//
// public List<xcArticle> getFoods() {
// return foods;
// }
//
// public void setFoods(List<xcArticle> foods) {
// this.foods = foods;
// }
//
// public List<xcArticle> getPlays() {
// return plays;
// }
//
// public void setPlays(List<xcArticle> plays) {
// this.plays = plays;
// }
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/IxcDataSource.java
import com.huijimuhe.commonlayout.data.xc.xcDetailResponse;
import com.huijimuhe.commonlayout.data.xc.xcFeedResponse;
import com.huijimuhe.commonlayout.data.xc.xcFxResponse;
import com.huijimuhe.commonlayout.data.xc.xcJxResponse;
package com.huijimuhe.commonlayout.data.xc.source;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public interface IxcDataSource {
interface JxListLoadCallBack {
|
void onSuccess(xcJxResponse response);
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/IxcDataSource.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFeedResponse.java
// public class xcFeedResponse {
//
// private List<xcFeed> contents;
//
// public List<xcFeed> getContents() {
// return contents;
// }
//
// public void setContents(List<xcFeed> contents) {
// this.contents = contents;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFxResponse.java
// public class xcFxResponse {
//
// private List<xcFeature> features;
//
// public List<xcFeature> getFeatures() {
// return features;
// }
//
// public void setFeatures(List<xcFeature> features) {
// this.features = features;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcJxResponse.java
// public class xcJxResponse {
//
// private List<xcBanner> ads_top;
// private List<xcSale> sales;
// private List<xcArticle> week_praise;
// private List<xcArticleGroup> subjects;
// private List<xcArticle> foods;
// private List<xcArticle> plays;
//
// public List<xcBanner> getAds_top() {
// return ads_top;
// }
//
// public void setAds_top(List<xcBanner> ads_top) {
// this.ads_top = ads_top;
// }
//
// public List<xcSale> getSales() {
// return sales;
// }
//
// public void setSales(List<xcSale> sales) {
// this.sales = sales;
// }
//
// public List<xcArticle> getWeek_praise() {
// return week_praise;
// }
//
// public void setWeek_praise(List<xcArticle> week_praise) {
// this.week_praise = week_praise;
// }
//
// public List<xcArticleGroup> getSubjects() {
// return subjects;
// }
//
// public void setSubjects(List<xcArticleGroup> subjects) {
// this.subjects = subjects;
// }
//
// public List<xcArticle> getFoods() {
// return foods;
// }
//
// public void setFoods(List<xcArticle> foods) {
// this.foods = foods;
// }
//
// public List<xcArticle> getPlays() {
// return plays;
// }
//
// public void setPlays(List<xcArticle> plays) {
// this.plays = plays;
// }
// }
|
import com.huijimuhe.commonlayout.data.xc.xcDetailResponse;
import com.huijimuhe.commonlayout.data.xc.xcFeedResponse;
import com.huijimuhe.commonlayout.data.xc.xcFxResponse;
import com.huijimuhe.commonlayout.data.xc.xcJxResponse;
|
package com.huijimuhe.commonlayout.data.xc.source;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public interface IxcDataSource {
interface JxListLoadCallBack {
void onSuccess(xcJxResponse response);
void onError(String msg);
}
interface FxListLoadCallBack {
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFeedResponse.java
// public class xcFeedResponse {
//
// private List<xcFeed> contents;
//
// public List<xcFeed> getContents() {
// return contents;
// }
//
// public void setContents(List<xcFeed> contents) {
// this.contents = contents;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFxResponse.java
// public class xcFxResponse {
//
// private List<xcFeature> features;
//
// public List<xcFeature> getFeatures() {
// return features;
// }
//
// public void setFeatures(List<xcFeature> features) {
// this.features = features;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcJxResponse.java
// public class xcJxResponse {
//
// private List<xcBanner> ads_top;
// private List<xcSale> sales;
// private List<xcArticle> week_praise;
// private List<xcArticleGroup> subjects;
// private List<xcArticle> foods;
// private List<xcArticle> plays;
//
// public List<xcBanner> getAds_top() {
// return ads_top;
// }
//
// public void setAds_top(List<xcBanner> ads_top) {
// this.ads_top = ads_top;
// }
//
// public List<xcSale> getSales() {
// return sales;
// }
//
// public void setSales(List<xcSale> sales) {
// this.sales = sales;
// }
//
// public List<xcArticle> getWeek_praise() {
// return week_praise;
// }
//
// public void setWeek_praise(List<xcArticle> week_praise) {
// this.week_praise = week_praise;
// }
//
// public List<xcArticleGroup> getSubjects() {
// return subjects;
// }
//
// public void setSubjects(List<xcArticleGroup> subjects) {
// this.subjects = subjects;
// }
//
// public List<xcArticle> getFoods() {
// return foods;
// }
//
// public void setFoods(List<xcArticle> foods) {
// this.foods = foods;
// }
//
// public List<xcArticle> getPlays() {
// return plays;
// }
//
// public void setPlays(List<xcArticle> plays) {
// this.plays = plays;
// }
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/IxcDataSource.java
import com.huijimuhe.commonlayout.data.xc.xcDetailResponse;
import com.huijimuhe.commonlayout.data.xc.xcFeedResponse;
import com.huijimuhe.commonlayout.data.xc.xcFxResponse;
import com.huijimuhe.commonlayout.data.xc.xcJxResponse;
package com.huijimuhe.commonlayout.data.xc.source;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public interface IxcDataSource {
interface JxListLoadCallBack {
void onSuccess(xcJxResponse response);
void onError(String msg);
}
interface FxListLoadCallBack {
|
void onSuccess(xcFxResponse response);
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/IxcDataSource.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFeedResponse.java
// public class xcFeedResponse {
//
// private List<xcFeed> contents;
//
// public List<xcFeed> getContents() {
// return contents;
// }
//
// public void setContents(List<xcFeed> contents) {
// this.contents = contents;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFxResponse.java
// public class xcFxResponse {
//
// private List<xcFeature> features;
//
// public List<xcFeature> getFeatures() {
// return features;
// }
//
// public void setFeatures(List<xcFeature> features) {
// this.features = features;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcJxResponse.java
// public class xcJxResponse {
//
// private List<xcBanner> ads_top;
// private List<xcSale> sales;
// private List<xcArticle> week_praise;
// private List<xcArticleGroup> subjects;
// private List<xcArticle> foods;
// private List<xcArticle> plays;
//
// public List<xcBanner> getAds_top() {
// return ads_top;
// }
//
// public void setAds_top(List<xcBanner> ads_top) {
// this.ads_top = ads_top;
// }
//
// public List<xcSale> getSales() {
// return sales;
// }
//
// public void setSales(List<xcSale> sales) {
// this.sales = sales;
// }
//
// public List<xcArticle> getWeek_praise() {
// return week_praise;
// }
//
// public void setWeek_praise(List<xcArticle> week_praise) {
// this.week_praise = week_praise;
// }
//
// public List<xcArticleGroup> getSubjects() {
// return subjects;
// }
//
// public void setSubjects(List<xcArticleGroup> subjects) {
// this.subjects = subjects;
// }
//
// public List<xcArticle> getFoods() {
// return foods;
// }
//
// public void setFoods(List<xcArticle> foods) {
// this.foods = foods;
// }
//
// public List<xcArticle> getPlays() {
// return plays;
// }
//
// public void setPlays(List<xcArticle> plays) {
// this.plays = plays;
// }
// }
|
import com.huijimuhe.commonlayout.data.xc.xcDetailResponse;
import com.huijimuhe.commonlayout.data.xc.xcFeedResponse;
import com.huijimuhe.commonlayout.data.xc.xcFxResponse;
import com.huijimuhe.commonlayout.data.xc.xcJxResponse;
|
package com.huijimuhe.commonlayout.data.xc.source;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public interface IxcDataSource {
interface JxListLoadCallBack {
void onSuccess(xcJxResponse response);
void onError(String msg);
}
interface FxListLoadCallBack {
void onSuccess(xcFxResponse response);
void onError(String msg);
}
interface FeedListLoadCallBack {
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFeedResponse.java
// public class xcFeedResponse {
//
// private List<xcFeed> contents;
//
// public List<xcFeed> getContents() {
// return contents;
// }
//
// public void setContents(List<xcFeed> contents) {
// this.contents = contents;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFxResponse.java
// public class xcFxResponse {
//
// private List<xcFeature> features;
//
// public List<xcFeature> getFeatures() {
// return features;
// }
//
// public void setFeatures(List<xcFeature> features) {
// this.features = features;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcJxResponse.java
// public class xcJxResponse {
//
// private List<xcBanner> ads_top;
// private List<xcSale> sales;
// private List<xcArticle> week_praise;
// private List<xcArticleGroup> subjects;
// private List<xcArticle> foods;
// private List<xcArticle> plays;
//
// public List<xcBanner> getAds_top() {
// return ads_top;
// }
//
// public void setAds_top(List<xcBanner> ads_top) {
// this.ads_top = ads_top;
// }
//
// public List<xcSale> getSales() {
// return sales;
// }
//
// public void setSales(List<xcSale> sales) {
// this.sales = sales;
// }
//
// public List<xcArticle> getWeek_praise() {
// return week_praise;
// }
//
// public void setWeek_praise(List<xcArticle> week_praise) {
// this.week_praise = week_praise;
// }
//
// public List<xcArticleGroup> getSubjects() {
// return subjects;
// }
//
// public void setSubjects(List<xcArticleGroup> subjects) {
// this.subjects = subjects;
// }
//
// public List<xcArticle> getFoods() {
// return foods;
// }
//
// public void setFoods(List<xcArticle> foods) {
// this.foods = foods;
// }
//
// public List<xcArticle> getPlays() {
// return plays;
// }
//
// public void setPlays(List<xcArticle> plays) {
// this.plays = plays;
// }
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/IxcDataSource.java
import com.huijimuhe.commonlayout.data.xc.xcDetailResponse;
import com.huijimuhe.commonlayout.data.xc.xcFeedResponse;
import com.huijimuhe.commonlayout.data.xc.xcFxResponse;
import com.huijimuhe.commonlayout.data.xc.xcJxResponse;
package com.huijimuhe.commonlayout.data.xc.source;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public interface IxcDataSource {
interface JxListLoadCallBack {
void onSuccess(xcJxResponse response);
void onError(String msg);
}
interface FxListLoadCallBack {
void onSuccess(xcFxResponse response);
void onError(String msg);
}
interface FeedListLoadCallBack {
|
void onSuccess(xcFeedResponse response);
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/xcJxListRepository.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcJxResponse.java
// public class xcJxResponse {
//
// private List<xcBanner> ads_top;
// private List<xcSale> sales;
// private List<xcArticle> week_praise;
// private List<xcArticleGroup> subjects;
// private List<xcArticle> foods;
// private List<xcArticle> plays;
//
// public List<xcBanner> getAds_top() {
// return ads_top;
// }
//
// public void setAds_top(List<xcBanner> ads_top) {
// this.ads_top = ads_top;
// }
//
// public List<xcSale> getSales() {
// return sales;
// }
//
// public void setSales(List<xcSale> sales) {
// this.sales = sales;
// }
//
// public List<xcArticle> getWeek_praise() {
// return week_praise;
// }
//
// public void setWeek_praise(List<xcArticle> week_praise) {
// this.week_praise = week_praise;
// }
//
// public List<xcArticleGroup> getSubjects() {
// return subjects;
// }
//
// public void setSubjects(List<xcArticleGroup> subjects) {
// this.subjects = subjects;
// }
//
// public List<xcArticle> getFoods() {
// return foods;
// }
//
// public void setFoods(List<xcArticle> foods) {
// this.foods = foods;
// }
//
// public List<xcArticle> getPlays() {
// return plays;
// }
//
// public void setPlays(List<xcArticle> plays) {
// this.plays = plays;
// }
// }
|
import android.content.Context;
import com.google.gson.Gson;
import com.huijimuhe.commonlayout.data.xc.xcJxResponse;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
|
package com.huijimuhe.commonlayout.data.xc.source;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public class xcJxListRepository {
public void load(Context context, final IxcDataSource.JxListLoadCallBack callback){
String dummy=readDummy(context);
try {
JSONObject json=new JSONObject(dummy);
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcJxResponse.java
// public class xcJxResponse {
//
// private List<xcBanner> ads_top;
// private List<xcSale> sales;
// private List<xcArticle> week_praise;
// private List<xcArticleGroup> subjects;
// private List<xcArticle> foods;
// private List<xcArticle> plays;
//
// public List<xcBanner> getAds_top() {
// return ads_top;
// }
//
// public void setAds_top(List<xcBanner> ads_top) {
// this.ads_top = ads_top;
// }
//
// public List<xcSale> getSales() {
// return sales;
// }
//
// public void setSales(List<xcSale> sales) {
// this.sales = sales;
// }
//
// public List<xcArticle> getWeek_praise() {
// return week_praise;
// }
//
// public void setWeek_praise(List<xcArticle> week_praise) {
// this.week_praise = week_praise;
// }
//
// public List<xcArticleGroup> getSubjects() {
// return subjects;
// }
//
// public void setSubjects(List<xcArticleGroup> subjects) {
// this.subjects = subjects;
// }
//
// public List<xcArticle> getFoods() {
// return foods;
// }
//
// public void setFoods(List<xcArticle> foods) {
// this.foods = foods;
// }
//
// public List<xcArticle> getPlays() {
// return plays;
// }
//
// public void setPlays(List<xcArticle> plays) {
// this.plays = plays;
// }
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/xcJxListRepository.java
import android.content.Context;
import com.google.gson.Gson;
import com.huijimuhe.commonlayout.data.xc.xcJxResponse;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
package com.huijimuhe.commonlayout.data.xc.source;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public class xcJxListRepository {
public void load(Context context, final IxcDataSource.JxListLoadCallBack callback){
String dummy=readDummy(context);
try {
JSONObject json=new JSONObject(dummy);
|
callback.onSuccess(new Gson().fromJson(json.getString("data"),xcJxResponse.class));
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/xcFxListRepository.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFxResponse.java
// public class xcFxResponse {
//
// private List<xcFeature> features;
//
// public List<xcFeature> getFeatures() {
// return features;
// }
//
// public void setFeatures(List<xcFeature> features) {
// this.features = features;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcJxResponse.java
// public class xcJxResponse {
//
// private List<xcBanner> ads_top;
// private List<xcSale> sales;
// private List<xcArticle> week_praise;
// private List<xcArticleGroup> subjects;
// private List<xcArticle> foods;
// private List<xcArticle> plays;
//
// public List<xcBanner> getAds_top() {
// return ads_top;
// }
//
// public void setAds_top(List<xcBanner> ads_top) {
// this.ads_top = ads_top;
// }
//
// public List<xcSale> getSales() {
// return sales;
// }
//
// public void setSales(List<xcSale> sales) {
// this.sales = sales;
// }
//
// public List<xcArticle> getWeek_praise() {
// return week_praise;
// }
//
// public void setWeek_praise(List<xcArticle> week_praise) {
// this.week_praise = week_praise;
// }
//
// public List<xcArticleGroup> getSubjects() {
// return subjects;
// }
//
// public void setSubjects(List<xcArticleGroup> subjects) {
// this.subjects = subjects;
// }
//
// public List<xcArticle> getFoods() {
// return foods;
// }
//
// public void setFoods(List<xcArticle> foods) {
// this.foods = foods;
// }
//
// public List<xcArticle> getPlays() {
// return plays;
// }
//
// public void setPlays(List<xcArticle> plays) {
// this.plays = plays;
// }
// }
|
import android.content.Context;
import com.google.gson.Gson;
import com.huijimuhe.commonlayout.data.xc.xcFxResponse;
import com.huijimuhe.commonlayout.data.xc.xcJxResponse;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
|
package com.huijimuhe.commonlayout.data.xc.source;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public class xcFxListRepository {
public void load(Context context, final IxcDataSource.FxListLoadCallBack callback){
String dummy=readDummy(context);
try {
JSONObject json=new JSONObject(dummy);
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFxResponse.java
// public class xcFxResponse {
//
// private List<xcFeature> features;
//
// public List<xcFeature> getFeatures() {
// return features;
// }
//
// public void setFeatures(List<xcFeature> features) {
// this.features = features;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcJxResponse.java
// public class xcJxResponse {
//
// private List<xcBanner> ads_top;
// private List<xcSale> sales;
// private List<xcArticle> week_praise;
// private List<xcArticleGroup> subjects;
// private List<xcArticle> foods;
// private List<xcArticle> plays;
//
// public List<xcBanner> getAds_top() {
// return ads_top;
// }
//
// public void setAds_top(List<xcBanner> ads_top) {
// this.ads_top = ads_top;
// }
//
// public List<xcSale> getSales() {
// return sales;
// }
//
// public void setSales(List<xcSale> sales) {
// this.sales = sales;
// }
//
// public List<xcArticle> getWeek_praise() {
// return week_praise;
// }
//
// public void setWeek_praise(List<xcArticle> week_praise) {
// this.week_praise = week_praise;
// }
//
// public List<xcArticleGroup> getSubjects() {
// return subjects;
// }
//
// public void setSubjects(List<xcArticleGroup> subjects) {
// this.subjects = subjects;
// }
//
// public List<xcArticle> getFoods() {
// return foods;
// }
//
// public void setFoods(List<xcArticle> foods) {
// this.foods = foods;
// }
//
// public List<xcArticle> getPlays() {
// return plays;
// }
//
// public void setPlays(List<xcArticle> plays) {
// this.plays = plays;
// }
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/xcFxListRepository.java
import android.content.Context;
import com.google.gson.Gson;
import com.huijimuhe.commonlayout.data.xc.xcFxResponse;
import com.huijimuhe.commonlayout.data.xc.xcJxResponse;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
package com.huijimuhe.commonlayout.data.xc.source;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public class xcFxListRepository {
public void load(Context context, final IxcDataSource.FxListLoadCallBack callback){
String dummy=readDummy(context);
try {
JSONObject json=new JSONObject(dummy);
|
callback.onSuccess(new Gson().fromJson(json.getString("data"),xcFxResponse.class));
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/widget/NineGridLayout.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/utils/ViewUtility.java
// public class ViewUtility {
// @SuppressWarnings({"unchecked", "UnusedDeclaration"})
// public static <T extends View> T findViewById(View view, int id) {
// return (T) view.findViewById(id);
// }
//
// @SuppressWarnings({"unchecked", "UnusedDeclaration"})
// public static <T extends View> T findViewById(Activity activity, int id) {
// return (T) activity.findViewById(id);
// }
//
//
// public final static int getWindowsWidth(Activity activity) {
// DisplayMetrics dm = new DisplayMetrics();
// activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
// return dm.widthPixels;
// }
//
// public static int dip2px(Context context, float dpValue) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (dpValue * scale + 0.5f);
// }
//
// public static int px2dip(Context context, float pxValue) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (pxValue / scale + 0.5f);
// }
//
// /** 获取手机的密度*/
// public static float getDensity(Context context) {
// DisplayMetrics dm = context.getResources().getDisplayMetrics();
// return dm.density;
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.huijimuhe.commonlayout.utils.ViewUtility;
import java.util.List;
|
package com.huijimuhe.commonlayout.widget;
/**
* @ClassName MultiImageView.java
* @author shoyu
* @version
* @Description: 显示1~N张图片的View
*/
public class NineGridLayout extends LinearLayout {
public static int MAX_WIDTH = 0;
// 照片的Url列表
private List<String> imagesList;
/** 长度 单位为Pixel **/
private int pxOneMaxWandH; // 单张图最大允许宽高
private int pxMoreWandH = 0;// 多张图的宽高
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/utils/ViewUtility.java
// public class ViewUtility {
// @SuppressWarnings({"unchecked", "UnusedDeclaration"})
// public static <T extends View> T findViewById(View view, int id) {
// return (T) view.findViewById(id);
// }
//
// @SuppressWarnings({"unchecked", "UnusedDeclaration"})
// public static <T extends View> T findViewById(Activity activity, int id) {
// return (T) activity.findViewById(id);
// }
//
//
// public final static int getWindowsWidth(Activity activity) {
// DisplayMetrics dm = new DisplayMetrics();
// activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
// return dm.widthPixels;
// }
//
// public static int dip2px(Context context, float dpValue) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (dpValue * scale + 0.5f);
// }
//
// public static int px2dip(Context context, float pxValue) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (pxValue / scale + 0.5f);
// }
//
// /** 获取手机的密度*/
// public static float getDensity(Context context) {
// DisplayMetrics dm = context.getResources().getDisplayMetrics();
// return dm.density;
// }
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/widget/NineGridLayout.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.huijimuhe.commonlayout.utils.ViewUtility;
import java.util.List;
package com.huijimuhe.commonlayout.widget;
/**
* @ClassName MultiImageView.java
* @author shoyu
* @version
* @Description: 显示1~N张图片的View
*/
public class NineGridLayout extends LinearLayout {
public static int MAX_WIDTH = 0;
// 照片的Url列表
private List<String> imagesList;
/** 长度 单位为Pixel **/
private int pxOneMaxWandH; // 单张图最大允许宽高
private int pxMoreWandH = 0;// 多张图的宽高
|
private int pxImagePadding = ViewUtility.dip2px(getContext(), 3);// 图片间的间距
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/render/HeaderRender.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractRender.java
// public abstract class AbstractRender{
//
// public abstract<T extends AbstractViewHolder> T getReusableComponent();
// public abstract void bindData(int position);
//
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractViewHolder.java
// public abstract class AbstractViewHolder extends RecyclerView.ViewHolder{
//
// public AbstractViewHolder(View itemView) {
// super(itemView);
// }
//
// }
|
import android.view.View;
import com.huijimuhe.commonlayout.adapter.base.AbstractRender;
import com.huijimuhe.commonlayout.adapter.base.AbstractViewHolder;
|
package com.huijimuhe.commonlayout.adapter.render;
/**
* Created by Huijimuhe on 2016/6/11.
* This is a part of Homedev
* enjoy
*/
public class HeaderRender extends AbstractRender {
private ViewHolder mHolder;
public HeaderRender(View parent) {
this.mHolder = new ViewHolder(parent);
}
@Override
public void bindData(int position) {
}
@Override
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractRender.java
// public abstract class AbstractRender{
//
// public abstract<T extends AbstractViewHolder> T getReusableComponent();
// public abstract void bindData(int position);
//
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/base/AbstractViewHolder.java
// public abstract class AbstractViewHolder extends RecyclerView.ViewHolder{
//
// public AbstractViewHolder(View itemView) {
// super(itemView);
// }
//
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/Adapter/render/HeaderRender.java
import android.view.View;
import com.huijimuhe.commonlayout.adapter.base.AbstractRender;
import com.huijimuhe.commonlayout.adapter.base.AbstractViewHolder;
package com.huijimuhe.commonlayout.adapter.render;
/**
* Created by Huijimuhe on 2016/6/11.
* This is a part of Homedev
* enjoy
*/
public class HeaderRender extends AbstractRender {
private ViewHolder mHolder;
public HeaderRender(View parent) {
this.mHolder = new ViewHolder(parent);
}
@Override
public void bindData(int position) {
}
@Override
|
public AbstractViewHolder getReusableComponent() {
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/xcFeedListRepository.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFeedResponse.java
// public class xcFeedResponse {
//
// private List<xcFeed> contents;
//
// public List<xcFeed> getContents() {
// return contents;
// }
//
// public void setContents(List<xcFeed> contents) {
// this.contents = contents;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFxResponse.java
// public class xcFxResponse {
//
// private List<xcFeature> features;
//
// public List<xcFeature> getFeatures() {
// return features;
// }
//
// public void setFeatures(List<xcFeature> features) {
// this.features = features;
// }
// }
|
import android.content.Context;
import com.google.gson.Gson;
import com.huijimuhe.commonlayout.data.xc.xcFeedResponse;
import com.huijimuhe.commonlayout.data.xc.xcFxResponse;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
|
package com.huijimuhe.commonlayout.data.xc.source;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public class xcFeedListRepository {
public void load(Context context, final IxcDataSource.FeedListLoadCallBack callback){
String dummy=readDummy(context);
try {
JSONObject json=new JSONObject(dummy);
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFeedResponse.java
// public class xcFeedResponse {
//
// private List<xcFeed> contents;
//
// public List<xcFeed> getContents() {
// return contents;
// }
//
// public void setContents(List<xcFeed> contents) {
// this.contents = contents;
// }
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/xcFxResponse.java
// public class xcFxResponse {
//
// private List<xcFeature> features;
//
// public List<xcFeature> getFeatures() {
// return features;
// }
//
// public void setFeatures(List<xcFeature> features) {
// this.features = features;
// }
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/data/xc/source/xcFeedListRepository.java
import android.content.Context;
import com.google.gson.Gson;
import com.huijimuhe.commonlayout.data.xc.xcFeedResponse;
import com.huijimuhe.commonlayout.data.xc.xcFxResponse;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
package com.huijimuhe.commonlayout.data.xc.source;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public class xcFeedListRepository {
public void load(Context context, final IxcDataSource.FeedListLoadCallBack callback){
String dummy=readDummy(context);
try {
JSONObject json=new JSONObject(dummy);
|
callback.onSuccess(new Gson().fromJson(json.getString("data"),xcFeedResponse.class));
|
huijimuhe/common-layout-android
|
CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/xc/xcDetailContract.java
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/BasePresenter.java
// public interface BasePresenter {
//
// void start();
//
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/BaseView.java
// public interface BaseView<T> {
//
// void showLoading(boolean isActive);
//
// void showError();
//
// }
|
import android.content.Context;
import com.huijimuhe.commonlayout.data.xc.xcDetailResponse;
import com.huijimuhe.commonlayout.presenter.BasePresenter;
import com.huijimuhe.commonlayout.presenter.BaseView;
|
package com.huijimuhe.commonlayout.presenter.xc;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public class xcDetailContract {
public interface View extends BaseView<Presenter> {
void showContainer(xcDetailResponse response);
}
|
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/BasePresenter.java
// public interface BasePresenter {
//
// void start();
//
// }
//
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/BaseView.java
// public interface BaseView<T> {
//
// void showLoading(boolean isActive);
//
// void showError();
//
// }
// Path: CommonLayout/app/src/main/java/com/huijimuhe/commonlayout/presenter/xc/xcDetailContract.java
import android.content.Context;
import com.huijimuhe.commonlayout.data.xc.xcDetailResponse;
import com.huijimuhe.commonlayout.presenter.BasePresenter;
import com.huijimuhe.commonlayout.presenter.BaseView;
package com.huijimuhe.commonlayout.presenter.xc;
/**
* Created by Huijimuhe on 2016/6/26.
* This is a part of Group
* enjoy
*/
public class xcDetailContract {
public interface View extends BaseView<Presenter> {
void showContainer(xcDetailResponse response);
}
|
public interface Presenter extends BasePresenter {
|
dhbw-horb/forgetIT
|
forgetIT/src/forgetit/gui/views/ViewTodo.java
|
// Path: forgetIT/src/forgetit/common/Category.java
// public enum Category {
// APPOINTMENT,
// NOTE,
// TODO;
// }
//
// Path: forgetIT/src/forgetit/common/Entity.java
// @javax.persistence.Entity
// public class Entity implements Serializable {
//
// private int id;
// private String title;
// private String description;
//
// private Status status;
//
// private Function priority;
//
// private Date startDate;
//
// private Date endDate;
//
// private List<Tag> tags;
//
// private List<Entity> dependencies; // All notes, that have to happen before
// private Category category;
//
// public Entity() {
//
// this.title = "";
// this.description = "";
// this.status = Status.IDLE;
// this.priority = new Function();
// this.startDate = new Date();
// this.endDate = new Date();
// this.tags = new LinkedList<Tag>();
// }
//
// public String getTitle() {
//
// return title;
// }
//
// public void setTitle(String title) {
//
// this.title = title;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// public Status getStatus() {
//
// return status;
// }
//
// public void setStatus(Status status) {
//
// this.status = status;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Function getPriority() {
//
// if (priority == null) {
// return new Function();
// }
// return priority;
// }
//
// public void setPriority(Function priority) {
//
// this.priority = priority;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getStartDate() {
//
// return startDate;
// }
//
// public void setStartDate(Date startDate) {
//
// this.startDate = startDate;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getEndDate() {
//
// return endDate;
// }
//
// public void setEndDate(Date endDate) {
//
// this.endDate = endDate;
// }
//
// @ManyToMany(targetEntity = forgetit.common.Tag.class, cascade = { CascadeType.ALL, CascadeType.PERSIST,
// CascadeType.MERGE })
// @JoinTable(name = "ENTITY_TAG", joinColumns = @JoinColumn(name = "ENTITY_ID"), inverseJoinColumns = @JoinColumn(name = "TAG_ID"))
// public List<Tag> getTags() {
//
// return tags;
// }
//
// public void setTags(List<Tag> tags) {
//
// this.tags = tags;
// }
//
// @OneToMany
// public List<Entity> getDependencies() {
//
// return dependencies;
// }
//
// public void setDependencies(List<Entity> dependencies) {
//
// this.dependencies = dependencies;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public Category getCategory() {
//
// return category;
// }
//
// public void setCategory(Category category) {
//
// this.category = category;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// }
//
// Path: forgetIT/src/forgetit/common/Function.java
// @Entity
// public class Function {
//
// @Id
// @GeneratedValue
// private int id;
//
// @OneToOne(fetch = FetchType.LAZY)
// @JoinColumn(nullable = false)
// private forgetit.common.Entity entity_id;
//
// // x^0....x^n
// @ElementCollection
// @CollectionTable(name = "coefficients")
// @Column(name = "coefficients")
// private List<Integer> coefficients;
//
// public List<Integer> getCoefficients() {
//
// return coefficients;
// }
//
// public void setCoefficients(List<Integer> coefficients) {
//
// this.coefficients = coefficients;
// }
//
// public int getY(int x) {
//
// // TODO implement
// try {
// // static priority
// return coefficients.get(0);
// } catch (Exception e) {
// return 0;
// }
// }
//
// }
|
import forgetit.common.Entity;
import forgetit.common.Function;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import forgetit.common.Category;
|
}
}
@Override
public void refreshView(List<Entity> entities) {
// if there is no entity, the table should not be visible
if(entities.size() <= 0) {
table.setVisible(false);
return;
} else if (!table.isVisible()) {
table.setVisible(true);
}
// remove content of the table
table.removeAll();
// set new content of the table
for (Entity entity : entities) {
TableItem item = new TableItem (table, SWT.NONE);
item.setText (0, entity.getTitle());
item.setText (1, ""+entity.getPriority().getY(0));
}
// resize columns
for (int i=0; i < table.getColumnCount(); i++) {
table.getColumn(i).pack();
}
}
@Override
|
// Path: forgetIT/src/forgetit/common/Category.java
// public enum Category {
// APPOINTMENT,
// NOTE,
// TODO;
// }
//
// Path: forgetIT/src/forgetit/common/Entity.java
// @javax.persistence.Entity
// public class Entity implements Serializable {
//
// private int id;
// private String title;
// private String description;
//
// private Status status;
//
// private Function priority;
//
// private Date startDate;
//
// private Date endDate;
//
// private List<Tag> tags;
//
// private List<Entity> dependencies; // All notes, that have to happen before
// private Category category;
//
// public Entity() {
//
// this.title = "";
// this.description = "";
// this.status = Status.IDLE;
// this.priority = new Function();
// this.startDate = new Date();
// this.endDate = new Date();
// this.tags = new LinkedList<Tag>();
// }
//
// public String getTitle() {
//
// return title;
// }
//
// public void setTitle(String title) {
//
// this.title = title;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// public Status getStatus() {
//
// return status;
// }
//
// public void setStatus(Status status) {
//
// this.status = status;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Function getPriority() {
//
// if (priority == null) {
// return new Function();
// }
// return priority;
// }
//
// public void setPriority(Function priority) {
//
// this.priority = priority;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getStartDate() {
//
// return startDate;
// }
//
// public void setStartDate(Date startDate) {
//
// this.startDate = startDate;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getEndDate() {
//
// return endDate;
// }
//
// public void setEndDate(Date endDate) {
//
// this.endDate = endDate;
// }
//
// @ManyToMany(targetEntity = forgetit.common.Tag.class, cascade = { CascadeType.ALL, CascadeType.PERSIST,
// CascadeType.MERGE })
// @JoinTable(name = "ENTITY_TAG", joinColumns = @JoinColumn(name = "ENTITY_ID"), inverseJoinColumns = @JoinColumn(name = "TAG_ID"))
// public List<Tag> getTags() {
//
// return tags;
// }
//
// public void setTags(List<Tag> tags) {
//
// this.tags = tags;
// }
//
// @OneToMany
// public List<Entity> getDependencies() {
//
// return dependencies;
// }
//
// public void setDependencies(List<Entity> dependencies) {
//
// this.dependencies = dependencies;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public Category getCategory() {
//
// return category;
// }
//
// public void setCategory(Category category) {
//
// this.category = category;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// }
//
// Path: forgetIT/src/forgetit/common/Function.java
// @Entity
// public class Function {
//
// @Id
// @GeneratedValue
// private int id;
//
// @OneToOne(fetch = FetchType.LAZY)
// @JoinColumn(nullable = false)
// private forgetit.common.Entity entity_id;
//
// // x^0....x^n
// @ElementCollection
// @CollectionTable(name = "coefficients")
// @Column(name = "coefficients")
// private List<Integer> coefficients;
//
// public List<Integer> getCoefficients() {
//
// return coefficients;
// }
//
// public void setCoefficients(List<Integer> coefficients) {
//
// this.coefficients = coefficients;
// }
//
// public int getY(int x) {
//
// // TODO implement
// try {
// // static priority
// return coefficients.get(0);
// } catch (Exception e) {
// return 0;
// }
// }
//
// }
// Path: forgetIT/src/forgetit/gui/views/ViewTodo.java
import forgetit.common.Entity;
import forgetit.common.Function;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import forgetit.common.Category;
}
}
@Override
public void refreshView(List<Entity> entities) {
// if there is no entity, the table should not be visible
if(entities.size() <= 0) {
table.setVisible(false);
return;
} else if (!table.isVisible()) {
table.setVisible(true);
}
// remove content of the table
table.removeAll();
// set new content of the table
for (Entity entity : entities) {
TableItem item = new TableItem (table, SWT.NONE);
item.setText (0, entity.getTitle());
item.setText (1, ""+entity.getPriority().getY(0));
}
// resize columns
for (int i=0; i < table.getColumnCount(); i++) {
table.getColumn(i).pack();
}
}
@Override
|
public Category getCategory() {
|
dhbw-horb/forgetIT
|
forgetIT/src/forgetit/gui/views/IEntitiesView.java
|
// Path: forgetIT/src/forgetit/common/Category.java
// public enum Category {
// APPOINTMENT,
// NOTE,
// TODO;
// }
//
// Path: forgetIT/src/forgetit/common/Entity.java
// @javax.persistence.Entity
// public class Entity implements Serializable {
//
// private int id;
// private String title;
// private String description;
//
// private Status status;
//
// private Function priority;
//
// private Date startDate;
//
// private Date endDate;
//
// private List<Tag> tags;
//
// private List<Entity> dependencies; // All notes, that have to happen before
// private Category category;
//
// public Entity() {
//
// this.title = "";
// this.description = "";
// this.status = Status.IDLE;
// this.priority = new Function();
// this.startDate = new Date();
// this.endDate = new Date();
// this.tags = new LinkedList<Tag>();
// }
//
// public String getTitle() {
//
// return title;
// }
//
// public void setTitle(String title) {
//
// this.title = title;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// public Status getStatus() {
//
// return status;
// }
//
// public void setStatus(Status status) {
//
// this.status = status;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Function getPriority() {
//
// if (priority == null) {
// return new Function();
// }
// return priority;
// }
//
// public void setPriority(Function priority) {
//
// this.priority = priority;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getStartDate() {
//
// return startDate;
// }
//
// public void setStartDate(Date startDate) {
//
// this.startDate = startDate;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getEndDate() {
//
// return endDate;
// }
//
// public void setEndDate(Date endDate) {
//
// this.endDate = endDate;
// }
//
// @ManyToMany(targetEntity = forgetit.common.Tag.class, cascade = { CascadeType.ALL, CascadeType.PERSIST,
// CascadeType.MERGE })
// @JoinTable(name = "ENTITY_TAG", joinColumns = @JoinColumn(name = "ENTITY_ID"), inverseJoinColumns = @JoinColumn(name = "TAG_ID"))
// public List<Tag> getTags() {
//
// return tags;
// }
//
// public void setTags(List<Tag> tags) {
//
// this.tags = tags;
// }
//
// @OneToMany
// public List<Entity> getDependencies() {
//
// return dependencies;
// }
//
// public void setDependencies(List<Entity> dependencies) {
//
// this.dependencies = dependencies;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public Category getCategory() {
//
// return category;
// }
//
// public void setCategory(Category category) {
//
// this.category = category;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// }
|
import java.util.List;
import forgetit.common.Category;
import forgetit.common.Entity;
|
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.gui.views;
/**
* Through IEntitiesView the different views can be refreshed by GraphicsController.
*
* @author ChornHulio (<a href="mailto:[chornhulio@web.de]">chornhulio@web.de</a>)
* @since 0.1
*/
public interface IEntitiesView {
public void refreshView(List<Entity> entities);
|
// Path: forgetIT/src/forgetit/common/Category.java
// public enum Category {
// APPOINTMENT,
// NOTE,
// TODO;
// }
//
// Path: forgetIT/src/forgetit/common/Entity.java
// @javax.persistence.Entity
// public class Entity implements Serializable {
//
// private int id;
// private String title;
// private String description;
//
// private Status status;
//
// private Function priority;
//
// private Date startDate;
//
// private Date endDate;
//
// private List<Tag> tags;
//
// private List<Entity> dependencies; // All notes, that have to happen before
// private Category category;
//
// public Entity() {
//
// this.title = "";
// this.description = "";
// this.status = Status.IDLE;
// this.priority = new Function();
// this.startDate = new Date();
// this.endDate = new Date();
// this.tags = new LinkedList<Tag>();
// }
//
// public String getTitle() {
//
// return title;
// }
//
// public void setTitle(String title) {
//
// this.title = title;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// public Status getStatus() {
//
// return status;
// }
//
// public void setStatus(Status status) {
//
// this.status = status;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Function getPriority() {
//
// if (priority == null) {
// return new Function();
// }
// return priority;
// }
//
// public void setPriority(Function priority) {
//
// this.priority = priority;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getStartDate() {
//
// return startDate;
// }
//
// public void setStartDate(Date startDate) {
//
// this.startDate = startDate;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getEndDate() {
//
// return endDate;
// }
//
// public void setEndDate(Date endDate) {
//
// this.endDate = endDate;
// }
//
// @ManyToMany(targetEntity = forgetit.common.Tag.class, cascade = { CascadeType.ALL, CascadeType.PERSIST,
// CascadeType.MERGE })
// @JoinTable(name = "ENTITY_TAG", joinColumns = @JoinColumn(name = "ENTITY_ID"), inverseJoinColumns = @JoinColumn(name = "TAG_ID"))
// public List<Tag> getTags() {
//
// return tags;
// }
//
// public void setTags(List<Tag> tags) {
//
// this.tags = tags;
// }
//
// @OneToMany
// public List<Entity> getDependencies() {
//
// return dependencies;
// }
//
// public void setDependencies(List<Entity> dependencies) {
//
// this.dependencies = dependencies;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public Category getCategory() {
//
// return category;
// }
//
// public void setCategory(Category category) {
//
// this.category = category;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// }
// Path: forgetIT/src/forgetit/gui/views/IEntitiesView.java
import java.util.List;
import forgetit.common.Category;
import forgetit.common.Entity;
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.gui.views;
/**
* Through IEntitiesView the different views can be refreshed by GraphicsController.
*
* @author ChornHulio (<a href="mailto:[chornhulio@web.de]">chornhulio@web.de</a>)
* @since 0.1
*/
public interface IEntitiesView {
public void refreshView(List<Entity> entities);
|
public Category getCategory();
|
dhbw-horb/forgetIT
|
forgetIT/src/forgetit/gui/views/ViewNotes.java
|
// Path: forgetIT/src/forgetit/common/Category.java
// public enum Category {
// APPOINTMENT,
// NOTE,
// TODO;
// }
//
// Path: forgetIT/src/forgetit/common/Entity.java
// @javax.persistence.Entity
// public class Entity implements Serializable {
//
// private int id;
// private String title;
// private String description;
//
// private Status status;
//
// private Function priority;
//
// private Date startDate;
//
// private Date endDate;
//
// private List<Tag> tags;
//
// private List<Entity> dependencies; // All notes, that have to happen before
// private Category category;
//
// public Entity() {
//
// this.title = "";
// this.description = "";
// this.status = Status.IDLE;
// this.priority = new Function();
// this.startDate = new Date();
// this.endDate = new Date();
// this.tags = new LinkedList<Tag>();
// }
//
// public String getTitle() {
//
// return title;
// }
//
// public void setTitle(String title) {
//
// this.title = title;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// public Status getStatus() {
//
// return status;
// }
//
// public void setStatus(Status status) {
//
// this.status = status;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Function getPriority() {
//
// if (priority == null) {
// return new Function();
// }
// return priority;
// }
//
// public void setPriority(Function priority) {
//
// this.priority = priority;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getStartDate() {
//
// return startDate;
// }
//
// public void setStartDate(Date startDate) {
//
// this.startDate = startDate;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getEndDate() {
//
// return endDate;
// }
//
// public void setEndDate(Date endDate) {
//
// this.endDate = endDate;
// }
//
// @ManyToMany(targetEntity = forgetit.common.Tag.class, cascade = { CascadeType.ALL, CascadeType.PERSIST,
// CascadeType.MERGE })
// @JoinTable(name = "ENTITY_TAG", joinColumns = @JoinColumn(name = "ENTITY_ID"), inverseJoinColumns = @JoinColumn(name = "TAG_ID"))
// public List<Tag> getTags() {
//
// return tags;
// }
//
// public void setTags(List<Tag> tags) {
//
// this.tags = tags;
// }
//
// @OneToMany
// public List<Entity> getDependencies() {
//
// return dependencies;
// }
//
// public void setDependencies(List<Entity> dependencies) {
//
// this.dependencies = dependencies;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public Category getCategory() {
//
// return category;
// }
//
// public void setCategory(Category category) {
//
// this.category = category;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// }
|
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import forgetit.common.Category;
import forgetit.common.Entity;
|
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.gui.views;
/**
* The view for notes
*
* The outer design (borders, titles, ...) of this view is dependent on StandardView.
* Through IEntitiesView this view can be refreshed by GraphicsController.
*
* @author ChornHulio (<a href="mailto:[chornhulio@web.de]">chornhulio@web.de</a>)
* @since 0.1
*/
public class ViewNotes extends StandardView implements IEntitiesView {
Composite parent;
Table table;
public ViewNotes(Composite parent) {
super(parent, "Notes");
this.parent = parent;
this.table = null;
initGui();
}
private void initGui() {
GridLayout layout = new GridLayout();
layout.numColumns = 1;
content.setLayout(layout);
// init a new table
table = new Table (content, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
table.setLinesVisible (true);
table.setHeaderVisible (true);
table.setVisible(false);
GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
table.setLayoutData(gridData);
// set titles of the table
String[] titles = {"Title", "Description"};
for (int i=0; i < titles.length; i++) {
TableColumn column = new TableColumn (table, SWT.NONE);
column.setText (titles [i]);
}
}
@Override
|
// Path: forgetIT/src/forgetit/common/Category.java
// public enum Category {
// APPOINTMENT,
// NOTE,
// TODO;
// }
//
// Path: forgetIT/src/forgetit/common/Entity.java
// @javax.persistence.Entity
// public class Entity implements Serializable {
//
// private int id;
// private String title;
// private String description;
//
// private Status status;
//
// private Function priority;
//
// private Date startDate;
//
// private Date endDate;
//
// private List<Tag> tags;
//
// private List<Entity> dependencies; // All notes, that have to happen before
// private Category category;
//
// public Entity() {
//
// this.title = "";
// this.description = "";
// this.status = Status.IDLE;
// this.priority = new Function();
// this.startDate = new Date();
// this.endDate = new Date();
// this.tags = new LinkedList<Tag>();
// }
//
// public String getTitle() {
//
// return title;
// }
//
// public void setTitle(String title) {
//
// this.title = title;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// public Status getStatus() {
//
// return status;
// }
//
// public void setStatus(Status status) {
//
// this.status = status;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Function getPriority() {
//
// if (priority == null) {
// return new Function();
// }
// return priority;
// }
//
// public void setPriority(Function priority) {
//
// this.priority = priority;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getStartDate() {
//
// return startDate;
// }
//
// public void setStartDate(Date startDate) {
//
// this.startDate = startDate;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getEndDate() {
//
// return endDate;
// }
//
// public void setEndDate(Date endDate) {
//
// this.endDate = endDate;
// }
//
// @ManyToMany(targetEntity = forgetit.common.Tag.class, cascade = { CascadeType.ALL, CascadeType.PERSIST,
// CascadeType.MERGE })
// @JoinTable(name = "ENTITY_TAG", joinColumns = @JoinColumn(name = "ENTITY_ID"), inverseJoinColumns = @JoinColumn(name = "TAG_ID"))
// public List<Tag> getTags() {
//
// return tags;
// }
//
// public void setTags(List<Tag> tags) {
//
// this.tags = tags;
// }
//
// @OneToMany
// public List<Entity> getDependencies() {
//
// return dependencies;
// }
//
// public void setDependencies(List<Entity> dependencies) {
//
// this.dependencies = dependencies;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public Category getCategory() {
//
// return category;
// }
//
// public void setCategory(Category category) {
//
// this.category = category;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// }
// Path: forgetIT/src/forgetit/gui/views/ViewNotes.java
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import forgetit.common.Category;
import forgetit.common.Entity;
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.gui.views;
/**
* The view for notes
*
* The outer design (borders, titles, ...) of this view is dependent on StandardView.
* Through IEntitiesView this view can be refreshed by GraphicsController.
*
* @author ChornHulio (<a href="mailto:[chornhulio@web.de]">chornhulio@web.de</a>)
* @since 0.1
*/
public class ViewNotes extends StandardView implements IEntitiesView {
Composite parent;
Table table;
public ViewNotes(Composite parent) {
super(parent, "Notes");
this.parent = parent;
this.table = null;
initGui();
}
private void initGui() {
GridLayout layout = new GridLayout();
layout.numColumns = 1;
content.setLayout(layout);
// init a new table
table = new Table (content, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
table.setLinesVisible (true);
table.setHeaderVisible (true);
table.setVisible(false);
GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
table.setLayoutData(gridData);
// set titles of the table
String[] titles = {"Title", "Description"};
for (int i=0; i < titles.length; i++) {
TableColumn column = new TableColumn (table, SWT.NONE);
column.setText (titles [i]);
}
}
@Override
|
public void refreshView(List<Entity> entities) {
|
dhbw-horb/forgetIT
|
forgetIT/src/forgetit/gui/views/ViewNotes.java
|
// Path: forgetIT/src/forgetit/common/Category.java
// public enum Category {
// APPOINTMENT,
// NOTE,
// TODO;
// }
//
// Path: forgetIT/src/forgetit/common/Entity.java
// @javax.persistence.Entity
// public class Entity implements Serializable {
//
// private int id;
// private String title;
// private String description;
//
// private Status status;
//
// private Function priority;
//
// private Date startDate;
//
// private Date endDate;
//
// private List<Tag> tags;
//
// private List<Entity> dependencies; // All notes, that have to happen before
// private Category category;
//
// public Entity() {
//
// this.title = "";
// this.description = "";
// this.status = Status.IDLE;
// this.priority = new Function();
// this.startDate = new Date();
// this.endDate = new Date();
// this.tags = new LinkedList<Tag>();
// }
//
// public String getTitle() {
//
// return title;
// }
//
// public void setTitle(String title) {
//
// this.title = title;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// public Status getStatus() {
//
// return status;
// }
//
// public void setStatus(Status status) {
//
// this.status = status;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Function getPriority() {
//
// if (priority == null) {
// return new Function();
// }
// return priority;
// }
//
// public void setPriority(Function priority) {
//
// this.priority = priority;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getStartDate() {
//
// return startDate;
// }
//
// public void setStartDate(Date startDate) {
//
// this.startDate = startDate;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getEndDate() {
//
// return endDate;
// }
//
// public void setEndDate(Date endDate) {
//
// this.endDate = endDate;
// }
//
// @ManyToMany(targetEntity = forgetit.common.Tag.class, cascade = { CascadeType.ALL, CascadeType.PERSIST,
// CascadeType.MERGE })
// @JoinTable(name = "ENTITY_TAG", joinColumns = @JoinColumn(name = "ENTITY_ID"), inverseJoinColumns = @JoinColumn(name = "TAG_ID"))
// public List<Tag> getTags() {
//
// return tags;
// }
//
// public void setTags(List<Tag> tags) {
//
// this.tags = tags;
// }
//
// @OneToMany
// public List<Entity> getDependencies() {
//
// return dependencies;
// }
//
// public void setDependencies(List<Entity> dependencies) {
//
// this.dependencies = dependencies;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public Category getCategory() {
//
// return category;
// }
//
// public void setCategory(Category category) {
//
// this.category = category;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// }
|
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import forgetit.common.Category;
import forgetit.common.Entity;
|
}
}
@Override
public void refreshView(List<Entity> entities) {
// if there is no entity, the table should not be visible
if(entities.size() <= 0) {
table.setVisible(false);
return;
} else if (!table.isVisible()) {
table.setVisible(true);
}
// remove content of the table
table.removeAll();
// set content of the table
for (Entity entity : entities) {
TableItem item = new TableItem (table, SWT.NONE);
item.setText (0, entity.getTitle());
item.setText (1, entity.getDescription());
}
// resize columns
for (int i=0; i < table.getColumnCount(); i++) {
table.getColumn (i).pack ();
}
}
@Override
|
// Path: forgetIT/src/forgetit/common/Category.java
// public enum Category {
// APPOINTMENT,
// NOTE,
// TODO;
// }
//
// Path: forgetIT/src/forgetit/common/Entity.java
// @javax.persistence.Entity
// public class Entity implements Serializable {
//
// private int id;
// private String title;
// private String description;
//
// private Status status;
//
// private Function priority;
//
// private Date startDate;
//
// private Date endDate;
//
// private List<Tag> tags;
//
// private List<Entity> dependencies; // All notes, that have to happen before
// private Category category;
//
// public Entity() {
//
// this.title = "";
// this.description = "";
// this.status = Status.IDLE;
// this.priority = new Function();
// this.startDate = new Date();
// this.endDate = new Date();
// this.tags = new LinkedList<Tag>();
// }
//
// public String getTitle() {
//
// return title;
// }
//
// public void setTitle(String title) {
//
// this.title = title;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// public Status getStatus() {
//
// return status;
// }
//
// public void setStatus(Status status) {
//
// this.status = status;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Function getPriority() {
//
// if (priority == null) {
// return new Function();
// }
// return priority;
// }
//
// public void setPriority(Function priority) {
//
// this.priority = priority;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getStartDate() {
//
// return startDate;
// }
//
// public void setStartDate(Date startDate) {
//
// this.startDate = startDate;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getEndDate() {
//
// return endDate;
// }
//
// public void setEndDate(Date endDate) {
//
// this.endDate = endDate;
// }
//
// @ManyToMany(targetEntity = forgetit.common.Tag.class, cascade = { CascadeType.ALL, CascadeType.PERSIST,
// CascadeType.MERGE })
// @JoinTable(name = "ENTITY_TAG", joinColumns = @JoinColumn(name = "ENTITY_ID"), inverseJoinColumns = @JoinColumn(name = "TAG_ID"))
// public List<Tag> getTags() {
//
// return tags;
// }
//
// public void setTags(List<Tag> tags) {
//
// this.tags = tags;
// }
//
// @OneToMany
// public List<Entity> getDependencies() {
//
// return dependencies;
// }
//
// public void setDependencies(List<Entity> dependencies) {
//
// this.dependencies = dependencies;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public Category getCategory() {
//
// return category;
// }
//
// public void setCategory(Category category) {
//
// this.category = category;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// }
// Path: forgetIT/src/forgetit/gui/views/ViewNotes.java
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import forgetit.common.Category;
import forgetit.common.Entity;
}
}
@Override
public void refreshView(List<Entity> entities) {
// if there is no entity, the table should not be visible
if(entities.size() <= 0) {
table.setVisible(false);
return;
} else if (!table.isVisible()) {
table.setVisible(true);
}
// remove content of the table
table.removeAll();
// set content of the table
for (Entity entity : entities) {
TableItem item = new TableItem (table, SWT.NONE);
item.setText (0, entity.getTitle());
item.setText (1, entity.getDescription());
}
// resize columns
for (int i=0; i < table.getColumnCount(); i++) {
table.getColumn (i).pack ();
}
}
@Override
|
public Category getCategory() {
|
dhbw-horb/forgetIT
|
forgetIT/src/forgetit/logic/LogicTags.java
|
// Path: forgetIT/src/forgetit/common/Tag.java
// @javax.persistence.Entity
// public class Tag implements Serializable {
//
// private int id;
// private String name;
// private String description;
// private List<Entity> entities;
//
// @ManyToMany(targetEntity = forgetit.common.Entity.class, mappedBy = "tags", cascade = { CascadeType.ALL,
// CascadeType.PERSIST, CascadeType.MERGE })
// public List<Entity> getEntities() {
//
// return entities;
// }
//
// public Tag() {
//
// }
//
// public Tag(int id) {
//
// this.setId(id);
// }
//
// public Tag(int id, String name) {
//
// this.setId(id);
// this.name = name;
// }
//
// public Tag(int id, String name, String description) {
//
// this.setId(id);
// this.name = name;
// this.description = description;
// }
//
// public String getName() {
//
// return name;
// }
//
// public void setName(String name) {
//
// this.name = name;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// public void setEntities(List<Entity> entities) {
//
// this.entities = entities;
// }
//
// }
//
// Path: forgetIT/src/forgetit/logic/interfaces/ILogicInternalTags.java
// public interface ILogicInternalTags {
//
// /**
// *
// * @return all tags in the database
// */
// public List<Tag> getTags();
//
// }
//
// Path: forgetIT/src/forgetit/logic/tag/LogicTagsInternal.java
// public class LogicTagsInternal implements ILogicInternalTags {
//
// private IDBTags dbTags;
//
// public LogicTagsInternal() {
// try{
// dbTags = new DBTags();
// }catch(Exception e){
// System.err.println("Can't instantiate DBTags");
// System.err.println(e.getMessage());
// e.printStackTrace();
//
// }
// }
//
// @Override
// public List<Tag> getTags() {
// try{
// return dbTags.getTags();
// }catch(Exception e){
// System.err.println("Can't get Tags");
// System.err.println(e.getMessage());
// e.printStackTrace();
// return null;
// }
//
//
// }
//
// }
|
import java.util.List;
import forgetit.common.Tag;
import forgetit.logic.interfaces.ILogicInternalTags;
import forgetit.logic.tag.LogicTagsInternal;
|
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.logic;
/**
* Implementation of @see ILogicTags
* @author David Henn (<a href="mailto:[david.henn@gmail.com]">david.henn@gmail.com</a>)
* @version 0.1
*/
public class LogicTags implements ILogicTags {
private ILogicInternalTags internalTags;
public LogicTags(){
|
// Path: forgetIT/src/forgetit/common/Tag.java
// @javax.persistence.Entity
// public class Tag implements Serializable {
//
// private int id;
// private String name;
// private String description;
// private List<Entity> entities;
//
// @ManyToMany(targetEntity = forgetit.common.Entity.class, mappedBy = "tags", cascade = { CascadeType.ALL,
// CascadeType.PERSIST, CascadeType.MERGE })
// public List<Entity> getEntities() {
//
// return entities;
// }
//
// public Tag() {
//
// }
//
// public Tag(int id) {
//
// this.setId(id);
// }
//
// public Tag(int id, String name) {
//
// this.setId(id);
// this.name = name;
// }
//
// public Tag(int id, String name, String description) {
//
// this.setId(id);
// this.name = name;
// this.description = description;
// }
//
// public String getName() {
//
// return name;
// }
//
// public void setName(String name) {
//
// this.name = name;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// public void setEntities(List<Entity> entities) {
//
// this.entities = entities;
// }
//
// }
//
// Path: forgetIT/src/forgetit/logic/interfaces/ILogicInternalTags.java
// public interface ILogicInternalTags {
//
// /**
// *
// * @return all tags in the database
// */
// public List<Tag> getTags();
//
// }
//
// Path: forgetIT/src/forgetit/logic/tag/LogicTagsInternal.java
// public class LogicTagsInternal implements ILogicInternalTags {
//
// private IDBTags dbTags;
//
// public LogicTagsInternal() {
// try{
// dbTags = new DBTags();
// }catch(Exception e){
// System.err.println("Can't instantiate DBTags");
// System.err.println(e.getMessage());
// e.printStackTrace();
//
// }
// }
//
// @Override
// public List<Tag> getTags() {
// try{
// return dbTags.getTags();
// }catch(Exception e){
// System.err.println("Can't get Tags");
// System.err.println(e.getMessage());
// e.printStackTrace();
// return null;
// }
//
//
// }
//
// }
// Path: forgetIT/src/forgetit/logic/LogicTags.java
import java.util.List;
import forgetit.common.Tag;
import forgetit.logic.interfaces.ILogicInternalTags;
import forgetit.logic.tag.LogicTagsInternal;
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.logic;
/**
* Implementation of @see ILogicTags
* @author David Henn (<a href="mailto:[david.henn@gmail.com]">david.henn@gmail.com</a>)
* @version 0.1
*/
public class LogicTags implements ILogicTags {
private ILogicInternalTags internalTags;
public LogicTags(){
|
internalTags = new LogicTagsInternal();
|
dhbw-horb/forgetIT
|
forgetIT/src/forgetit/logic/LogicTags.java
|
// Path: forgetIT/src/forgetit/common/Tag.java
// @javax.persistence.Entity
// public class Tag implements Serializable {
//
// private int id;
// private String name;
// private String description;
// private List<Entity> entities;
//
// @ManyToMany(targetEntity = forgetit.common.Entity.class, mappedBy = "tags", cascade = { CascadeType.ALL,
// CascadeType.PERSIST, CascadeType.MERGE })
// public List<Entity> getEntities() {
//
// return entities;
// }
//
// public Tag() {
//
// }
//
// public Tag(int id) {
//
// this.setId(id);
// }
//
// public Tag(int id, String name) {
//
// this.setId(id);
// this.name = name;
// }
//
// public Tag(int id, String name, String description) {
//
// this.setId(id);
// this.name = name;
// this.description = description;
// }
//
// public String getName() {
//
// return name;
// }
//
// public void setName(String name) {
//
// this.name = name;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// public void setEntities(List<Entity> entities) {
//
// this.entities = entities;
// }
//
// }
//
// Path: forgetIT/src/forgetit/logic/interfaces/ILogicInternalTags.java
// public interface ILogicInternalTags {
//
// /**
// *
// * @return all tags in the database
// */
// public List<Tag> getTags();
//
// }
//
// Path: forgetIT/src/forgetit/logic/tag/LogicTagsInternal.java
// public class LogicTagsInternal implements ILogicInternalTags {
//
// private IDBTags dbTags;
//
// public LogicTagsInternal() {
// try{
// dbTags = new DBTags();
// }catch(Exception e){
// System.err.println("Can't instantiate DBTags");
// System.err.println(e.getMessage());
// e.printStackTrace();
//
// }
// }
//
// @Override
// public List<Tag> getTags() {
// try{
// return dbTags.getTags();
// }catch(Exception e){
// System.err.println("Can't get Tags");
// System.err.println(e.getMessage());
// e.printStackTrace();
// return null;
// }
//
//
// }
//
// }
|
import java.util.List;
import forgetit.common.Tag;
import forgetit.logic.interfaces.ILogicInternalTags;
import forgetit.logic.tag.LogicTagsInternal;
|
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.logic;
/**
* Implementation of @see ILogicTags
* @author David Henn (<a href="mailto:[david.henn@gmail.com]">david.henn@gmail.com</a>)
* @version 0.1
*/
public class LogicTags implements ILogicTags {
private ILogicInternalTags internalTags;
public LogicTags(){
internalTags = new LogicTagsInternal();
}
@Override
|
// Path: forgetIT/src/forgetit/common/Tag.java
// @javax.persistence.Entity
// public class Tag implements Serializable {
//
// private int id;
// private String name;
// private String description;
// private List<Entity> entities;
//
// @ManyToMany(targetEntity = forgetit.common.Entity.class, mappedBy = "tags", cascade = { CascadeType.ALL,
// CascadeType.PERSIST, CascadeType.MERGE })
// public List<Entity> getEntities() {
//
// return entities;
// }
//
// public Tag() {
//
// }
//
// public Tag(int id) {
//
// this.setId(id);
// }
//
// public Tag(int id, String name) {
//
// this.setId(id);
// this.name = name;
// }
//
// public Tag(int id, String name, String description) {
//
// this.setId(id);
// this.name = name;
// this.description = description;
// }
//
// public String getName() {
//
// return name;
// }
//
// public void setName(String name) {
//
// this.name = name;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// public void setEntities(List<Entity> entities) {
//
// this.entities = entities;
// }
//
// }
//
// Path: forgetIT/src/forgetit/logic/interfaces/ILogicInternalTags.java
// public interface ILogicInternalTags {
//
// /**
// *
// * @return all tags in the database
// */
// public List<Tag> getTags();
//
// }
//
// Path: forgetIT/src/forgetit/logic/tag/LogicTagsInternal.java
// public class LogicTagsInternal implements ILogicInternalTags {
//
// private IDBTags dbTags;
//
// public LogicTagsInternal() {
// try{
// dbTags = new DBTags();
// }catch(Exception e){
// System.err.println("Can't instantiate DBTags");
// System.err.println(e.getMessage());
// e.printStackTrace();
//
// }
// }
//
// @Override
// public List<Tag> getTags() {
// try{
// return dbTags.getTags();
// }catch(Exception e){
// System.err.println("Can't get Tags");
// System.err.println(e.getMessage());
// e.printStackTrace();
// return null;
// }
//
//
// }
//
// }
// Path: forgetIT/src/forgetit/logic/LogicTags.java
import java.util.List;
import forgetit.common.Tag;
import forgetit.logic.interfaces.ILogicInternalTags;
import forgetit.logic.tag.LogicTagsInternal;
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.logic;
/**
* Implementation of @see ILogicTags
* @author David Henn (<a href="mailto:[david.henn@gmail.com]">david.henn@gmail.com</a>)
* @version 0.1
*/
public class LogicTags implements ILogicTags {
private ILogicInternalTags internalTags;
public LogicTags(){
internalTags = new LogicTagsInternal();
}
@Override
|
public List<Tag> getTags() {
|
dhbw-horb/forgetIT
|
forgetIT/src/forgetit/db/DBEntityHandler.java
|
// Path: forgetIT/src/forgetit/common/Entity.java
// @javax.persistence.Entity
// public class Entity implements Serializable {
//
// private int id;
// private String title;
// private String description;
//
// private Status status;
//
// private Function priority;
//
// private Date startDate;
//
// private Date endDate;
//
// private List<Tag> tags;
//
// private List<Entity> dependencies; // All notes, that have to happen before
// private Category category;
//
// public Entity() {
//
// this.title = "";
// this.description = "";
// this.status = Status.IDLE;
// this.priority = new Function();
// this.startDate = new Date();
// this.endDate = new Date();
// this.tags = new LinkedList<Tag>();
// }
//
// public String getTitle() {
//
// return title;
// }
//
// public void setTitle(String title) {
//
// this.title = title;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// public Status getStatus() {
//
// return status;
// }
//
// public void setStatus(Status status) {
//
// this.status = status;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Function getPriority() {
//
// if (priority == null) {
// return new Function();
// }
// return priority;
// }
//
// public void setPriority(Function priority) {
//
// this.priority = priority;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getStartDate() {
//
// return startDate;
// }
//
// public void setStartDate(Date startDate) {
//
// this.startDate = startDate;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getEndDate() {
//
// return endDate;
// }
//
// public void setEndDate(Date endDate) {
//
// this.endDate = endDate;
// }
//
// @ManyToMany(targetEntity = forgetit.common.Tag.class, cascade = { CascadeType.ALL, CascadeType.PERSIST,
// CascadeType.MERGE })
// @JoinTable(name = "ENTITY_TAG", joinColumns = @JoinColumn(name = "ENTITY_ID"), inverseJoinColumns = @JoinColumn(name = "TAG_ID"))
// public List<Tag> getTags() {
//
// return tags;
// }
//
// public void setTags(List<Tag> tags) {
//
// this.tags = tags;
// }
//
// @OneToMany
// public List<Entity> getDependencies() {
//
// return dependencies;
// }
//
// public void setDependencies(List<Entity> dependencies) {
//
// this.dependencies = dependencies;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public Category getCategory() {
//
// return category;
// }
//
// public void setCategory(Category category) {
//
// this.category = category;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// }
|
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import forgetit.common.Entity;
|
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.db;
/**
*
* @author David Henn
* @see IDBEntity
*
*/
public class DBEntityHandler implements IDBEntity {
final static Logger logger = LoggerFactory.getLogger(DBEntityHandler.class);
|
// Path: forgetIT/src/forgetit/common/Entity.java
// @javax.persistence.Entity
// public class Entity implements Serializable {
//
// private int id;
// private String title;
// private String description;
//
// private Status status;
//
// private Function priority;
//
// private Date startDate;
//
// private Date endDate;
//
// private List<Tag> tags;
//
// private List<Entity> dependencies; // All notes, that have to happen before
// private Category category;
//
// public Entity() {
//
// this.title = "";
// this.description = "";
// this.status = Status.IDLE;
// this.priority = new Function();
// this.startDate = new Date();
// this.endDate = new Date();
// this.tags = new LinkedList<Tag>();
// }
//
// public String getTitle() {
//
// return title;
// }
//
// public void setTitle(String title) {
//
// this.title = title;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// public Status getStatus() {
//
// return status;
// }
//
// public void setStatus(Status status) {
//
// this.status = status;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Function getPriority() {
//
// if (priority == null) {
// return new Function();
// }
// return priority;
// }
//
// public void setPriority(Function priority) {
//
// this.priority = priority;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getStartDate() {
//
// return startDate;
// }
//
// public void setStartDate(Date startDate) {
//
// this.startDate = startDate;
// }
//
// @OneToOne(mappedBy = "entity_id")
// public Date getEndDate() {
//
// return endDate;
// }
//
// public void setEndDate(Date endDate) {
//
// this.endDate = endDate;
// }
//
// @ManyToMany(targetEntity = forgetit.common.Tag.class, cascade = { CascadeType.ALL, CascadeType.PERSIST,
// CascadeType.MERGE })
// @JoinTable(name = "ENTITY_TAG", joinColumns = @JoinColumn(name = "ENTITY_ID"), inverseJoinColumns = @JoinColumn(name = "TAG_ID"))
// public List<Tag> getTags() {
//
// return tags;
// }
//
// public void setTags(List<Tag> tags) {
//
// this.tags = tags;
// }
//
// @OneToMany
// public List<Entity> getDependencies() {
//
// return dependencies;
// }
//
// public void setDependencies(List<Entity> dependencies) {
//
// this.dependencies = dependencies;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public Category getCategory() {
//
// return category;
// }
//
// public void setCategory(Category category) {
//
// this.category = category;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// }
// Path: forgetIT/src/forgetit/db/DBEntityHandler.java
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import forgetit.common.Entity;
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.db;
/**
*
* @author David Henn
* @see IDBEntity
*
*/
public class DBEntityHandler implements IDBEntity {
final static Logger logger = LoggerFactory.getLogger(DBEntityHandler.class);
|
public void addEntity(Entity entity) {
|
dhbw-horb/forgetIT
|
forgetIT/src/forgetit/logic/Calendar.java
|
// Path: forgetIT/src/forgetit/common/Date.java
// @javax.persistence.Entity
// public class Date {
//
// @Id
// @GeneratedValue
// private int id;
// int year;
// int month;
// int day;
// int hour;
// int minute;
//
// @OneToOne(fetch = FetchType.LAZY)
// @JoinColumn(nullable = false)
// private forgetit.common.Entity entity_id;
//
// public Date(int year, int month, int day, int hour, int minute) {
//
// this.year = year;
// this.month = month + 1; // TODO check if this addition is ok
// this.day = day;
// this.hour = hour;
// this.minute = minute;
// }
//
// public Date() {
//
// }
//
// @Override
// public String toString() {
//
// return year + "-" + month + "-" + day + "-" + hour + ":" + minute;
// }
//
// @Override
// public boolean equals(Object date) {
//
// if (date instanceof Date) {
// boolean isEqual = true;
// Date compDate = (Date) date;
// if (this.year != compDate.getYear()) {
// isEqual = false;
// }
// if (this.month != compDate.getMonth()) {
// isEqual = false;
// }
// if (this.day != compDate.getDay()) {
// isEqual = false;
// }
// if (this.hour != compDate.getHour()) {
// isEqual = false;
// }
// if (this.minute != compDate.getMinute()) {
// isEqual = false;
// }
//
// return isEqual;
// } else {
// return false;
// }
//
// }
//
// public int getYear() {
//
// return year;
// }
//
// public void setYear(int year) {
//
// this.year = year;
// }
//
// public int getMonth() {
//
// return month;
// }
//
// public void setMonth(int month) {
//
// this.month = month;
// }
//
// public int getDay() {
//
// return day;
// }
//
// public void setDay(int day) {
//
// this.day = day;
// }
//
// public int getHour() {
//
// return hour;
// }
//
// public void setHour(int hour) {
//
// this.hour = hour;
// }
//
// public int getMinute() {
//
// return minute;
// }
//
// public void setMinute(int minute) {
//
// this.minute = minute;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// public int getId() {
//
// return id;
// }
//
// }
//
// Path: forgetIT/src/forgetit/logic/interfaces/ICalendar.java
// public interface ICalendar {
//
// /**
// * Checks if a given date is valid
// * @param date the date to check
// * @return true if valid
// */
// public boolean checkDate(Date date);
//
// /**
// * calculates the new date from a given date and a number of days
// * @param days the days to add to the date
// * @param date the date from which to start
// * @return the new date
// * @throws Exception if the given date isn't valid
// */
// public Date addDays(int days, Date date) throws Exception;
//
// /**
// * calculates the new date from a given date and a number of days
// * @param days how many days before the given date
// * @param date the date from which to start
// * @return the new date
// * @throws Exception if the given date isn't valid
// */
// public Date subtractDays(int days, Date date) throws Exception;
//
// /**
// *
// * @return the date of today
// */
// public Date today();
//
// /**
// * converts String in Date
// *
// * possible strings are YYYY.MM.DD or DD.MM.YYYY
// * chars between digits don't care
// *
// * @param str the date as a String
// * @return the date
// * @throws IllegalArgumentException if the string is no date
// * @throws NumberFormatException if the parts of the string are not convertable
// */
// public Date convertStringToDate(String str) throws IllegalArgumentException, NumberFormatException;
//
// /**
// * converts a Date to a String in US style
// * @param date the date
// * @return the date as string
// */
// public String convertDateToStringInUSStyle(Date date);
//
// /**
// * converts a Date to a String in german style
// * @param date the date
// * @return the date as string
// */
// public String convertDateToStringInGermanStyle(Date date);
// }
|
import java.util.GregorianCalendar;
import java.util.TimeZone;
import forgetit.common.Date;
import forgetit.logic.interfaces.ICalendar;
|
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.logic;
/**
* Implementation of @see ICalendar
* @author David Henn (<a href="mailto:[david.henn@gmail.com]">david.henn@gmail.com</a>)
* @version 0.1
*/
public class Calendar implements ICalendar {
@Override
|
// Path: forgetIT/src/forgetit/common/Date.java
// @javax.persistence.Entity
// public class Date {
//
// @Id
// @GeneratedValue
// private int id;
// int year;
// int month;
// int day;
// int hour;
// int minute;
//
// @OneToOne(fetch = FetchType.LAZY)
// @JoinColumn(nullable = false)
// private forgetit.common.Entity entity_id;
//
// public Date(int year, int month, int day, int hour, int minute) {
//
// this.year = year;
// this.month = month + 1; // TODO check if this addition is ok
// this.day = day;
// this.hour = hour;
// this.minute = minute;
// }
//
// public Date() {
//
// }
//
// @Override
// public String toString() {
//
// return year + "-" + month + "-" + day + "-" + hour + ":" + minute;
// }
//
// @Override
// public boolean equals(Object date) {
//
// if (date instanceof Date) {
// boolean isEqual = true;
// Date compDate = (Date) date;
// if (this.year != compDate.getYear()) {
// isEqual = false;
// }
// if (this.month != compDate.getMonth()) {
// isEqual = false;
// }
// if (this.day != compDate.getDay()) {
// isEqual = false;
// }
// if (this.hour != compDate.getHour()) {
// isEqual = false;
// }
// if (this.minute != compDate.getMinute()) {
// isEqual = false;
// }
//
// return isEqual;
// } else {
// return false;
// }
//
// }
//
// public int getYear() {
//
// return year;
// }
//
// public void setYear(int year) {
//
// this.year = year;
// }
//
// public int getMonth() {
//
// return month;
// }
//
// public void setMonth(int month) {
//
// this.month = month;
// }
//
// public int getDay() {
//
// return day;
// }
//
// public void setDay(int day) {
//
// this.day = day;
// }
//
// public int getHour() {
//
// return hour;
// }
//
// public void setHour(int hour) {
//
// this.hour = hour;
// }
//
// public int getMinute() {
//
// return minute;
// }
//
// public void setMinute(int minute) {
//
// this.minute = minute;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// public int getId() {
//
// return id;
// }
//
// }
//
// Path: forgetIT/src/forgetit/logic/interfaces/ICalendar.java
// public interface ICalendar {
//
// /**
// * Checks if a given date is valid
// * @param date the date to check
// * @return true if valid
// */
// public boolean checkDate(Date date);
//
// /**
// * calculates the new date from a given date and a number of days
// * @param days the days to add to the date
// * @param date the date from which to start
// * @return the new date
// * @throws Exception if the given date isn't valid
// */
// public Date addDays(int days, Date date) throws Exception;
//
// /**
// * calculates the new date from a given date and a number of days
// * @param days how many days before the given date
// * @param date the date from which to start
// * @return the new date
// * @throws Exception if the given date isn't valid
// */
// public Date subtractDays(int days, Date date) throws Exception;
//
// /**
// *
// * @return the date of today
// */
// public Date today();
//
// /**
// * converts String in Date
// *
// * possible strings are YYYY.MM.DD or DD.MM.YYYY
// * chars between digits don't care
// *
// * @param str the date as a String
// * @return the date
// * @throws IllegalArgumentException if the string is no date
// * @throws NumberFormatException if the parts of the string are not convertable
// */
// public Date convertStringToDate(String str) throws IllegalArgumentException, NumberFormatException;
//
// /**
// * converts a Date to a String in US style
// * @param date the date
// * @return the date as string
// */
// public String convertDateToStringInUSStyle(Date date);
//
// /**
// * converts a Date to a String in german style
// * @param date the date
// * @return the date as string
// */
// public String convertDateToStringInGermanStyle(Date date);
// }
// Path: forgetIT/src/forgetit/logic/Calendar.java
import java.util.GregorianCalendar;
import java.util.TimeZone;
import forgetit.common.Date;
import forgetit.logic.interfaces.ICalendar;
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.logic;
/**
* Implementation of @see ICalendar
* @author David Henn (<a href="mailto:[david.henn@gmail.com]">david.henn@gmail.com</a>)
* @version 0.1
*/
public class Calendar implements ICalendar {
@Override
|
public boolean checkDate(Date date) {
|
dhbw-horb/forgetIT
|
forgetIT/src/forgetit/db/DBTags.java
|
// Path: forgetIT/src/forgetit/common/Tag.java
// @javax.persistence.Entity
// public class Tag implements Serializable {
//
// private int id;
// private String name;
// private String description;
// private List<Entity> entities;
//
// @ManyToMany(targetEntity = forgetit.common.Entity.class, mappedBy = "tags", cascade = { CascadeType.ALL,
// CascadeType.PERSIST, CascadeType.MERGE })
// public List<Entity> getEntities() {
//
// return entities;
// }
//
// public Tag() {
//
// }
//
// public Tag(int id) {
//
// this.setId(id);
// }
//
// public Tag(int id, String name) {
//
// this.setId(id);
// this.name = name;
// }
//
// public Tag(int id, String name, String description) {
//
// this.setId(id);
// this.name = name;
// this.description = description;
// }
//
// public String getName() {
//
// return name;
// }
//
// public void setName(String name) {
//
// this.name = name;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// public void setEntities(List<Entity> entities) {
//
// this.entities = entities;
// }
//
// }
|
import java.util.Iterator;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import forgetit.common.Tag;
|
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.db;
/**
*
* @author David Henn
* @see IDBTags
*
*/
public class DBTags implements IDBTags {
final static Logger logger = LoggerFactory.getLogger(DBTags.class);
@Override
|
// Path: forgetIT/src/forgetit/common/Tag.java
// @javax.persistence.Entity
// public class Tag implements Serializable {
//
// private int id;
// private String name;
// private String description;
// private List<Entity> entities;
//
// @ManyToMany(targetEntity = forgetit.common.Entity.class, mappedBy = "tags", cascade = { CascadeType.ALL,
// CascadeType.PERSIST, CascadeType.MERGE })
// public List<Entity> getEntities() {
//
// return entities;
// }
//
// public Tag() {
//
// }
//
// public Tag(int id) {
//
// this.setId(id);
// }
//
// public Tag(int id, String name) {
//
// this.setId(id);
// this.name = name;
// }
//
// public Tag(int id, String name, String description) {
//
// this.setId(id);
// this.name = name;
// this.description = description;
// }
//
// public String getName() {
//
// return name;
// }
//
// public void setName(String name) {
//
// this.name = name;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// public void setEntities(List<Entity> entities) {
//
// this.entities = entities;
// }
//
// }
// Path: forgetIT/src/forgetit/db/DBTags.java
import java.util.Iterator;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import forgetit.common.Tag;
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.db;
/**
*
* @author David Henn
* @see IDBTags
*
*/
public class DBTags implements IDBTags {
final static Logger logger = LoggerFactory.getLogger(DBTags.class);
@Override
|
public List<Tag> getTags() {
|
dhbw-horb/forgetIT
|
forgetIT/test/forgetit/logic/TestCalendar.java
|
// Path: forgetIT/src/forgetit/common/Date.java
// @javax.persistence.Entity
// public class Date {
//
// @Id
// @GeneratedValue
// private int id;
// int year;
// int month;
// int day;
// int hour;
// int minute;
//
// @OneToOne(fetch = FetchType.LAZY)
// @JoinColumn(nullable = false)
// private forgetit.common.Entity entity_id;
//
// public Date(int year, int month, int day, int hour, int minute) {
//
// this.year = year;
// this.month = month + 1; // TODO check if this addition is ok
// this.day = day;
// this.hour = hour;
// this.minute = minute;
// }
//
// public Date() {
//
// }
//
// @Override
// public String toString() {
//
// return year + "-" + month + "-" + day + "-" + hour + ":" + minute;
// }
//
// @Override
// public boolean equals(Object date) {
//
// if (date instanceof Date) {
// boolean isEqual = true;
// Date compDate = (Date) date;
// if (this.year != compDate.getYear()) {
// isEqual = false;
// }
// if (this.month != compDate.getMonth()) {
// isEqual = false;
// }
// if (this.day != compDate.getDay()) {
// isEqual = false;
// }
// if (this.hour != compDate.getHour()) {
// isEqual = false;
// }
// if (this.minute != compDate.getMinute()) {
// isEqual = false;
// }
//
// return isEqual;
// } else {
// return false;
// }
//
// }
//
// public int getYear() {
//
// return year;
// }
//
// public void setYear(int year) {
//
// this.year = year;
// }
//
// public int getMonth() {
//
// return month;
// }
//
// public void setMonth(int month) {
//
// this.month = month;
// }
//
// public int getDay() {
//
// return day;
// }
//
// public void setDay(int day) {
//
// this.day = day;
// }
//
// public int getHour() {
//
// return hour;
// }
//
// public void setHour(int hour) {
//
// this.hour = hour;
// }
//
// public int getMinute() {
//
// return minute;
// }
//
// public void setMinute(int minute) {
//
// this.minute = minute;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// public int getId() {
//
// return id;
// }
//
// }
|
import org.junit.Assert;
import org.junit.Test;
import forgetit.common.Date;
|
package forgetit.logic;
public class TestCalendar {
@Test public void checkDate(){
Calendar cal = new Calendar();
|
// Path: forgetIT/src/forgetit/common/Date.java
// @javax.persistence.Entity
// public class Date {
//
// @Id
// @GeneratedValue
// private int id;
// int year;
// int month;
// int day;
// int hour;
// int minute;
//
// @OneToOne(fetch = FetchType.LAZY)
// @JoinColumn(nullable = false)
// private forgetit.common.Entity entity_id;
//
// public Date(int year, int month, int day, int hour, int minute) {
//
// this.year = year;
// this.month = month + 1; // TODO check if this addition is ok
// this.day = day;
// this.hour = hour;
// this.minute = minute;
// }
//
// public Date() {
//
// }
//
// @Override
// public String toString() {
//
// return year + "-" + month + "-" + day + "-" + hour + ":" + minute;
// }
//
// @Override
// public boolean equals(Object date) {
//
// if (date instanceof Date) {
// boolean isEqual = true;
// Date compDate = (Date) date;
// if (this.year != compDate.getYear()) {
// isEqual = false;
// }
// if (this.month != compDate.getMonth()) {
// isEqual = false;
// }
// if (this.day != compDate.getDay()) {
// isEqual = false;
// }
// if (this.hour != compDate.getHour()) {
// isEqual = false;
// }
// if (this.minute != compDate.getMinute()) {
// isEqual = false;
// }
//
// return isEqual;
// } else {
// return false;
// }
//
// }
//
// public int getYear() {
//
// return year;
// }
//
// public void setYear(int year) {
//
// this.year = year;
// }
//
// public int getMonth() {
//
// return month;
// }
//
// public void setMonth(int month) {
//
// this.month = month;
// }
//
// public int getDay() {
//
// return day;
// }
//
// public void setDay(int day) {
//
// this.day = day;
// }
//
// public int getHour() {
//
// return hour;
// }
//
// public void setHour(int hour) {
//
// this.hour = hour;
// }
//
// public int getMinute() {
//
// return minute;
// }
//
// public void setMinute(int minute) {
//
// this.minute = minute;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// public int getId() {
//
// return id;
// }
//
// }
// Path: forgetIT/test/forgetit/logic/TestCalendar.java
import org.junit.Assert;
import org.junit.Test;
import forgetit.common.Date;
package forgetit.logic;
public class TestCalendar {
@Test public void checkDate(){
Calendar cal = new Calendar();
|
boolean isValid1 = cal.checkDate(new Date(2011, 3, 28, 15, 14));
|
dhbw-horb/forgetIT
|
forgetIT/src/forgetit/logic/tag/LogicTagsInternal.java
|
// Path: forgetIT/src/forgetit/common/Tag.java
// @javax.persistence.Entity
// public class Tag implements Serializable {
//
// private int id;
// private String name;
// private String description;
// private List<Entity> entities;
//
// @ManyToMany(targetEntity = forgetit.common.Entity.class, mappedBy = "tags", cascade = { CascadeType.ALL,
// CascadeType.PERSIST, CascadeType.MERGE })
// public List<Entity> getEntities() {
//
// return entities;
// }
//
// public Tag() {
//
// }
//
// public Tag(int id) {
//
// this.setId(id);
// }
//
// public Tag(int id, String name) {
//
// this.setId(id);
// this.name = name;
// }
//
// public Tag(int id, String name, String description) {
//
// this.setId(id);
// this.name = name;
// this.description = description;
// }
//
// public String getName() {
//
// return name;
// }
//
// public void setName(String name) {
//
// this.name = name;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// public void setEntities(List<Entity> entities) {
//
// this.entities = entities;
// }
//
// }
//
// Path: forgetIT/src/forgetit/db/DBTags.java
// public class DBTags implements IDBTags {
//
// final static Logger logger = LoggerFactory.getLogger(DBTags.class);
//
// @Override
// public List<Tag> getTags() {
//
// Transaction tx = null;
// Session session = SessionFactoryUtil.getInstance().getCurrentSession();
// try {
// tx = session.beginTransaction();
// List tags = session.createQuery("select t from Tag as t").list();
// for (Iterator iter = tags.iterator(); iter.hasNext();) {
// Tag element = (Tag) iter.next();
// logger.debug("{}", element);
// logger.info("{}", element.getId());
// logger.info("{}", element.getName());
// logger.info("{}", element.getDescription());
// }
// tx.commit();
// return tags;
// } catch (RuntimeException e) {
// if (tx != null && tx.isActive()) {
// try {
// tx.rollback();
// } catch (HibernateException e1) {
// logger.debug("Error rolling back transaction");
// }
// throw e;
// }
// }
// return null;
// }
//
// }
//
// Path: forgetIT/src/forgetit/db/IDBTags.java
// public interface IDBTags {
// /**
// *
// * @return all tags in the database
// */
// public List<Tag> getTags();
// }
//
// Path: forgetIT/src/forgetit/logic/interfaces/ILogicInternalTags.java
// public interface ILogicInternalTags {
//
// /**
// *
// * @return all tags in the database
// */
// public List<Tag> getTags();
//
// }
|
import java.util.List;
import forgetit.common.Tag;
import forgetit.db.DBTags;
import forgetit.db.IDBTags;
import forgetit.logic.interfaces.ILogicInternalTags;
|
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.logic.tag;
/**
* Implementation of @see ILogicInternalTags
* @author David Henn (<a href="mailto:[david.henn@gmail.com]">david.henn@gmail.com</a>)
* @version 0.1
*
*/
public class LogicTagsInternal implements ILogicInternalTags {
private IDBTags dbTags;
public LogicTagsInternal() {
try{
|
// Path: forgetIT/src/forgetit/common/Tag.java
// @javax.persistence.Entity
// public class Tag implements Serializable {
//
// private int id;
// private String name;
// private String description;
// private List<Entity> entities;
//
// @ManyToMany(targetEntity = forgetit.common.Entity.class, mappedBy = "tags", cascade = { CascadeType.ALL,
// CascadeType.PERSIST, CascadeType.MERGE })
// public List<Entity> getEntities() {
//
// return entities;
// }
//
// public Tag() {
//
// }
//
// public Tag(int id) {
//
// this.setId(id);
// }
//
// public Tag(int id, String name) {
//
// this.setId(id);
// this.name = name;
// }
//
// public Tag(int id, String name, String description) {
//
// this.setId(id);
// this.name = name;
// this.description = description;
// }
//
// public String getName() {
//
// return name;
// }
//
// public void setName(String name) {
//
// this.name = name;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// public void setEntities(List<Entity> entities) {
//
// this.entities = entities;
// }
//
// }
//
// Path: forgetIT/src/forgetit/db/DBTags.java
// public class DBTags implements IDBTags {
//
// final static Logger logger = LoggerFactory.getLogger(DBTags.class);
//
// @Override
// public List<Tag> getTags() {
//
// Transaction tx = null;
// Session session = SessionFactoryUtil.getInstance().getCurrentSession();
// try {
// tx = session.beginTransaction();
// List tags = session.createQuery("select t from Tag as t").list();
// for (Iterator iter = tags.iterator(); iter.hasNext();) {
// Tag element = (Tag) iter.next();
// logger.debug("{}", element);
// logger.info("{}", element.getId());
// logger.info("{}", element.getName());
// logger.info("{}", element.getDescription());
// }
// tx.commit();
// return tags;
// } catch (RuntimeException e) {
// if (tx != null && tx.isActive()) {
// try {
// tx.rollback();
// } catch (HibernateException e1) {
// logger.debug("Error rolling back transaction");
// }
// throw e;
// }
// }
// return null;
// }
//
// }
//
// Path: forgetIT/src/forgetit/db/IDBTags.java
// public interface IDBTags {
// /**
// *
// * @return all tags in the database
// */
// public List<Tag> getTags();
// }
//
// Path: forgetIT/src/forgetit/logic/interfaces/ILogicInternalTags.java
// public interface ILogicInternalTags {
//
// /**
// *
// * @return all tags in the database
// */
// public List<Tag> getTags();
//
// }
// Path: forgetIT/src/forgetit/logic/tag/LogicTagsInternal.java
import java.util.List;
import forgetit.common.Tag;
import forgetit.db.DBTags;
import forgetit.db.IDBTags;
import forgetit.logic.interfaces.ILogicInternalTags;
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.logic.tag;
/**
* Implementation of @see ILogicInternalTags
* @author David Henn (<a href="mailto:[david.henn@gmail.com]">david.henn@gmail.com</a>)
* @version 0.1
*
*/
public class LogicTagsInternal implements ILogicInternalTags {
private IDBTags dbTags;
public LogicTagsInternal() {
try{
|
dbTags = new DBTags();
|
dhbw-horb/forgetIT
|
forgetIT/src/forgetit/logic/tag/LogicTagsInternal.java
|
// Path: forgetIT/src/forgetit/common/Tag.java
// @javax.persistence.Entity
// public class Tag implements Serializable {
//
// private int id;
// private String name;
// private String description;
// private List<Entity> entities;
//
// @ManyToMany(targetEntity = forgetit.common.Entity.class, mappedBy = "tags", cascade = { CascadeType.ALL,
// CascadeType.PERSIST, CascadeType.MERGE })
// public List<Entity> getEntities() {
//
// return entities;
// }
//
// public Tag() {
//
// }
//
// public Tag(int id) {
//
// this.setId(id);
// }
//
// public Tag(int id, String name) {
//
// this.setId(id);
// this.name = name;
// }
//
// public Tag(int id, String name, String description) {
//
// this.setId(id);
// this.name = name;
// this.description = description;
// }
//
// public String getName() {
//
// return name;
// }
//
// public void setName(String name) {
//
// this.name = name;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// public void setEntities(List<Entity> entities) {
//
// this.entities = entities;
// }
//
// }
//
// Path: forgetIT/src/forgetit/db/DBTags.java
// public class DBTags implements IDBTags {
//
// final static Logger logger = LoggerFactory.getLogger(DBTags.class);
//
// @Override
// public List<Tag> getTags() {
//
// Transaction tx = null;
// Session session = SessionFactoryUtil.getInstance().getCurrentSession();
// try {
// tx = session.beginTransaction();
// List tags = session.createQuery("select t from Tag as t").list();
// for (Iterator iter = tags.iterator(); iter.hasNext();) {
// Tag element = (Tag) iter.next();
// logger.debug("{}", element);
// logger.info("{}", element.getId());
// logger.info("{}", element.getName());
// logger.info("{}", element.getDescription());
// }
// tx.commit();
// return tags;
// } catch (RuntimeException e) {
// if (tx != null && tx.isActive()) {
// try {
// tx.rollback();
// } catch (HibernateException e1) {
// logger.debug("Error rolling back transaction");
// }
// throw e;
// }
// }
// return null;
// }
//
// }
//
// Path: forgetIT/src/forgetit/db/IDBTags.java
// public interface IDBTags {
// /**
// *
// * @return all tags in the database
// */
// public List<Tag> getTags();
// }
//
// Path: forgetIT/src/forgetit/logic/interfaces/ILogicInternalTags.java
// public interface ILogicInternalTags {
//
// /**
// *
// * @return all tags in the database
// */
// public List<Tag> getTags();
//
// }
|
import java.util.List;
import forgetit.common.Tag;
import forgetit.db.DBTags;
import forgetit.db.IDBTags;
import forgetit.logic.interfaces.ILogicInternalTags;
|
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.logic.tag;
/**
* Implementation of @see ILogicInternalTags
* @author David Henn (<a href="mailto:[david.henn@gmail.com]">david.henn@gmail.com</a>)
* @version 0.1
*
*/
public class LogicTagsInternal implements ILogicInternalTags {
private IDBTags dbTags;
public LogicTagsInternal() {
try{
dbTags = new DBTags();
}catch(Exception e){
System.err.println("Can't instantiate DBTags");
System.err.println(e.getMessage());
e.printStackTrace();
}
}
@Override
|
// Path: forgetIT/src/forgetit/common/Tag.java
// @javax.persistence.Entity
// public class Tag implements Serializable {
//
// private int id;
// private String name;
// private String description;
// private List<Entity> entities;
//
// @ManyToMany(targetEntity = forgetit.common.Entity.class, mappedBy = "tags", cascade = { CascadeType.ALL,
// CascadeType.PERSIST, CascadeType.MERGE })
// public List<Entity> getEntities() {
//
// return entities;
// }
//
// public Tag() {
//
// }
//
// public Tag(int id) {
//
// this.setId(id);
// }
//
// public Tag(int id, String name) {
//
// this.setId(id);
// this.name = name;
// }
//
// public Tag(int id, String name, String description) {
//
// this.setId(id);
// this.name = name;
// this.description = description;
// }
//
// public String getName() {
//
// return name;
// }
//
// public void setName(String name) {
//
// this.name = name;
// }
//
// public String getDescription() {
//
// return description;
// }
//
// public void setDescription(String description) {
//
// this.description = description;
// }
//
// @Id
// @GeneratedValue
// public int getId() {
//
// return id;
// }
//
// public void setId(int id) {
//
// this.id = id;
// }
//
// public void setEntities(List<Entity> entities) {
//
// this.entities = entities;
// }
//
// }
//
// Path: forgetIT/src/forgetit/db/DBTags.java
// public class DBTags implements IDBTags {
//
// final static Logger logger = LoggerFactory.getLogger(DBTags.class);
//
// @Override
// public List<Tag> getTags() {
//
// Transaction tx = null;
// Session session = SessionFactoryUtil.getInstance().getCurrentSession();
// try {
// tx = session.beginTransaction();
// List tags = session.createQuery("select t from Tag as t").list();
// for (Iterator iter = tags.iterator(); iter.hasNext();) {
// Tag element = (Tag) iter.next();
// logger.debug("{}", element);
// logger.info("{}", element.getId());
// logger.info("{}", element.getName());
// logger.info("{}", element.getDescription());
// }
// tx.commit();
// return tags;
// } catch (RuntimeException e) {
// if (tx != null && tx.isActive()) {
// try {
// tx.rollback();
// } catch (HibernateException e1) {
// logger.debug("Error rolling back transaction");
// }
// throw e;
// }
// }
// return null;
// }
//
// }
//
// Path: forgetIT/src/forgetit/db/IDBTags.java
// public interface IDBTags {
// /**
// *
// * @return all tags in the database
// */
// public List<Tag> getTags();
// }
//
// Path: forgetIT/src/forgetit/logic/interfaces/ILogicInternalTags.java
// public interface ILogicInternalTags {
//
// /**
// *
// * @return all tags in the database
// */
// public List<Tag> getTags();
//
// }
// Path: forgetIT/src/forgetit/logic/tag/LogicTagsInternal.java
import java.util.List;
import forgetit.common.Tag;
import forgetit.db.DBTags;
import forgetit.db.IDBTags;
import forgetit.logic.interfaces.ILogicInternalTags;
/*
* Copyright 2011 DHBW Stuttgart Campus Horb
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 forgetit.logic.tag;
/**
* Implementation of @see ILogicInternalTags
* @author David Henn (<a href="mailto:[david.henn@gmail.com]">david.henn@gmail.com</a>)
* @version 0.1
*
*/
public class LogicTagsInternal implements ILogicInternalTags {
private IDBTags dbTags;
public LogicTagsInternal() {
try{
dbTags = new DBTags();
}catch(Exception e){
System.err.println("Can't instantiate DBTags");
System.err.println(e.getMessage());
e.printStackTrace();
}
}
@Override
|
public List<Tag> getTags() {
|
ksoichiro/SimpleAlertDialog-for-Android
|
simplealertdialog-tests/src/com/simplealertdialog/test/DirectUseTest.java
|
// Path: simplealertdialog/src/com/simplealertdialog/SimpleAlertDialogFragment.java
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public class SimpleAlertDialogFragment extends DialogFragment {
//
// /**
// * Default constructor.
// */
// public SimpleAlertDialogFragment() {
// }
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// Bundle args = getArguments();
// // Cancelable must be set to DialogFragment
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// setCancelable(args.getBoolean(SimpleAlertDialog.ARG_CANCELABLE, true));
// }
// return new InternalHelper<Fragment, Activity>() {
// public Activity getActivity() {
// return SimpleAlertDialogFragment.this.getActivity();
// }
//
// public Fragment getTargetFragment() {
// return SimpleAlertDialogFragment.this.getTargetFragment();
// }
// }.createDialog(args);
// }
//
// @Override
// public void onCancel(DialogInterface dialog) {
// super.onCancel(dialog);
// int requestCode = 0;
// Bundle args = getArguments();
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// requestCode = args.getInt(SimpleAlertDialog.ARG_REQUEST_CODE);
// }
// Fragment targetFragment = getTargetFragment();
// if (targetFragment != null
// && targetFragment instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) targetFragment)
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// if (getActivity() != null
// && getActivity() instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) getActivity())
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// }
//
// /**
// * Dialog builder for {@code android.app.Fragment}.
// * <p/>
// * {@inheritDoc}
// */
// public static class Builder extends
// SimpleAlertDialog.Builder<SimpleAlertDialogFragment, Fragment> {
// private Fragment mTargetFragment;
//
// @Override
// public Builder setTargetFragment(final Fragment targetFragment) {
// mTargetFragment = targetFragment;
// return this;
// }
//
// @Override
// public SimpleAlertDialogFragment create() {
// Bundle args = createArguments();
// SimpleAlertDialogFragment fragment = new SimpleAlertDialogFragment();
// fragment.setArguments(args);
// if (mTargetFragment != null) {
// fragment.setTargetFragment(mTargetFragment, 0);
// }
// return fragment;
// }
// }
//
// }
|
import android.annotation.TargetApi;
import android.app.Fragment;
import android.os.Build;
import android.test.ActivityInstrumentationTestCase2;
import com.simplealertdialog.SimpleAlertDialogFragment;
|
/*
* Copyright 2014 Soichiro Kashima
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.simplealertdialog.test;
/**
* Basic tests that use SimpleAlertDialog directly from test cases.
*/
public class DirectUseTest extends ActivityInstrumentationTestCase2<DummyActivity> {
@TargetApi(Build.VERSION_CODES.FROYO)
public DirectUseTest() {
super(DummyActivity.class);
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void testBuilderCreate() {
|
// Path: simplealertdialog/src/com/simplealertdialog/SimpleAlertDialogFragment.java
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public class SimpleAlertDialogFragment extends DialogFragment {
//
// /**
// * Default constructor.
// */
// public SimpleAlertDialogFragment() {
// }
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// Bundle args = getArguments();
// // Cancelable must be set to DialogFragment
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// setCancelable(args.getBoolean(SimpleAlertDialog.ARG_CANCELABLE, true));
// }
// return new InternalHelper<Fragment, Activity>() {
// public Activity getActivity() {
// return SimpleAlertDialogFragment.this.getActivity();
// }
//
// public Fragment getTargetFragment() {
// return SimpleAlertDialogFragment.this.getTargetFragment();
// }
// }.createDialog(args);
// }
//
// @Override
// public void onCancel(DialogInterface dialog) {
// super.onCancel(dialog);
// int requestCode = 0;
// Bundle args = getArguments();
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// requestCode = args.getInt(SimpleAlertDialog.ARG_REQUEST_CODE);
// }
// Fragment targetFragment = getTargetFragment();
// if (targetFragment != null
// && targetFragment instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) targetFragment)
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// if (getActivity() != null
// && getActivity() instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) getActivity())
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// }
//
// /**
// * Dialog builder for {@code android.app.Fragment}.
// * <p/>
// * {@inheritDoc}
// */
// public static class Builder extends
// SimpleAlertDialog.Builder<SimpleAlertDialogFragment, Fragment> {
// private Fragment mTargetFragment;
//
// @Override
// public Builder setTargetFragment(final Fragment targetFragment) {
// mTargetFragment = targetFragment;
// return this;
// }
//
// @Override
// public SimpleAlertDialogFragment create() {
// Bundle args = createArguments();
// SimpleAlertDialogFragment fragment = new SimpleAlertDialogFragment();
// fragment.setArguments(args);
// if (mTargetFragment != null) {
// fragment.setTargetFragment(mTargetFragment, 0);
// }
// return fragment;
// }
// }
//
// }
// Path: simplealertdialog-tests/src/com/simplealertdialog/test/DirectUseTest.java
import android.annotation.TargetApi;
import android.app.Fragment;
import android.os.Build;
import android.test.ActivityInstrumentationTestCase2;
import com.simplealertdialog.SimpleAlertDialogFragment;
/*
* Copyright 2014 Soichiro Kashima
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.simplealertdialog.test;
/**
* Basic tests that use SimpleAlertDialog directly from test cases.
*/
public class DirectUseTest extends ActivityInstrumentationTestCase2<DummyActivity> {
@TargetApi(Build.VERSION_CODES.FROYO)
public DirectUseTest() {
super(DummyActivity.class);
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void testBuilderCreate() {
|
new SimpleAlertDialogFragment.Builder()
|
ksoichiro/SimpleAlertDialog-for-Android
|
simplealertdialog-tests/src/com/simplealertdialog/test/NormalActivityTest.java
|
// Path: simplealertdialog/src/com/simplealertdialog/SimpleAlertDialogFragment.java
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public class SimpleAlertDialogFragment extends DialogFragment {
//
// /**
// * Default constructor.
// */
// public SimpleAlertDialogFragment() {
// }
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// Bundle args = getArguments();
// // Cancelable must be set to DialogFragment
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// setCancelable(args.getBoolean(SimpleAlertDialog.ARG_CANCELABLE, true));
// }
// return new InternalHelper<Fragment, Activity>() {
// public Activity getActivity() {
// return SimpleAlertDialogFragment.this.getActivity();
// }
//
// public Fragment getTargetFragment() {
// return SimpleAlertDialogFragment.this.getTargetFragment();
// }
// }.createDialog(args);
// }
//
// @Override
// public void onCancel(DialogInterface dialog) {
// super.onCancel(dialog);
// int requestCode = 0;
// Bundle args = getArguments();
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// requestCode = args.getInt(SimpleAlertDialog.ARG_REQUEST_CODE);
// }
// Fragment targetFragment = getTargetFragment();
// if (targetFragment != null
// && targetFragment instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) targetFragment)
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// if (getActivity() != null
// && getActivity() instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) getActivity())
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// }
//
// /**
// * Dialog builder for {@code android.app.Fragment}.
// * <p/>
// * {@inheritDoc}
// */
// public static class Builder extends
// SimpleAlertDialog.Builder<SimpleAlertDialogFragment, Fragment> {
// private Fragment mTargetFragment;
//
// @Override
// public Builder setTargetFragment(final Fragment targetFragment) {
// mTargetFragment = targetFragment;
// return this;
// }
//
// @Override
// public SimpleAlertDialogFragment create() {
// Bundle args = createArguments();
// SimpleAlertDialogFragment fragment = new SimpleAlertDialogFragment();
// fragment.setArguments(args);
// if (mTargetFragment != null) {
// fragment.setTargetFragment(mTargetFragment, 0);
// }
// return fragment;
// }
// }
//
// }
|
import android.annotation.TargetApi;
import android.app.Dialog;
import android.app.Fragment;
import android.os.Build;
import android.test.ActivityInstrumentationTestCase2;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ListView;
import com.simplealertdialog.SimpleAlertDialogFragment;
|
/*
* Copyright 2014 Soichiro Kashima
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.simplealertdialog.test;
/**
* Tests for using SimpleAlertDialog with Activity in Android 3.0+.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class NormalActivityTest extends ActivityInstrumentationTestCase2<NormalActivity> {
private NormalActivity activity;
public NormalActivityTest() {
super(NormalActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setActivityInitialTouchMode(true);
activity = getActivity();
}
public void testMessage() throws Throwable {
runTestOnUiThread(new Runnable() {
@Override
public void run() {
activity.findViewById(com.simplealertdialog.test.R.id.btn_message).performClick();
activity.getFragmentManager().executePendingTransactions();
}
});
getInstrumentation().waitForIdleSync();
Fragment f = getActivity().getFragmentManager().findFragmentByTag("dialog");
assertNotNull(f);
|
// Path: simplealertdialog/src/com/simplealertdialog/SimpleAlertDialogFragment.java
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public class SimpleAlertDialogFragment extends DialogFragment {
//
// /**
// * Default constructor.
// */
// public SimpleAlertDialogFragment() {
// }
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// Bundle args = getArguments();
// // Cancelable must be set to DialogFragment
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// setCancelable(args.getBoolean(SimpleAlertDialog.ARG_CANCELABLE, true));
// }
// return new InternalHelper<Fragment, Activity>() {
// public Activity getActivity() {
// return SimpleAlertDialogFragment.this.getActivity();
// }
//
// public Fragment getTargetFragment() {
// return SimpleAlertDialogFragment.this.getTargetFragment();
// }
// }.createDialog(args);
// }
//
// @Override
// public void onCancel(DialogInterface dialog) {
// super.onCancel(dialog);
// int requestCode = 0;
// Bundle args = getArguments();
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// requestCode = args.getInt(SimpleAlertDialog.ARG_REQUEST_CODE);
// }
// Fragment targetFragment = getTargetFragment();
// if (targetFragment != null
// && targetFragment instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) targetFragment)
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// if (getActivity() != null
// && getActivity() instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) getActivity())
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// }
//
// /**
// * Dialog builder for {@code android.app.Fragment}.
// * <p/>
// * {@inheritDoc}
// */
// public static class Builder extends
// SimpleAlertDialog.Builder<SimpleAlertDialogFragment, Fragment> {
// private Fragment mTargetFragment;
//
// @Override
// public Builder setTargetFragment(final Fragment targetFragment) {
// mTargetFragment = targetFragment;
// return this;
// }
//
// @Override
// public SimpleAlertDialogFragment create() {
// Bundle args = createArguments();
// SimpleAlertDialogFragment fragment = new SimpleAlertDialogFragment();
// fragment.setArguments(args);
// if (mTargetFragment != null) {
// fragment.setTargetFragment(mTargetFragment, 0);
// }
// return fragment;
// }
// }
//
// }
// Path: simplealertdialog-tests/src/com/simplealertdialog/test/NormalActivityTest.java
import android.annotation.TargetApi;
import android.app.Dialog;
import android.app.Fragment;
import android.os.Build;
import android.test.ActivityInstrumentationTestCase2;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ListView;
import com.simplealertdialog.SimpleAlertDialogFragment;
/*
* Copyright 2014 Soichiro Kashima
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.simplealertdialog.test;
/**
* Tests for using SimpleAlertDialog with Activity in Android 3.0+.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class NormalActivityTest extends ActivityInstrumentationTestCase2<NormalActivity> {
private NormalActivity activity;
public NormalActivityTest() {
super(NormalActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setActivityInitialTouchMode(true);
activity = getActivity();
}
public void testMessage() throws Throwable {
runTestOnUiThread(new Runnable() {
@Override
public void run() {
activity.findViewById(com.simplealertdialog.test.R.id.btn_message).performClick();
activity.getFragmentManager().executePendingTransactions();
}
});
getInstrumentation().waitForIdleSync();
Fragment f = getActivity().getFragmentManager().findFragmentByTag("dialog");
assertNotNull(f);
|
Dialog d = ((SimpleAlertDialogFragment) f).getDialog();
|
ksoichiro/SimpleAlertDialog-for-Android
|
simplealertdialog-tests/src/com/simplealertdialog/test/SupportActivityTest.java
|
// Path: simplealertdialog/src/com/simplealertdialog/SimpleAlertDialogSupportFragment.java
// public class SimpleAlertDialogSupportFragment extends DialogFragment {
//
// /**
// * Default constructor.
// */
// public SimpleAlertDialogSupportFragment() {
// }
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// Bundle args = getArguments();
// // Cancelable must be set to DialogFragment
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// setCancelable(args.getBoolean(SimpleAlertDialog.ARG_CANCELABLE, true));
// }
// return new InternalHelper<Fragment, FragmentActivity>() {
// public FragmentActivity getActivity() {
// return SimpleAlertDialogSupportFragment.this.getActivity();
// }
//
// public Fragment getTargetFragment() {
// return SimpleAlertDialogSupportFragment.this.getTargetFragment();
// }
// }.createDialog(args);
// }
//
// @Override
// public void onCancel(DialogInterface dialog) {
// super.onCancel(dialog);
// int requestCode = 0;
// Bundle args = getArguments();
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// requestCode = args.getInt(SimpleAlertDialog.ARG_REQUEST_CODE);
// }
// Fragment targetFragment = getTargetFragment();
// if (targetFragment != null
// && targetFragment instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) targetFragment)
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// if (getActivity() != null
// && getActivity() instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) getActivity())
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// }
//
// /**
// * Dialog builder for {@code android.support.v4.app.Fragment}.
// * <p/>
// * {@inheritDoc}
// */
// public static class Builder extends
// SimpleAlertDialog.Builder<SimpleAlertDialogSupportFragment, Fragment> {
// private Fragment mTargetFragment;
//
// @Override
// public Builder setTargetFragment(final Fragment targetFragment) {
// mTargetFragment = targetFragment;
// return this;
// }
//
// @Override
// public SimpleAlertDialogSupportFragment create() {
// Bundle args = createArguments();
// SimpleAlertDialogSupportFragment fragment = new SimpleAlertDialogSupportFragment();
// fragment.setArguments(args);
// if (mTargetFragment != null) {
// fragment.setTargetFragment(mTargetFragment, 0);
// }
// return fragment;
// }
// }
//
// }
|
import android.annotation.TargetApi;
import android.app.Dialog;
import android.os.Build;
import android.support.v4.app.Fragment;
import android.test.ActivityInstrumentationTestCase2;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ListView;
import com.simplealertdialog.SimpleAlertDialogSupportFragment;
|
/*
* Copyright 2014 Soichiro Kashima
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.simplealertdialog.test;
/**
* Tests for using SimpleAlertDialog with FragmentActivity in support-v4 library.
*/
public class SupportActivityTest extends ActivityInstrumentationTestCase2<SupportActivity> {
private SupportActivity activity;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public SupportActivityTest() {
super(SupportActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setActivityInitialTouchMode(true);
activity = getActivity();
}
public void testMessage() throws Throwable {
runTestOnUiThread(new Runnable() {
@Override
public void run() {
activity.findViewById(R.id.btn_message).performClick();
activity.getSupportFragmentManager().executePendingTransactions();
}
});
getInstrumentation().waitForIdleSync();
Fragment f = getActivity().getSupportFragmentManager().findFragmentByTag("dialog");
assertNotNull(f);
|
// Path: simplealertdialog/src/com/simplealertdialog/SimpleAlertDialogSupportFragment.java
// public class SimpleAlertDialogSupportFragment extends DialogFragment {
//
// /**
// * Default constructor.
// */
// public SimpleAlertDialogSupportFragment() {
// }
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// Bundle args = getArguments();
// // Cancelable must be set to DialogFragment
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// setCancelable(args.getBoolean(SimpleAlertDialog.ARG_CANCELABLE, true));
// }
// return new InternalHelper<Fragment, FragmentActivity>() {
// public FragmentActivity getActivity() {
// return SimpleAlertDialogSupportFragment.this.getActivity();
// }
//
// public Fragment getTargetFragment() {
// return SimpleAlertDialogSupportFragment.this.getTargetFragment();
// }
// }.createDialog(args);
// }
//
// @Override
// public void onCancel(DialogInterface dialog) {
// super.onCancel(dialog);
// int requestCode = 0;
// Bundle args = getArguments();
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// requestCode = args.getInt(SimpleAlertDialog.ARG_REQUEST_CODE);
// }
// Fragment targetFragment = getTargetFragment();
// if (targetFragment != null
// && targetFragment instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) targetFragment)
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// if (getActivity() != null
// && getActivity() instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) getActivity())
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// }
//
// /**
// * Dialog builder for {@code android.support.v4.app.Fragment}.
// * <p/>
// * {@inheritDoc}
// */
// public static class Builder extends
// SimpleAlertDialog.Builder<SimpleAlertDialogSupportFragment, Fragment> {
// private Fragment mTargetFragment;
//
// @Override
// public Builder setTargetFragment(final Fragment targetFragment) {
// mTargetFragment = targetFragment;
// return this;
// }
//
// @Override
// public SimpleAlertDialogSupportFragment create() {
// Bundle args = createArguments();
// SimpleAlertDialogSupportFragment fragment = new SimpleAlertDialogSupportFragment();
// fragment.setArguments(args);
// if (mTargetFragment != null) {
// fragment.setTargetFragment(mTargetFragment, 0);
// }
// return fragment;
// }
// }
//
// }
// Path: simplealertdialog-tests/src/com/simplealertdialog/test/SupportActivityTest.java
import android.annotation.TargetApi;
import android.app.Dialog;
import android.os.Build;
import android.support.v4.app.Fragment;
import android.test.ActivityInstrumentationTestCase2;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ListView;
import com.simplealertdialog.SimpleAlertDialogSupportFragment;
/*
* Copyright 2014 Soichiro Kashima
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.simplealertdialog.test;
/**
* Tests for using SimpleAlertDialog with FragmentActivity in support-v4 library.
*/
public class SupportActivityTest extends ActivityInstrumentationTestCase2<SupportActivity> {
private SupportActivity activity;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public SupportActivityTest() {
super(SupportActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setActivityInitialTouchMode(true);
activity = getActivity();
}
public void testMessage() throws Throwable {
runTestOnUiThread(new Runnable() {
@Override
public void run() {
activity.findViewById(R.id.btn_message).performClick();
activity.getSupportFragmentManager().executePendingTransactions();
}
});
getInstrumentation().waitForIdleSync();
Fragment f = getActivity().getSupportFragmentManager().findFragmentByTag("dialog");
assertNotNull(f);
|
Dialog d = ((SimpleAlertDialogSupportFragment) f).getDialog();
|
ksoichiro/SimpleAlertDialog-for-Android
|
simplealertdialog-samples/demos/src/androidTest/java/com/simplealertdialog/sample/demos/test/MainActivityTest.java
|
// Path: simplealertdialog-samples/demos/src/main/java/com/simplealertdialog/sample/demos/AboutActivity.java
// public final class AboutActivity extends Activity {
//
// @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_about);
//
// if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) {
// getActionBar().setDisplayHomeAsUpEnabled(true);
// if (Build.VERSION_CODES.ICE_CREAM_SANDWICH <= Build.VERSION.SDK_INT) {
// getActionBar().setHomeButtonEnabled(true);
// }
// }
//
// ((TextView) findViewById(R.id.version_name)).setText(getVersionName());
// ((TextView) findViewById(R.id.copyright)).setText(Html
// .fromHtml(getString(R.string.msg_copyright)));
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem menu) {
// int id = menu.getItemId();
// if (id == android.R.id.home) {
// finish();
// return true;
// }
// return false;
// }
//
// private String getVersionName() {
// final PackageManager manager = getPackageManager();
// String versionName;
// try {
// final PackageInfo info = manager.getPackageInfo(
// getPackageName(),
// PackageManager.GET_META_DATA);
// versionName = info.versionName;
// } catch (NameNotFoundException e) {
// versionName = "";
// }
// return versionName;
// }
//
// }
//
// Path: simplealertdialog-samples/demos/src/main/java/com/simplealertdialog/sample/demos/MainActivity.java
// public class MainActivity extends ListActivity {
//
// private static final Comparator<Map<String, Object>> DISPLAY_NAME_COMPARATOR = new Comparator<Map<String, Object>>() {
// private final Collator collator = Collator.getInstance();
//
// @Override
// public int compare(Map<String, Object> lhs, Map<String, Object> rhs) {
// return collator.compare(lhs.get("className"), rhs.get("className"));
// }
// };
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setListAdapter(new SimpleAdapter(this, getData(),
// R.layout.list_item_main,
// new String[] {
// "className",
// "description",
// },
// new int[] {
// R.id.className,
// R.id.description,
// }));
// }
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// getMenuInflater().inflate(R.menu.activity_main, menu);
// return true;
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem menu) {
// int id = menu.getItemId();
// if (id == R.id.menu_about) {
// startActivity(new Intent(getApplicationContext(), AboutActivity.class));
// return true;
// }
// return false;
// }
//
// private List<Map<String, Object>> getData() {
// List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
//
// Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
// mainIntent.addCategory("com.simplealertdialog.sample.demos");
// if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
// mainIntent.addCategory("com.simplealertdialog.sample.demos.gingerbread");
// }
//
// PackageManager pm = getPackageManager();
// List<ResolveInfo> list = pm.queryIntentActivities(mainIntent, 0);
//
// if (list == null) {
// return data;
// }
//
// int len = list.size();
// for (int i = 0; i < len; i++) {
// ResolveInfo info = list.get(i);
// CharSequence labelSeq = info.loadLabel(pm);
// String label = labelSeq != null
// ? labelSeq.toString()
// : info.activityInfo.name;
//
// String[] labelPath = label.split("/");
//
// String nextLabel = labelPath[0];
//
// if (labelPath.length == 1) {
// addItem(data,
// info.activityInfo.name.replace(info.activityInfo.packageName + "", ""),
// nextLabel,
// activityIntent(
// info.activityInfo.applicationInfo.packageName,
// info.activityInfo.name));
// }
// }
//
// Collections.sort(data, DISPLAY_NAME_COMPARATOR);
//
// return data;
// }
//
// protected Intent activityIntent(String pkg, String componentName) {
// Intent result = new Intent();
// result.setClassName(pkg, componentName);
// return result;
// }
//
// protected void addItem(List<Map<String, Object>> data, String className, String description,
// Intent intent) {
// Map<String, Object> temp = new HashMap<String, Object>();
// temp.put("className", className);
// temp.put("description", description);
// temp.put("intent", intent);
// data.add(temp);
// }
//
// @Override
// @SuppressWarnings("unchecked")
// protected void onListItemClick(ListView l, View v, int position, long id) {
// Map<String, Object> map = (Map<String, Object>) l.getItemAtPosition(position);
//
// Intent intent = (Intent) map.get("intent");
// startActivity(intent);
// }
// }
|
import android.app.Instrumentation;
import android.test.InstrumentationTestCase;
import android.view.KeyEvent;
import com.simplealertdialog.sample.demos.AboutActivity;
import com.simplealertdialog.sample.demos.MainActivity;
|
package com.simplealertdialog.sample.demos.test;
public class MainActivityTest extends InstrumentationTestCase {
private MainActivity mainActivity;
public void testLaunch() {
mainActivity = launchActivity("com.simplealertdialog.sample.demos", MainActivity.class, null);
getInstrumentation().waitForIdleSync();
assertNotNull(mainActivity);
mainActivity.finish();
}
public void testLaunchAboutActivity() {
|
// Path: simplealertdialog-samples/demos/src/main/java/com/simplealertdialog/sample/demos/AboutActivity.java
// public final class AboutActivity extends Activity {
//
// @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_about);
//
// if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) {
// getActionBar().setDisplayHomeAsUpEnabled(true);
// if (Build.VERSION_CODES.ICE_CREAM_SANDWICH <= Build.VERSION.SDK_INT) {
// getActionBar().setHomeButtonEnabled(true);
// }
// }
//
// ((TextView) findViewById(R.id.version_name)).setText(getVersionName());
// ((TextView) findViewById(R.id.copyright)).setText(Html
// .fromHtml(getString(R.string.msg_copyright)));
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem menu) {
// int id = menu.getItemId();
// if (id == android.R.id.home) {
// finish();
// return true;
// }
// return false;
// }
//
// private String getVersionName() {
// final PackageManager manager = getPackageManager();
// String versionName;
// try {
// final PackageInfo info = manager.getPackageInfo(
// getPackageName(),
// PackageManager.GET_META_DATA);
// versionName = info.versionName;
// } catch (NameNotFoundException e) {
// versionName = "";
// }
// return versionName;
// }
//
// }
//
// Path: simplealertdialog-samples/demos/src/main/java/com/simplealertdialog/sample/demos/MainActivity.java
// public class MainActivity extends ListActivity {
//
// private static final Comparator<Map<String, Object>> DISPLAY_NAME_COMPARATOR = new Comparator<Map<String, Object>>() {
// private final Collator collator = Collator.getInstance();
//
// @Override
// public int compare(Map<String, Object> lhs, Map<String, Object> rhs) {
// return collator.compare(lhs.get("className"), rhs.get("className"));
// }
// };
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setListAdapter(new SimpleAdapter(this, getData(),
// R.layout.list_item_main,
// new String[] {
// "className",
// "description",
// },
// new int[] {
// R.id.className,
// R.id.description,
// }));
// }
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// getMenuInflater().inflate(R.menu.activity_main, menu);
// return true;
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem menu) {
// int id = menu.getItemId();
// if (id == R.id.menu_about) {
// startActivity(new Intent(getApplicationContext(), AboutActivity.class));
// return true;
// }
// return false;
// }
//
// private List<Map<String, Object>> getData() {
// List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
//
// Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
// mainIntent.addCategory("com.simplealertdialog.sample.demos");
// if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
// mainIntent.addCategory("com.simplealertdialog.sample.demos.gingerbread");
// }
//
// PackageManager pm = getPackageManager();
// List<ResolveInfo> list = pm.queryIntentActivities(mainIntent, 0);
//
// if (list == null) {
// return data;
// }
//
// int len = list.size();
// for (int i = 0; i < len; i++) {
// ResolveInfo info = list.get(i);
// CharSequence labelSeq = info.loadLabel(pm);
// String label = labelSeq != null
// ? labelSeq.toString()
// : info.activityInfo.name;
//
// String[] labelPath = label.split("/");
//
// String nextLabel = labelPath[0];
//
// if (labelPath.length == 1) {
// addItem(data,
// info.activityInfo.name.replace(info.activityInfo.packageName + "", ""),
// nextLabel,
// activityIntent(
// info.activityInfo.applicationInfo.packageName,
// info.activityInfo.name));
// }
// }
//
// Collections.sort(data, DISPLAY_NAME_COMPARATOR);
//
// return data;
// }
//
// protected Intent activityIntent(String pkg, String componentName) {
// Intent result = new Intent();
// result.setClassName(pkg, componentName);
// return result;
// }
//
// protected void addItem(List<Map<String, Object>> data, String className, String description,
// Intent intent) {
// Map<String, Object> temp = new HashMap<String, Object>();
// temp.put("className", className);
// temp.put("description", description);
// temp.put("intent", intent);
// data.add(temp);
// }
//
// @Override
// @SuppressWarnings("unchecked")
// protected void onListItemClick(ListView l, View v, int position, long id) {
// Map<String, Object> map = (Map<String, Object>) l.getItemAtPosition(position);
//
// Intent intent = (Intent) map.get("intent");
// startActivity(intent);
// }
// }
// Path: simplealertdialog-samples/demos/src/androidTest/java/com/simplealertdialog/sample/demos/test/MainActivityTest.java
import android.app.Instrumentation;
import android.test.InstrumentationTestCase;
import android.view.KeyEvent;
import com.simplealertdialog.sample.demos.AboutActivity;
import com.simplealertdialog.sample.demos.MainActivity;
package com.simplealertdialog.sample.demos.test;
public class MainActivityTest extends InstrumentationTestCase {
private MainActivity mainActivity;
public void testLaunch() {
mainActivity = launchActivity("com.simplealertdialog.sample.demos", MainActivity.class, null);
getInstrumentation().waitForIdleSync();
assertNotNull(mainActivity);
mainActivity.finish();
}
public void testLaunchAboutActivity() {
|
Instrumentation.ActivityMonitor monitorAbout = new Instrumentation.ActivityMonitor(AboutActivity.class.getCanonicalName(), null, false);
|
ksoichiro/SimpleAlertDialog-for-Android
|
simplealertdialog-tests/src/com/simplealertdialog/test/FragmentActivityTest.java
|
// Path: simplealertdialog/src/com/simplealertdialog/SimpleAlertDialogFragment.java
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public class SimpleAlertDialogFragment extends DialogFragment {
//
// /**
// * Default constructor.
// */
// public SimpleAlertDialogFragment() {
// }
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// Bundle args = getArguments();
// // Cancelable must be set to DialogFragment
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// setCancelable(args.getBoolean(SimpleAlertDialog.ARG_CANCELABLE, true));
// }
// return new InternalHelper<Fragment, Activity>() {
// public Activity getActivity() {
// return SimpleAlertDialogFragment.this.getActivity();
// }
//
// public Fragment getTargetFragment() {
// return SimpleAlertDialogFragment.this.getTargetFragment();
// }
// }.createDialog(args);
// }
//
// @Override
// public void onCancel(DialogInterface dialog) {
// super.onCancel(dialog);
// int requestCode = 0;
// Bundle args = getArguments();
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// requestCode = args.getInt(SimpleAlertDialog.ARG_REQUEST_CODE);
// }
// Fragment targetFragment = getTargetFragment();
// if (targetFragment != null
// && targetFragment instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) targetFragment)
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// if (getActivity() != null
// && getActivity() instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) getActivity())
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// }
//
// /**
// * Dialog builder for {@code android.app.Fragment}.
// * <p/>
// * {@inheritDoc}
// */
// public static class Builder extends
// SimpleAlertDialog.Builder<SimpleAlertDialogFragment, Fragment> {
// private Fragment mTargetFragment;
//
// @Override
// public Builder setTargetFragment(final Fragment targetFragment) {
// mTargetFragment = targetFragment;
// return this;
// }
//
// @Override
// public SimpleAlertDialogFragment create() {
// Bundle args = createArguments();
// SimpleAlertDialogFragment fragment = new SimpleAlertDialogFragment();
// fragment.setArguments(args);
// if (mTargetFragment != null) {
// fragment.setTargetFragment(mTargetFragment, 0);
// }
// return fragment;
// }
// }
//
// }
|
import android.annotation.TargetApi;
import android.app.Dialog;
import android.app.Fragment;
import android.os.Build;
import android.test.ActivityInstrumentationTestCase2;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.simplealertdialog.SimpleAlertDialogFragment;
|
/*
* Copyright 2014 Soichiro Kashima
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.simplealertdialog.test;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class FragmentActivityTest extends ActivityInstrumentationTestCase2<FragmentNormalActivity> {
private FragmentNormalActivity activity;
public FragmentActivityTest() {
super(FragmentNormalActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setActivityInitialTouchMode(true);
activity = getActivity();
}
public void testMessage() throws Throwable {
runTestOnUiThread(new Runnable() {
@Override
public void run() {
Fragment f = activity.getFragmentManager().findFragmentById(R.id.fragment_sample);
assertNotNull(f);
assertNotNull(f.getView());
f.getView().findViewById(R.id.btn_frag_message).performClick();
activity.getFragmentManager().executePendingTransactions();
}
});
getInstrumentation().waitForIdleSync();
Fragment f = getActivity().getFragmentManager().findFragmentByTag("dialog");
assertNotNull(f);
|
// Path: simplealertdialog/src/com/simplealertdialog/SimpleAlertDialogFragment.java
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public class SimpleAlertDialogFragment extends DialogFragment {
//
// /**
// * Default constructor.
// */
// public SimpleAlertDialogFragment() {
// }
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// Bundle args = getArguments();
// // Cancelable must be set to DialogFragment
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// setCancelable(args.getBoolean(SimpleAlertDialog.ARG_CANCELABLE, true));
// }
// return new InternalHelper<Fragment, Activity>() {
// public Activity getActivity() {
// return SimpleAlertDialogFragment.this.getActivity();
// }
//
// public Fragment getTargetFragment() {
// return SimpleAlertDialogFragment.this.getTargetFragment();
// }
// }.createDialog(args);
// }
//
// @Override
// public void onCancel(DialogInterface dialog) {
// super.onCancel(dialog);
// int requestCode = 0;
// Bundle args = getArguments();
// if (args != null && args.containsKey(SimpleAlertDialog.ARG_CANCELABLE)) {
// requestCode = args.getInt(SimpleAlertDialog.ARG_REQUEST_CODE);
// }
// Fragment targetFragment = getTargetFragment();
// if (targetFragment != null
// && targetFragment instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) targetFragment)
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// if (getActivity() != null
// && getActivity() instanceof SimpleAlertDialog.OnCancelListener) {
// ((SimpleAlertDialog.OnCancelListener) getActivity())
// .onDialogCancel((SimpleAlertDialog) dialog,
// requestCode,
// ((SimpleAlertDialog) dialog).getView());
// }
// }
//
// /**
// * Dialog builder for {@code android.app.Fragment}.
// * <p/>
// * {@inheritDoc}
// */
// public static class Builder extends
// SimpleAlertDialog.Builder<SimpleAlertDialogFragment, Fragment> {
// private Fragment mTargetFragment;
//
// @Override
// public Builder setTargetFragment(final Fragment targetFragment) {
// mTargetFragment = targetFragment;
// return this;
// }
//
// @Override
// public SimpleAlertDialogFragment create() {
// Bundle args = createArguments();
// SimpleAlertDialogFragment fragment = new SimpleAlertDialogFragment();
// fragment.setArguments(args);
// if (mTargetFragment != null) {
// fragment.setTargetFragment(mTargetFragment, 0);
// }
// return fragment;
// }
// }
//
// }
// Path: simplealertdialog-tests/src/com/simplealertdialog/test/FragmentActivityTest.java
import android.annotation.TargetApi;
import android.app.Dialog;
import android.app.Fragment;
import android.os.Build;
import android.test.ActivityInstrumentationTestCase2;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.simplealertdialog.SimpleAlertDialogFragment;
/*
* Copyright 2014 Soichiro Kashima
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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 com.simplealertdialog.test;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class FragmentActivityTest extends ActivityInstrumentationTestCase2<FragmentNormalActivity> {
private FragmentNormalActivity activity;
public FragmentActivityTest() {
super(FragmentNormalActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setActivityInitialTouchMode(true);
activity = getActivity();
}
public void testMessage() throws Throwable {
runTestOnUiThread(new Runnable() {
@Override
public void run() {
Fragment f = activity.getFragmentManager().findFragmentById(R.id.fragment_sample);
assertNotNull(f);
assertNotNull(f.getView());
f.getView().findViewById(R.id.btn_frag_message).performClick();
activity.getFragmentManager().executePendingTransactions();
}
});
getInstrumentation().waitForIdleSync();
Fragment f = getActivity().getFragmentManager().findFragmentByTag("dialog");
assertNotNull(f);
|
Dialog d = ((SimpleAlertDialogFragment) f).getDialog();
|
srcvirus/floodlight
|
src/test/java/net/floodlightcontroller/flowcache/FlowReconcileMgrTest.java
|
// Path: src/main/java/net/floodlightcontroller/core/module/FloodlightModuleContext.java
// public class FloodlightModuleContext implements IFloodlightModuleContext {
// protected Map<Class<? extends IFloodlightService>, IFloodlightService> serviceMap;
// protected Map<Class<? extends IFloodlightModule>, Map<String, String>> configParams;
// protected Collection<IFloodlightModule> moduleSet;
//
// /**
// * Creates the ModuleContext for use with this IFloodlightProvider.
// * This will be used as a module registry for all IFloodlightModule(s).
// */
// public FloodlightModuleContext() {
// serviceMap =
// new HashMap<Class<? extends IFloodlightService>,
// IFloodlightService>();
// configParams =
// new HashMap<Class<? extends IFloodlightModule>,
// Map<String, String>>();
// }
//
// /**
// * Adds a IFloodlightModule for this Context.
// * @param clazz the service class
// * @param service The IFloodlightService to add to the registry
// */
// public void addService(Class<? extends IFloodlightService> clazz,
// IFloodlightService service) {
// serviceMap.put(clazz, service);
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public <T extends IFloodlightService> T getServiceImpl(Class<T> service) {
// IFloodlightService s = serviceMap.get(service);
// return (T)s;
// }
//
// @Override
// public Collection<Class<? extends IFloodlightService>> getAllServices() {
// return serviceMap.keySet();
// }
//
// @Override
// public Collection<IFloodlightModule> getAllModules() {
// return moduleSet;
// }
//
// public void setModuleSet(Collection<IFloodlightModule> modSet) {
// this.moduleSet = modSet;
// }
//
// @Override
// public Map<String, String> getConfigParams(IFloodlightModule module) {
// Class<? extends IFloodlightModule> clazz = module.getClass();
// return getConfigParams(clazz);
// }
//
// @Override
// public Map<String, String> getConfigParams(Class<? extends IFloodlightModule> clazz) {
// Map<String, String> retMap = configParams.get(clazz);
// if (retMap == null) {
// // Return an empty map if none exists so the module does not
// // need to null check the map
// retMap = new HashMap<String, String>();
// configParams.put(clazz, retMap);
// }
//
// // also add any configuration parameters for superclasses, but
// // only if more specific configuration does not override it
// for (Class<? extends IFloodlightModule> c : configParams.keySet()) {
// if (c.isAssignableFrom(clazz)) {
// for (Map.Entry<String, String> ent : configParams.get(c).entrySet()) {
// if (!retMap.containsKey(ent.getKey())) {
// retMap.put(ent.getKey(), ent.getValue());
// }
// }
// }
// }
//
// return retMap;
// }
//
// /**
// * Adds a configuration parameter for a module
// * @param mod The fully qualified module name to add the parameter to
// * @param key The configuration parameter key
// * @param value The configuration parameter value
// */
// public void addConfigParam(IFloodlightModule mod, String key, String value) {
// Map<String, String> moduleParams = configParams.get(mod.getClass());
// if (moduleParams == null) {
// moduleParams = new HashMap<String, String>();
// configParams.put(mod.getClass(), moduleParams);
// }
// moduleParams.put(key, value);
// }
// }
|
import static org.easymock.EasyMock.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.ListIterator;
import net.floodlightcontroller.core.IListener.Command;
import net.floodlightcontroller.core.module.FloodlightModuleContext;
import net.floodlightcontroller.core.test.MockThreadPoolService;
import net.floodlightcontroller.counter.ICounterStoreService;
import net.floodlightcontroller.counter.SimpleCounter;
import net.floodlightcontroller.counter.CounterValue.CounterType;
import net.floodlightcontroller.flowcache.IFlowReconcileListener;
import net.floodlightcontroller.flowcache.OFMatchReconcile;
import net.floodlightcontroller.test.FloodlightTestCase;
import net.floodlightcontroller.threadpool.IThreadPoolService;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
import org.junit.Before;
import org.junit.Test;
import org.openflow.protocol.OFStatisticsRequest;
import org.openflow.protocol.OFType;
|
/**
* Copyright 2013, Big Switch Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* 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 net.floodlightcontroller.flowcache;
public class FlowReconcileMgrTest extends FloodlightTestCase {
protected FlowReconcileManager flowReconcileMgr;
protected MockThreadPoolService threadPool;
protected ICounterStoreService counterStore;
|
// Path: src/main/java/net/floodlightcontroller/core/module/FloodlightModuleContext.java
// public class FloodlightModuleContext implements IFloodlightModuleContext {
// protected Map<Class<? extends IFloodlightService>, IFloodlightService> serviceMap;
// protected Map<Class<? extends IFloodlightModule>, Map<String, String>> configParams;
// protected Collection<IFloodlightModule> moduleSet;
//
// /**
// * Creates the ModuleContext for use with this IFloodlightProvider.
// * This will be used as a module registry for all IFloodlightModule(s).
// */
// public FloodlightModuleContext() {
// serviceMap =
// new HashMap<Class<? extends IFloodlightService>,
// IFloodlightService>();
// configParams =
// new HashMap<Class<? extends IFloodlightModule>,
// Map<String, String>>();
// }
//
// /**
// * Adds a IFloodlightModule for this Context.
// * @param clazz the service class
// * @param service The IFloodlightService to add to the registry
// */
// public void addService(Class<? extends IFloodlightService> clazz,
// IFloodlightService service) {
// serviceMap.put(clazz, service);
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public <T extends IFloodlightService> T getServiceImpl(Class<T> service) {
// IFloodlightService s = serviceMap.get(service);
// return (T)s;
// }
//
// @Override
// public Collection<Class<? extends IFloodlightService>> getAllServices() {
// return serviceMap.keySet();
// }
//
// @Override
// public Collection<IFloodlightModule> getAllModules() {
// return moduleSet;
// }
//
// public void setModuleSet(Collection<IFloodlightModule> modSet) {
// this.moduleSet = modSet;
// }
//
// @Override
// public Map<String, String> getConfigParams(IFloodlightModule module) {
// Class<? extends IFloodlightModule> clazz = module.getClass();
// return getConfigParams(clazz);
// }
//
// @Override
// public Map<String, String> getConfigParams(Class<? extends IFloodlightModule> clazz) {
// Map<String, String> retMap = configParams.get(clazz);
// if (retMap == null) {
// // Return an empty map if none exists so the module does not
// // need to null check the map
// retMap = new HashMap<String, String>();
// configParams.put(clazz, retMap);
// }
//
// // also add any configuration parameters for superclasses, but
// // only if more specific configuration does not override it
// for (Class<? extends IFloodlightModule> c : configParams.keySet()) {
// if (c.isAssignableFrom(clazz)) {
// for (Map.Entry<String, String> ent : configParams.get(c).entrySet()) {
// if (!retMap.containsKey(ent.getKey())) {
// retMap.put(ent.getKey(), ent.getValue());
// }
// }
// }
// }
//
// return retMap;
// }
//
// /**
// * Adds a configuration parameter for a module
// * @param mod The fully qualified module name to add the parameter to
// * @param key The configuration parameter key
// * @param value The configuration parameter value
// */
// public void addConfigParam(IFloodlightModule mod, String key, String value) {
// Map<String, String> moduleParams = configParams.get(mod.getClass());
// if (moduleParams == null) {
// moduleParams = new HashMap<String, String>();
// configParams.put(mod.getClass(), moduleParams);
// }
// moduleParams.put(key, value);
// }
// }
// Path: src/test/java/net/floodlightcontroller/flowcache/FlowReconcileMgrTest.java
import static org.easymock.EasyMock.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.ListIterator;
import net.floodlightcontroller.core.IListener.Command;
import net.floodlightcontroller.core.module.FloodlightModuleContext;
import net.floodlightcontroller.core.test.MockThreadPoolService;
import net.floodlightcontroller.counter.ICounterStoreService;
import net.floodlightcontroller.counter.SimpleCounter;
import net.floodlightcontroller.counter.CounterValue.CounterType;
import net.floodlightcontroller.flowcache.IFlowReconcileListener;
import net.floodlightcontroller.flowcache.OFMatchReconcile;
import net.floodlightcontroller.test.FloodlightTestCase;
import net.floodlightcontroller.threadpool.IThreadPoolService;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
import org.junit.Before;
import org.junit.Test;
import org.openflow.protocol.OFStatisticsRequest;
import org.openflow.protocol.OFType;
/**
* Copyright 2013, Big Switch Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* 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 net.floodlightcontroller.flowcache;
public class FlowReconcileMgrTest extends FloodlightTestCase {
protected FlowReconcileManager flowReconcileMgr;
protected MockThreadPoolService threadPool;
protected ICounterStoreService counterStore;
|
protected FloodlightModuleContext fmc;
|
justyoyo/Contrast
|
example/src/main/java/com/justyoyo/contrast/example/DemoActivity.java
|
// Path: core/src/main/java/com/justyoyo/contrast/WriterException.java
// public final class WriterException extends Exception {
//
// public WriterException() {
// }
//
// public WriterException(String message) {
// super(message);
// }
//
// public WriterException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: qrcode/src/main/java/com/justyoyo/contrast/qrcode/QRCodeEncoder.java
// public final class QRCodeEncoder {
//
// private static final int WHITE = 0xFFFFFFFF;
// private static final int BLACK = 0xFF000000;
//
// private int dimension = Integer.MIN_VALUE;
// private String displayContents = null;
// private String contents = null;
// private Map<EncodeHintType, Object> hints = null;
// private boolean encoded = false;
//
// public QRCodeEncoder(int dimension, Map<EncodeHintType, Object> hints) {
// this(null, dimension, hints);
// }
//
// public QRCodeEncoder(String data, int dimension, Map<EncodeHintType, Object> hints) {
// this.dimension = dimension;
// this.encoded = encodeContents(data);
// this.hints = hints;
// }
//
// public String getContents() {
// return contents;
// }
//
// public String getDisplayContents() {
// return displayContents;
// }
//
// private static int getColor(Map<EncodeHintType, Object> hints, EncodeHintType key, int defaultColor) {
// Object foreground = hints.get(key);
// if (foreground == null || !(foreground instanceof Integer)) {
// return defaultColor;
// } else {
// return ((Integer) foreground);
// }
// }
//
// public void setData(String data) {
// encoded = encodeContents(data);
// }
//
// public void setDimension(int dimension) {
// this.dimension = dimension;
// }
//
// public Bitmap encodeAsBitmap() throws WriterException {
// if (!encoded)
// return null;
//
// Map<EncodeHintType, Object> hints = this.hints;
// if (hints == null)
// hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
//
// // Add encoding if it exits
// String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
// if (encoding == null)
// encoding = guessAppropriateEncoding(contents);
// if (encoding != null) {
// hints.put(EncodeHintType.CHARACTER_SET, encoding);
// }
// QRCodeWriter writer = new QRCodeWriter();
// BitMatrix result = writer.encode(contents, dimension, dimension, BarcodeFormat.QR_CODE, hints);
// int width = result.getWidth();
// int height = result.getHeight();
// int[] pixels = new int[width * height];
//
// int foregroundColor = getColor(hints, EncodeHintType.FOREGROUND_COLOR, BLACK);
// int backgroundColor = getColor(hints, EncodeHintType.BACKGROUND_COLOR, WHITE);
//
// // All are 0, or black, by default
// for (int y = 0; y < height; y++) {
// int offset = y * width;
// for (int x = 0; x < width; x++) {
// pixels[offset + x] = result.get(x, y) ? foregroundColor : backgroundColor;
// }
// }
//
// Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
// bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
// return bitmap;
// }
//
// private boolean encodeContents(String data) {
// contents = data;
// displayContents = data;
// return contents != null && contents.length() > 0;
// }
//
// private static String guessAppropriateEncoding(CharSequence contents) {
// // Very crude at the moment
// for (int i = 0; i < contents.length(); i++) {
// if (contents.charAt(i) > 0xFF) {
// return "UTF-8";
// }
// }
// return null;
// }
//
// private static String trim(String s) {
// if (s == null) {
// return null;
// }
// String result = s.trim();
// return result.length() == 0 ? null : result;
// }
//
// private static String escapeMECARD(String input) {
// if (input == null || (input.indexOf(':') < 0 && input.indexOf(';') < 0)) {
// return input;
// }
// int length = input.length();
// StringBuilder result = new StringBuilder(length);
// for (int i = 0; i < length; i++) {
// char c = input.charAt(i);
// if (c == ':' || c == ';') {
// result.append('\\');
// }
// result.append(c);
// }
// return result.toString();
// }
// }
|
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.justyoyo.contrast.WriterException;
import com.justyoyo.contrast.qrcode.QRCodeEncoder;
|
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
private ImageView mQRCodeImage;
private TextView mQRCodeText;
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_demo, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mQRCodeImage = (ImageView) view.findViewById(R.id.qrcode_image);
mQRCodeText = (TextView) view.findViewById(R.id.qrcode_text);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
float size = 192f * getResources().getDisplayMetrics().density;
|
// Path: core/src/main/java/com/justyoyo/contrast/WriterException.java
// public final class WriterException extends Exception {
//
// public WriterException() {
// }
//
// public WriterException(String message) {
// super(message);
// }
//
// public WriterException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: qrcode/src/main/java/com/justyoyo/contrast/qrcode/QRCodeEncoder.java
// public final class QRCodeEncoder {
//
// private static final int WHITE = 0xFFFFFFFF;
// private static final int BLACK = 0xFF000000;
//
// private int dimension = Integer.MIN_VALUE;
// private String displayContents = null;
// private String contents = null;
// private Map<EncodeHintType, Object> hints = null;
// private boolean encoded = false;
//
// public QRCodeEncoder(int dimension, Map<EncodeHintType, Object> hints) {
// this(null, dimension, hints);
// }
//
// public QRCodeEncoder(String data, int dimension, Map<EncodeHintType, Object> hints) {
// this.dimension = dimension;
// this.encoded = encodeContents(data);
// this.hints = hints;
// }
//
// public String getContents() {
// return contents;
// }
//
// public String getDisplayContents() {
// return displayContents;
// }
//
// private static int getColor(Map<EncodeHintType, Object> hints, EncodeHintType key, int defaultColor) {
// Object foreground = hints.get(key);
// if (foreground == null || !(foreground instanceof Integer)) {
// return defaultColor;
// } else {
// return ((Integer) foreground);
// }
// }
//
// public void setData(String data) {
// encoded = encodeContents(data);
// }
//
// public void setDimension(int dimension) {
// this.dimension = dimension;
// }
//
// public Bitmap encodeAsBitmap() throws WriterException {
// if (!encoded)
// return null;
//
// Map<EncodeHintType, Object> hints = this.hints;
// if (hints == null)
// hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
//
// // Add encoding if it exits
// String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
// if (encoding == null)
// encoding = guessAppropriateEncoding(contents);
// if (encoding != null) {
// hints.put(EncodeHintType.CHARACTER_SET, encoding);
// }
// QRCodeWriter writer = new QRCodeWriter();
// BitMatrix result = writer.encode(contents, dimension, dimension, BarcodeFormat.QR_CODE, hints);
// int width = result.getWidth();
// int height = result.getHeight();
// int[] pixels = new int[width * height];
//
// int foregroundColor = getColor(hints, EncodeHintType.FOREGROUND_COLOR, BLACK);
// int backgroundColor = getColor(hints, EncodeHintType.BACKGROUND_COLOR, WHITE);
//
// // All are 0, or black, by default
// for (int y = 0; y < height; y++) {
// int offset = y * width;
// for (int x = 0; x < width; x++) {
// pixels[offset + x] = result.get(x, y) ? foregroundColor : backgroundColor;
// }
// }
//
// Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
// bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
// return bitmap;
// }
//
// private boolean encodeContents(String data) {
// contents = data;
// displayContents = data;
// return contents != null && contents.length() > 0;
// }
//
// private static String guessAppropriateEncoding(CharSequence contents) {
// // Very crude at the moment
// for (int i = 0; i < contents.length(); i++) {
// if (contents.charAt(i) > 0xFF) {
// return "UTF-8";
// }
// }
// return null;
// }
//
// private static String trim(String s) {
// if (s == null) {
// return null;
// }
// String result = s.trim();
// return result.length() == 0 ? null : result;
// }
//
// private static String escapeMECARD(String input) {
// if (input == null || (input.indexOf(':') < 0 && input.indexOf(';') < 0)) {
// return input;
// }
// int length = input.length();
// StringBuilder result = new StringBuilder(length);
// for (int i = 0; i < length; i++) {
// char c = input.charAt(i);
// if (c == ':' || c == ';') {
// result.append('\\');
// }
// result.append(c);
// }
// return result.toString();
// }
// }
// Path: example/src/main/java/com/justyoyo/contrast/example/DemoActivity.java
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.justyoyo.contrast.WriterException;
import com.justyoyo.contrast.qrcode.QRCodeEncoder;
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
private ImageView mQRCodeImage;
private TextView mQRCodeText;
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_demo, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mQRCodeImage = (ImageView) view.findViewById(R.id.qrcode_image);
mQRCodeText = (TextView) view.findViewById(R.id.qrcode_text);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
float size = 192f * getResources().getDisplayMetrics().density;
|
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder("4040111111111111", (int) size, null);
|
justyoyo/Contrast
|
example/src/main/java/com/justyoyo/contrast/example/DemoActivity.java
|
// Path: core/src/main/java/com/justyoyo/contrast/WriterException.java
// public final class WriterException extends Exception {
//
// public WriterException() {
// }
//
// public WriterException(String message) {
// super(message);
// }
//
// public WriterException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: qrcode/src/main/java/com/justyoyo/contrast/qrcode/QRCodeEncoder.java
// public final class QRCodeEncoder {
//
// private static final int WHITE = 0xFFFFFFFF;
// private static final int BLACK = 0xFF000000;
//
// private int dimension = Integer.MIN_VALUE;
// private String displayContents = null;
// private String contents = null;
// private Map<EncodeHintType, Object> hints = null;
// private boolean encoded = false;
//
// public QRCodeEncoder(int dimension, Map<EncodeHintType, Object> hints) {
// this(null, dimension, hints);
// }
//
// public QRCodeEncoder(String data, int dimension, Map<EncodeHintType, Object> hints) {
// this.dimension = dimension;
// this.encoded = encodeContents(data);
// this.hints = hints;
// }
//
// public String getContents() {
// return contents;
// }
//
// public String getDisplayContents() {
// return displayContents;
// }
//
// private static int getColor(Map<EncodeHintType, Object> hints, EncodeHintType key, int defaultColor) {
// Object foreground = hints.get(key);
// if (foreground == null || !(foreground instanceof Integer)) {
// return defaultColor;
// } else {
// return ((Integer) foreground);
// }
// }
//
// public void setData(String data) {
// encoded = encodeContents(data);
// }
//
// public void setDimension(int dimension) {
// this.dimension = dimension;
// }
//
// public Bitmap encodeAsBitmap() throws WriterException {
// if (!encoded)
// return null;
//
// Map<EncodeHintType, Object> hints = this.hints;
// if (hints == null)
// hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
//
// // Add encoding if it exits
// String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
// if (encoding == null)
// encoding = guessAppropriateEncoding(contents);
// if (encoding != null) {
// hints.put(EncodeHintType.CHARACTER_SET, encoding);
// }
// QRCodeWriter writer = new QRCodeWriter();
// BitMatrix result = writer.encode(contents, dimension, dimension, BarcodeFormat.QR_CODE, hints);
// int width = result.getWidth();
// int height = result.getHeight();
// int[] pixels = new int[width * height];
//
// int foregroundColor = getColor(hints, EncodeHintType.FOREGROUND_COLOR, BLACK);
// int backgroundColor = getColor(hints, EncodeHintType.BACKGROUND_COLOR, WHITE);
//
// // All are 0, or black, by default
// for (int y = 0; y < height; y++) {
// int offset = y * width;
// for (int x = 0; x < width; x++) {
// pixels[offset + x] = result.get(x, y) ? foregroundColor : backgroundColor;
// }
// }
//
// Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
// bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
// return bitmap;
// }
//
// private boolean encodeContents(String data) {
// contents = data;
// displayContents = data;
// return contents != null && contents.length() > 0;
// }
//
// private static String guessAppropriateEncoding(CharSequence contents) {
// // Very crude at the moment
// for (int i = 0; i < contents.length(); i++) {
// if (contents.charAt(i) > 0xFF) {
// return "UTF-8";
// }
// }
// return null;
// }
//
// private static String trim(String s) {
// if (s == null) {
// return null;
// }
// String result = s.trim();
// return result.length() == 0 ? null : result;
// }
//
// private static String escapeMECARD(String input) {
// if (input == null || (input.indexOf(':') < 0 && input.indexOf(';') < 0)) {
// return input;
// }
// int length = input.length();
// StringBuilder result = new StringBuilder(length);
// for (int i = 0; i < length; i++) {
// char c = input.charAt(i);
// if (c == ':' || c == ';') {
// result.append('\\');
// }
// result.append(c);
// }
// return result.toString();
// }
// }
|
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.justyoyo.contrast.WriterException;
import com.justyoyo.contrast.qrcode.QRCodeEncoder;
|
*/
public static class PlaceholderFragment extends Fragment {
private ImageView mQRCodeImage;
private TextView mQRCodeText;
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_demo, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mQRCodeImage = (ImageView) view.findViewById(R.id.qrcode_image);
mQRCodeText = (TextView) view.findViewById(R.id.qrcode_text);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
float size = 192f * getResources().getDisplayMetrics().density;
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder("4040111111111111", (int) size, null);
Bitmap bitmap = null;
try {
bitmap = qrCodeEncoder.encodeAsBitmap();
|
// Path: core/src/main/java/com/justyoyo/contrast/WriterException.java
// public final class WriterException extends Exception {
//
// public WriterException() {
// }
//
// public WriterException(String message) {
// super(message);
// }
//
// public WriterException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: qrcode/src/main/java/com/justyoyo/contrast/qrcode/QRCodeEncoder.java
// public final class QRCodeEncoder {
//
// private static final int WHITE = 0xFFFFFFFF;
// private static final int BLACK = 0xFF000000;
//
// private int dimension = Integer.MIN_VALUE;
// private String displayContents = null;
// private String contents = null;
// private Map<EncodeHintType, Object> hints = null;
// private boolean encoded = false;
//
// public QRCodeEncoder(int dimension, Map<EncodeHintType, Object> hints) {
// this(null, dimension, hints);
// }
//
// public QRCodeEncoder(String data, int dimension, Map<EncodeHintType, Object> hints) {
// this.dimension = dimension;
// this.encoded = encodeContents(data);
// this.hints = hints;
// }
//
// public String getContents() {
// return contents;
// }
//
// public String getDisplayContents() {
// return displayContents;
// }
//
// private static int getColor(Map<EncodeHintType, Object> hints, EncodeHintType key, int defaultColor) {
// Object foreground = hints.get(key);
// if (foreground == null || !(foreground instanceof Integer)) {
// return defaultColor;
// } else {
// return ((Integer) foreground);
// }
// }
//
// public void setData(String data) {
// encoded = encodeContents(data);
// }
//
// public void setDimension(int dimension) {
// this.dimension = dimension;
// }
//
// public Bitmap encodeAsBitmap() throws WriterException {
// if (!encoded)
// return null;
//
// Map<EncodeHintType, Object> hints = this.hints;
// if (hints == null)
// hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
//
// // Add encoding if it exits
// String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
// if (encoding == null)
// encoding = guessAppropriateEncoding(contents);
// if (encoding != null) {
// hints.put(EncodeHintType.CHARACTER_SET, encoding);
// }
// QRCodeWriter writer = new QRCodeWriter();
// BitMatrix result = writer.encode(contents, dimension, dimension, BarcodeFormat.QR_CODE, hints);
// int width = result.getWidth();
// int height = result.getHeight();
// int[] pixels = new int[width * height];
//
// int foregroundColor = getColor(hints, EncodeHintType.FOREGROUND_COLOR, BLACK);
// int backgroundColor = getColor(hints, EncodeHintType.BACKGROUND_COLOR, WHITE);
//
// // All are 0, or black, by default
// for (int y = 0; y < height; y++) {
// int offset = y * width;
// for (int x = 0; x < width; x++) {
// pixels[offset + x] = result.get(x, y) ? foregroundColor : backgroundColor;
// }
// }
//
// Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
// bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
// return bitmap;
// }
//
// private boolean encodeContents(String data) {
// contents = data;
// displayContents = data;
// return contents != null && contents.length() > 0;
// }
//
// private static String guessAppropriateEncoding(CharSequence contents) {
// // Very crude at the moment
// for (int i = 0; i < contents.length(); i++) {
// if (contents.charAt(i) > 0xFF) {
// return "UTF-8";
// }
// }
// return null;
// }
//
// private static String trim(String s) {
// if (s == null) {
// return null;
// }
// String result = s.trim();
// return result.length() == 0 ? null : result;
// }
//
// private static String escapeMECARD(String input) {
// if (input == null || (input.indexOf(':') < 0 && input.indexOf(';') < 0)) {
// return input;
// }
// int length = input.length();
// StringBuilder result = new StringBuilder(length);
// for (int i = 0; i < length; i++) {
// char c = input.charAt(i);
// if (c == ':' || c == ';') {
// result.append('\\');
// }
// result.append(c);
// }
// return result.toString();
// }
// }
// Path: example/src/main/java/com/justyoyo/contrast/example/DemoActivity.java
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.justyoyo.contrast.WriterException;
import com.justyoyo.contrast.qrcode.QRCodeEncoder;
*/
public static class PlaceholderFragment extends Fragment {
private ImageView mQRCodeImage;
private TextView mQRCodeText;
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_demo, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mQRCodeImage = (ImageView) view.findViewById(R.id.qrcode_image);
mQRCodeText = (TextView) view.findViewById(R.id.qrcode_text);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
float size = 192f * getResources().getDisplayMetrics().density;
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder("4040111111111111", (int) size, null);
Bitmap bitmap = null;
try {
bitmap = qrCodeEncoder.encodeAsBitmap();
|
} catch (WriterException e) {
|
justyoyo/Contrast
|
pdf417/src/main/java/com/justyoyo/contrast/pdf417/PDF417.java
|
// Path: core/src/main/java/com/justyoyo/contrast/WriterException.java
// public final class WriterException extends Exception {
//
// public WriterException() {
// }
//
// public WriterException(String message) {
// super(message);
// }
//
// public WriterException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: core/src/main/java/com/justyoyo/contrast/common/BarcodeMatrix.java
// public final class BarcodeMatrix {
//
// private final BarcodeRow[] matrix;
// private int currentRow;
// private final int height;
// private final int width;
//
// /**
// * @param height the height of the matrix (Rows)
// * @param width the width of the matrix (Cols)
// */
// public BarcodeMatrix(int height, int width) {
// matrix = new BarcodeRow[height];
// //Initializes the array to the correct width
// for (int i = 0, matrixLength = matrix.length; i < matrixLength; i++) {
// matrix[i] = new BarcodeRow((width + 4) * 17 + 1);
// }
// this.width = width * 17;
// this.height = height;
// this.currentRow = -1;
// }
//
// public void set(int x, int y, byte value) {
// matrix[y].set(x, value);
// }
//
// /*
// void setMatrix(int x, int y, boolean black) {
// set(x, y, (byte) (black ? 1 : 0));
// }
// */
//
// public void startRow() {
// ++currentRow;
// }
//
// public BarcodeRow getCurrentRow() {
// return matrix[currentRow];
// }
//
// public byte[][] getMatrix() {
// return getScaledMatrix(1, 1);
// }
//
// /*
// public byte[][] getScaledMatrix(int scale) {
// return getScaledMatrix(scale, scale);
// }
// */
//
// public byte[][] getScaledMatrix(int xScale, int yScale) {
// byte[][] matrixOut = new byte[height * yScale][width * xScale];
// int yMax = height * yScale;
// for (int i = 0; i < yMax; i++) {
// matrixOut[yMax - i - 1] = matrix[i / yScale].getScaledRow(xScale);
// }
// return matrixOut;
// }
// }
//
// Path: core/src/main/java/com/justyoyo/contrast/common/BarcodeRow.java
// public final class BarcodeRow {
//
// private final byte[] row;
// //A tacker for position in the bar
// private int currentLocation;
//
// /**
// * Creates a Barcode row of the width
// */
// BarcodeRow(int width) {
// this.row = new byte[width];
// currentLocation = 0;
// }
//
// /**
// * Sets a specific location in the bar
// *
// * @param x The location in the bar
// * @param value Black if true, white if false;
// */
// void set(int x, byte value) {
// row[x] = value;
// }
//
// /**
// * Sets a specific location in the bar
// *
// * @param x The location in the bar
// * @param black Black if true, white if false;
// */
// private void set(int x, boolean black) {
// row[x] = (byte) (black ? 1 : 0);
// }
//
// /**
// * @param black A boolean which is true if the bar black false if it is white
// * @param width How many spots wide the bar is.
// */
// public void addBar(boolean black, int width) {
// for (int ii = 0; ii < width; ii++) {
// set(currentLocation++, black);
// }
// }
//
// /*
// byte[] getRow() {
// return row;
// }
// */
//
// /**
// * This function scales the row
// *
// * @param scale How much you want the image to be scaled, must be greater than or equal to 1.
// * @return the scaled row
// */
// byte[] getScaledRow(int scale) {
// byte[] output = new byte[row.length * scale];
// for (int i = 0; i < output.length; i++) {
// output[i] = row[i / scale];
// }
// return output;
// }
// }
//
// Path: core/src/main/java/com/justyoyo/contrast/common/Compaction.java
// public enum Compaction {
//
// AUTO,
// TEXT,
// BYTE,
// NUMERIC
//
// }
|
import com.justyoyo.contrast.WriterException;
import com.justyoyo.contrast.common.BarcodeMatrix;
import com.justyoyo.contrast.common.BarcodeRow;
import com.justyoyo.contrast.common.Compaction;
import java.nio.charset.Charset;
|
* Descriptor and any pad codewords
* @param k the number of error correction codewords
* @param c the number of columns in the symbol in the data region (excluding start, stop and
* row indicator codewords)
* @return the number of rows in the symbol (r)
*/
private static int calculateNumberOfRows(int m, int k, int c) {
int r = ((m + 1 + k) / c) + 1;
if (c * r >= (m + 1 + k + c)) {
r--;
}
return r;
}
/**
* Calculates the number of pad codewords as described in 4.9.2 of ISO/IEC 15438:2001(E).
*
* @param m the number of source codewords prior to the additional of the Symbol Length
* Descriptor and any pad codewords
* @param k the number of error correction codewords
* @param c the number of columns in the symbol in the data region (excluding start, stop and
* row indicator codewords)
* @param r the number of rows in the symbol
* @return the number of pad codewords
*/
private static int getNumberOfPadCodewords(int m, int k, int c, int r) {
int n = c * r - k;
return n > m + 1 ? n - m - 1 : 0;
}
|
// Path: core/src/main/java/com/justyoyo/contrast/WriterException.java
// public final class WriterException extends Exception {
//
// public WriterException() {
// }
//
// public WriterException(String message) {
// super(message);
// }
//
// public WriterException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: core/src/main/java/com/justyoyo/contrast/common/BarcodeMatrix.java
// public final class BarcodeMatrix {
//
// private final BarcodeRow[] matrix;
// private int currentRow;
// private final int height;
// private final int width;
//
// /**
// * @param height the height of the matrix (Rows)
// * @param width the width of the matrix (Cols)
// */
// public BarcodeMatrix(int height, int width) {
// matrix = new BarcodeRow[height];
// //Initializes the array to the correct width
// for (int i = 0, matrixLength = matrix.length; i < matrixLength; i++) {
// matrix[i] = new BarcodeRow((width + 4) * 17 + 1);
// }
// this.width = width * 17;
// this.height = height;
// this.currentRow = -1;
// }
//
// public void set(int x, int y, byte value) {
// matrix[y].set(x, value);
// }
//
// /*
// void setMatrix(int x, int y, boolean black) {
// set(x, y, (byte) (black ? 1 : 0));
// }
// */
//
// public void startRow() {
// ++currentRow;
// }
//
// public BarcodeRow getCurrentRow() {
// return matrix[currentRow];
// }
//
// public byte[][] getMatrix() {
// return getScaledMatrix(1, 1);
// }
//
// /*
// public byte[][] getScaledMatrix(int scale) {
// return getScaledMatrix(scale, scale);
// }
// */
//
// public byte[][] getScaledMatrix(int xScale, int yScale) {
// byte[][] matrixOut = new byte[height * yScale][width * xScale];
// int yMax = height * yScale;
// for (int i = 0; i < yMax; i++) {
// matrixOut[yMax - i - 1] = matrix[i / yScale].getScaledRow(xScale);
// }
// return matrixOut;
// }
// }
//
// Path: core/src/main/java/com/justyoyo/contrast/common/BarcodeRow.java
// public final class BarcodeRow {
//
// private final byte[] row;
// //A tacker for position in the bar
// private int currentLocation;
//
// /**
// * Creates a Barcode row of the width
// */
// BarcodeRow(int width) {
// this.row = new byte[width];
// currentLocation = 0;
// }
//
// /**
// * Sets a specific location in the bar
// *
// * @param x The location in the bar
// * @param value Black if true, white if false;
// */
// void set(int x, byte value) {
// row[x] = value;
// }
//
// /**
// * Sets a specific location in the bar
// *
// * @param x The location in the bar
// * @param black Black if true, white if false;
// */
// private void set(int x, boolean black) {
// row[x] = (byte) (black ? 1 : 0);
// }
//
// /**
// * @param black A boolean which is true if the bar black false if it is white
// * @param width How many spots wide the bar is.
// */
// public void addBar(boolean black, int width) {
// for (int ii = 0; ii < width; ii++) {
// set(currentLocation++, black);
// }
// }
//
// /*
// byte[] getRow() {
// return row;
// }
// */
//
// /**
// * This function scales the row
// *
// * @param scale How much you want the image to be scaled, must be greater than or equal to 1.
// * @return the scaled row
// */
// byte[] getScaledRow(int scale) {
// byte[] output = new byte[row.length * scale];
// for (int i = 0; i < output.length; i++) {
// output[i] = row[i / scale];
// }
// return output;
// }
// }
//
// Path: core/src/main/java/com/justyoyo/contrast/common/Compaction.java
// public enum Compaction {
//
// AUTO,
// TEXT,
// BYTE,
// NUMERIC
//
// }
// Path: pdf417/src/main/java/com/justyoyo/contrast/pdf417/PDF417.java
import com.justyoyo.contrast.WriterException;
import com.justyoyo.contrast.common.BarcodeMatrix;
import com.justyoyo.contrast.common.BarcodeRow;
import com.justyoyo.contrast.common.Compaction;
import java.nio.charset.Charset;
* Descriptor and any pad codewords
* @param k the number of error correction codewords
* @param c the number of columns in the symbol in the data region (excluding start, stop and
* row indicator codewords)
* @return the number of rows in the symbol (r)
*/
private static int calculateNumberOfRows(int m, int k, int c) {
int r = ((m + 1 + k) / c) + 1;
if (c * r >= (m + 1 + k + c)) {
r--;
}
return r;
}
/**
* Calculates the number of pad codewords as described in 4.9.2 of ISO/IEC 15438:2001(E).
*
* @param m the number of source codewords prior to the additional of the Symbol Length
* Descriptor and any pad codewords
* @param k the number of error correction codewords
* @param c the number of columns in the symbol in the data region (excluding start, stop and
* row indicator codewords)
* @param r the number of rows in the symbol
* @return the number of pad codewords
*/
private static int getNumberOfPadCodewords(int m, int k, int c, int r) {
int n = c * r - k;
return n > m + 1 ? n - m - 1 : 0;
}
|
private static void encodeChar(int pattern, int len, BarcodeRow logic) {
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.