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
lisicnu/Log4Android
src/main/java/com/github/lisicnu/log4android/format/command/DateFormatCommand.java
// Path: src/main/java/com/github/lisicnu/log4android/Level.java // public enum Level { // FATAL(Level.FATAL_INT), // ERROR(Level.ERROR_INT), // WARN(Level.WARN_INT), // INFO(Level.INFO_INT), // DEBUG(Level.DEBUG_INT), // TRACE(Level.TRACE_INT), // OFF(Level.OFF_INT); // // public static final int FATAL_INT = 16; // public static final int ERROR_INT = 8; // public static final int WARN_INT = 4; // public static final int INFO_INT = 2; // public static final int DEBUG_INT = 1; // public static final int TRACE_INT = 0; // public static final int OFF_INT = -1; // // private final int levelValue; // // private Level(final int levelValue) { // this.levelValue = levelValue; // } // // public int toInt() { // return levelValue; // } // // public String toString() { // return this.name(); // } // }
import android.util.Log; import com.github.lisicnu.log4android.Level; import java.util.Calendar; import java.util.Date;
/* * Copyright 2009 The MicroLog project @sourceforge.net * 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.github.lisicnu.log4android.format.command; /** * This class is used for formatting dates. * * Minimum requirements; CLDC 1.0 * * @author Johan Karlsson (johan.karlsson@jayway.se) * */ public class DateFormatCommand implements FormatCommandInterface { private static final String TAG = DateFormatCommand.class.getSimpleName(); public static int USER_FORMAT = 0; public final static int ABSOLUTE_FORMAT = 1; public final static int DATE_FORMAT = 2; public final static int ISO_8601_FORMAT = 3; public final static String ABSOLUTE_FORMAT_STRING = "ABSOLUTE"; public final static String DATE_FORMAT_STRING = "DATE"; public final static String ISO_8601_FORMAT_STRING = "ISO8601"; final static String[] MONTH_ARRAY = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; private final Calendar calendar = Calendar.getInstance(); int format = ISO_8601_FORMAT; /** * @see com.github.lisicnu.log4android.format.command.FormatCommandInterface#execute(String, * String, long, com.github.lisicnu.log4android.Level, * Object, Throwable) */
// Path: src/main/java/com/github/lisicnu/log4android/Level.java // public enum Level { // FATAL(Level.FATAL_INT), // ERROR(Level.ERROR_INT), // WARN(Level.WARN_INT), // INFO(Level.INFO_INT), // DEBUG(Level.DEBUG_INT), // TRACE(Level.TRACE_INT), // OFF(Level.OFF_INT); // // public static final int FATAL_INT = 16; // public static final int ERROR_INT = 8; // public static final int WARN_INT = 4; // public static final int INFO_INT = 2; // public static final int DEBUG_INT = 1; // public static final int TRACE_INT = 0; // public static final int OFF_INT = -1; // // private final int levelValue; // // private Level(final int levelValue) { // this.levelValue = levelValue; // } // // public int toInt() { // return levelValue; // } // // public String toString() { // return this.name(); // } // } // Path: src/main/java/com/github/lisicnu/log4android/format/command/DateFormatCommand.java import android.util.Log; import com.github.lisicnu.log4android.Level; import java.util.Calendar; import java.util.Date; /* * Copyright 2009 The MicroLog project @sourceforge.net * 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.github.lisicnu.log4android.format.command; /** * This class is used for formatting dates. * * Minimum requirements; CLDC 1.0 * * @author Johan Karlsson (johan.karlsson@jayway.se) * */ public class DateFormatCommand implements FormatCommandInterface { private static final String TAG = DateFormatCommand.class.getSimpleName(); public static int USER_FORMAT = 0; public final static int ABSOLUTE_FORMAT = 1; public final static int DATE_FORMAT = 2; public final static int ISO_8601_FORMAT = 3; public final static String ABSOLUTE_FORMAT_STRING = "ABSOLUTE"; public final static String DATE_FORMAT_STRING = "DATE"; public final static String ISO_8601_FORMAT_STRING = "ISO8601"; final static String[] MONTH_ARRAY = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; private final Calendar calendar = Calendar.getInstance(); int format = ISO_8601_FORMAT; /** * @see com.github.lisicnu.log4android.format.command.FormatCommandInterface#execute(String, * String, long, com.github.lisicnu.log4android.Level, * Object, Throwable) */
public String execute(String clientID, String name, long time, Level level, Object message,
lisicnu/Log4Android
src/main/java/com/github/lisicnu/log4android/format/command/MessageFormatCommand.java
// Path: src/main/java/com/github/lisicnu/log4android/Level.java // public enum Level { // FATAL(Level.FATAL_INT), // ERROR(Level.ERROR_INT), // WARN(Level.WARN_INT), // INFO(Level.INFO_INT), // DEBUG(Level.DEBUG_INT), // TRACE(Level.TRACE_INT), // OFF(Level.OFF_INT); // // public static final int FATAL_INT = 16; // public static final int ERROR_INT = 8; // public static final int WARN_INT = 4; // public static final int INFO_INT = 2; // public static final int DEBUG_INT = 1; // public static final int TRACE_INT = 0; // public static final int OFF_INT = -1; // // private final int levelValue; // // private Level(final int levelValue) { // this.levelValue = levelValue; // } // // public int toInt() { // return levelValue; // } // // public String toString() { // return this.name(); // } // }
import com.github.lisicnu.log4android.Level;
/* * Copyright 2008 The Microlog project @sourceforge.net * 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.github.lisicnu.log4android.format.command; /** * Convert the logged message. * * @author Johan Karlsson (johan.karlsson@jayway.se) */ public class MessageFormatCommand implements FormatCommandInterface { /** * @see com.github.lisicnu.log4android.format.command.FormatCommandInterface#init(String) */ public void init(String initString){ // Do nothing on purpose. } /** * @see com.github.lisicnu.log4android.format.command.FormatCommandInterface#execute(String, * String, long, com.github.lisicnu.log4android.Level, Object, * Throwable) */
// Path: src/main/java/com/github/lisicnu/log4android/Level.java // public enum Level { // FATAL(Level.FATAL_INT), // ERROR(Level.ERROR_INT), // WARN(Level.WARN_INT), // INFO(Level.INFO_INT), // DEBUG(Level.DEBUG_INT), // TRACE(Level.TRACE_INT), // OFF(Level.OFF_INT); // // public static final int FATAL_INT = 16; // public static final int ERROR_INT = 8; // public static final int WARN_INT = 4; // public static final int INFO_INT = 2; // public static final int DEBUG_INT = 1; // public static final int TRACE_INT = 0; // public static final int OFF_INT = -1; // // private final int levelValue; // // private Level(final int levelValue) { // this.levelValue = levelValue; // } // // public int toInt() { // return levelValue; // } // // public String toString() { // return this.name(); // } // } // Path: src/main/java/com/github/lisicnu/log4android/format/command/MessageFormatCommand.java import com.github.lisicnu.log4android.Level; /* * Copyright 2008 The Microlog project @sourceforge.net * 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.github.lisicnu.log4android.format.command; /** * Convert the logged message. * * @author Johan Karlsson (johan.karlsson@jayway.se) */ public class MessageFormatCommand implements FormatCommandInterface { /** * @see com.github.lisicnu.log4android.format.command.FormatCommandInterface#init(String) */ public void init(String initString){ // Do nothing on purpose. } /** * @see com.github.lisicnu.log4android.format.command.FormatCommandInterface#execute(String, * String, long, com.github.lisicnu.log4android.Level, Object, * Throwable) */
public String execute(String clientID, String name, long time, Level level,
lisicnu/Log4Android
src/main/java/com/github/lisicnu/log4android/format/command/NoFormatCommand.java
// Path: src/main/java/com/github/lisicnu/log4android/Level.java // public enum Level { // FATAL(Level.FATAL_INT), // ERROR(Level.ERROR_INT), // WARN(Level.WARN_INT), // INFO(Level.INFO_INT), // DEBUG(Level.DEBUG_INT), // TRACE(Level.TRACE_INT), // OFF(Level.OFF_INT); // // public static final int FATAL_INT = 16; // public static final int ERROR_INT = 8; // public static final int WARN_INT = 4; // public static final int INFO_INT = 2; // public static final int DEBUG_INT = 1; // public static final int TRACE_INT = 0; // public static final int OFF_INT = -1; // // private final int levelValue; // // private Level(final int levelValue) { // this.levelValue = levelValue; // } // // public int toInt() { // return levelValue; // } // // public String toString() { // return this.name(); // } // }
import com.github.lisicnu.log4android.Level;
/* * Copyright 2008 The Microlog project @sourceforge.net * 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.github.lisicnu.log4android.format.command; /** * This command does not do any formatting. It just stores the * <code>preFormatString</code> and returns it. * * @author Johan Karlsson (johan.karlsson@jayway.se) */ public class NoFormatCommand implements FormatCommandInterface { private String preFormatString = ""; /** * @see com.github.lisicnu.log4android.format.command.FormatCommandInterface#init(String) */ public void init(String preFormatString){ this.preFormatString = preFormatString; } /** * Convert, i.e. return the <code>preFormatString</code>. * * @see com.github.lisicnu.log4android.format.command.FormatCommandInterface#execute(String, * String, long, com.github.lisicnu.log4android.Level, Object, * Throwable) */
// Path: src/main/java/com/github/lisicnu/log4android/Level.java // public enum Level { // FATAL(Level.FATAL_INT), // ERROR(Level.ERROR_INT), // WARN(Level.WARN_INT), // INFO(Level.INFO_INT), // DEBUG(Level.DEBUG_INT), // TRACE(Level.TRACE_INT), // OFF(Level.OFF_INT); // // public static final int FATAL_INT = 16; // public static final int ERROR_INT = 8; // public static final int WARN_INT = 4; // public static final int INFO_INT = 2; // public static final int DEBUG_INT = 1; // public static final int TRACE_INT = 0; // public static final int OFF_INT = -1; // // private final int levelValue; // // private Level(final int levelValue) { // this.levelValue = levelValue; // } // // public int toInt() { // return levelValue; // } // // public String toString() { // return this.name(); // } // } // Path: src/main/java/com/github/lisicnu/log4android/format/command/NoFormatCommand.java import com.github.lisicnu.log4android.Level; /* * Copyright 2008 The Microlog project @sourceforge.net * 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.github.lisicnu.log4android.format.command; /** * This command does not do any formatting. It just stores the * <code>preFormatString</code> and returns it. * * @author Johan Karlsson (johan.karlsson@jayway.se) */ public class NoFormatCommand implements FormatCommandInterface { private String preFormatString = ""; /** * @see com.github.lisicnu.log4android.format.command.FormatCommandInterface#init(String) */ public void init(String preFormatString){ this.preFormatString = preFormatString; } /** * Convert, i.e. return the <code>preFormatString</code>. * * @see com.github.lisicnu.log4android.format.command.FormatCommandInterface#execute(String, * String, long, com.github.lisicnu.log4android.Level, Object, * Throwable) */
public String execute(String clientID, String name, long time, Level level,
lisicnu/Log4Android
src/main/java/com/github/lisicnu/log4android/appender/SyslogAppender.java
// Path: src/main/java/com/github/lisicnu/log4android/Level.java // public enum Level { // FATAL(Level.FATAL_INT), // ERROR(Level.ERROR_INT), // WARN(Level.WARN_INT), // INFO(Level.INFO_INT), // DEBUG(Level.DEBUG_INT), // TRACE(Level.TRACE_INT), // OFF(Level.OFF_INT); // // public static final int FATAL_INT = 16; // public static final int ERROR_INT = 8; // public static final int WARN_INT = 4; // public static final int INFO_INT = 2; // public static final int DEBUG_INT = 1; // public static final int TRACE_INT = 0; // public static final int OFF_INT = -1; // // private final int levelValue; // // private Level(final int levelValue) { // this.levelValue = levelValue; // } // // public int toInt() { // return levelValue; // } // // public String toString() { // return this.name(); // } // }
import com.github.lisicnu.log4android.Level;
/** * */ package com.github.lisicnu.log4android.appender; /** * * @author Johan Karlsson * */ public class SyslogAppender extends DatagramAppender { private SyslogMessage syslogMessage = new SyslogMessage(); public SyslogAppender(){ super.setPort(SyslogMessage.DEFAULT_SYSLOG_PORT); syslogMessage.setTag(SyslogMessage.DEFAULT_SYSLOG_TAG); syslogMessage.setFacility(SyslogMessage.FACILITY_USER_LEVEL_MESSAGE); syslogMessage.setSeverity(SyslogMessage.SEVERITY_DEBUG); } /** * Do the logging. * @param level * the level to use for the logging. * @param message * the message to log. * @param t * the exception to log. */
// Path: src/main/java/com/github/lisicnu/log4android/Level.java // public enum Level { // FATAL(Level.FATAL_INT), // ERROR(Level.ERROR_INT), // WARN(Level.WARN_INT), // INFO(Level.INFO_INT), // DEBUG(Level.DEBUG_INT), // TRACE(Level.TRACE_INT), // OFF(Level.OFF_INT); // // public static final int FATAL_INT = 16; // public static final int ERROR_INT = 8; // public static final int WARN_INT = 4; // public static final int INFO_INT = 2; // public static final int DEBUG_INT = 1; // public static final int TRACE_INT = 0; // public static final int OFF_INT = -1; // // private final int levelValue; // // private Level(final int levelValue) { // this.levelValue = levelValue; // } // // public int toInt() { // return levelValue; // } // // public String toString() { // return this.name(); // } // } // Path: src/main/java/com/github/lisicnu/log4android/appender/SyslogAppender.java import com.github.lisicnu.log4android.Level; /** * */ package com.github.lisicnu.log4android.appender; /** * * @author Johan Karlsson * */ public class SyslogAppender extends DatagramAppender { private SyslogMessage syslogMessage = new SyslogMessage(); public SyslogAppender(){ super.setPort(SyslogMessage.DEFAULT_SYSLOG_PORT); syslogMessage.setTag(SyslogMessage.DEFAULT_SYSLOG_TAG); syslogMessage.setFacility(SyslogMessage.FACILITY_USER_LEVEL_MESSAGE); syslogMessage.setSeverity(SyslogMessage.SEVERITY_DEBUG); } /** * Do the logging. * @param level * the level to use for the logging. * @param message * the message to log. * @param t * the exception to log. */
public void doLog(String clientID, String name, long time, Level level,
lisicnu/Log4Android
src/main/java/com/github/lisicnu/log4android/appender/FileAppender.java
// Path: src/main/java/com/github/lisicnu/log4android/Level.java // public enum Level { // FATAL(Level.FATAL_INT), // ERROR(Level.ERROR_INT), // WARN(Level.WARN_INT), // INFO(Level.INFO_INT), // DEBUG(Level.DEBUG_INT), // TRACE(Level.TRACE_INT), // OFF(Level.OFF_INT); // // public static final int FATAL_INT = 16; // public static final int ERROR_INT = 8; // public static final int WARN_INT = 4; // public static final int INFO_INT = 2; // public static final int DEBUG_INT = 1; // public static final int TRACE_INT = 0; // public static final int OFF_INT = -1; // // private final int levelValue; // // private Level(final int levelValue) { // this.levelValue = levelValue; // } // // public int toInt() { // return levelValue; // } // // public String toString() { // return this.name(); // } // }
import android.content.Context; import android.os.Build; import android.os.Environment; import android.util.Log; import com.github.lisicnu.log4android.Level; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Random;
FileOutputStream fileOutputStream = new FileOutputStream(logFile, wraper.appendFile); writer = new PrintWriter(fileOutputStream); writer.println("\r\n##########################################################\r\n"); logOpen = true; } String curLogFile = ""; public String getCurLogFile() { return curLogFile; } @Override public void clear() { throw new UnsupportedOperationException(); } @Override public synchronized void close() throws IOException { Log.i(TAG, "Closing the FileAppender"); if (writer != null) { writer.close(); } } @Override
// Path: src/main/java/com/github/lisicnu/log4android/Level.java // public enum Level { // FATAL(Level.FATAL_INT), // ERROR(Level.ERROR_INT), // WARN(Level.WARN_INT), // INFO(Level.INFO_INT), // DEBUG(Level.DEBUG_INT), // TRACE(Level.TRACE_INT), // OFF(Level.OFF_INT); // // public static final int FATAL_INT = 16; // public static final int ERROR_INT = 8; // public static final int WARN_INT = 4; // public static final int INFO_INT = 2; // public static final int DEBUG_INT = 1; // public static final int TRACE_INT = 0; // public static final int OFF_INT = -1; // // private final int levelValue; // // private Level(final int levelValue) { // this.levelValue = levelValue; // } // // public int toInt() { // return levelValue; // } // // public String toString() { // return this.name(); // } // } // Path: src/main/java/com/github/lisicnu/log4android/appender/FileAppender.java import android.content.Context; import android.os.Build; import android.os.Environment; import android.util.Log; import com.github.lisicnu.log4android.Level; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Random; FileOutputStream fileOutputStream = new FileOutputStream(logFile, wraper.appendFile); writer = new PrintWriter(fileOutputStream); writer.println("\r\n##########################################################\r\n"); logOpen = true; } String curLogFile = ""; public String getCurLogFile() { return curLogFile; } @Override public void clear() { throw new UnsupportedOperationException(); } @Override public synchronized void close() throws IOException { Log.i(TAG, "Closing the FileAppender"); if (writer != null) { writer.close(); } } @Override
public synchronized void doLog(String clientID, String name, long time, Level level,
lisicnu/Log4Android
src/main/java/com/github/lisicnu/log4android/Logger.java
// Path: src/main/java/com/github/lisicnu/log4android/appender/Appender.java // public interface Appender { // // /** // * Size returned if log size cannot be determined. // */ // int SIZE_UNDEFINED = -1; // // /** // * Do the logging. // * // * @param clientID // * the id of the client. // * @param name // * the name of the logger. // * @param time // * the time since the first logging has done (in milliseconds). // * @param level // * the logging level // * @param message // * the message to log. // * @param t // * the exception to log. // */ // void doLog(String clientID, String name, long time, Level level, Object message, Throwable t); // // /** // * Clear the log. // */ // void clear(); // // /** // * Close the log. The consequence is that the logging is disabled until the // * log is opened. The logging could be enabled by calling // * <code>open()</code>. // * // * @throws java.io.IOException // * if the close failed. // */ // void close() throws IOException; // // /** // * Open the log. The consequence is that the logging is enabled. // * // * @throws java.io.IOException // * if the open failed. // * // */ // void open() throws IOException; // // /** // * Check if the log is open. // * // * @return true if the log is open, false otherwise. // */ // boolean isLogOpen(); // // /** // * Get the size of the log. This may not be applicable to all types of // * appenders. // * // * @return the size of the log. // */ // long getLogSize(); // // /** // * Set the formatter to use. // * // * @param formatter // * The formatter to set. // */ // void setFormatter(Formatter formatter); // // /** // * Get the formatter that is in use. // * // * @return Returns the formatter. // */ // Formatter getFormatter(); // // } // // Path: src/main/java/com/github/lisicnu/log4android/factory/DefaultAppenderFactory.java // public enum DefaultAppenderFactory { // ; // // public static Appender createDefaultAppender() { // Appender appender = new LogCatAppender(); // appender.setFormatter(new PatternFormatter()); // // return appender; // } // } // // Path: src/main/java/com/github/lisicnu/log4android/repository/CommonLoggerRepository.java // public interface CommonLoggerRepository { // /** // * Get the effective level for the specified logger. Note that the level of // * the current logger is not checked, since this level could be get from the // * logger itself. // * // * @return the effective <code>Level</code> // */ // public Level getEffectiveLevel(String loggerName); // }
import android.util.Log; import com.github.lisicnu.log4android.appender.Appender; import com.github.lisicnu.log4android.factory.DefaultAppenderFactory; import com.github.lisicnu.log4android.repository.CommonLoggerRepository; import java.io.IOException; import java.util.List; import java.util.ListIterator; import java.util.Vector;
/* * Copyright 2008 The Microlog project @sourceforge.net * 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.github.lisicnu.log4android; /** * The <code>Logger</code> class is used for logging. * <p/> * This is similar to the Log4j <code>Logger</code> class. The method names are * the same, but we do not claim that they are 100% compatible. * <p/> * You have the ability to use named loggers as in Log4j. If you want to save * memory, you could use unnamed loggers. * * @author Johan Karlsson (johan.karlsson@jayway.se) * @author Darius Katz * @author Karsten Ohme * @since 0.1 */ public final class Logger { public static final Level DEFAULT_LOG_LEVEL = Level.DEBUG; public static final String DEFAULT_CLIENT_ID = "Microlog"; private String clientID = DEFAULT_CLIENT_ID; private static final String TAG = Logger.class.getSimpleName(); private static final StopWatch stopWatch = new StopWatch();
// Path: src/main/java/com/github/lisicnu/log4android/appender/Appender.java // public interface Appender { // // /** // * Size returned if log size cannot be determined. // */ // int SIZE_UNDEFINED = -1; // // /** // * Do the logging. // * // * @param clientID // * the id of the client. // * @param name // * the name of the logger. // * @param time // * the time since the first logging has done (in milliseconds). // * @param level // * the logging level // * @param message // * the message to log. // * @param t // * the exception to log. // */ // void doLog(String clientID, String name, long time, Level level, Object message, Throwable t); // // /** // * Clear the log. // */ // void clear(); // // /** // * Close the log. The consequence is that the logging is disabled until the // * log is opened. The logging could be enabled by calling // * <code>open()</code>. // * // * @throws java.io.IOException // * if the close failed. // */ // void close() throws IOException; // // /** // * Open the log. The consequence is that the logging is enabled. // * // * @throws java.io.IOException // * if the open failed. // * // */ // void open() throws IOException; // // /** // * Check if the log is open. // * // * @return true if the log is open, false otherwise. // */ // boolean isLogOpen(); // // /** // * Get the size of the log. This may not be applicable to all types of // * appenders. // * // * @return the size of the log. // */ // long getLogSize(); // // /** // * Set the formatter to use. // * // * @param formatter // * The formatter to set. // */ // void setFormatter(Formatter formatter); // // /** // * Get the formatter that is in use. // * // * @return Returns the formatter. // */ // Formatter getFormatter(); // // } // // Path: src/main/java/com/github/lisicnu/log4android/factory/DefaultAppenderFactory.java // public enum DefaultAppenderFactory { // ; // // public static Appender createDefaultAppender() { // Appender appender = new LogCatAppender(); // appender.setFormatter(new PatternFormatter()); // // return appender; // } // } // // Path: src/main/java/com/github/lisicnu/log4android/repository/CommonLoggerRepository.java // public interface CommonLoggerRepository { // /** // * Get the effective level for the specified logger. Note that the level of // * the current logger is not checked, since this level could be get from the // * logger itself. // * // * @return the effective <code>Level</code> // */ // public Level getEffectiveLevel(String loggerName); // } // Path: src/main/java/com/github/lisicnu/log4android/Logger.java import android.util.Log; import com.github.lisicnu.log4android.appender.Appender; import com.github.lisicnu.log4android.factory.DefaultAppenderFactory; import com.github.lisicnu.log4android.repository.CommonLoggerRepository; import java.io.IOException; import java.util.List; import java.util.ListIterator; import java.util.Vector; /* * Copyright 2008 The Microlog project @sourceforge.net * 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.github.lisicnu.log4android; /** * The <code>Logger</code> class is used for logging. * <p/> * This is similar to the Log4j <code>Logger</code> class. The method names are * the same, but we do not claim that they are 100% compatible. * <p/> * You have the ability to use named loggers as in Log4j. If you want to save * memory, you could use unnamed loggers. * * @author Johan Karlsson (johan.karlsson@jayway.se) * @author Darius Katz * @author Karsten Ohme * @since 0.1 */ public final class Logger { public static final Level DEFAULT_LOG_LEVEL = Level.DEBUG; public static final String DEFAULT_CLIENT_ID = "Microlog"; private String clientID = DEFAULT_CLIENT_ID; private static final String TAG = Logger.class.getSimpleName(); private static final StopWatch stopWatch = new StopWatch();
private final static List<Appender> appenderList = new Vector<Appender>(4);
lisicnu/Log4Android
src/main/java/com/github/lisicnu/log4android/Logger.java
// Path: src/main/java/com/github/lisicnu/log4android/appender/Appender.java // public interface Appender { // // /** // * Size returned if log size cannot be determined. // */ // int SIZE_UNDEFINED = -1; // // /** // * Do the logging. // * // * @param clientID // * the id of the client. // * @param name // * the name of the logger. // * @param time // * the time since the first logging has done (in milliseconds). // * @param level // * the logging level // * @param message // * the message to log. // * @param t // * the exception to log. // */ // void doLog(String clientID, String name, long time, Level level, Object message, Throwable t); // // /** // * Clear the log. // */ // void clear(); // // /** // * Close the log. The consequence is that the logging is disabled until the // * log is opened. The logging could be enabled by calling // * <code>open()</code>. // * // * @throws java.io.IOException // * if the close failed. // */ // void close() throws IOException; // // /** // * Open the log. The consequence is that the logging is enabled. // * // * @throws java.io.IOException // * if the open failed. // * // */ // void open() throws IOException; // // /** // * Check if the log is open. // * // * @return true if the log is open, false otherwise. // */ // boolean isLogOpen(); // // /** // * Get the size of the log. This may not be applicable to all types of // * appenders. // * // * @return the size of the log. // */ // long getLogSize(); // // /** // * Set the formatter to use. // * // * @param formatter // * The formatter to set. // */ // void setFormatter(Formatter formatter); // // /** // * Get the formatter that is in use. // * // * @return Returns the formatter. // */ // Formatter getFormatter(); // // } // // Path: src/main/java/com/github/lisicnu/log4android/factory/DefaultAppenderFactory.java // public enum DefaultAppenderFactory { // ; // // public static Appender createDefaultAppender() { // Appender appender = new LogCatAppender(); // appender.setFormatter(new PatternFormatter()); // // return appender; // } // } // // Path: src/main/java/com/github/lisicnu/log4android/repository/CommonLoggerRepository.java // public interface CommonLoggerRepository { // /** // * Get the effective level for the specified logger. Note that the level of // * the current logger is not checked, since this level could be get from the // * logger itself. // * // * @return the effective <code>Level</code> // */ // public Level getEffectiveLevel(String loggerName); // }
import android.util.Log; import com.github.lisicnu.log4android.appender.Appender; import com.github.lisicnu.log4android.factory.DefaultAppenderFactory; import com.github.lisicnu.log4android.repository.CommonLoggerRepository; import java.io.IOException; import java.util.List; import java.util.ListIterator; import java.util.Vector;
/* * Copyright 2008 The Microlog project @sourceforge.net * 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.github.lisicnu.log4android; /** * The <code>Logger</code> class is used for logging. * <p/> * This is similar to the Log4j <code>Logger</code> class. The method names are * the same, but we do not claim that they are 100% compatible. * <p/> * You have the ability to use named loggers as in Log4j. If you want to save * memory, you could use unnamed loggers. * * @author Johan Karlsson (johan.karlsson@jayway.se) * @author Darius Katz * @author Karsten Ohme * @since 0.1 */ public final class Logger { public static final Level DEFAULT_LOG_LEVEL = Level.DEBUG; public static final String DEFAULT_CLIENT_ID = "Microlog"; private String clientID = DEFAULT_CLIENT_ID; private static final String TAG = Logger.class.getSimpleName(); private static final StopWatch stopWatch = new StopWatch(); private final static List<Appender> appenderList = new Vector<Appender>(4); private static boolean firstLogEvent = true;
// Path: src/main/java/com/github/lisicnu/log4android/appender/Appender.java // public interface Appender { // // /** // * Size returned if log size cannot be determined. // */ // int SIZE_UNDEFINED = -1; // // /** // * Do the logging. // * // * @param clientID // * the id of the client. // * @param name // * the name of the logger. // * @param time // * the time since the first logging has done (in milliseconds). // * @param level // * the logging level // * @param message // * the message to log. // * @param t // * the exception to log. // */ // void doLog(String clientID, String name, long time, Level level, Object message, Throwable t); // // /** // * Clear the log. // */ // void clear(); // // /** // * Close the log. The consequence is that the logging is disabled until the // * log is opened. The logging could be enabled by calling // * <code>open()</code>. // * // * @throws java.io.IOException // * if the close failed. // */ // void close() throws IOException; // // /** // * Open the log. The consequence is that the logging is enabled. // * // * @throws java.io.IOException // * if the open failed. // * // */ // void open() throws IOException; // // /** // * Check if the log is open. // * // * @return true if the log is open, false otherwise. // */ // boolean isLogOpen(); // // /** // * Get the size of the log. This may not be applicable to all types of // * appenders. // * // * @return the size of the log. // */ // long getLogSize(); // // /** // * Set the formatter to use. // * // * @param formatter // * The formatter to set. // */ // void setFormatter(Formatter formatter); // // /** // * Get the formatter that is in use. // * // * @return Returns the formatter. // */ // Formatter getFormatter(); // // } // // Path: src/main/java/com/github/lisicnu/log4android/factory/DefaultAppenderFactory.java // public enum DefaultAppenderFactory { // ; // // public static Appender createDefaultAppender() { // Appender appender = new LogCatAppender(); // appender.setFormatter(new PatternFormatter()); // // return appender; // } // } // // Path: src/main/java/com/github/lisicnu/log4android/repository/CommonLoggerRepository.java // public interface CommonLoggerRepository { // /** // * Get the effective level for the specified logger. Note that the level of // * the current logger is not checked, since this level could be get from the // * logger itself. // * // * @return the effective <code>Level</code> // */ // public Level getEffectiveLevel(String loggerName); // } // Path: src/main/java/com/github/lisicnu/log4android/Logger.java import android.util.Log; import com.github.lisicnu.log4android.appender.Appender; import com.github.lisicnu.log4android.factory.DefaultAppenderFactory; import com.github.lisicnu.log4android.repository.CommonLoggerRepository; import java.io.IOException; import java.util.List; import java.util.ListIterator; import java.util.Vector; /* * Copyright 2008 The Microlog project @sourceforge.net * 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.github.lisicnu.log4android; /** * The <code>Logger</code> class is used for logging. * <p/> * This is similar to the Log4j <code>Logger</code> class. The method names are * the same, but we do not claim that they are 100% compatible. * <p/> * You have the ability to use named loggers as in Log4j. If you want to save * memory, you could use unnamed loggers. * * @author Johan Karlsson (johan.karlsson@jayway.se) * @author Darius Katz * @author Karsten Ohme * @since 0.1 */ public final class Logger { public static final Level DEFAULT_LOG_LEVEL = Level.DEBUG; public static final String DEFAULT_CLIENT_ID = "Microlog"; private String clientID = DEFAULT_CLIENT_ID; private static final String TAG = Logger.class.getSimpleName(); private static final StopWatch stopWatch = new StopWatch(); private final static List<Appender> appenderList = new Vector<Appender>(4); private static boolean firstLogEvent = true;
private CommonLoggerRepository commonLoggerRepository = null;
lisicnu/Log4Android
src/main/java/com/github/lisicnu/log4android/Logger.java
// Path: src/main/java/com/github/lisicnu/log4android/appender/Appender.java // public interface Appender { // // /** // * Size returned if log size cannot be determined. // */ // int SIZE_UNDEFINED = -1; // // /** // * Do the logging. // * // * @param clientID // * the id of the client. // * @param name // * the name of the logger. // * @param time // * the time since the first logging has done (in milliseconds). // * @param level // * the logging level // * @param message // * the message to log. // * @param t // * the exception to log. // */ // void doLog(String clientID, String name, long time, Level level, Object message, Throwable t); // // /** // * Clear the log. // */ // void clear(); // // /** // * Close the log. The consequence is that the logging is disabled until the // * log is opened. The logging could be enabled by calling // * <code>open()</code>. // * // * @throws java.io.IOException // * if the close failed. // */ // void close() throws IOException; // // /** // * Open the log. The consequence is that the logging is enabled. // * // * @throws java.io.IOException // * if the open failed. // * // */ // void open() throws IOException; // // /** // * Check if the log is open. // * // * @return true if the log is open, false otherwise. // */ // boolean isLogOpen(); // // /** // * Get the size of the log. This may not be applicable to all types of // * appenders. // * // * @return the size of the log. // */ // long getLogSize(); // // /** // * Set the formatter to use. // * // * @param formatter // * The formatter to set. // */ // void setFormatter(Formatter formatter); // // /** // * Get the formatter that is in use. // * // * @return Returns the formatter. // */ // Formatter getFormatter(); // // } // // Path: src/main/java/com/github/lisicnu/log4android/factory/DefaultAppenderFactory.java // public enum DefaultAppenderFactory { // ; // // public static Appender createDefaultAppender() { // Appender appender = new LogCatAppender(); // appender.setFormatter(new PatternFormatter()); // // return appender; // } // } // // Path: src/main/java/com/github/lisicnu/log4android/repository/CommonLoggerRepository.java // public interface CommonLoggerRepository { // /** // * Get the effective level for the specified logger. Note that the level of // * the current logger is not checked, since this level could be get from the // * logger itself. // * // * @return the effective <code>Level</code> // */ // public Level getEffectiveLevel(String loggerName); // }
import android.util.Log; import com.github.lisicnu.log4android.appender.Appender; import com.github.lisicnu.log4android.factory.DefaultAppenderFactory; import com.github.lisicnu.log4android.repository.CommonLoggerRepository; import java.io.IOException; import java.util.List; import java.util.ListIterator; import java.util.Vector;
} if (getEffectiveLevel().toInt() <= level.toInt() && level.toInt() > Level.OFF_INT) { if (firstLogEvent == true) { addDefaultAppender(); try { open(); } catch (IOException e) { Log.e(TAG, "Failed to open the log. " + e); } stopWatch.start(); firstLogEvent = false; } ListIterator<Appender> ite = appenderList.listIterator(); while (ite.hasNext()) { Appender appender = ite.next(); if (appender != null) appender.doLog(clientID, name, stopWatch.getCurrentTime(), level, message, t); } } } private void addDefaultAppender() { if (appenderList.size() == 0) { Log.w(TAG, "Warning! No appender is set, using LogCatAppender with PatternFormatter " + "or not =" + isAddDefaultLogger()); if (isAddDefaultLogger()) {
// Path: src/main/java/com/github/lisicnu/log4android/appender/Appender.java // public interface Appender { // // /** // * Size returned if log size cannot be determined. // */ // int SIZE_UNDEFINED = -1; // // /** // * Do the logging. // * // * @param clientID // * the id of the client. // * @param name // * the name of the logger. // * @param time // * the time since the first logging has done (in milliseconds). // * @param level // * the logging level // * @param message // * the message to log. // * @param t // * the exception to log. // */ // void doLog(String clientID, String name, long time, Level level, Object message, Throwable t); // // /** // * Clear the log. // */ // void clear(); // // /** // * Close the log. The consequence is that the logging is disabled until the // * log is opened. The logging could be enabled by calling // * <code>open()</code>. // * // * @throws java.io.IOException // * if the close failed. // */ // void close() throws IOException; // // /** // * Open the log. The consequence is that the logging is enabled. // * // * @throws java.io.IOException // * if the open failed. // * // */ // void open() throws IOException; // // /** // * Check if the log is open. // * // * @return true if the log is open, false otherwise. // */ // boolean isLogOpen(); // // /** // * Get the size of the log. This may not be applicable to all types of // * appenders. // * // * @return the size of the log. // */ // long getLogSize(); // // /** // * Set the formatter to use. // * // * @param formatter // * The formatter to set. // */ // void setFormatter(Formatter formatter); // // /** // * Get the formatter that is in use. // * // * @return Returns the formatter. // */ // Formatter getFormatter(); // // } // // Path: src/main/java/com/github/lisicnu/log4android/factory/DefaultAppenderFactory.java // public enum DefaultAppenderFactory { // ; // // public static Appender createDefaultAppender() { // Appender appender = new LogCatAppender(); // appender.setFormatter(new PatternFormatter()); // // return appender; // } // } // // Path: src/main/java/com/github/lisicnu/log4android/repository/CommonLoggerRepository.java // public interface CommonLoggerRepository { // /** // * Get the effective level for the specified logger. Note that the level of // * the current logger is not checked, since this level could be get from the // * logger itself. // * // * @return the effective <code>Level</code> // */ // public Level getEffectiveLevel(String loggerName); // } // Path: src/main/java/com/github/lisicnu/log4android/Logger.java import android.util.Log; import com.github.lisicnu.log4android.appender.Appender; import com.github.lisicnu.log4android.factory.DefaultAppenderFactory; import com.github.lisicnu.log4android.repository.CommonLoggerRepository; import java.io.IOException; import java.util.List; import java.util.ListIterator; import java.util.Vector; } if (getEffectiveLevel().toInt() <= level.toInt() && level.toInt() > Level.OFF_INT) { if (firstLogEvent == true) { addDefaultAppender(); try { open(); } catch (IOException e) { Log.e(TAG, "Failed to open the log. " + e); } stopWatch.start(); firstLogEvent = false; } ListIterator<Appender> ite = appenderList.listIterator(); while (ite.hasNext()) { Appender appender = ite.next(); if (appender != null) appender.doLog(clientID, name, stopWatch.getCurrentTime(), level, message, t); } } } private void addDefaultAppender() { if (appenderList.size() == 0) { Log.w(TAG, "Warning! No appender is set, using LogCatAppender with PatternFormatter " + "or not =" + isAddDefaultLogger()); if (isAddDefaultLogger()) {
Appender appender = DefaultAppenderFactory.createDefaultAppender();
lisicnu/Log4Android
src/main/java/com/github/lisicnu/log4android/format/command/FormatCommandInterface.java
// Path: src/main/java/com/github/lisicnu/log4android/Level.java // public enum Level { // FATAL(Level.FATAL_INT), // ERROR(Level.ERROR_INT), // WARN(Level.WARN_INT), // INFO(Level.INFO_INT), // DEBUG(Level.DEBUG_INT), // TRACE(Level.TRACE_INT), // OFF(Level.OFF_INT); // // public static final int FATAL_INT = 16; // public static final int ERROR_INT = 8; // public static final int WARN_INT = 4; // public static final int INFO_INT = 2; // public static final int DEBUG_INT = 1; // public static final int TRACE_INT = 0; // public static final int OFF_INT = -1; // // private final int levelValue; // // private Level(final int levelValue) { // this.levelValue = levelValue; // } // // public int toInt() { // return levelValue; // } // // public String toString() { // return this.name(); // } // }
import com.github.lisicnu.log4android.Level;
/* * Copyright 2008 The Microlog project @sourceforge.net * 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.github.lisicnu.log4android.format.command; /** * An interface for (pattern) format command objects. * * @author Johan Karlsson (johan.karlsson@jayway.se) */ public interface FormatCommandInterface { /** * Set a <code>String</code> that is not formatted. * * @param initString * the <code>String</code> to be used for initialization. */ public void init(String initString); /** * Set the necessary log data to convert. * * @param clientID * the client id. * @param name * the name of the logger. * @param time * the time since the first logging has done (in milliseconds). * @param level * the log level. * @param message * the log message. * @param throwable * the logged <code>Throwable</code> object. * * @return a converted <code>String</code>. */
// Path: src/main/java/com/github/lisicnu/log4android/Level.java // public enum Level { // FATAL(Level.FATAL_INT), // ERROR(Level.ERROR_INT), // WARN(Level.WARN_INT), // INFO(Level.INFO_INT), // DEBUG(Level.DEBUG_INT), // TRACE(Level.TRACE_INT), // OFF(Level.OFF_INT); // // public static final int FATAL_INT = 16; // public static final int ERROR_INT = 8; // public static final int WARN_INT = 4; // public static final int INFO_INT = 2; // public static final int DEBUG_INT = 1; // public static final int TRACE_INT = 0; // public static final int OFF_INT = -1; // // private final int levelValue; // // private Level(final int levelValue) { // this.levelValue = levelValue; // } // // public int toInt() { // return levelValue; // } // // public String toString() { // return this.name(); // } // } // Path: src/main/java/com/github/lisicnu/log4android/format/command/FormatCommandInterface.java import com.github.lisicnu.log4android.Level; /* * Copyright 2008 The Microlog project @sourceforge.net * 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.github.lisicnu.log4android.format.command; /** * An interface for (pattern) format command objects. * * @author Johan Karlsson (johan.karlsson@jayway.se) */ public interface FormatCommandInterface { /** * Set a <code>String</code> that is not formatted. * * @param initString * the <code>String</code> to be used for initialization. */ public void init(String initString); /** * Set the necessary log data to convert. * * @param clientID * the client id. * @param name * the name of the logger. * @param time * the time since the first logging has done (in milliseconds). * @param level * the log level. * @param message * the log message. * @param throwable * the logged <code>Throwable</code> object. * * @return a converted <code>String</code>. */
public String execute(String clientID, String name, long time, Level level,
lisicnu/Log4Android
src/main/java/com/github/lisicnu/log4android/format/command/ThrowableFormatCommand.java
// Path: src/main/java/com/github/lisicnu/log4android/Level.java // public enum Level { // FATAL(Level.FATAL_INT), // ERROR(Level.ERROR_INT), // WARN(Level.WARN_INT), // INFO(Level.INFO_INT), // DEBUG(Level.DEBUG_INT), // TRACE(Level.TRACE_INT), // OFF(Level.OFF_INT); // // public static final int FATAL_INT = 16; // public static final int ERROR_INT = 8; // public static final int WARN_INT = 4; // public static final int INFO_INT = 2; // public static final int DEBUG_INT = 1; // public static final int TRACE_INT = 0; // public static final int OFF_INT = -1; // // private final int levelValue; // // private Level(final int levelValue) { // this.levelValue = levelValue; // } // // public int toInt() { // return levelValue; // } // // public String toString() { // return this.name(); // } // }
import com.github.lisicnu.log4android.Level;
/* * Copyright 2008 The Microlog project @sourceforge.net * 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.github.lisicnu.log4android.format.command; /** * Converts the <code>Throwable</code> to a message. * * @author Johan Karlsson (johan.karlsson@jayway.se) */ public class ThrowableFormatCommand implements FormatCommandInterface { /** * @see com.github.lisicnu.log4android.format.command.FormatCommandInterface#init(String) */ public void init(String initString){ // Do nothing. } /** * Set the log data. * * @see FormatCommandInterface#execute(String, String, long, Level, Object, * Throwable) */
// Path: src/main/java/com/github/lisicnu/log4android/Level.java // public enum Level { // FATAL(Level.FATAL_INT), // ERROR(Level.ERROR_INT), // WARN(Level.WARN_INT), // INFO(Level.INFO_INT), // DEBUG(Level.DEBUG_INT), // TRACE(Level.TRACE_INT), // OFF(Level.OFF_INT); // // public static final int FATAL_INT = 16; // public static final int ERROR_INT = 8; // public static final int WARN_INT = 4; // public static final int INFO_INT = 2; // public static final int DEBUG_INT = 1; // public static final int TRACE_INT = 0; // public static final int OFF_INT = -1; // // private final int levelValue; // // private Level(final int levelValue) { // this.levelValue = levelValue; // } // // public int toInt() { // return levelValue; // } // // public String toString() { // return this.name(); // } // } // Path: src/main/java/com/github/lisicnu/log4android/format/command/ThrowableFormatCommand.java import com.github.lisicnu.log4android.Level; /* * Copyright 2008 The Microlog project @sourceforge.net * 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.github.lisicnu.log4android.format.command; /** * Converts the <code>Throwable</code> to a message. * * @author Johan Karlsson (johan.karlsson@jayway.se) */ public class ThrowableFormatCommand implements FormatCommandInterface { /** * @see com.github.lisicnu.log4android.format.command.FormatCommandInterface#init(String) */ public void init(String initString){ // Do nothing. } /** * Set the log data. * * @see FormatCommandInterface#execute(String, String, long, Level, Object, * Throwable) */
public String execute(String clientID, String name, long time, Level level,
baloise/rocket-chat-rest-client
src/main/java/com/github/baloise/rocketchatrestclient/RocketChatRestApiV1Settings.java
// Path: src/main/java/com/github/baloise/rocketchatrestclient/model/Setting.java // public class Setting { // private String id; // private Object value; // // @JsonGetter("_id") // public String getId(){ // return id; // } // // @JsonSetter("_id") // public void setId(String id){ // this.id = id; // } // // @JsonGetter("value") // public Object getValue(){ // // if (value instanceof String) { // String _value = (String) value; // if (Boolean.FALSE.toString().equalsIgnoreCase(_value) // || Boolean.TRUE.toString().equalsIgnoreCase(_value)) { // return Boolean.valueOf((String) value); // } // } // // return value; // } // // @JsonSetter("value") // public void setValue(Object value){ // this.value = value; // } // // }
import java.io.IOException; import com.github.baloise.rocketchatrestclient.model.Setting;
package com.github.baloise.rocketchatrestclient; public class RocketChatRestApiV1Settings { private RocketChatClientCallBuilder callBuilder; protected RocketChatRestApiV1Settings(RocketChatClientCallBuilder callBuilder){ this.callBuilder = callBuilder; }
// Path: src/main/java/com/github/baloise/rocketchatrestclient/model/Setting.java // public class Setting { // private String id; // private Object value; // // @JsonGetter("_id") // public String getId(){ // return id; // } // // @JsonSetter("_id") // public void setId(String id){ // this.id = id; // } // // @JsonGetter("value") // public Object getValue(){ // // if (value instanceof String) { // String _value = (String) value; // if (Boolean.FALSE.toString().equalsIgnoreCase(_value) // || Boolean.TRUE.toString().equalsIgnoreCase(_value)) { // return Boolean.valueOf((String) value); // } // } // // return value; // } // // @JsonSetter("value") // public void setValue(Object value){ // this.value = value; // } // // } // Path: src/main/java/com/github/baloise/rocketchatrestclient/RocketChatRestApiV1Settings.java import java.io.IOException; import com.github.baloise.rocketchatrestclient.model.Setting; package com.github.baloise.rocketchatrestclient; public class RocketChatRestApiV1Settings { private RocketChatClientCallBuilder callBuilder; protected RocketChatRestApiV1Settings(RocketChatClientCallBuilder callBuilder){ this.callBuilder = callBuilder; }
public Setting[] list() throws IOException{
baloise/rocket-chat-rest-client
src/main/java/com/github/baloise/rocketchatrestclient/requests/ChannelHistoryRequest.java
// Path: src/main/java/com/github/baloise/rocketchatrestclient/util/Misc.java // public class Misc { // public static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); // }
import java.util.Date; import com.github.baloise.rocketchatrestclient.util.Misc;
package com.github.baloise.rocketchatrestclient.requests; public class ChannelHistoryRequest { private String roomId, latest, oldest; private boolean inclusive; public ChannelHistoryRequest(String roomId) { this.roomId = roomId; } public ChannelHistoryRequest(String roomId, String latest, String oldest, boolean inclusive) { this.roomId = roomId; this.latest = latest; this.oldest = oldest; this.inclusive = inclusive; } public String getRoomId() { return this.roomId; } public void setRoomId(String roomId) { this.roomId = roomId; } public String getLatest() { return this.latest; } public void setLatest(Date latest) {
// Path: src/main/java/com/github/baloise/rocketchatrestclient/util/Misc.java // public class Misc { // public static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); // } // Path: src/main/java/com/github/baloise/rocketchatrestclient/requests/ChannelHistoryRequest.java import java.util.Date; import com.github.baloise.rocketchatrestclient.util.Misc; package com.github.baloise.rocketchatrestclient.requests; public class ChannelHistoryRequest { private String roomId, latest, oldest; private boolean inclusive; public ChannelHistoryRequest(String roomId) { this.roomId = roomId; } public ChannelHistoryRequest(String roomId, String latest, String oldest, boolean inclusive) { this.roomId = roomId; this.latest = latest; this.oldest = oldest; this.inclusive = inclusive; } public String getRoomId() { return this.roomId; } public void setRoomId(String roomId) { this.roomId = roomId; } public String getLatest() { return this.latest; } public void setLatest(Date latest) {
this.latest = Misc.dateFormat.format(latest);
baloise/rocket-chat-rest-client
src/main/java/com/github/baloise/rocketchatrestclient/RocketChatClient.java
// Path: src/main/java/com/github/baloise/rocketchatrestclient/model/ServerInfo.java // public class ServerInfo { // private String version; // private ServerBuildInfo buildInfo; // private ServerCommitInfo commitInfo; // // public void setVersion(String version) { // this.version = version; // } // // public String getVersion() { // return this.version; // } // // @JsonSetter("build") // public void setBuildInfo(ServerBuildInfo info) { // this.buildInfo = info; // } // // @JsonGetter("build") // public ServerBuildInfo getBuildInfo() { // return this.buildInfo; // } // // @JsonSetter("commit") // public void setCommitInfo(ServerCommitInfo info) { // this.commitInfo = info; // } // // @JsonSetter("commit") // public ServerCommitInfo getCommitInfo() { // return this.commitInfo; // } // }
import java.io.IOException; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import javax.net.ssl.SSLContext; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.SSLContexts; import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import com.github.baloise.rocketchatrestclient.model.ServerInfo; import com.mashape.unirest.http.Unirest;
package com.github.baloise.rocketchatrestclient; /** * Client for Rocket.Chat which relies on the REST API v1. * <p> * Please note, this client does <strong>not</strong> cache any of the results. * * @version 0.1.0 * @since 0.0.1 */ public class RocketChatClient { private RocketChatClientCallBuilder callBuilder; private RocketChatRestApiV1Channels channels; private RocketChatRestApiV1Chat chat; private RocketChatRestApiV1Groups groups; private RocketChatRestApiV1Users users; private RocketChatRestApiV1Settings settings; /** * Initialize a new instance of the client providing the server's url along * with username and password to use. * * @param serverUrl * of the Rocket.Chat server, with or without it ending in * "/api/" * @param user * which to authenticate with * @param password * of the user to authenticate with */ public RocketChatClient(String serverUrl, String user, String password) { this.callBuilder = new RocketChatClientCallBuilder(serverUrl, user, password); this.channels = new RocketChatRestApiV1Channels(this.callBuilder); this.chat = new RocketChatRestApiV1Chat(this.callBuilder); this.groups = new RocketChatRestApiV1Groups(this.callBuilder); this.users = new RocketChatRestApiV1Users(this.callBuilder); this.settings = new RocketChatRestApiV1Settings(this.callBuilder); } /** * Trust self-signed certificates on the rocketchat server url. * @throws KeyManagementException * @throws NoSuchAlgorithmException * @throws KeyStoreException */ public void trustSelfSignedCertificates() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException { SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(); SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build(); Unirest.setHttpClient(httpclient); } /** * Forces a logout and clears the auth token if no exception happened. * * @throws IOException * is thrown if there was a problem connecting, including if the * result wasn't successful */ public void logout() throws IOException { this.callBuilder.logout(); } /** * Gets the {@link ServerInfo} from the server, containing the version. * * @return the {@link ServerInfo} * @throws IOException * is thrown if there was a problem connecting, including if the * result wasn't successful */
// Path: src/main/java/com/github/baloise/rocketchatrestclient/model/ServerInfo.java // public class ServerInfo { // private String version; // private ServerBuildInfo buildInfo; // private ServerCommitInfo commitInfo; // // public void setVersion(String version) { // this.version = version; // } // // public String getVersion() { // return this.version; // } // // @JsonSetter("build") // public void setBuildInfo(ServerBuildInfo info) { // this.buildInfo = info; // } // // @JsonGetter("build") // public ServerBuildInfo getBuildInfo() { // return this.buildInfo; // } // // @JsonSetter("commit") // public void setCommitInfo(ServerCommitInfo info) { // this.commitInfo = info; // } // // @JsonSetter("commit") // public ServerCommitInfo getCommitInfo() { // return this.commitInfo; // } // } // Path: src/main/java/com/github/baloise/rocketchatrestclient/RocketChatClient.java import java.io.IOException; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import javax.net.ssl.SSLContext; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.SSLContexts; import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import com.github.baloise.rocketchatrestclient.model.ServerInfo; import com.mashape.unirest.http.Unirest; package com.github.baloise.rocketchatrestclient; /** * Client for Rocket.Chat which relies on the REST API v1. * <p> * Please note, this client does <strong>not</strong> cache any of the results. * * @version 0.1.0 * @since 0.0.1 */ public class RocketChatClient { private RocketChatClientCallBuilder callBuilder; private RocketChatRestApiV1Channels channels; private RocketChatRestApiV1Chat chat; private RocketChatRestApiV1Groups groups; private RocketChatRestApiV1Users users; private RocketChatRestApiV1Settings settings; /** * Initialize a new instance of the client providing the server's url along * with username and password to use. * * @param serverUrl * of the Rocket.Chat server, with or without it ending in * "/api/" * @param user * which to authenticate with * @param password * of the user to authenticate with */ public RocketChatClient(String serverUrl, String user, String password) { this.callBuilder = new RocketChatClientCallBuilder(serverUrl, user, password); this.channels = new RocketChatRestApiV1Channels(this.callBuilder); this.chat = new RocketChatRestApiV1Chat(this.callBuilder); this.groups = new RocketChatRestApiV1Groups(this.callBuilder); this.users = new RocketChatRestApiV1Users(this.callBuilder); this.settings = new RocketChatRestApiV1Settings(this.callBuilder); } /** * Trust self-signed certificates on the rocketchat server url. * @throws KeyManagementException * @throws NoSuchAlgorithmException * @throws KeyStoreException */ public void trustSelfSignedCertificates() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException { SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(); SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build(); Unirest.setHttpClient(httpclient); } /** * Forces a logout and clears the auth token if no exception happened. * * @throws IOException * is thrown if there was a problem connecting, including if the * result wasn't successful */ public void logout() throws IOException { this.callBuilder.logout(); } /** * Gets the {@link ServerInfo} from the server, containing the version. * * @return the {@link ServerInfo} * @throws IOException * is thrown if there was a problem connecting, including if the * result wasn't successful */
public ServerInfo getServerInformation() throws IOException {
sarveshchavan7/Trivia-Knowledge
app/src/main/java/sarveshchavan777/inrerface2/HolderActivities/MainActivity.java
// Path: app/src/main/java/sarveshchavan777/inrerface2/ViewPager/MyPagerAdapterHome.java // public class MyPagerAdapterHome extends FragmentStatePagerAdapter { // Context context; // // public String yourStringArray[] = new String[3]; // public int icon[]; // // private int numbOfTabs; // Store the number of tabs, this will also be passed when the ViewPagerAdapter is created // // // public MyPagerAdapterHome(FragmentManager fm, int micon[], int mNumOfTabs, Context context) { // super(fm); // this.context = context; // this.icon = micon; // this.numbOfTabs = mNumOfTabs; // // } // // // @Override // public Fragment getItem(int position) { // // if (position == 0) // if the position is 0 we are returning the First f_per_easy.xmll // { // // return new HomePlayTab(); // // } else if (position == 1) // As we are having 3 tabs if the position is now 0 it must be 1 so we are returning second p_easyy.xml // { // return new HomeSettingTab(); // // } else { // return new HomeAchievementTab(); // // } // // } // // @Override // public CharSequence getPageTitle(int position) { // Drawable drawable = ContextCompat.getDrawable(context, icon[position]); // // WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Display display = wm.getDefaultDisplay(); // Point size = new Point(); // display.getSize(size); // int checkWidth = size.x; // int checkHeight = size.y; // // // //NORMAL // try { // if ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) { // if (checkWidth < 480 && checkHeight < 800) { // drawable.setBounds(0, 0, 24, 24); // // Toast.makeText(context, "Normal -less", Toast.LENGTH_LONG).show(); // } else if (checkWidth > 1080 && checkHeight > 1920) { // drawable.setBounds(0, 0, 90, 90); // // Toast.makeText(context, "NORMAL-large", Toast.LENGTH_LONG).show(); // } else { // drawable.setBounds(0, 0, 50, 50); // // Toast.makeText(context, "NORMAL-default", Toast.LENGTH_LONG).show(); // } // // } // } catch (Exception e) { // drawable.setBounds(0, 0, 50, 50); // // Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show(); // } // // //LARGE // try { // if ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) { // drawable.setBounds(0, 0, 60, 60); // // Toast.makeText(context, "large", Toast.LENGTH_LONG).show(); // } // } catch (Exception e) { // drawable.setBounds(0, 0, 50, 50); // // Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show(); // } // // //XLARGE // try { // if ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) { // drawable.setBounds(0, 0, 80, 80); // // Toast.makeText(context, "x-large", Toast.LENGTH_LONG).show(); // } // } catch (Exception e) { // drawable.setBounds(0, 0, 50, 50); // // Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show(); // } // // //SMALL // try { // if ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) { // drawable.setBounds(0, 0, 20, 20); // // Toast.makeText(context, "small", Toast.LENGTH_LONG).show(); // } // } catch (Exception e) { // drawable.setBounds(0, 0, 50, 50); // //Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show(); // } // // ImageSpan imageSpan = new ImageSpan(drawable); // SpannableString spannableString = new SpannableString(" "); // spannableString.setSpan(imageSpan, 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // return spannableString; // } // // @Override // public int getCount() { // return numbOfTabs; // } // }
import android.support.design.widget.FloatingActionButton; import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Toast; import sarveshchavan777.inrerface2.R; import sarveshchavan777.inrerface2.ViewPager.MyPagerAdapterHome;
package sarveshchavan777.inrerface2.HolderActivities; public class MainActivity extends AppCompatActivity { FloatingActionButton fab; int numboftabs = 3; public int icon[] = {R.drawable.homecartoon, R.drawable.settingscartoon, R.drawable.achievementcartoon}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.s_activity_main); ViewPager mPager; SlidingTabLayout mTabs; mPager = (ViewPager) findViewById(R.id.pager);
// Path: app/src/main/java/sarveshchavan777/inrerface2/ViewPager/MyPagerAdapterHome.java // public class MyPagerAdapterHome extends FragmentStatePagerAdapter { // Context context; // // public String yourStringArray[] = new String[3]; // public int icon[]; // // private int numbOfTabs; // Store the number of tabs, this will also be passed when the ViewPagerAdapter is created // // // public MyPagerAdapterHome(FragmentManager fm, int micon[], int mNumOfTabs, Context context) { // super(fm); // this.context = context; // this.icon = micon; // this.numbOfTabs = mNumOfTabs; // // } // // // @Override // public Fragment getItem(int position) { // // if (position == 0) // if the position is 0 we are returning the First f_per_easy.xmll // { // // return new HomePlayTab(); // // } else if (position == 1) // As we are having 3 tabs if the position is now 0 it must be 1 so we are returning second p_easyy.xml // { // return new HomeSettingTab(); // // } else { // return new HomeAchievementTab(); // // } // // } // // @Override // public CharSequence getPageTitle(int position) { // Drawable drawable = ContextCompat.getDrawable(context, icon[position]); // // WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Display display = wm.getDefaultDisplay(); // Point size = new Point(); // display.getSize(size); // int checkWidth = size.x; // int checkHeight = size.y; // // // //NORMAL // try { // if ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) { // if (checkWidth < 480 && checkHeight < 800) { // drawable.setBounds(0, 0, 24, 24); // // Toast.makeText(context, "Normal -less", Toast.LENGTH_LONG).show(); // } else if (checkWidth > 1080 && checkHeight > 1920) { // drawable.setBounds(0, 0, 90, 90); // // Toast.makeText(context, "NORMAL-large", Toast.LENGTH_LONG).show(); // } else { // drawable.setBounds(0, 0, 50, 50); // // Toast.makeText(context, "NORMAL-default", Toast.LENGTH_LONG).show(); // } // // } // } catch (Exception e) { // drawable.setBounds(0, 0, 50, 50); // // Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show(); // } // // //LARGE // try { // if ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) { // drawable.setBounds(0, 0, 60, 60); // // Toast.makeText(context, "large", Toast.LENGTH_LONG).show(); // } // } catch (Exception e) { // drawable.setBounds(0, 0, 50, 50); // // Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show(); // } // // //XLARGE // try { // if ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) { // drawable.setBounds(0, 0, 80, 80); // // Toast.makeText(context, "x-large", Toast.LENGTH_LONG).show(); // } // } catch (Exception e) { // drawable.setBounds(0, 0, 50, 50); // // Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show(); // } // // //SMALL // try { // if ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) { // drawable.setBounds(0, 0, 20, 20); // // Toast.makeText(context, "small", Toast.LENGTH_LONG).show(); // } // } catch (Exception e) { // drawable.setBounds(0, 0, 50, 50); // //Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show(); // } // // ImageSpan imageSpan = new ImageSpan(drawable); // SpannableString spannableString = new SpannableString(" "); // spannableString.setSpan(imageSpan, 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // return spannableString; // } // // @Override // public int getCount() { // return numbOfTabs; // } // } // Path: app/src/main/java/sarveshchavan777/inrerface2/HolderActivities/MainActivity.java import android.support.design.widget.FloatingActionButton; import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Toast; import sarveshchavan777.inrerface2.R; import sarveshchavan777.inrerface2.ViewPager.MyPagerAdapterHome; package sarveshchavan777.inrerface2.HolderActivities; public class MainActivity extends AppCompatActivity { FloatingActionButton fab; int numboftabs = 3; public int icon[] = {R.drawable.homecartoon, R.drawable.settingscartoon, R.drawable.achievementcartoon}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.s_activity_main); ViewPager mPager; SlidingTabLayout mTabs; mPager = (ViewPager) findViewById(R.id.pager);
mPager.setAdapter(new MyPagerAdapterHome(getSupportFragmentManager(), icon, numboftabs, getApplicationContext()));
sarveshchavan7/Trivia-Knowledge
app/src/main/java/sarveshchavan777/inrerface2/SplashScreen/SplashScreen.java
// Path: app/src/main/java/sarveshchavan777/inrerface2/HolderActivities/MainActivity.java // public class MainActivity extends AppCompatActivity { // // // FloatingActionButton fab; // int numboftabs = 3; // public int icon[] = {R.drawable.homecartoon, R.drawable.settingscartoon, R.drawable.achievementcartoon}; // // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.s_activity_main); // ViewPager mPager; // SlidingTabLayout mTabs; // // // mPager = (ViewPager) findViewById(R.id.pager); // mPager.setAdapter(new MyPagerAdapterHome(getSupportFragmentManager(), icon, numboftabs, getApplicationContext())); // mTabs = (SlidingTabLayout) findViewById(R.id.tabs); // // mTabs.setCustomTabView(R.layout.ha_customtablayout, R.id.textTab); // mTabs.setDistributeEvenly(true); // mTabs.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.darkpink)); // mTabs.setSelectedIndicatorColors(ContextCompat.getColor(getApplicationContext(), R.color.white)); // mTabs.setViewPager(mPager); // fab = (FloatingActionButton) findViewById(R.id.fab); // // fab.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // Toast.makeText(MainActivity.this, "google sign not available if imported from github", Toast.LENGTH_SHORT).show(); // // } // }); // } // // @Override // public void onBackPressed() { // super.onBackPressed(); // finish(); // System.exit(0); // } // // // }
import android.content.Intent; import android.util.Log; import com.daimajia.androidanimations.library.Techniques; import com.viksaa.sssplash.lib.activity.AwesomeSplash; import com.viksaa.sssplash.lib.cnst.Flags; import com.viksaa.sssplash.lib.model.ConfigSplash; import sarveshchavan777.inrerface2.HolderActivities.MainActivity; import sarveshchavan777.inrerface2.R;
package sarveshchavan777.inrerface2.SplashScreen; //extends AwesomeSplash! public class SplashScreen extends AwesomeSplash { //DO NOT OVERRIDE onCreate()! //if you need to start some services do it in initSplash()! String LOG_TAG = "this is my tag"; @Override public void initSplash(ConfigSplash configSplash) { if (!isTaskRoot()) { final Intent intent = getIntent(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(intent.getAction())) { Log.w(LOG_TAG, "Main Activity is not the root. Finishing Main Activity instead of launching."); finish(); return; } } /* you don't have to override every property */ //Customize Circular Reveal configSplash.setBackgroundColor(R.color.lightbluesplash); //any color you want form colors.xml configSplash.setAnimCircularRevealDuration(1000); //int ms configSplash.setRevealFlagX(Flags.REVEAL_RIGHT); //or Flags.REVEAL_LEFT configSplash.setRevealFlagY(Flags.REVEAL_BOTTOM); //or Flags.REVEAL_TOP //Choose LOGO OR PATH; if you don't provide String value for path it's logo by default //Customize Logo configSplash.setLogoSplash(R.drawable.cglogo); //or any other drawable configSplash.setAnimLogoSplashDuration(1000); //int ms configSplash.setAnimLogoSplashTechnique(Techniques.FadeIn); //choose one form Techniques (ref: https://github.com/daimajia/AndroidViewAnimations) //Customize Path // configSplash.setPathSplash(Constants.DROID_LOGO); //set path String configSplash.setOriginalHeight(400); //in relation to your svg (path) resource configSplash.setOriginalWidth(400); //in relation to your svg (path) resource configSplash.setAnimPathStrokeDrawingDuration(1000); configSplash.setPathSplashStrokeSize(3); //I advise value be <5 configSplash.setPathSplashStrokeColor(R.color.lightbluesplash); //any color you want form colors.xml configSplash.setAnimPathFillingDuration(1000); configSplash.setPathSplashFillColor(R.color.white); //path object filling color //Customize Title configSplash.setTitleSplash(getResources().getString(R.string.charetakergames)); configSplash.setTitleTextColor(R.color.white); configSplash.setTitleTextSize(20f); //float value configSplash.setAnimTitleDuration(0); configSplash.setAnimTitleTechnique(Techniques.FadeIn); configSplash.setTitleFont("fonts/grobold.ttf"); //provide string to your font located in assets/fonts/ } @Override public void animationsFinished() {
// Path: app/src/main/java/sarveshchavan777/inrerface2/HolderActivities/MainActivity.java // public class MainActivity extends AppCompatActivity { // // // FloatingActionButton fab; // int numboftabs = 3; // public int icon[] = {R.drawable.homecartoon, R.drawable.settingscartoon, R.drawable.achievementcartoon}; // // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.s_activity_main); // ViewPager mPager; // SlidingTabLayout mTabs; // // // mPager = (ViewPager) findViewById(R.id.pager); // mPager.setAdapter(new MyPagerAdapterHome(getSupportFragmentManager(), icon, numboftabs, getApplicationContext())); // mTabs = (SlidingTabLayout) findViewById(R.id.tabs); // // mTabs.setCustomTabView(R.layout.ha_customtablayout, R.id.textTab); // mTabs.setDistributeEvenly(true); // mTabs.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.darkpink)); // mTabs.setSelectedIndicatorColors(ContextCompat.getColor(getApplicationContext(), R.color.white)); // mTabs.setViewPager(mPager); // fab = (FloatingActionButton) findViewById(R.id.fab); // // fab.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // Toast.makeText(MainActivity.this, "google sign not available if imported from github", Toast.LENGTH_SHORT).show(); // // } // }); // } // // @Override // public void onBackPressed() { // super.onBackPressed(); // finish(); // System.exit(0); // } // // // } // Path: app/src/main/java/sarveshchavan777/inrerface2/SplashScreen/SplashScreen.java import android.content.Intent; import android.util.Log; import com.daimajia.androidanimations.library.Techniques; import com.viksaa.sssplash.lib.activity.AwesomeSplash; import com.viksaa.sssplash.lib.cnst.Flags; import com.viksaa.sssplash.lib.model.ConfigSplash; import sarveshchavan777.inrerface2.HolderActivities.MainActivity; import sarveshchavan777.inrerface2.R; package sarveshchavan777.inrerface2.SplashScreen; //extends AwesomeSplash! public class SplashScreen extends AwesomeSplash { //DO NOT OVERRIDE onCreate()! //if you need to start some services do it in initSplash()! String LOG_TAG = "this is my tag"; @Override public void initSplash(ConfigSplash configSplash) { if (!isTaskRoot()) { final Intent intent = getIntent(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(intent.getAction())) { Log.w(LOG_TAG, "Main Activity is not the root. Finishing Main Activity instead of launching."); finish(); return; } } /* you don't have to override every property */ //Customize Circular Reveal configSplash.setBackgroundColor(R.color.lightbluesplash); //any color you want form colors.xml configSplash.setAnimCircularRevealDuration(1000); //int ms configSplash.setRevealFlagX(Flags.REVEAL_RIGHT); //or Flags.REVEAL_LEFT configSplash.setRevealFlagY(Flags.REVEAL_BOTTOM); //or Flags.REVEAL_TOP //Choose LOGO OR PATH; if you don't provide String value for path it's logo by default //Customize Logo configSplash.setLogoSplash(R.drawable.cglogo); //or any other drawable configSplash.setAnimLogoSplashDuration(1000); //int ms configSplash.setAnimLogoSplashTechnique(Techniques.FadeIn); //choose one form Techniques (ref: https://github.com/daimajia/AndroidViewAnimations) //Customize Path // configSplash.setPathSplash(Constants.DROID_LOGO); //set path String configSplash.setOriginalHeight(400); //in relation to your svg (path) resource configSplash.setOriginalWidth(400); //in relation to your svg (path) resource configSplash.setAnimPathStrokeDrawingDuration(1000); configSplash.setPathSplashStrokeSize(3); //I advise value be <5 configSplash.setPathSplashStrokeColor(R.color.lightbluesplash); //any color you want form colors.xml configSplash.setAnimPathFillingDuration(1000); configSplash.setPathSplashFillColor(R.color.white); //path object filling color //Customize Title configSplash.setTitleSplash(getResources().getString(R.string.charetakergames)); configSplash.setTitleTextColor(R.color.white); configSplash.setTitleTextSize(20f); //float value configSplash.setAnimTitleDuration(0); configSplash.setAnimTitleTechnique(Techniques.FadeIn); configSplash.setTitleFont("fonts/grobold.ttf"); //provide string to your font located in assets/fonts/ } @Override public void animationsFinished() {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
sarveshchavan7/Trivia-Knowledge
app/src/main/java/sarveshchavan777/inrerface2/db/DemoHelperClass.java
// Path: app/src/main/java/sarveshchavan777/inrerface2/Activity/FreeHint.java // public class FreeHint { // // //Question id for which random no's are generated (i.e qid of free hint used) // private int freeHintUsedId ; // // //This are the random numbers generated // private int randomNoOne ; // private int randomNoTwo ; // private int randomNoThree ; // private int randomNoFour ; // private int randomNoFive ; // // public FreeHint(){ // freeHintUsedId = 0; // randomNoOne = 0 ; // randomNoTwo = 0; // randomNoThree = 0; // randomNoFour = 0; // randomNoFive = 0; // } // // public FreeHint(int freeHintUsedId , int randomNoOne , int randomNoTwo, int randomNoThree, int randomNoFour, int randomNoFive){ // this.freeHintUsedId = freeHintUsedId; // this.randomNoOne = randomNoOne; // this.randomNoTwo = randomNoTwo; // this.randomNoThree = randomNoThree; // this.randomNoFour = randomNoFour; // this.randomNoFive = randomNoFive; // } // // public int getFreeHintUsedId(){ // return freeHintUsedId; // } // // public int getRandomNoOne(){ // return randomNoOne; // } // // public int getRandomNoTwo(){ // return randomNoTwo; // } // // public int getRandomNoThree(){ // return randomNoThree; // } // // public int getRandomNoFour(){ // return randomNoFour; // } // // public int getRandomNoFive(){ // return randomNoFive; // } // // public void setFreeHintUsedId (int freeHintUsedId){ // this.freeHintUsedId = freeHintUsedId; // } // // public void setRandomNoOne(int randomNoOne){ // this.randomNoOne = randomNoOne; // } // // public void setRandomNoTwo(int randomNoTwo){ // this.randomNoTwo = randomNoTwo; // } // // public void setRandomNoThree(int randomNoThree){ // this.randomNoThree = randomNoThree; // } // // public void setRandomNoFour(int randomNoFour){ // this.randomNoFour = randomNoFour; // } // // public void setRandomNoFive(int randomNoFive){ // this.randomNoFive = randomNoFive; // } // } // // Path: app/src/main/java/sarveshchavan777/inrerface2/Activity/Questions.java // public class Questions extends Activity { // private int ID; // private String Question; // // private String Answer; // private String Answer2; // private String RANDOMANS1; // private String RANDOMANS2; // private String USELESSSTRING; // // public Questions() { // ID = 0; // Question = ""; // // Answer = ""; // Answer2 = ""; // // RANDOMANS1 = ""; // RANDOMANS2 = ""; // USELESSSTRING = ""; // } // // public Questions(String qUESTION, String aNSWER, String aNSWER2, String rANDOMANS1, String rANDOMANS2, String uSLESSSTRING) { // Question = qUESTION; // // Answer = aNSWER; // Answer2 = aNSWER2; // // RANDOMANS1 = rANDOMANS1; // RANDOMANS2 = rANDOMANS2; // USELESSSTRING = uSLESSSTRING; // } // // public int getID() { // return ID; // } // // public String getQUESTION() { // return Question; // } // // // public String getANSWER() { // return Answer; // } // // public String getANSWER2() { // return Answer2; // } // // public String getRANDOMANS1() { // return RANDOMANS1; // } // // public String getRANDOMANS2() { // return RANDOMANS2; // } // // public String getUSELESSSTRING() { // return USELESSSTRING; // } // // public void setID(int id) { // ID = id; // } // // public void setQuestion(String question) { // Question = question; // } // // // public void setAnswer(String answer) { // Answer = answer; // } // // public void setAnswer2(String answer2) { // Answer2 = answer2; // } // // public void setRANDOMANS1(String randomans1) { // RANDOMANS1 = randomans1; // } // // public void setRANDOMANS2(String randomans2) { // RANDOMANS2 = randomans2; // } // // public void setUSELESSSTRING(String uselessstring) { // USELESSSTRING = uselessstring; // } // // }
import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.widget.Toast; import java.util.ArrayList; import java.util.List; import sarveshchavan777.inrerface2.Activity.FreeHint; import sarveshchavan777.inrerface2.Activity.Questions;
while (cursor.moveToNext()) { int hintId = cursor.getInt(0); list.add(hintId); } db.setTransactionSuccessful(); db.endTransaction(); cursor.close(); db.close(); return list; } public void insertRandomNumbers(int id,int one , int two ,int three , int four , int five) { ContentValues contentValues = new ContentValues(); contentValues.put(ID,id); contentValues.put(ONE, one); contentValues.put(TWO, two); contentValues.put(THREE, three); contentValues.put(FOUR, four); contentValues.put(FIVE, five); SQLiteDatabase db = this.getWritableDatabase(); db.beginTransaction(); db.insert(TABLE_NAME4, null, contentValues); db.setTransactionSuccessful(); db.endTransaction(); db.close(); }
// Path: app/src/main/java/sarveshchavan777/inrerface2/Activity/FreeHint.java // public class FreeHint { // // //Question id for which random no's are generated (i.e qid of free hint used) // private int freeHintUsedId ; // // //This are the random numbers generated // private int randomNoOne ; // private int randomNoTwo ; // private int randomNoThree ; // private int randomNoFour ; // private int randomNoFive ; // // public FreeHint(){ // freeHintUsedId = 0; // randomNoOne = 0 ; // randomNoTwo = 0; // randomNoThree = 0; // randomNoFour = 0; // randomNoFive = 0; // } // // public FreeHint(int freeHintUsedId , int randomNoOne , int randomNoTwo, int randomNoThree, int randomNoFour, int randomNoFive){ // this.freeHintUsedId = freeHintUsedId; // this.randomNoOne = randomNoOne; // this.randomNoTwo = randomNoTwo; // this.randomNoThree = randomNoThree; // this.randomNoFour = randomNoFour; // this.randomNoFive = randomNoFive; // } // // public int getFreeHintUsedId(){ // return freeHintUsedId; // } // // public int getRandomNoOne(){ // return randomNoOne; // } // // public int getRandomNoTwo(){ // return randomNoTwo; // } // // public int getRandomNoThree(){ // return randomNoThree; // } // // public int getRandomNoFour(){ // return randomNoFour; // } // // public int getRandomNoFive(){ // return randomNoFive; // } // // public void setFreeHintUsedId (int freeHintUsedId){ // this.freeHintUsedId = freeHintUsedId; // } // // public void setRandomNoOne(int randomNoOne){ // this.randomNoOne = randomNoOne; // } // // public void setRandomNoTwo(int randomNoTwo){ // this.randomNoTwo = randomNoTwo; // } // // public void setRandomNoThree(int randomNoThree){ // this.randomNoThree = randomNoThree; // } // // public void setRandomNoFour(int randomNoFour){ // this.randomNoFour = randomNoFour; // } // // public void setRandomNoFive(int randomNoFive){ // this.randomNoFive = randomNoFive; // } // } // // Path: app/src/main/java/sarveshchavan777/inrerface2/Activity/Questions.java // public class Questions extends Activity { // private int ID; // private String Question; // // private String Answer; // private String Answer2; // private String RANDOMANS1; // private String RANDOMANS2; // private String USELESSSTRING; // // public Questions() { // ID = 0; // Question = ""; // // Answer = ""; // Answer2 = ""; // // RANDOMANS1 = ""; // RANDOMANS2 = ""; // USELESSSTRING = ""; // } // // public Questions(String qUESTION, String aNSWER, String aNSWER2, String rANDOMANS1, String rANDOMANS2, String uSLESSSTRING) { // Question = qUESTION; // // Answer = aNSWER; // Answer2 = aNSWER2; // // RANDOMANS1 = rANDOMANS1; // RANDOMANS2 = rANDOMANS2; // USELESSSTRING = uSLESSSTRING; // } // // public int getID() { // return ID; // } // // public String getQUESTION() { // return Question; // } // // // public String getANSWER() { // return Answer; // } // // public String getANSWER2() { // return Answer2; // } // // public String getRANDOMANS1() { // return RANDOMANS1; // } // // public String getRANDOMANS2() { // return RANDOMANS2; // } // // public String getUSELESSSTRING() { // return USELESSSTRING; // } // // public void setID(int id) { // ID = id; // } // // public void setQuestion(String question) { // Question = question; // } // // // public void setAnswer(String answer) { // Answer = answer; // } // // public void setAnswer2(String answer2) { // Answer2 = answer2; // } // // public void setRANDOMANS1(String randomans1) { // RANDOMANS1 = randomans1; // } // // public void setRANDOMANS2(String randomans2) { // RANDOMANS2 = randomans2; // } // // public void setUSELESSSTRING(String uselessstring) { // USELESSSTRING = uselessstring; // } // // } // Path: app/src/main/java/sarveshchavan777/inrerface2/db/DemoHelperClass.java import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.widget.Toast; import java.util.ArrayList; import java.util.List; import sarveshchavan777.inrerface2.Activity.FreeHint; import sarveshchavan777.inrerface2.Activity.Questions; while (cursor.moveToNext()) { int hintId = cursor.getInt(0); list.add(hintId); } db.setTransactionSuccessful(); db.endTransaction(); cursor.close(); db.close(); return list; } public void insertRandomNumbers(int id,int one , int two ,int three , int four , int five) { ContentValues contentValues = new ContentValues(); contentValues.put(ID,id); contentValues.put(ONE, one); contentValues.put(TWO, two); contentValues.put(THREE, three); contentValues.put(FOUR, four); contentValues.put(FIVE, five); SQLiteDatabase db = this.getWritableDatabase(); db.beginTransaction(); db.insert(TABLE_NAME4, null, contentValues); db.setTransactionSuccessful(); db.endTransaction(); db.close(); }
public List<FreeHint> getRandomNumbers() {
gtomato/carouselview
demo/src/main/java/com/gtomato/android/demo/carouselviewdemo/RandomPageFragment.java
// Path: demo/src/main/java/com/gtomato/android/util/Metrics.java // public class Metrics { // /** // * Covert dp to px // * @param dp // * @param context // * @return pixel // */ // public static float convertDpToPixel(float dp, Context context){ // float px = dp * getDensity(context); // return px; // } // // /** // * Covert px to dp // * @param px // * @param context // * @return dp // */ // public static float convertPixelToDp(float px, Context context){ // float dp = px / getDensity(context); // return dp; // } // // /** // * Get density // * 120dpi = 0.75 // * 160dpi = 1 (default) // * 240dpi = 1.5 // * @param context // * @return // */ // public static float getDensity(Context context){ // DisplayMetrics metrics = context.getResources().getDisplayMetrics(); // return metrics.density; // } // }
import android.content.Context; import android.graphics.Color; import android.os.Bundle; import android.support.v4.app.Fragment; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.TextView; import com.gtomato.android.util.Metrics; import java.util.Random;
package com.gtomato.android.demo.carouselviewdemo; /** * A simple {@link android.support.v4.app.Fragment} subclass. */ public class RandomPageFragment extends Fragment { public final static String TEXT = "TEXT"; private String text; public RandomPageFragment() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); text = getArguments().getString(TEXT); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return createView(getActivity(), 100, 150, text); } public static View createView(Context context, int widthDp, int heightDp, String text) { // FrameLayout l = new FrameLayout(context); // l.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); Log.d("page", "w = " + widthDp + ", h = " + heightDp); TextView textView = new TextView(context); textView.setId(R.id.carousel_child_container); textView.setLayoutParams(new FrameLayout.LayoutParams(
// Path: demo/src/main/java/com/gtomato/android/util/Metrics.java // public class Metrics { // /** // * Covert dp to px // * @param dp // * @param context // * @return pixel // */ // public static float convertDpToPixel(float dp, Context context){ // float px = dp * getDensity(context); // return px; // } // // /** // * Covert px to dp // * @param px // * @param context // * @return dp // */ // public static float convertPixelToDp(float px, Context context){ // float dp = px / getDensity(context); // return dp; // } // // /** // * Get density // * 120dpi = 0.75 // * 160dpi = 1 (default) // * 240dpi = 1.5 // * @param context // * @return // */ // public static float getDensity(Context context){ // DisplayMetrics metrics = context.getResources().getDisplayMetrics(); // return metrics.density; // } // } // Path: demo/src/main/java/com/gtomato/android/demo/carouselviewdemo/RandomPageFragment.java import android.content.Context; import android.graphics.Color; import android.os.Bundle; import android.support.v4.app.Fragment; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.TextView; import com.gtomato.android.util.Metrics; import java.util.Random; package com.gtomato.android.demo.carouselviewdemo; /** * A simple {@link android.support.v4.app.Fragment} subclass. */ public class RandomPageFragment extends Fragment { public final static String TEXT = "TEXT"; private String text; public RandomPageFragment() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); text = getArguments().getString(TEXT); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return createView(getActivity(), 100, 150, text); } public static View createView(Context context, int widthDp, int heightDp, String text) { // FrameLayout l = new FrameLayout(context); // l.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); Log.d("page", "w = " + widthDp + ", h = " + heightDp); TextView textView = new TextView(context); textView.setId(R.id.carousel_child_container); textView.setLayoutParams(new FrameLayout.LayoutParams(
widthDp > 0 ? (int) Metrics.convertDpToPixel(widthDp, context) : ViewGroup.LayoutParams.MATCH_PARENT,
OpenDDRdotORG/OpenDDR-Java
src/org/openddr/simpleapi/oddr/vocabulary/VocabularyHolder.java
// Path: src/org/openddr/simpleapi/oddr/cache/Cache.java // public interface Cache { // // public Object getCachedElement(String id); // // public void setCachedElement(String id, Object object); // // public void clear(); // // public int usedEntries(); // // public Collection<Map.Entry> getAll(); // } // // Path: src/org/openddr/simpleapi/oddr/cache/CacheImpl.java // public class CacheImpl implements Cache { // // private static final float hashTableLoadFactor = 0.75f; // private LinkedHashMap map; // private int cacheSize; // // public CacheImpl() { // this.cacheSize = 100; // int hashTableCapacity = (int) Math.ceil(cacheSize / hashTableLoadFactor) + 1; // map = new LinkedHashMap(hashTableCapacity, hashTableLoadFactor, true) { // private static final long serialVersionUID = 1; // // @Override // protected boolean removeEldestEntry(Map.Entry eldest) { // return size() > CacheImpl.this.cacheSize; // } // }; // } // // public synchronized Object getCachedElement(String id) { // return map.get(id); // } // // public synchronized void setCachedElement(String id, Object object) { // map.put(id, object); // } // // public synchronized void clear() { // map.clear(); // } // // public synchronized int usedEntries() { // return map.size(); // } // // public synchronized Collection<Map.Entry> getAll() { // return new ArrayList<Map.Entry>(map.entrySet()); // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/Vocabulary.java // public class Vocabulary { // // private String[] aspects = null; // private Map<String, VocabularyProperty> properties = null; // private Map<String, VocabularyVariable> vocabularyVariables = null; // private String vocabularyIRI = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public Map<String, VocabularyProperty> getProperties() { // return properties; // } // // public void setProperties(Map<String, VocabularyProperty> properties) { // this.properties = properties; // } // // public Map<String, VocabularyVariable> getVocabularyVariables() { // return vocabularyVariables; // } // // public void setVocabularyVariables(Map<String, VocabularyVariable> vocabularyVariables) { // this.vocabularyVariables = vocabularyVariables; // } // // public String getVocabularyIRI() { // return vocabularyIRI; // } // // public void setVocabularyIRI(String vocabularyIRI) { // this.vocabularyIRI = vocabularyIRI; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyProperty.java // public class VocabularyProperty { // // private String[] aspects = null; // private String defaultAspect = null; // private String expr = null; // private String name = null; // private String type = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public String getDefaultAspect() { // return defaultAspect; // } // // public void setDefaultAspect(String defaultAspect) { // this.defaultAspect = defaultAspect; // } // // public String getExpr() { // return expr; // } // // public void setExpr(String expr) { // this.expr = expr; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // }
import java.util.Map; import org.apache.commons.lang.ArrayUtils; import org.openddr.simpleapi.oddr.cache.Cache; import org.openddr.simpleapi.oddr.cache.CacheImpl; import org.openddr.simpleapi.oddr.model.vocabulary.Vocabulary; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyProperty; import org.w3c.ddr.simple.exception.NameException;
/** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.vocabulary; public class VocabularyHolder { private Map<String, Vocabulary> vocabularies = null;
// Path: src/org/openddr/simpleapi/oddr/cache/Cache.java // public interface Cache { // // public Object getCachedElement(String id); // // public void setCachedElement(String id, Object object); // // public void clear(); // // public int usedEntries(); // // public Collection<Map.Entry> getAll(); // } // // Path: src/org/openddr/simpleapi/oddr/cache/CacheImpl.java // public class CacheImpl implements Cache { // // private static final float hashTableLoadFactor = 0.75f; // private LinkedHashMap map; // private int cacheSize; // // public CacheImpl() { // this.cacheSize = 100; // int hashTableCapacity = (int) Math.ceil(cacheSize / hashTableLoadFactor) + 1; // map = new LinkedHashMap(hashTableCapacity, hashTableLoadFactor, true) { // private static final long serialVersionUID = 1; // // @Override // protected boolean removeEldestEntry(Map.Entry eldest) { // return size() > CacheImpl.this.cacheSize; // } // }; // } // // public synchronized Object getCachedElement(String id) { // return map.get(id); // } // // public synchronized void setCachedElement(String id, Object object) { // map.put(id, object); // } // // public synchronized void clear() { // map.clear(); // } // // public synchronized int usedEntries() { // return map.size(); // } // // public synchronized Collection<Map.Entry> getAll() { // return new ArrayList<Map.Entry>(map.entrySet()); // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/Vocabulary.java // public class Vocabulary { // // private String[] aspects = null; // private Map<String, VocabularyProperty> properties = null; // private Map<String, VocabularyVariable> vocabularyVariables = null; // private String vocabularyIRI = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public Map<String, VocabularyProperty> getProperties() { // return properties; // } // // public void setProperties(Map<String, VocabularyProperty> properties) { // this.properties = properties; // } // // public Map<String, VocabularyVariable> getVocabularyVariables() { // return vocabularyVariables; // } // // public void setVocabularyVariables(Map<String, VocabularyVariable> vocabularyVariables) { // this.vocabularyVariables = vocabularyVariables; // } // // public String getVocabularyIRI() { // return vocabularyIRI; // } // // public void setVocabularyIRI(String vocabularyIRI) { // this.vocabularyIRI = vocabularyIRI; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyProperty.java // public class VocabularyProperty { // // private String[] aspects = null; // private String defaultAspect = null; // private String expr = null; // private String name = null; // private String type = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public String getDefaultAspect() { // return defaultAspect; // } // // public void setDefaultAspect(String defaultAspect) { // this.defaultAspect = defaultAspect; // } // // public String getExpr() { // return expr; // } // // public void setExpr(String expr) { // this.expr = expr; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // } // Path: src/org/openddr/simpleapi/oddr/vocabulary/VocabularyHolder.java import java.util.Map; import org.apache.commons.lang.ArrayUtils; import org.openddr.simpleapi.oddr.cache.Cache; import org.openddr.simpleapi.oddr.cache.CacheImpl; import org.openddr.simpleapi.oddr.model.vocabulary.Vocabulary; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyProperty; import org.w3c.ddr.simple.exception.NameException; /** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.vocabulary; public class VocabularyHolder { private Map<String, Vocabulary> vocabularies = null;
private Cache vocabularyPropertyCache = new CacheImpl();
OpenDDRdotORG/OpenDDR-Java
src/org/openddr/simpleapi/oddr/vocabulary/VocabularyHolder.java
// Path: src/org/openddr/simpleapi/oddr/cache/Cache.java // public interface Cache { // // public Object getCachedElement(String id); // // public void setCachedElement(String id, Object object); // // public void clear(); // // public int usedEntries(); // // public Collection<Map.Entry> getAll(); // } // // Path: src/org/openddr/simpleapi/oddr/cache/CacheImpl.java // public class CacheImpl implements Cache { // // private static final float hashTableLoadFactor = 0.75f; // private LinkedHashMap map; // private int cacheSize; // // public CacheImpl() { // this.cacheSize = 100; // int hashTableCapacity = (int) Math.ceil(cacheSize / hashTableLoadFactor) + 1; // map = new LinkedHashMap(hashTableCapacity, hashTableLoadFactor, true) { // private static final long serialVersionUID = 1; // // @Override // protected boolean removeEldestEntry(Map.Entry eldest) { // return size() > CacheImpl.this.cacheSize; // } // }; // } // // public synchronized Object getCachedElement(String id) { // return map.get(id); // } // // public synchronized void setCachedElement(String id, Object object) { // map.put(id, object); // } // // public synchronized void clear() { // map.clear(); // } // // public synchronized int usedEntries() { // return map.size(); // } // // public synchronized Collection<Map.Entry> getAll() { // return new ArrayList<Map.Entry>(map.entrySet()); // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/Vocabulary.java // public class Vocabulary { // // private String[] aspects = null; // private Map<String, VocabularyProperty> properties = null; // private Map<String, VocabularyVariable> vocabularyVariables = null; // private String vocabularyIRI = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public Map<String, VocabularyProperty> getProperties() { // return properties; // } // // public void setProperties(Map<String, VocabularyProperty> properties) { // this.properties = properties; // } // // public Map<String, VocabularyVariable> getVocabularyVariables() { // return vocabularyVariables; // } // // public void setVocabularyVariables(Map<String, VocabularyVariable> vocabularyVariables) { // this.vocabularyVariables = vocabularyVariables; // } // // public String getVocabularyIRI() { // return vocabularyIRI; // } // // public void setVocabularyIRI(String vocabularyIRI) { // this.vocabularyIRI = vocabularyIRI; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyProperty.java // public class VocabularyProperty { // // private String[] aspects = null; // private String defaultAspect = null; // private String expr = null; // private String name = null; // private String type = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public String getDefaultAspect() { // return defaultAspect; // } // // public void setDefaultAspect(String defaultAspect) { // this.defaultAspect = defaultAspect; // } // // public String getExpr() { // return expr; // } // // public void setExpr(String expr) { // this.expr = expr; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // }
import java.util.Map; import org.apache.commons.lang.ArrayUtils; import org.openddr.simpleapi.oddr.cache.Cache; import org.openddr.simpleapi.oddr.cache.CacheImpl; import org.openddr.simpleapi.oddr.model.vocabulary.Vocabulary; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyProperty; import org.w3c.ddr.simple.exception.NameException;
/** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.vocabulary; public class VocabularyHolder { private Map<String, Vocabulary> vocabularies = null;
// Path: src/org/openddr/simpleapi/oddr/cache/Cache.java // public interface Cache { // // public Object getCachedElement(String id); // // public void setCachedElement(String id, Object object); // // public void clear(); // // public int usedEntries(); // // public Collection<Map.Entry> getAll(); // } // // Path: src/org/openddr/simpleapi/oddr/cache/CacheImpl.java // public class CacheImpl implements Cache { // // private static final float hashTableLoadFactor = 0.75f; // private LinkedHashMap map; // private int cacheSize; // // public CacheImpl() { // this.cacheSize = 100; // int hashTableCapacity = (int) Math.ceil(cacheSize / hashTableLoadFactor) + 1; // map = new LinkedHashMap(hashTableCapacity, hashTableLoadFactor, true) { // private static final long serialVersionUID = 1; // // @Override // protected boolean removeEldestEntry(Map.Entry eldest) { // return size() > CacheImpl.this.cacheSize; // } // }; // } // // public synchronized Object getCachedElement(String id) { // return map.get(id); // } // // public synchronized void setCachedElement(String id, Object object) { // map.put(id, object); // } // // public synchronized void clear() { // map.clear(); // } // // public synchronized int usedEntries() { // return map.size(); // } // // public synchronized Collection<Map.Entry> getAll() { // return new ArrayList<Map.Entry>(map.entrySet()); // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/Vocabulary.java // public class Vocabulary { // // private String[] aspects = null; // private Map<String, VocabularyProperty> properties = null; // private Map<String, VocabularyVariable> vocabularyVariables = null; // private String vocabularyIRI = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public Map<String, VocabularyProperty> getProperties() { // return properties; // } // // public void setProperties(Map<String, VocabularyProperty> properties) { // this.properties = properties; // } // // public Map<String, VocabularyVariable> getVocabularyVariables() { // return vocabularyVariables; // } // // public void setVocabularyVariables(Map<String, VocabularyVariable> vocabularyVariables) { // this.vocabularyVariables = vocabularyVariables; // } // // public String getVocabularyIRI() { // return vocabularyIRI; // } // // public void setVocabularyIRI(String vocabularyIRI) { // this.vocabularyIRI = vocabularyIRI; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyProperty.java // public class VocabularyProperty { // // private String[] aspects = null; // private String defaultAspect = null; // private String expr = null; // private String name = null; // private String type = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public String getDefaultAspect() { // return defaultAspect; // } // // public void setDefaultAspect(String defaultAspect) { // this.defaultAspect = defaultAspect; // } // // public String getExpr() { // return expr; // } // // public void setExpr(String expr) { // this.expr = expr; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // } // Path: src/org/openddr/simpleapi/oddr/vocabulary/VocabularyHolder.java import java.util.Map; import org.apache.commons.lang.ArrayUtils; import org.openddr.simpleapi.oddr.cache.Cache; import org.openddr.simpleapi.oddr.cache.CacheImpl; import org.openddr.simpleapi.oddr.model.vocabulary.Vocabulary; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyProperty; import org.w3c.ddr.simple.exception.NameException; /** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.vocabulary; public class VocabularyHolder { private Map<String, Vocabulary> vocabularies = null;
private Cache vocabularyPropertyCache = new CacheImpl();
OpenDDRdotORG/OpenDDR-Java
src/org/openddr/simpleapi/oddr/vocabulary/VocabularyHolder.java
// Path: src/org/openddr/simpleapi/oddr/cache/Cache.java // public interface Cache { // // public Object getCachedElement(String id); // // public void setCachedElement(String id, Object object); // // public void clear(); // // public int usedEntries(); // // public Collection<Map.Entry> getAll(); // } // // Path: src/org/openddr/simpleapi/oddr/cache/CacheImpl.java // public class CacheImpl implements Cache { // // private static final float hashTableLoadFactor = 0.75f; // private LinkedHashMap map; // private int cacheSize; // // public CacheImpl() { // this.cacheSize = 100; // int hashTableCapacity = (int) Math.ceil(cacheSize / hashTableLoadFactor) + 1; // map = new LinkedHashMap(hashTableCapacity, hashTableLoadFactor, true) { // private static final long serialVersionUID = 1; // // @Override // protected boolean removeEldestEntry(Map.Entry eldest) { // return size() > CacheImpl.this.cacheSize; // } // }; // } // // public synchronized Object getCachedElement(String id) { // return map.get(id); // } // // public synchronized void setCachedElement(String id, Object object) { // map.put(id, object); // } // // public synchronized void clear() { // map.clear(); // } // // public synchronized int usedEntries() { // return map.size(); // } // // public synchronized Collection<Map.Entry> getAll() { // return new ArrayList<Map.Entry>(map.entrySet()); // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/Vocabulary.java // public class Vocabulary { // // private String[] aspects = null; // private Map<String, VocabularyProperty> properties = null; // private Map<String, VocabularyVariable> vocabularyVariables = null; // private String vocabularyIRI = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public Map<String, VocabularyProperty> getProperties() { // return properties; // } // // public void setProperties(Map<String, VocabularyProperty> properties) { // this.properties = properties; // } // // public Map<String, VocabularyVariable> getVocabularyVariables() { // return vocabularyVariables; // } // // public void setVocabularyVariables(Map<String, VocabularyVariable> vocabularyVariables) { // this.vocabularyVariables = vocabularyVariables; // } // // public String getVocabularyIRI() { // return vocabularyIRI; // } // // public void setVocabularyIRI(String vocabularyIRI) { // this.vocabularyIRI = vocabularyIRI; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyProperty.java // public class VocabularyProperty { // // private String[] aspects = null; // private String defaultAspect = null; // private String expr = null; // private String name = null; // private String type = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public String getDefaultAspect() { // return defaultAspect; // } // // public void setDefaultAspect(String defaultAspect) { // this.defaultAspect = defaultAspect; // } // // public String getExpr() { // return expr; // } // // public void setExpr(String expr) { // this.expr = expr; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // }
import java.util.Map; import org.apache.commons.lang.ArrayUtils; import org.openddr.simpleapi.oddr.cache.Cache; import org.openddr.simpleapi.oddr.cache.CacheImpl; import org.openddr.simpleapi.oddr.model.vocabulary.Vocabulary; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyProperty; import org.w3c.ddr.simple.exception.NameException;
/** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.vocabulary; public class VocabularyHolder { private Map<String, Vocabulary> vocabularies = null; private Cache vocabularyPropertyCache = new CacheImpl(); public VocabularyHolder(Map<String, Vocabulary> vocabularies) { this.vocabularies = vocabularies; } public void existVocabulary(String vocabularyIRI) throws NameException { if (vocabularies.get(vocabularyIRI) == null) { throw new NameException(NameException.VOCABULARY_NOT_RECOGNIZED, "unknow \"" + vocabularyIRI + "\" vacabulary"); } }
// Path: src/org/openddr/simpleapi/oddr/cache/Cache.java // public interface Cache { // // public Object getCachedElement(String id); // // public void setCachedElement(String id, Object object); // // public void clear(); // // public int usedEntries(); // // public Collection<Map.Entry> getAll(); // } // // Path: src/org/openddr/simpleapi/oddr/cache/CacheImpl.java // public class CacheImpl implements Cache { // // private static final float hashTableLoadFactor = 0.75f; // private LinkedHashMap map; // private int cacheSize; // // public CacheImpl() { // this.cacheSize = 100; // int hashTableCapacity = (int) Math.ceil(cacheSize / hashTableLoadFactor) + 1; // map = new LinkedHashMap(hashTableCapacity, hashTableLoadFactor, true) { // private static final long serialVersionUID = 1; // // @Override // protected boolean removeEldestEntry(Map.Entry eldest) { // return size() > CacheImpl.this.cacheSize; // } // }; // } // // public synchronized Object getCachedElement(String id) { // return map.get(id); // } // // public synchronized void setCachedElement(String id, Object object) { // map.put(id, object); // } // // public synchronized void clear() { // map.clear(); // } // // public synchronized int usedEntries() { // return map.size(); // } // // public synchronized Collection<Map.Entry> getAll() { // return new ArrayList<Map.Entry>(map.entrySet()); // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/Vocabulary.java // public class Vocabulary { // // private String[] aspects = null; // private Map<String, VocabularyProperty> properties = null; // private Map<String, VocabularyVariable> vocabularyVariables = null; // private String vocabularyIRI = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public Map<String, VocabularyProperty> getProperties() { // return properties; // } // // public void setProperties(Map<String, VocabularyProperty> properties) { // this.properties = properties; // } // // public Map<String, VocabularyVariable> getVocabularyVariables() { // return vocabularyVariables; // } // // public void setVocabularyVariables(Map<String, VocabularyVariable> vocabularyVariables) { // this.vocabularyVariables = vocabularyVariables; // } // // public String getVocabularyIRI() { // return vocabularyIRI; // } // // public void setVocabularyIRI(String vocabularyIRI) { // this.vocabularyIRI = vocabularyIRI; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyProperty.java // public class VocabularyProperty { // // private String[] aspects = null; // private String defaultAspect = null; // private String expr = null; // private String name = null; // private String type = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public String getDefaultAspect() { // return defaultAspect; // } // // public void setDefaultAspect(String defaultAspect) { // this.defaultAspect = defaultAspect; // } // // public String getExpr() { // return expr; // } // // public void setExpr(String expr) { // this.expr = expr; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // } // Path: src/org/openddr/simpleapi/oddr/vocabulary/VocabularyHolder.java import java.util.Map; import org.apache.commons.lang.ArrayUtils; import org.openddr.simpleapi.oddr.cache.Cache; import org.openddr.simpleapi.oddr.cache.CacheImpl; import org.openddr.simpleapi.oddr.model.vocabulary.Vocabulary; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyProperty; import org.w3c.ddr.simple.exception.NameException; /** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.vocabulary; public class VocabularyHolder { private Map<String, Vocabulary> vocabularies = null; private Cache vocabularyPropertyCache = new CacheImpl(); public VocabularyHolder(Map<String, Vocabulary> vocabularies) { this.vocabularies = vocabularies; } public void existVocabulary(String vocabularyIRI) throws NameException { if (vocabularies.get(vocabularyIRI) == null) { throw new NameException(NameException.VOCABULARY_NOT_RECOGNIZED, "unknow \"" + vocabularyIRI + "\" vacabulary"); } }
public VocabularyProperty existProperty(String propertyName, String aspect, String vocabularyIRI) throws NameException {
OpenDDRdotORG/OpenDDR-Java
src/org/openddr/simpleapi/oddr/builder/device/OrderedTokenDeviceBuilder.java
// Path: src/org/openddr/simpleapi/oddr/model/device/Device.java // public class Device extends BuiltObject implements Comparable, Cloneable { // // private String id; // private String parentId = "root"; // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getParentId() { // return parentId; // } // // public void setParentId(String parentId) { // this.parentId = parentId; // } // // public int compareTo(Object o) { // if (o == null || !(o instanceof Device)) { // return Integer.MAX_VALUE; // } // // Device bd = (Device) o; // return this.getConfidence() - bd.getConfidence(); // } // // public Object clone() { // Device d = new Device(); // d.setId(id); // d.setParentId(parentId); // d.setConfidence(getConfidence()); // d.putPropertiesMap(getPropertiesMap()); // return d; // } // // public boolean containsProperty(String propertyName) { // return // properties != null && // properties.containsKey(propertyName); // } // }
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.LinkedHashMap; import java.util.Map; import org.openddr.simpleapi.oddr.model.device.Device;
/** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.builder.device; public abstract class OrderedTokenDeviceBuilder implements DeviceBuilder { protected LinkedHashMap<String, Object> orderedRules; public OrderedTokenDeviceBuilder() { orderedRules = new LinkedHashMap<String, Object>(); }
// Path: src/org/openddr/simpleapi/oddr/model/device/Device.java // public class Device extends BuiltObject implements Comparable, Cloneable { // // private String id; // private String parentId = "root"; // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getParentId() { // return parentId; // } // // public void setParentId(String parentId) { // this.parentId = parentId; // } // // public int compareTo(Object o) { // if (o == null || !(o instanceof Device)) { // return Integer.MAX_VALUE; // } // // Device bd = (Device) o; // return this.getConfidence() - bd.getConfidence(); // } // // public Object clone() { // Device d = new Device(); // d.setId(id); // d.setParentId(parentId); // d.setConfidence(getConfidence()); // d.putPropertiesMap(getPropertiesMap()); // return d; // } // // public boolean containsProperty(String propertyName) { // return // properties != null && // properties.containsKey(propertyName); // } // } // Path: src/org/openddr/simpleapi/oddr/builder/device/OrderedTokenDeviceBuilder.java import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.LinkedHashMap; import java.util.Map; import org.openddr.simpleapi.oddr.model.device.Device; /** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.builder.device; public abstract class OrderedTokenDeviceBuilder implements DeviceBuilder { protected LinkedHashMap<String, Object> orderedRules; public OrderedTokenDeviceBuilder() { orderedRules = new LinkedHashMap<String, Object>(); }
abstract protected void afterOderingCompleteInit(Map<String, Device> devices);
OpenDDRdotORG/OpenDDR-Java
src/org/openddr/simpleapi/oddr/builder/device/DeviceBuilder.java
// Path: src/org/openddr/simpleapi/oddr/builder/Builder.java // public interface Builder { // // public boolean canBuild(UserAgent userAgent); // // public BuiltObject build(UserAgent userAgent, int confidenceTreshold); // } // // Path: src/org/openddr/simpleapi/oddr/model/device/Device.java // public class Device extends BuiltObject implements Comparable, Cloneable { // // private String id; // private String parentId = "root"; // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getParentId() { // return parentId; // } // // public void setParentId(String parentId) { // this.parentId = parentId; // } // // public int compareTo(Object o) { // if (o == null || !(o instanceof Device)) { // return Integer.MAX_VALUE; // } // // Device bd = (Device) o; // return this.getConfidence() - bd.getConfidence(); // } // // public Object clone() { // Device d = new Device(); // d.setId(id); // d.setParentId(parentId); // d.setConfidence(getConfidence()); // d.putPropertiesMap(getPropertiesMap()); // return d; // } // // public boolean containsProperty(String propertyName) { // return // properties != null && // properties.containsKey(propertyName); // } // }
import org.openddr.simpleapi.oddr.builder.Builder; import org.openddr.simpleapi.oddr.model.device.Device; import java.util.List; import java.util.Map;
/** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.builder.device; public interface DeviceBuilder extends Builder { public void putDevice(String deviceID, List<String> initProperties);
// Path: src/org/openddr/simpleapi/oddr/builder/Builder.java // public interface Builder { // // public boolean canBuild(UserAgent userAgent); // // public BuiltObject build(UserAgent userAgent, int confidenceTreshold); // } // // Path: src/org/openddr/simpleapi/oddr/model/device/Device.java // public class Device extends BuiltObject implements Comparable, Cloneable { // // private String id; // private String parentId = "root"; // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getParentId() { // return parentId; // } // // public void setParentId(String parentId) { // this.parentId = parentId; // } // // public int compareTo(Object o) { // if (o == null || !(o instanceof Device)) { // return Integer.MAX_VALUE; // } // // Device bd = (Device) o; // return this.getConfidence() - bd.getConfidence(); // } // // public Object clone() { // Device d = new Device(); // d.setId(id); // d.setParentId(parentId); // d.setConfidence(getConfidence()); // d.putPropertiesMap(getPropertiesMap()); // return d; // } // // public boolean containsProperty(String propertyName) { // return // properties != null && // properties.containsKey(propertyName); // } // } // Path: src/org/openddr/simpleapi/oddr/builder/device/DeviceBuilder.java import org.openddr.simpleapi.oddr.builder.Builder; import org.openddr.simpleapi.oddr.model.device.Device; import java.util.List; import java.util.Map; /** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.builder.device; public interface DeviceBuilder extends Builder { public void putDevice(String deviceID, List<String> initProperties);
public void completeInit(Map<String, Device> devices);
OpenDDRdotORG/OpenDDR-Java
src/org/openddr/simpleapi/oddr/documenthandler/VocabularyHandler.java
// Path: src/org/openddr/simpleapi/oddr/model/vocabulary/Vocabulary.java // public class Vocabulary { // // private String[] aspects = null; // private Map<String, VocabularyProperty> properties = null; // private Map<String, VocabularyVariable> vocabularyVariables = null; // private String vocabularyIRI = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public Map<String, VocabularyProperty> getProperties() { // return properties; // } // // public void setProperties(Map<String, VocabularyProperty> properties) { // this.properties = properties; // } // // public Map<String, VocabularyVariable> getVocabularyVariables() { // return vocabularyVariables; // } // // public void setVocabularyVariables(Map<String, VocabularyVariable> vocabularyVariables) { // this.vocabularyVariables = vocabularyVariables; // } // // public String getVocabularyIRI() { // return vocabularyIRI; // } // // public void setVocabularyIRI(String vocabularyIRI) { // this.vocabularyIRI = vocabularyIRI; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyProperty.java // public class VocabularyProperty { // // private String[] aspects = null; // private String defaultAspect = null; // private String expr = null; // private String name = null; // private String type = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public String getDefaultAspect() { // return defaultAspect; // } // // public void setDefaultAspect(String defaultAspect) { // this.defaultAspect = defaultAspect; // } // // public String getExpr() { // return expr; // } // // public void setExpr(String expr) { // this.expr = expr; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyVariable.java // public class VocabularyVariable { // // private String aspect = null; // private String id = null; // private String name = null; // private String vocabulary = null; // // public String getAspect() { // return aspect; // } // // public void setAspect(String aspect) { // this.aspect = aspect; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getVocabulary() { // return vocabulary; // } // // public void setVocabulary(String vocabulary) { // this.vocabulary = vocabulary; // } // // @Override // public String toString() { // return "VocabularyVariable {" + " aspect=" + aspect + " id=" + id + " name=" + name + " vocabulary=" + vocabulary + '}'; // } // }
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.openddr.simpleapi.oddr.model.vocabulary.Vocabulary; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyProperty; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyVariable; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler;
/** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.documenthandler; public class VocabularyHandler extends DefaultHandler { private static final String ELEMENT_VOCABULARY_DESCRIPTION = "VocabularyDescription"; private static final String ELEMENT_ASPECTS = "Aspects"; private static final String ELEMENT_ASPECT = "Aspect"; private static final String ELEMENT_VARIABLES = "Variables"; private static final String ELEMENT_VARIABLE = "Variable"; private static final String ELEMENT_PROPERTIES = "Properties"; private static final String ELEMENT_PROPERTY = "Property"; private static final String ATTRIBUTE_PROPERTY_TARGET = "target"; private static final String ATTRIBUTE_PROPERTY_ASPECT_NAME = "name"; private static final String ATTRIBUTE_PROPERTY_ASPECT = "aspect"; private static final String ATTRIBUTE_PROPERTY_NAME = "name"; private static final String ATTRIBUTE_PROPERTY_VOCABULARY = "vocabulary"; private static final String ATTRIBUTE_PROPERTY_ID = "id"; private static final String ATTRIBUTE_PROPERTY_DATA_TYPE = "datatype"; private static final String ATTRIBUTE_PROPERTY_EXPR = "expr"; private static final String ATTRIBUTE_PROPERTY_ASPECTS = "aspects"; private static final String ATTRIBUTE_PROPERTY_DEFAULT_ASPECT = "defaultAspect";
// Path: src/org/openddr/simpleapi/oddr/model/vocabulary/Vocabulary.java // public class Vocabulary { // // private String[] aspects = null; // private Map<String, VocabularyProperty> properties = null; // private Map<String, VocabularyVariable> vocabularyVariables = null; // private String vocabularyIRI = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public Map<String, VocabularyProperty> getProperties() { // return properties; // } // // public void setProperties(Map<String, VocabularyProperty> properties) { // this.properties = properties; // } // // public Map<String, VocabularyVariable> getVocabularyVariables() { // return vocabularyVariables; // } // // public void setVocabularyVariables(Map<String, VocabularyVariable> vocabularyVariables) { // this.vocabularyVariables = vocabularyVariables; // } // // public String getVocabularyIRI() { // return vocabularyIRI; // } // // public void setVocabularyIRI(String vocabularyIRI) { // this.vocabularyIRI = vocabularyIRI; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyProperty.java // public class VocabularyProperty { // // private String[] aspects = null; // private String defaultAspect = null; // private String expr = null; // private String name = null; // private String type = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public String getDefaultAspect() { // return defaultAspect; // } // // public void setDefaultAspect(String defaultAspect) { // this.defaultAspect = defaultAspect; // } // // public String getExpr() { // return expr; // } // // public void setExpr(String expr) { // this.expr = expr; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyVariable.java // public class VocabularyVariable { // // private String aspect = null; // private String id = null; // private String name = null; // private String vocabulary = null; // // public String getAspect() { // return aspect; // } // // public void setAspect(String aspect) { // this.aspect = aspect; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getVocabulary() { // return vocabulary; // } // // public void setVocabulary(String vocabulary) { // this.vocabulary = vocabulary; // } // // @Override // public String toString() { // return "VocabularyVariable {" + " aspect=" + aspect + " id=" + id + " name=" + name + " vocabulary=" + vocabulary + '}'; // } // } // Path: src/org/openddr/simpleapi/oddr/documenthandler/VocabularyHandler.java import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.openddr.simpleapi.oddr.model.vocabulary.Vocabulary; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyProperty; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyVariable; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; /** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.documenthandler; public class VocabularyHandler extends DefaultHandler { private static final String ELEMENT_VOCABULARY_DESCRIPTION = "VocabularyDescription"; private static final String ELEMENT_ASPECTS = "Aspects"; private static final String ELEMENT_ASPECT = "Aspect"; private static final String ELEMENT_VARIABLES = "Variables"; private static final String ELEMENT_VARIABLE = "Variable"; private static final String ELEMENT_PROPERTIES = "Properties"; private static final String ELEMENT_PROPERTY = "Property"; private static final String ATTRIBUTE_PROPERTY_TARGET = "target"; private static final String ATTRIBUTE_PROPERTY_ASPECT_NAME = "name"; private static final String ATTRIBUTE_PROPERTY_ASPECT = "aspect"; private static final String ATTRIBUTE_PROPERTY_NAME = "name"; private static final String ATTRIBUTE_PROPERTY_VOCABULARY = "vocabulary"; private static final String ATTRIBUTE_PROPERTY_ID = "id"; private static final String ATTRIBUTE_PROPERTY_DATA_TYPE = "datatype"; private static final String ATTRIBUTE_PROPERTY_EXPR = "expr"; private static final String ATTRIBUTE_PROPERTY_ASPECTS = "aspects"; private static final String ATTRIBUTE_PROPERTY_DEFAULT_ASPECT = "defaultAspect";
private Vocabulary vocabulary = null;
OpenDDRdotORG/OpenDDR-Java
src/org/openddr/simpleapi/oddr/documenthandler/VocabularyHandler.java
// Path: src/org/openddr/simpleapi/oddr/model/vocabulary/Vocabulary.java // public class Vocabulary { // // private String[] aspects = null; // private Map<String, VocabularyProperty> properties = null; // private Map<String, VocabularyVariable> vocabularyVariables = null; // private String vocabularyIRI = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public Map<String, VocabularyProperty> getProperties() { // return properties; // } // // public void setProperties(Map<String, VocabularyProperty> properties) { // this.properties = properties; // } // // public Map<String, VocabularyVariable> getVocabularyVariables() { // return vocabularyVariables; // } // // public void setVocabularyVariables(Map<String, VocabularyVariable> vocabularyVariables) { // this.vocabularyVariables = vocabularyVariables; // } // // public String getVocabularyIRI() { // return vocabularyIRI; // } // // public void setVocabularyIRI(String vocabularyIRI) { // this.vocabularyIRI = vocabularyIRI; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyProperty.java // public class VocabularyProperty { // // private String[] aspects = null; // private String defaultAspect = null; // private String expr = null; // private String name = null; // private String type = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public String getDefaultAspect() { // return defaultAspect; // } // // public void setDefaultAspect(String defaultAspect) { // this.defaultAspect = defaultAspect; // } // // public String getExpr() { // return expr; // } // // public void setExpr(String expr) { // this.expr = expr; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyVariable.java // public class VocabularyVariable { // // private String aspect = null; // private String id = null; // private String name = null; // private String vocabulary = null; // // public String getAspect() { // return aspect; // } // // public void setAspect(String aspect) { // this.aspect = aspect; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getVocabulary() { // return vocabulary; // } // // public void setVocabulary(String vocabulary) { // this.vocabulary = vocabulary; // } // // @Override // public String toString() { // return "VocabularyVariable {" + " aspect=" + aspect + " id=" + id + " name=" + name + " vocabulary=" + vocabulary + '}'; // } // }
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.openddr.simpleapi.oddr.model.vocabulary.Vocabulary; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyProperty; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyVariable; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler;
/** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.documenthandler; public class VocabularyHandler extends DefaultHandler { private static final String ELEMENT_VOCABULARY_DESCRIPTION = "VocabularyDescription"; private static final String ELEMENT_ASPECTS = "Aspects"; private static final String ELEMENT_ASPECT = "Aspect"; private static final String ELEMENT_VARIABLES = "Variables"; private static final String ELEMENT_VARIABLE = "Variable"; private static final String ELEMENT_PROPERTIES = "Properties"; private static final String ELEMENT_PROPERTY = "Property"; private static final String ATTRIBUTE_PROPERTY_TARGET = "target"; private static final String ATTRIBUTE_PROPERTY_ASPECT_NAME = "name"; private static final String ATTRIBUTE_PROPERTY_ASPECT = "aspect"; private static final String ATTRIBUTE_PROPERTY_NAME = "name"; private static final String ATTRIBUTE_PROPERTY_VOCABULARY = "vocabulary"; private static final String ATTRIBUTE_PROPERTY_ID = "id"; private static final String ATTRIBUTE_PROPERTY_DATA_TYPE = "datatype"; private static final String ATTRIBUTE_PROPERTY_EXPR = "expr"; private static final String ATTRIBUTE_PROPERTY_ASPECTS = "aspects"; private static final String ATTRIBUTE_PROPERTY_DEFAULT_ASPECT = "defaultAspect"; private Vocabulary vocabulary = null; private String aspect = null; private List<String> aspects = null;
// Path: src/org/openddr/simpleapi/oddr/model/vocabulary/Vocabulary.java // public class Vocabulary { // // private String[] aspects = null; // private Map<String, VocabularyProperty> properties = null; // private Map<String, VocabularyVariable> vocabularyVariables = null; // private String vocabularyIRI = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public Map<String, VocabularyProperty> getProperties() { // return properties; // } // // public void setProperties(Map<String, VocabularyProperty> properties) { // this.properties = properties; // } // // public Map<String, VocabularyVariable> getVocabularyVariables() { // return vocabularyVariables; // } // // public void setVocabularyVariables(Map<String, VocabularyVariable> vocabularyVariables) { // this.vocabularyVariables = vocabularyVariables; // } // // public String getVocabularyIRI() { // return vocabularyIRI; // } // // public void setVocabularyIRI(String vocabularyIRI) { // this.vocabularyIRI = vocabularyIRI; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyProperty.java // public class VocabularyProperty { // // private String[] aspects = null; // private String defaultAspect = null; // private String expr = null; // private String name = null; // private String type = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public String getDefaultAspect() { // return defaultAspect; // } // // public void setDefaultAspect(String defaultAspect) { // this.defaultAspect = defaultAspect; // } // // public String getExpr() { // return expr; // } // // public void setExpr(String expr) { // this.expr = expr; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyVariable.java // public class VocabularyVariable { // // private String aspect = null; // private String id = null; // private String name = null; // private String vocabulary = null; // // public String getAspect() { // return aspect; // } // // public void setAspect(String aspect) { // this.aspect = aspect; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getVocabulary() { // return vocabulary; // } // // public void setVocabulary(String vocabulary) { // this.vocabulary = vocabulary; // } // // @Override // public String toString() { // return "VocabularyVariable {" + " aspect=" + aspect + " id=" + id + " name=" + name + " vocabulary=" + vocabulary + '}'; // } // } // Path: src/org/openddr/simpleapi/oddr/documenthandler/VocabularyHandler.java import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.openddr.simpleapi.oddr.model.vocabulary.Vocabulary; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyProperty; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyVariable; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; /** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.documenthandler; public class VocabularyHandler extends DefaultHandler { private static final String ELEMENT_VOCABULARY_DESCRIPTION = "VocabularyDescription"; private static final String ELEMENT_ASPECTS = "Aspects"; private static final String ELEMENT_ASPECT = "Aspect"; private static final String ELEMENT_VARIABLES = "Variables"; private static final String ELEMENT_VARIABLE = "Variable"; private static final String ELEMENT_PROPERTIES = "Properties"; private static final String ELEMENT_PROPERTY = "Property"; private static final String ATTRIBUTE_PROPERTY_TARGET = "target"; private static final String ATTRIBUTE_PROPERTY_ASPECT_NAME = "name"; private static final String ATTRIBUTE_PROPERTY_ASPECT = "aspect"; private static final String ATTRIBUTE_PROPERTY_NAME = "name"; private static final String ATTRIBUTE_PROPERTY_VOCABULARY = "vocabulary"; private static final String ATTRIBUTE_PROPERTY_ID = "id"; private static final String ATTRIBUTE_PROPERTY_DATA_TYPE = "datatype"; private static final String ATTRIBUTE_PROPERTY_EXPR = "expr"; private static final String ATTRIBUTE_PROPERTY_ASPECTS = "aspects"; private static final String ATTRIBUTE_PROPERTY_DEFAULT_ASPECT = "defaultAspect"; private Vocabulary vocabulary = null; private String aspect = null; private List<String> aspects = null;
private VocabularyProperty vocabularyProperty = null;
OpenDDRdotORG/OpenDDR-Java
src/org/openddr/simpleapi/oddr/documenthandler/VocabularyHandler.java
// Path: src/org/openddr/simpleapi/oddr/model/vocabulary/Vocabulary.java // public class Vocabulary { // // private String[] aspects = null; // private Map<String, VocabularyProperty> properties = null; // private Map<String, VocabularyVariable> vocabularyVariables = null; // private String vocabularyIRI = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public Map<String, VocabularyProperty> getProperties() { // return properties; // } // // public void setProperties(Map<String, VocabularyProperty> properties) { // this.properties = properties; // } // // public Map<String, VocabularyVariable> getVocabularyVariables() { // return vocabularyVariables; // } // // public void setVocabularyVariables(Map<String, VocabularyVariable> vocabularyVariables) { // this.vocabularyVariables = vocabularyVariables; // } // // public String getVocabularyIRI() { // return vocabularyIRI; // } // // public void setVocabularyIRI(String vocabularyIRI) { // this.vocabularyIRI = vocabularyIRI; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyProperty.java // public class VocabularyProperty { // // private String[] aspects = null; // private String defaultAspect = null; // private String expr = null; // private String name = null; // private String type = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public String getDefaultAspect() { // return defaultAspect; // } // // public void setDefaultAspect(String defaultAspect) { // this.defaultAspect = defaultAspect; // } // // public String getExpr() { // return expr; // } // // public void setExpr(String expr) { // this.expr = expr; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyVariable.java // public class VocabularyVariable { // // private String aspect = null; // private String id = null; // private String name = null; // private String vocabulary = null; // // public String getAspect() { // return aspect; // } // // public void setAspect(String aspect) { // this.aspect = aspect; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getVocabulary() { // return vocabulary; // } // // public void setVocabulary(String vocabulary) { // this.vocabulary = vocabulary; // } // // @Override // public String toString() { // return "VocabularyVariable {" + " aspect=" + aspect + " id=" + id + " name=" + name + " vocabulary=" + vocabulary + '}'; // } // }
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.openddr.simpleapi.oddr.model.vocabulary.Vocabulary; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyProperty; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyVariable; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler;
/** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.documenthandler; public class VocabularyHandler extends DefaultHandler { private static final String ELEMENT_VOCABULARY_DESCRIPTION = "VocabularyDescription"; private static final String ELEMENT_ASPECTS = "Aspects"; private static final String ELEMENT_ASPECT = "Aspect"; private static final String ELEMENT_VARIABLES = "Variables"; private static final String ELEMENT_VARIABLE = "Variable"; private static final String ELEMENT_PROPERTIES = "Properties"; private static final String ELEMENT_PROPERTY = "Property"; private static final String ATTRIBUTE_PROPERTY_TARGET = "target"; private static final String ATTRIBUTE_PROPERTY_ASPECT_NAME = "name"; private static final String ATTRIBUTE_PROPERTY_ASPECT = "aspect"; private static final String ATTRIBUTE_PROPERTY_NAME = "name"; private static final String ATTRIBUTE_PROPERTY_VOCABULARY = "vocabulary"; private static final String ATTRIBUTE_PROPERTY_ID = "id"; private static final String ATTRIBUTE_PROPERTY_DATA_TYPE = "datatype"; private static final String ATTRIBUTE_PROPERTY_EXPR = "expr"; private static final String ATTRIBUTE_PROPERTY_ASPECTS = "aspects"; private static final String ATTRIBUTE_PROPERTY_DEFAULT_ASPECT = "defaultAspect"; private Vocabulary vocabulary = null; private String aspect = null; private List<String> aspects = null; private VocabularyProperty vocabularyProperty = null; private Map<String, VocabularyProperty> vocabularyProperties = null;
// Path: src/org/openddr/simpleapi/oddr/model/vocabulary/Vocabulary.java // public class Vocabulary { // // private String[] aspects = null; // private Map<String, VocabularyProperty> properties = null; // private Map<String, VocabularyVariable> vocabularyVariables = null; // private String vocabularyIRI = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public Map<String, VocabularyProperty> getProperties() { // return properties; // } // // public void setProperties(Map<String, VocabularyProperty> properties) { // this.properties = properties; // } // // public Map<String, VocabularyVariable> getVocabularyVariables() { // return vocabularyVariables; // } // // public void setVocabularyVariables(Map<String, VocabularyVariable> vocabularyVariables) { // this.vocabularyVariables = vocabularyVariables; // } // // public String getVocabularyIRI() { // return vocabularyIRI; // } // // public void setVocabularyIRI(String vocabularyIRI) { // this.vocabularyIRI = vocabularyIRI; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyProperty.java // public class VocabularyProperty { // // private String[] aspects = null; // private String defaultAspect = null; // private String expr = null; // private String name = null; // private String type = null; // // public String[] getAspects() { // return aspects; // } // // public void setAspects(String[] aspects) { // this.aspects = aspects; // } // // public String getDefaultAspect() { // return defaultAspect; // } // // public void setDefaultAspect(String defaultAspect) { // this.defaultAspect = defaultAspect; // } // // public String getExpr() { // return expr; // } // // public void setExpr(String expr) { // this.expr = expr; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // } // // Path: src/org/openddr/simpleapi/oddr/model/vocabulary/VocabularyVariable.java // public class VocabularyVariable { // // private String aspect = null; // private String id = null; // private String name = null; // private String vocabulary = null; // // public String getAspect() { // return aspect; // } // // public void setAspect(String aspect) { // this.aspect = aspect; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getVocabulary() { // return vocabulary; // } // // public void setVocabulary(String vocabulary) { // this.vocabulary = vocabulary; // } // // @Override // public String toString() { // return "VocabularyVariable {" + " aspect=" + aspect + " id=" + id + " name=" + name + " vocabulary=" + vocabulary + '}'; // } // } // Path: src/org/openddr/simpleapi/oddr/documenthandler/VocabularyHandler.java import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.openddr.simpleapi.oddr.model.vocabulary.Vocabulary; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyProperty; import org.openddr.simpleapi.oddr.model.vocabulary.VocabularyVariable; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; /** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.documenthandler; public class VocabularyHandler extends DefaultHandler { private static final String ELEMENT_VOCABULARY_DESCRIPTION = "VocabularyDescription"; private static final String ELEMENT_ASPECTS = "Aspects"; private static final String ELEMENT_ASPECT = "Aspect"; private static final String ELEMENT_VARIABLES = "Variables"; private static final String ELEMENT_VARIABLE = "Variable"; private static final String ELEMENT_PROPERTIES = "Properties"; private static final String ELEMENT_PROPERTY = "Property"; private static final String ATTRIBUTE_PROPERTY_TARGET = "target"; private static final String ATTRIBUTE_PROPERTY_ASPECT_NAME = "name"; private static final String ATTRIBUTE_PROPERTY_ASPECT = "aspect"; private static final String ATTRIBUTE_PROPERTY_NAME = "name"; private static final String ATTRIBUTE_PROPERTY_VOCABULARY = "vocabulary"; private static final String ATTRIBUTE_PROPERTY_ID = "id"; private static final String ATTRIBUTE_PROPERTY_DATA_TYPE = "datatype"; private static final String ATTRIBUTE_PROPERTY_EXPR = "expr"; private static final String ATTRIBUTE_PROPERTY_ASPECTS = "aspects"; private static final String ATTRIBUTE_PROPERTY_DEFAULT_ASPECT = "defaultAspect"; private Vocabulary vocabulary = null; private String aspect = null; private List<String> aspects = null; private VocabularyProperty vocabularyProperty = null; private Map<String, VocabularyProperty> vocabularyProperties = null;
private Map<String, VocabularyVariable> vocabularyVariables = null;
OpenDDRdotORG/OpenDDR-Java
src/org/openddr/simpleapi/oddr/documenthandler/DeviceBuilderHandler.java
// Path: src/org/openddr/simpleapi/oddr/builder/device/DeviceBuilder.java // public interface DeviceBuilder extends Builder { // // public void putDevice(String deviceID, List<String> initProperties); // // public void completeInit(Map<String, Device> devices); // }
import java.util.ArrayList; import java.util.List; import org.openddr.simpleapi.oddr.builder.device.DeviceBuilder; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler;
/** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.documenthandler; public class DeviceBuilderHandler extends DefaultHandler { private Object BUILDER_DEVICE = "builder"; private static final String ELEMENT_DEVICE = "device"; private static final String ELEMENT_PROPERTY = "property"; private static final String ELEMENT_LIST = "list"; private static final String ELEMENT_VALUE = "value"; private static final String ATTRIBUTE_DEVICE_ID = "id"; private String character = "";
// Path: src/org/openddr/simpleapi/oddr/builder/device/DeviceBuilder.java // public interface DeviceBuilder extends Builder { // // public void putDevice(String deviceID, List<String> initProperties); // // public void completeInit(Map<String, Device> devices); // } // Path: src/org/openddr/simpleapi/oddr/documenthandler/DeviceBuilderHandler.java import java.util.ArrayList; import java.util.List; import org.openddr.simpleapi.oddr.builder.device.DeviceBuilder; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; /** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>. * */ package org.openddr.simpleapi.oddr.documenthandler; public class DeviceBuilderHandler extends DefaultHandler { private Object BUILDER_DEVICE = "builder"; private static final String ELEMENT_DEVICE = "device"; private static final String ELEMENT_PROPERTY = "property"; private static final String ELEMENT_LIST = "list"; private static final String ELEMENT_VALUE = "value"; private static final String ATTRIBUTE_DEVICE_ID = "id"; private String character = "";
private DeviceBuilder deviceBuilderInstance;
3pillarlabs/spring-integration-aws
spring-integration-aws/src/test/java/org/springframework/integration/aws/support/SnsTestProxyImpl.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/core/HttpEndpoint.java // public class HttpEndpoint implements HttpRequestHandler { // // private static final String SUBSCRIPTION_CONFIRMATION = "SubscriptionConfirmation"; // private static final String NOTIFICATION = "Notification"; // private static final String SNS_MESSAGE_TYPE = "x-amz-sns-message-type"; // // private final Log log = LogFactory.getLog(HttpEndpoint.class); // // private boolean passThru; // private volatile NotificationHandler notificationHandler; // // public HttpEndpoint(NotificationHandler notificationHandler) { // this(); // this.notificationHandler = notificationHandler; // } // // public HttpEndpoint() { // super(); // this.passThru = false; // } // // public void setNotificationHandler(NotificationHandler notificationHandler) { // this.notificationHandler = notificationHandler; // } // // public void setPassThru(boolean passThru) { // this.passThru = passThru; // } // // @Override // public void handleRequest(HttpServletRequest request, // HttpServletResponse response) throws ServletException, IOException { // // boolean unprocessable = true; // if (request.getMethod().equals(RequestMethod.POST.toString())) { // // if (SUBSCRIPTION_CONFIRMATION.equals(request // .getHeader(SNS_MESSAGE_TYPE))) { // // unprocessable = false; // handleSubscriptionConfirmation(request, response); // // } else if (NOTIFICATION.equals(request.getHeader(SNS_MESSAGE_TYPE))) { // // if (notificationHandler != null) { // unprocessable = false; // handleNotification(request, response); // } // } // // } // if (unprocessable) { // log.warn("Unprocessable request: " // + request.getRequestURL().toString()); // response.setStatus(HttpServletResponse.SC_NOT_ACCEPTABLE); // } // } // // private void handleSubscriptionConfirmation(HttpServletRequest request, // HttpServletResponse response) throws IOException { // try { // String source = readBody(request); // log.debug("Subscription confirmation:\n" + source); // JSONObject confirmation = new JSONObject(source); // // if (validSignature(source, confirmation)) { // URL subscribeUrl = new URL( // confirmation.getString("SubscribeURL")); // HttpURLConnection http = (HttpURLConnection) subscribeUrl // .openConnection(); // http.setDoOutput(false); // http.setDoInput(true); // StringBuilder buffer = new StringBuilder(); // byte[] buf = new byte[4096]; // while ((http.getInputStream().read(buf)) >= 0) { // buffer.append(new String(buf)); // } // log.debug("SubscribeURL response:\n" + buffer.toString()); // } // response.setStatus(HttpServletResponse.SC_OK); // // } catch (JSONException e) { // throw new IOException(e.getMessage(), e); // } // } // // private void handleNotification(HttpServletRequest request, // HttpServletResponse response) throws IOException { // try { // // String source = readBody(request); // log.debug("Message received:\n" + source); // JSONObject notification = new JSONObject(source); // if (passThru || validSignature(source, notification)) { // notificationHandler.onNotification(notification // .getString("Message")); // } // response.setStatus(HttpServletResponse.SC_ACCEPTED); // } catch (JSONException e) { // throw new IOException(e.getMessage(), e); // } // } // // private String readBody(HttpServletRequest request) throws IOException { // // StringBuilder buffer = new StringBuilder(request.getContentLength()); // String line = null; // BufferedReader reader = request.getReader(); // while ((line = reader.readLine()) != null) { // buffer.append(line); // } // // return buffer.toString(); // } // // private boolean validSignature(String source, JSONObject jsonObject) // throws JSONException, IOException { // // PublicKey pubKey = fetchPubKey(jsonObject.getString("SigningCertURL")); // SignatureChecker signatureChecker = new SignatureChecker(); // // return signatureChecker.verifyMessageSignature(source, pubKey); // } // // private PublicKey fetchPubKey(String signingCertURL) throws IOException { // // try { // URL url = new URL(signingCertURL); // InputStream inStream = url.openStream(); // CertificateFactory cf = CertificateFactory.getInstance("X.509"); // X509Certificate cert = (X509Certificate) cf // .generateCertificate(inStream); // inStream.close(); // // return cert.getPublicKey(); // // } catch (Exception e) { // throw new IOException(e); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/support/SnsTestProxy.java // public interface SnsTestProxy { // // public abstract void setQueue(BlockingQueue<String> queue); // // public abstract void setHttpEndpoint(HttpEndpoint httpEndpoint); // // public abstract void dispatchMessage(String jsonPayload); // // }
import java.util.concurrent.BlockingQueue; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.integration.aws.sns.core.HttpEndpoint; import org.springframework.integration.aws.sns.support.SnsTestProxy; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.web.bind.annotation.RequestMethod;
package org.springframework.integration.aws.support; public class SnsTestProxyImpl implements SnsTestProxy { private final Log log = LogFactory.getLog(SnsTestProxyImpl.class); private BlockingQueue<String> queue;
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/core/HttpEndpoint.java // public class HttpEndpoint implements HttpRequestHandler { // // private static final String SUBSCRIPTION_CONFIRMATION = "SubscriptionConfirmation"; // private static final String NOTIFICATION = "Notification"; // private static final String SNS_MESSAGE_TYPE = "x-amz-sns-message-type"; // // private final Log log = LogFactory.getLog(HttpEndpoint.class); // // private boolean passThru; // private volatile NotificationHandler notificationHandler; // // public HttpEndpoint(NotificationHandler notificationHandler) { // this(); // this.notificationHandler = notificationHandler; // } // // public HttpEndpoint() { // super(); // this.passThru = false; // } // // public void setNotificationHandler(NotificationHandler notificationHandler) { // this.notificationHandler = notificationHandler; // } // // public void setPassThru(boolean passThru) { // this.passThru = passThru; // } // // @Override // public void handleRequest(HttpServletRequest request, // HttpServletResponse response) throws ServletException, IOException { // // boolean unprocessable = true; // if (request.getMethod().equals(RequestMethod.POST.toString())) { // // if (SUBSCRIPTION_CONFIRMATION.equals(request // .getHeader(SNS_MESSAGE_TYPE))) { // // unprocessable = false; // handleSubscriptionConfirmation(request, response); // // } else if (NOTIFICATION.equals(request.getHeader(SNS_MESSAGE_TYPE))) { // // if (notificationHandler != null) { // unprocessable = false; // handleNotification(request, response); // } // } // // } // if (unprocessable) { // log.warn("Unprocessable request: " // + request.getRequestURL().toString()); // response.setStatus(HttpServletResponse.SC_NOT_ACCEPTABLE); // } // } // // private void handleSubscriptionConfirmation(HttpServletRequest request, // HttpServletResponse response) throws IOException { // try { // String source = readBody(request); // log.debug("Subscription confirmation:\n" + source); // JSONObject confirmation = new JSONObject(source); // // if (validSignature(source, confirmation)) { // URL subscribeUrl = new URL( // confirmation.getString("SubscribeURL")); // HttpURLConnection http = (HttpURLConnection) subscribeUrl // .openConnection(); // http.setDoOutput(false); // http.setDoInput(true); // StringBuilder buffer = new StringBuilder(); // byte[] buf = new byte[4096]; // while ((http.getInputStream().read(buf)) >= 0) { // buffer.append(new String(buf)); // } // log.debug("SubscribeURL response:\n" + buffer.toString()); // } // response.setStatus(HttpServletResponse.SC_OK); // // } catch (JSONException e) { // throw new IOException(e.getMessage(), e); // } // } // // private void handleNotification(HttpServletRequest request, // HttpServletResponse response) throws IOException { // try { // // String source = readBody(request); // log.debug("Message received:\n" + source); // JSONObject notification = new JSONObject(source); // if (passThru || validSignature(source, notification)) { // notificationHandler.onNotification(notification // .getString("Message")); // } // response.setStatus(HttpServletResponse.SC_ACCEPTED); // } catch (JSONException e) { // throw new IOException(e.getMessage(), e); // } // } // // private String readBody(HttpServletRequest request) throws IOException { // // StringBuilder buffer = new StringBuilder(request.getContentLength()); // String line = null; // BufferedReader reader = request.getReader(); // while ((line = reader.readLine()) != null) { // buffer.append(line); // } // // return buffer.toString(); // } // // private boolean validSignature(String source, JSONObject jsonObject) // throws JSONException, IOException { // // PublicKey pubKey = fetchPubKey(jsonObject.getString("SigningCertURL")); // SignatureChecker signatureChecker = new SignatureChecker(); // // return signatureChecker.verifyMessageSignature(source, pubKey); // } // // private PublicKey fetchPubKey(String signingCertURL) throws IOException { // // try { // URL url = new URL(signingCertURL); // InputStream inStream = url.openStream(); // CertificateFactory cf = CertificateFactory.getInstance("X.509"); // X509Certificate cert = (X509Certificate) cf // .generateCertificate(inStream); // inStream.close(); // // return cert.getPublicKey(); // // } catch (Exception e) { // throw new IOException(e); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/support/SnsTestProxy.java // public interface SnsTestProxy { // // public abstract void setQueue(BlockingQueue<String> queue); // // public abstract void setHttpEndpoint(HttpEndpoint httpEndpoint); // // public abstract void dispatchMessage(String jsonPayload); // // } // Path: spring-integration-aws/src/test/java/org/springframework/integration/aws/support/SnsTestProxyImpl.java import java.util.concurrent.BlockingQueue; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.integration.aws.sns.core.HttpEndpoint; import org.springframework.integration.aws.sns.support.SnsTestProxy; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.web.bind.annotation.RequestMethod; package org.springframework.integration.aws.support; public class SnsTestProxyImpl implements SnsTestProxy { private final Log log = LogFactory.getLog(SnsTestProxyImpl.class); private BlockingQueue<String> queue;
private HttpEndpoint httpEndpoint;
3pillarlabs/spring-integration-aws
spring-integration-aws/src/test/java/org/springframework/integration/aws/JsonMessageMarshallerTest.java
// Path: spring-integration-aws/src/test/java/org/springframework/integration/aws/support/TestPojo.java // public class TestPojo { // // private String name; // private String email; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // @Override // public boolean equals(Object obj) { // boolean same = false; // if (this.getClass().isInstance(obj)) { // TestPojo other = (TestPojo) obj; // same = ((this.name == null || this.name.equals(other.name)) && (this.email == null || this.email // .equals(other.email))); // } // return same; // } // // }
import static junit.framework.Assert.*; import java.util.Arrays; import java.util.Date; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.springframework.integration.Message; import org.springframework.integration.MessageHeaders; import org.springframework.integration.aws.support.TestPojo; import org.springframework.integration.support.MessageBuilder;
package org.springframework.integration.aws; @RunWith(JUnit4.class) public class JsonMessageMarshallerTest { private JsonMessageMarshaller marshaller; @Before public void setup() { marshaller = new JsonMessageMarshaller(); } @Test public void testSerialization() throws MessageMarshallerException {
// Path: spring-integration-aws/src/test/java/org/springframework/integration/aws/support/TestPojo.java // public class TestPojo { // // private String name; // private String email; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // @Override // public boolean equals(Object obj) { // boolean same = false; // if (this.getClass().isInstance(obj)) { // TestPojo other = (TestPojo) obj; // same = ((this.name == null || this.name.equals(other.name)) && (this.email == null || this.email // .equals(other.email))); // } // return same; // } // // } // Path: spring-integration-aws/src/test/java/org/springframework/integration/aws/JsonMessageMarshallerTest.java import static junit.framework.Assert.*; import java.util.Arrays; import java.util.Date; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.springframework.integration.Message; import org.springframework.integration.MessageHeaders; import org.springframework.integration.aws.support.TestPojo; import org.springframework.integration.support.MessageBuilder; package org.springframework.integration.aws; @RunWith(JUnit4.class) public class JsonMessageMarshallerTest { private JsonMessageMarshaller marshaller; @Before public void setup() { marshaller = new JsonMessageMarshaller(); } @Test public void testSerialization() throws MessageMarshallerException {
TestPojo pojo = new TestPojo();
3pillarlabs/spring-integration-aws
spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/support/SnsTestProxy.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/core/HttpEndpoint.java // public class HttpEndpoint implements HttpRequestHandler { // // private static final String SUBSCRIPTION_CONFIRMATION = "SubscriptionConfirmation"; // private static final String NOTIFICATION = "Notification"; // private static final String SNS_MESSAGE_TYPE = "x-amz-sns-message-type"; // // private final Log log = LogFactory.getLog(HttpEndpoint.class); // // private boolean passThru; // private volatile NotificationHandler notificationHandler; // // public HttpEndpoint(NotificationHandler notificationHandler) { // this(); // this.notificationHandler = notificationHandler; // } // // public HttpEndpoint() { // super(); // this.passThru = false; // } // // public void setNotificationHandler(NotificationHandler notificationHandler) { // this.notificationHandler = notificationHandler; // } // // public void setPassThru(boolean passThru) { // this.passThru = passThru; // } // // @Override // public void handleRequest(HttpServletRequest request, // HttpServletResponse response) throws ServletException, IOException { // // boolean unprocessable = true; // if (request.getMethod().equals(RequestMethod.POST.toString())) { // // if (SUBSCRIPTION_CONFIRMATION.equals(request // .getHeader(SNS_MESSAGE_TYPE))) { // // unprocessable = false; // handleSubscriptionConfirmation(request, response); // // } else if (NOTIFICATION.equals(request.getHeader(SNS_MESSAGE_TYPE))) { // // if (notificationHandler != null) { // unprocessable = false; // handleNotification(request, response); // } // } // // } // if (unprocessable) { // log.warn("Unprocessable request: " // + request.getRequestURL().toString()); // response.setStatus(HttpServletResponse.SC_NOT_ACCEPTABLE); // } // } // // private void handleSubscriptionConfirmation(HttpServletRequest request, // HttpServletResponse response) throws IOException { // try { // String source = readBody(request); // log.debug("Subscription confirmation:\n" + source); // JSONObject confirmation = new JSONObject(source); // // if (validSignature(source, confirmation)) { // URL subscribeUrl = new URL( // confirmation.getString("SubscribeURL")); // HttpURLConnection http = (HttpURLConnection) subscribeUrl // .openConnection(); // http.setDoOutput(false); // http.setDoInput(true); // StringBuilder buffer = new StringBuilder(); // byte[] buf = new byte[4096]; // while ((http.getInputStream().read(buf)) >= 0) { // buffer.append(new String(buf)); // } // log.debug("SubscribeURL response:\n" + buffer.toString()); // } // response.setStatus(HttpServletResponse.SC_OK); // // } catch (JSONException e) { // throw new IOException(e.getMessage(), e); // } // } // // private void handleNotification(HttpServletRequest request, // HttpServletResponse response) throws IOException { // try { // // String source = readBody(request); // log.debug("Message received:\n" + source); // JSONObject notification = new JSONObject(source); // if (passThru || validSignature(source, notification)) { // notificationHandler.onNotification(notification // .getString("Message")); // } // response.setStatus(HttpServletResponse.SC_ACCEPTED); // } catch (JSONException e) { // throw new IOException(e.getMessage(), e); // } // } // // private String readBody(HttpServletRequest request) throws IOException { // // StringBuilder buffer = new StringBuilder(request.getContentLength()); // String line = null; // BufferedReader reader = request.getReader(); // while ((line = reader.readLine()) != null) { // buffer.append(line); // } // // return buffer.toString(); // } // // private boolean validSignature(String source, JSONObject jsonObject) // throws JSONException, IOException { // // PublicKey pubKey = fetchPubKey(jsonObject.getString("SigningCertURL")); // SignatureChecker signatureChecker = new SignatureChecker(); // // return signatureChecker.verifyMessageSignature(source, pubKey); // } // // private PublicKey fetchPubKey(String signingCertURL) throws IOException { // // try { // URL url = new URL(signingCertURL); // InputStream inStream = url.openStream(); // CertificateFactory cf = CertificateFactory.getInstance("X.509"); // X509Certificate cert = (X509Certificate) cf // .generateCertificate(inStream); // inStream.close(); // // return cert.getPublicKey(); // // } catch (Exception e) { // throw new IOException(e); // } // } // // }
import java.util.concurrent.BlockingQueue; import org.springframework.integration.aws.sns.core.HttpEndpoint;
package org.springframework.integration.aws.sns.support; public interface SnsTestProxy { public abstract void setQueue(BlockingQueue<String> queue);
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/core/HttpEndpoint.java // public class HttpEndpoint implements HttpRequestHandler { // // private static final String SUBSCRIPTION_CONFIRMATION = "SubscriptionConfirmation"; // private static final String NOTIFICATION = "Notification"; // private static final String SNS_MESSAGE_TYPE = "x-amz-sns-message-type"; // // private final Log log = LogFactory.getLog(HttpEndpoint.class); // // private boolean passThru; // private volatile NotificationHandler notificationHandler; // // public HttpEndpoint(NotificationHandler notificationHandler) { // this(); // this.notificationHandler = notificationHandler; // } // // public HttpEndpoint() { // super(); // this.passThru = false; // } // // public void setNotificationHandler(NotificationHandler notificationHandler) { // this.notificationHandler = notificationHandler; // } // // public void setPassThru(boolean passThru) { // this.passThru = passThru; // } // // @Override // public void handleRequest(HttpServletRequest request, // HttpServletResponse response) throws ServletException, IOException { // // boolean unprocessable = true; // if (request.getMethod().equals(RequestMethod.POST.toString())) { // // if (SUBSCRIPTION_CONFIRMATION.equals(request // .getHeader(SNS_MESSAGE_TYPE))) { // // unprocessable = false; // handleSubscriptionConfirmation(request, response); // // } else if (NOTIFICATION.equals(request.getHeader(SNS_MESSAGE_TYPE))) { // // if (notificationHandler != null) { // unprocessable = false; // handleNotification(request, response); // } // } // // } // if (unprocessable) { // log.warn("Unprocessable request: " // + request.getRequestURL().toString()); // response.setStatus(HttpServletResponse.SC_NOT_ACCEPTABLE); // } // } // // private void handleSubscriptionConfirmation(HttpServletRequest request, // HttpServletResponse response) throws IOException { // try { // String source = readBody(request); // log.debug("Subscription confirmation:\n" + source); // JSONObject confirmation = new JSONObject(source); // // if (validSignature(source, confirmation)) { // URL subscribeUrl = new URL( // confirmation.getString("SubscribeURL")); // HttpURLConnection http = (HttpURLConnection) subscribeUrl // .openConnection(); // http.setDoOutput(false); // http.setDoInput(true); // StringBuilder buffer = new StringBuilder(); // byte[] buf = new byte[4096]; // while ((http.getInputStream().read(buf)) >= 0) { // buffer.append(new String(buf)); // } // log.debug("SubscribeURL response:\n" + buffer.toString()); // } // response.setStatus(HttpServletResponse.SC_OK); // // } catch (JSONException e) { // throw new IOException(e.getMessage(), e); // } // } // // private void handleNotification(HttpServletRequest request, // HttpServletResponse response) throws IOException { // try { // // String source = readBody(request); // log.debug("Message received:\n" + source); // JSONObject notification = new JSONObject(source); // if (passThru || validSignature(source, notification)) { // notificationHandler.onNotification(notification // .getString("Message")); // } // response.setStatus(HttpServletResponse.SC_ACCEPTED); // } catch (JSONException e) { // throw new IOException(e.getMessage(), e); // } // } // // private String readBody(HttpServletRequest request) throws IOException { // // StringBuilder buffer = new StringBuilder(request.getContentLength()); // String line = null; // BufferedReader reader = request.getReader(); // while ((line = reader.readLine()) != null) { // buffer.append(line); // } // // return buffer.toString(); // } // // private boolean validSignature(String source, JSONObject jsonObject) // throws JSONException, IOException { // // PublicKey pubKey = fetchPubKey(jsonObject.getString("SigningCertURL")); // SignatureChecker signatureChecker = new SignatureChecker(); // // return signatureChecker.verifyMessageSignature(source, pubKey); // } // // private PublicKey fetchPubKey(String signingCertURL) throws IOException { // // try { // URL url = new URL(signingCertURL); // InputStream inStream = url.openStream(); // CertificateFactory cf = CertificateFactory.getInstance("X.509"); // X509Certificate cert = (X509Certificate) cf // .generateCertificate(inStream); // inStream.close(); // // return cert.getPublicKey(); // // } catch (Exception e) { // throw new IOException(e); // } // } // // } // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/support/SnsTestProxy.java import java.util.concurrent.BlockingQueue; import org.springframework.integration.aws.sns.core.HttpEndpoint; package org.springframework.integration.aws.sns.support; public interface SnsTestProxy { public abstract void setQueue(BlockingQueue<String> queue);
public abstract void setHttpEndpoint(HttpEndpoint httpEndpoint);
3pillarlabs/spring-integration-aws
spring-integration-aws/src/test/java/org/springframework/integration/aws/support/TestMessageMarshaller.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/MessageMarshaller.java // public interface MessageMarshaller { // // /** // * Converts a Message to a String. // * // * @param message // * @return serialized string // * @throws MessageMarshallerException // */ // String serialize(Message<?> message) throws MessageMarshallerException; // // /** // * Converts input String to Message. // * // * @param input // * @return Message // * @throws MessageMarshallerException // */ // Message<?> deserialize(String input) throws MessageMarshallerException; // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/MessageMarshallerException.java // public class MessageMarshallerException extends Exception { // // private static final long serialVersionUID = 1L; // // public MessageMarshallerException(String message, Throwable cause) { // super(message, cause); // } // // public MessageMarshallerException(String message) { // super(message); // } // // }
import org.springframework.integration.Message; import org.springframework.integration.aws.MessageMarshaller; import org.springframework.integration.aws.MessageMarshallerException; import org.springframework.integration.support.MessageBuilder;
package org.springframework.integration.aws.support; /** * Dummy implementation for configuration tests. * * @author Sayantam Dey * */ public class TestMessageMarshaller implements MessageMarshaller { @Override public String serialize(Message<?> message)
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/MessageMarshaller.java // public interface MessageMarshaller { // // /** // * Converts a Message to a String. // * // * @param message // * @return serialized string // * @throws MessageMarshallerException // */ // String serialize(Message<?> message) throws MessageMarshallerException; // // /** // * Converts input String to Message. // * // * @param input // * @return Message // * @throws MessageMarshallerException // */ // Message<?> deserialize(String input) throws MessageMarshallerException; // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/MessageMarshallerException.java // public class MessageMarshallerException extends Exception { // // private static final long serialVersionUID = 1L; // // public MessageMarshallerException(String message, Throwable cause) { // super(message, cause); // } // // public MessageMarshallerException(String message) { // super(message); // } // // } // Path: spring-integration-aws/src/test/java/org/springframework/integration/aws/support/TestMessageMarshaller.java import org.springframework.integration.Message; import org.springframework.integration.aws.MessageMarshaller; import org.springframework.integration.aws.MessageMarshallerException; import org.springframework.integration.support.MessageBuilder; package org.springframework.integration.aws.support; /** * Dummy implementation for configuration tests. * * @author Sayantam Dey * */ public class TestMessageMarshaller implements MessageMarshaller { @Override public String serialize(Message<?> message)
throws MessageMarshallerException {
3pillarlabs/spring-integration-aws
spring-integration-aws/src/test/java/org/springframework/integration/aws/sns/config/SnsClientConfigurationTest.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/channel/PublishSubscribeSnsChannel.java // public class PublishSubscribeSnsChannel extends AbstractMessageChannel // implements SubscribableChannel, SmartLifecycle, DisposableBean { // // private final Log log = LogFactory.getLog(PublishSubscribeSnsChannel.class); // // private int phase = 0; // private boolean autoStartup = true; // private boolean running = false; // private NotificationHandler notificationHandler; // // private volatile SnsExecutor snsExecutor; // private volatile MessageDispatcher dispatcher; // // public PublishSubscribeSnsChannel() { // super(); // this.dispatcher = new BroadcastingDispatcher(); // } // // public void setSnsExecutor(SnsExecutor snsExecutor) { // this.snsExecutor = snsExecutor; // } // // @Override // protected boolean doSend(Message<?> message, long timeout) { // snsExecutor.executeOutboundOperation(message); // return true; // } // // @Override // public void start() { // snsExecutor.registerHandler(notificationHandler); // running = true; // log.info(getComponentName() + "[" + this.getClass().getName() // + "] started listening for messages..."); // } // // @Override // public void stop() { // if (running) { // running = false; // log.info(getComponentName() + "[" + this.getClass().getName() // + "] listener stopped"); // } // } // // @Override // public boolean isRunning() { // return running; // } // // @Override // public int getPhase() { // return phase; // } // // public void setPhase(int phase) { // this.phase = phase; // } // // @Override // public void destroy() throws Exception { // stop(); // } // // @Override // public boolean isAutoStartup() { // return autoStartup; // } // // public void setAutoStartup(boolean autoStartup) { // this.autoStartup = autoStartup; // } // // @Override // public void stop(Runnable callback) { // stop(); // callback.run(); // } // // @Override // public boolean subscribe(MessageHandler handler) { // return dispatcher.addHandler(handler); // } // // @Override // public boolean unsubscribe(MessageHandler handler) { // return dispatcher.removeHandler(handler); // } // // @Override // protected void onInit() throws Exception { // super.onInit(); // Assert.notNull(snsExecutor, "'snsExecutor' must not be null"); // notificationHandler = new NotificationHandler() { // // @Override // protected void dispatch(Message<?> message) { // dispatcher.dispatch(message); // } // }; // // log.info("Initialized SNS Channel: [" + getComponentName() + "]"); // // } // // @Override // public String getComponentType() { // return "publish-subscribe-channel"; // } // // }
import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; import org.junit.After; import org.junit.Test; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.aws.sns.channel.PublishSubscribeSnsChannel; import org.springframework.integration.test.util.TestUtils; import com.amazonaws.ClientConfiguration; import com.amazonaws.Protocol;
package org.springframework.integration.aws.sns.config; /** * SnsClientConfigurationTest * * @author scubi */ public class SnsClientConfigurationTest { private ConfigurableApplicationContext context;
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/channel/PublishSubscribeSnsChannel.java // public class PublishSubscribeSnsChannel extends AbstractMessageChannel // implements SubscribableChannel, SmartLifecycle, DisposableBean { // // private final Log log = LogFactory.getLog(PublishSubscribeSnsChannel.class); // // private int phase = 0; // private boolean autoStartup = true; // private boolean running = false; // private NotificationHandler notificationHandler; // // private volatile SnsExecutor snsExecutor; // private volatile MessageDispatcher dispatcher; // // public PublishSubscribeSnsChannel() { // super(); // this.dispatcher = new BroadcastingDispatcher(); // } // // public void setSnsExecutor(SnsExecutor snsExecutor) { // this.snsExecutor = snsExecutor; // } // // @Override // protected boolean doSend(Message<?> message, long timeout) { // snsExecutor.executeOutboundOperation(message); // return true; // } // // @Override // public void start() { // snsExecutor.registerHandler(notificationHandler); // running = true; // log.info(getComponentName() + "[" + this.getClass().getName() // + "] started listening for messages..."); // } // // @Override // public void stop() { // if (running) { // running = false; // log.info(getComponentName() + "[" + this.getClass().getName() // + "] listener stopped"); // } // } // // @Override // public boolean isRunning() { // return running; // } // // @Override // public int getPhase() { // return phase; // } // // public void setPhase(int phase) { // this.phase = phase; // } // // @Override // public void destroy() throws Exception { // stop(); // } // // @Override // public boolean isAutoStartup() { // return autoStartup; // } // // public void setAutoStartup(boolean autoStartup) { // this.autoStartup = autoStartup; // } // // @Override // public void stop(Runnable callback) { // stop(); // callback.run(); // } // // @Override // public boolean subscribe(MessageHandler handler) { // return dispatcher.addHandler(handler); // } // // @Override // public boolean unsubscribe(MessageHandler handler) { // return dispatcher.removeHandler(handler); // } // // @Override // protected void onInit() throws Exception { // super.onInit(); // Assert.notNull(snsExecutor, "'snsExecutor' must not be null"); // notificationHandler = new NotificationHandler() { // // @Override // protected void dispatch(Message<?> message) { // dispatcher.dispatch(message); // } // }; // // log.info("Initialized SNS Channel: [" + getComponentName() + "]"); // // } // // @Override // public String getComponentType() { // return "publish-subscribe-channel"; // } // // } // Path: spring-integration-aws/src/test/java/org/springframework/integration/aws/sns/config/SnsClientConfigurationTest.java import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; import org.junit.After; import org.junit.Test; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.aws.sns.channel.PublishSubscribeSnsChannel; import org.springframework.integration.test.util.TestUtils; import com.amazonaws.ClientConfiguration; import com.amazonaws.Protocol; package org.springframework.integration.aws.sns.config; /** * SnsClientConfigurationTest * * @author scubi */ public class SnsClientConfigurationTest { private ConfigurableApplicationContext context;
private PublishSubscribeSnsChannel snsChannelWithClientConfiguration;
3pillarlabs/spring-integration-aws
spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/Permission.java // public class Permission { // // /** // * The unique identification of the permission. See // * {@link com.amazonaws.services.sqs.model.AddPermissionRequest#setLabel(String)} // * for constraints. // */ // private String label; // // /** // * AWS account numbers to be given the permission. // */ // private Set<String> awsAccountIds; // // /** // * The actions to be allowed for the specified AWS accounts // */ // private Set<String> actions; // // public Permission() { // } // // public Permission(String label, Set<String> aWSAccountIds, // Set<String> actions) { // this(); // this.label = label; // this.awsAccountIds = aWSAccountIds; // this.actions = actions; // } // // public String getLabel() { // return label; // } // // public void setLabel(String label) { // this.label = label; // } // // public Set<String> getAwsAccountIds() { // return awsAccountIds; // } // // public void setAwsAccountIds(Set<String> awsAccountIds) { // this.awsAccountIds = awsAccountIds; // } // // public Set<String> getActions() { // return actions; // } // // public void setActions(Set<String> actions) { // this.actions = actions; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + ((awsAccountIds == null) ? 0 : awsAccountIds.hashCode()); // result = prime * result + ((actions == null) ? 0 : actions.hashCode()); // result = prime * result + ((label == null) ? 0 : label.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; // Permission other = (Permission) obj; // if (awsAccountIds == null) { // if (other.awsAccountIds != null) // return false; // } else if (!awsAccountIds.equals(other.awsAccountIds)) // return false; // if (actions == null) { // if (other.actions != null) // return false; // } else if (!actions.equals(other.actions)) // return false; // if (label == null) { // if (other.label != null) // return false; // } else if (!label.equals(other.label)) // return false; // return true; // } // // }
import java.util.HashSet; import java.util.Set; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.Permission; import org.springframework.util.xml.DomUtils; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList;
package org.springframework.integration.aws.config; /** * @author Sayantam Dey * @since 2.0.0 * */ public final class AwsParserUtils { private AwsParserUtils() { } public static void registerPermissions(Element element, BeanDefinitionBuilder executorBuilder, ParserContext parserContext) { Element permissionsElement = DomUtils.getChildElementByTagName(element, "permissions"); if (permissionsElement != null) {
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/Permission.java // public class Permission { // // /** // * The unique identification of the permission. See // * {@link com.amazonaws.services.sqs.model.AddPermissionRequest#setLabel(String)} // * for constraints. // */ // private String label; // // /** // * AWS account numbers to be given the permission. // */ // private Set<String> awsAccountIds; // // /** // * The actions to be allowed for the specified AWS accounts // */ // private Set<String> actions; // // public Permission() { // } // // public Permission(String label, Set<String> aWSAccountIds, // Set<String> actions) { // this(); // this.label = label; // this.awsAccountIds = aWSAccountIds; // this.actions = actions; // } // // public String getLabel() { // return label; // } // // public void setLabel(String label) { // this.label = label; // } // // public Set<String> getAwsAccountIds() { // return awsAccountIds; // } // // public void setAwsAccountIds(Set<String> awsAccountIds) { // this.awsAccountIds = awsAccountIds; // } // // public Set<String> getActions() { // return actions; // } // // public void setActions(Set<String> actions) { // this.actions = actions; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + ((awsAccountIds == null) ? 0 : awsAccountIds.hashCode()); // result = prime * result + ((actions == null) ? 0 : actions.hashCode()); // result = prime * result + ((label == null) ? 0 : label.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; // Permission other = (Permission) obj; // if (awsAccountIds == null) { // if (other.awsAccountIds != null) // return false; // } else if (!awsAccountIds.equals(other.awsAccountIds)) // return false; // if (actions == null) { // if (other.actions != null) // return false; // } else if (!actions.equals(other.actions)) // return false; // if (label == null) { // if (other.label != null) // return false; // } else if (!label.equals(other.label)) // return false; // return true; // } // // } // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java import java.util.HashSet; import java.util.Set; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.Permission; import org.springframework.util.xml.DomUtils; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; package org.springframework.integration.aws.config; /** * @author Sayantam Dey * @since 2.0.0 * */ public final class AwsParserUtils { private AwsParserUtils() { } public static void registerPermissions(Element element, BeanDefinitionBuilder executorBuilder, ParserContext parserContext) { Element permissionsElement = DomUtils.getChildElementByTagName(element, "permissions"); if (permissionsElement != null) {
Set<Permission> permissions = new HashSet<Permission>();
3pillarlabs/spring-integration-aws
spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/config/SnsInboundChannelAdapterParser.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/inbound/SnsInboundChannelAdapter.java // public class SnsInboundChannelAdapter extends MessageProducerSupport { // // private final Log log = LogFactory.getLog(SnsInboundChannelAdapter.class); // // private volatile SnsExecutor snsExecutor; // // private NotificationHandler notificationHandler; // // public SnsInboundChannelAdapter() { // super(); // } // // public void setSnsExecutor(SnsExecutor snsExecutor) { // this.snsExecutor = snsExecutor; // } // // @Override // protected void doStart() { // super.doStart(); // // snsExecutor.registerHandler(notificationHandler); // // log.info("SNS inbound adapter: [" + getComponentName() // + "], started..."); // } // // @Override // protected void doStop() { // // super.doStop(); // // log.info("SNS inbound adapter: [" + getComponentName() + "], stopped."); // } // // /** // * Check for mandatory attributes // */ // @Override // protected void onInit() { // super.onInit(); // // Assert.notNull(snsExecutor, "snsExecutor must not be null."); // // this.notificationHandler = new NotificationHandler() { // // @Override // protected void dispatch(Message<?> message) { // sendMessage(message); // } // }; // // log.info("SNS inbound adapter: [" + getComponentName() // + "], initialized..."); // } // // @Override // public String getComponentType() { // return "sns:inbound-channel-adapter"; // } // // }
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sns.inbound.SnsInboundChannelAdapter; import org.springframework.integration.config.xml.AbstractChannelAdapterParser; import org.springframework.integration.config.xml.IntegrationNamespaceUtils; import org.w3c.dom.Element;
package org.springframework.integration.aws.sns.config; /** * The Sns Inbound Channel adapter parser * * @author Sayantam Dey * @since 1.0 * */ public class SnsInboundChannelAdapterParser extends AbstractChannelAdapterParser { @Override protected AbstractBeanDefinition doParse(Element element, ParserContext parserContext, String channelName) { final BeanDefinitionBuilder snsInboundChannelAdapterBuilder = BeanDefinitionBuilder
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/inbound/SnsInboundChannelAdapter.java // public class SnsInboundChannelAdapter extends MessageProducerSupport { // // private final Log log = LogFactory.getLog(SnsInboundChannelAdapter.class); // // private volatile SnsExecutor snsExecutor; // // private NotificationHandler notificationHandler; // // public SnsInboundChannelAdapter() { // super(); // } // // public void setSnsExecutor(SnsExecutor snsExecutor) { // this.snsExecutor = snsExecutor; // } // // @Override // protected void doStart() { // super.doStart(); // // snsExecutor.registerHandler(notificationHandler); // // log.info("SNS inbound adapter: [" + getComponentName() // + "], started..."); // } // // @Override // protected void doStop() { // // super.doStop(); // // log.info("SNS inbound adapter: [" + getComponentName() + "], stopped."); // } // // /** // * Check for mandatory attributes // */ // @Override // protected void onInit() { // super.onInit(); // // Assert.notNull(snsExecutor, "snsExecutor must not be null."); // // this.notificationHandler = new NotificationHandler() { // // @Override // protected void dispatch(Message<?> message) { // sendMessage(message); // } // }; // // log.info("SNS inbound adapter: [" + getComponentName() // + "], initialized..."); // } // // @Override // public String getComponentType() { // return "sns:inbound-channel-adapter"; // } // // } // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/config/SnsInboundChannelAdapterParser.java import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sns.inbound.SnsInboundChannelAdapter; import org.springframework.integration.config.xml.AbstractChannelAdapterParser; import org.springframework.integration.config.xml.IntegrationNamespaceUtils; import org.w3c.dom.Element; package org.springframework.integration.aws.sns.config; /** * The Sns Inbound Channel adapter parser * * @author Sayantam Dey * @since 1.0 * */ public class SnsInboundChannelAdapterParser extends AbstractChannelAdapterParser { @Override protected AbstractBeanDefinition doParse(Element element, ParserContext parserContext, String channelName) { final BeanDefinitionBuilder snsInboundChannelAdapterBuilder = BeanDefinitionBuilder
.genericBeanDefinition(SnsInboundChannelAdapter.class);
3pillarlabs/spring-integration-aws
spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/config/SnsInboundChannelAdapterParser.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/inbound/SnsInboundChannelAdapter.java // public class SnsInboundChannelAdapter extends MessageProducerSupport { // // private final Log log = LogFactory.getLog(SnsInboundChannelAdapter.class); // // private volatile SnsExecutor snsExecutor; // // private NotificationHandler notificationHandler; // // public SnsInboundChannelAdapter() { // super(); // } // // public void setSnsExecutor(SnsExecutor snsExecutor) { // this.snsExecutor = snsExecutor; // } // // @Override // protected void doStart() { // super.doStart(); // // snsExecutor.registerHandler(notificationHandler); // // log.info("SNS inbound adapter: [" + getComponentName() // + "], started..."); // } // // @Override // protected void doStop() { // // super.doStop(); // // log.info("SNS inbound adapter: [" + getComponentName() + "], stopped."); // } // // /** // * Check for mandatory attributes // */ // @Override // protected void onInit() { // super.onInit(); // // Assert.notNull(snsExecutor, "snsExecutor must not be null."); // // this.notificationHandler = new NotificationHandler() { // // @Override // protected void dispatch(Message<?> message) { // sendMessage(message); // } // }; // // log.info("SNS inbound adapter: [" + getComponentName() // + "], initialized..."); // } // // @Override // public String getComponentType() { // return "sns:inbound-channel-adapter"; // } // // }
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sns.inbound.SnsInboundChannelAdapter; import org.springframework.integration.config.xml.AbstractChannelAdapterParser; import org.springframework.integration.config.xml.IntegrationNamespaceUtils; import org.w3c.dom.Element;
snsInboundChannelAdapterBuilder, element, "auto-startup"); final BeanDefinitionBuilder snsExecutorBuilder = SnsParserUtils .getSnsExecutorBuilder(element, parserContext); final BeanDefinition snsExecutorBuilderBeanDefinition = snsExecutorBuilder .getBeanDefinition(); final String channelAdapterId = this.resolveId(element, snsInboundChannelAdapterBuilder.getRawBeanDefinition(), parserContext); final String snsExecutorBeanName = channelAdapterId + ".snsExecutor"; SnsParserUtils.registerSubscriptions(element, parserContext, snsExecutorBuilder, channelAdapterId); parserContext.registerBeanComponent(new BeanComponentDefinition( snsExecutorBuilderBeanDefinition, snsExecutorBeanName)); snsInboundChannelAdapterBuilder.addPropertyReference("snsExecutor", snsExecutorBeanName); SnsParserUtils.registerExecutorProxy(element, snsExecutorBeanName, parserContext); IntegrationNamespaceUtils.setValueIfAttributeDefined( snsInboundChannelAdapterBuilder, element, "phase"); IntegrationNamespaceUtils.setValueIfAttributeDefined( snsInboundChannelAdapterBuilder, element, "auto-startup");
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/inbound/SnsInboundChannelAdapter.java // public class SnsInboundChannelAdapter extends MessageProducerSupport { // // private final Log log = LogFactory.getLog(SnsInboundChannelAdapter.class); // // private volatile SnsExecutor snsExecutor; // // private NotificationHandler notificationHandler; // // public SnsInboundChannelAdapter() { // super(); // } // // public void setSnsExecutor(SnsExecutor snsExecutor) { // this.snsExecutor = snsExecutor; // } // // @Override // protected void doStart() { // super.doStart(); // // snsExecutor.registerHandler(notificationHandler); // // log.info("SNS inbound adapter: [" + getComponentName() // + "], started..."); // } // // @Override // protected void doStop() { // // super.doStop(); // // log.info("SNS inbound adapter: [" + getComponentName() + "], stopped."); // } // // /** // * Check for mandatory attributes // */ // @Override // protected void onInit() { // super.onInit(); // // Assert.notNull(snsExecutor, "snsExecutor must not be null."); // // this.notificationHandler = new NotificationHandler() { // // @Override // protected void dispatch(Message<?> message) { // sendMessage(message); // } // }; // // log.info("SNS inbound adapter: [" + getComponentName() // + "], initialized..."); // } // // @Override // public String getComponentType() { // return "sns:inbound-channel-adapter"; // } // // } // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/config/SnsInboundChannelAdapterParser.java import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sns.inbound.SnsInboundChannelAdapter; import org.springframework.integration.config.xml.AbstractChannelAdapterParser; import org.springframework.integration.config.xml.IntegrationNamespaceUtils; import org.w3c.dom.Element; snsInboundChannelAdapterBuilder, element, "auto-startup"); final BeanDefinitionBuilder snsExecutorBuilder = SnsParserUtils .getSnsExecutorBuilder(element, parserContext); final BeanDefinition snsExecutorBuilderBeanDefinition = snsExecutorBuilder .getBeanDefinition(); final String channelAdapterId = this.resolveId(element, snsInboundChannelAdapterBuilder.getRawBeanDefinition(), parserContext); final String snsExecutorBeanName = channelAdapterId + ".snsExecutor"; SnsParserUtils.registerSubscriptions(element, parserContext, snsExecutorBuilder, channelAdapterId); parserContext.registerBeanComponent(new BeanComponentDefinition( snsExecutorBuilderBeanDefinition, snsExecutorBeanName)); snsInboundChannelAdapterBuilder.addPropertyReference("snsExecutor", snsExecutorBeanName); SnsParserUtils.registerExecutorProxy(element, snsExecutorBeanName, parserContext); IntegrationNamespaceUtils.setValueIfAttributeDefined( snsInboundChannelAdapterBuilder, element, "phase"); IntegrationNamespaceUtils.setValueIfAttributeDefined( snsInboundChannelAdapterBuilder, element, "auto-startup");
AwsParserUtils.registerPermissions(element, snsExecutorBuilder,
3pillarlabs/spring-integration-aws
spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/config/SqsOutboundGatewayParser.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/outbound/SqsOutboundGateway.java // public class SqsOutboundGateway extends AbstractReplyProducingMessageHandler { // // private SqsExecutor sqsExecutor; // private boolean producesReply = true; // false for // // outbound-channel-adapter, true // // for outbound-gateway // // public SqsOutboundGateway() { // super(); // } // // public void setSqsExecutor(SqsExecutor sqsExecutor) { // this.sqsExecutor = sqsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(sqsExecutor, "'sqsExecutor' must not be null"); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result = this.sqsExecutor // .executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // }
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sqs.outbound.SqsOutboundGateway; import org.springframework.integration.config.xml.AbstractConsumerEndpointParser; import org.springframework.integration.config.xml.IntegrationNamespaceUtils; import org.springframework.util.StringUtils; import org.w3c.dom.Element;
package org.springframework.integration.aws.sqs.config; /** * The Parser for Sqs Outbound Gateway. * * @author Sayantam Dey * @since 1.0 * */ public class SqsOutboundGatewayParser extends AbstractConsumerEndpointParser { @Override protected BeanDefinitionBuilder parseHandler(Element gatewayElement, ParserContext parserContext) { final BeanDefinitionBuilder sqsOutboundGatewayBuilder = BeanDefinitionBuilder
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/outbound/SqsOutboundGateway.java // public class SqsOutboundGateway extends AbstractReplyProducingMessageHandler { // // private SqsExecutor sqsExecutor; // private boolean producesReply = true; // false for // // outbound-channel-adapter, true // // for outbound-gateway // // public SqsOutboundGateway() { // super(); // } // // public void setSqsExecutor(SqsExecutor sqsExecutor) { // this.sqsExecutor = sqsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(sqsExecutor, "'sqsExecutor' must not be null"); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result = this.sqsExecutor // .executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // } // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/config/SqsOutboundGatewayParser.java import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sqs.outbound.SqsOutboundGateway; import org.springframework.integration.config.xml.AbstractConsumerEndpointParser; import org.springframework.integration.config.xml.IntegrationNamespaceUtils; import org.springframework.util.StringUtils; import org.w3c.dom.Element; package org.springframework.integration.aws.sqs.config; /** * The Parser for Sqs Outbound Gateway. * * @author Sayantam Dey * @since 1.0 * */ public class SqsOutboundGatewayParser extends AbstractConsumerEndpointParser { @Override protected BeanDefinitionBuilder parseHandler(Element gatewayElement, ParserContext parserContext) { final BeanDefinitionBuilder sqsOutboundGatewayBuilder = BeanDefinitionBuilder
.genericBeanDefinition(SqsOutboundGateway.class);
3pillarlabs/spring-integration-aws
spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/config/SqsOutboundGatewayParser.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/outbound/SqsOutboundGateway.java // public class SqsOutboundGateway extends AbstractReplyProducingMessageHandler { // // private SqsExecutor sqsExecutor; // private boolean producesReply = true; // false for // // outbound-channel-adapter, true // // for outbound-gateway // // public SqsOutboundGateway() { // super(); // } // // public void setSqsExecutor(SqsExecutor sqsExecutor) { // this.sqsExecutor = sqsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(sqsExecutor, "'sqsExecutor' must not be null"); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result = this.sqsExecutor // .executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // }
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sqs.outbound.SqsOutboundGateway; import org.springframework.integration.config.xml.AbstractConsumerEndpointParser; import org.springframework.integration.config.xml.IntegrationNamespaceUtils; import org.springframework.util.StringUtils; import org.w3c.dom.Element;
final String replyChannel = gatewayElement .getAttribute("reply-channel"); if (StringUtils.hasText(replyChannel)) { sqsOutboundGatewayBuilder.addPropertyReference("outputChannel", replyChannel); } final BeanDefinitionBuilder sqsExecutorBuilder = SqsParserUtils .getSqsExecutorBuilder(gatewayElement, parserContext); final BeanDefinition sqsExecutorBuilderBeanDefinition = sqsExecutorBuilder .getBeanDefinition(); final String gatewayId = this .resolveId(gatewayElement, sqsOutboundGatewayBuilder.getRawBeanDefinition(), parserContext); final String sqsExecutorBeanName = SqsParserUtils .getExecutorBeanName(gatewayId); parserContext.registerBeanComponent(new BeanComponentDefinition( sqsExecutorBuilderBeanDefinition, sqsExecutorBeanName)); sqsOutboundGatewayBuilder.addPropertyReference("sqsExecutor", sqsExecutorBeanName); SqsParserUtils.registerExecutorProxy(gatewayElement, sqsExecutorBeanName, parserContext);
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/outbound/SqsOutboundGateway.java // public class SqsOutboundGateway extends AbstractReplyProducingMessageHandler { // // private SqsExecutor sqsExecutor; // private boolean producesReply = true; // false for // // outbound-channel-adapter, true // // for outbound-gateway // // public SqsOutboundGateway() { // super(); // } // // public void setSqsExecutor(SqsExecutor sqsExecutor) { // this.sqsExecutor = sqsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(sqsExecutor, "'sqsExecutor' must not be null"); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result = this.sqsExecutor // .executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // } // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/config/SqsOutboundGatewayParser.java import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sqs.outbound.SqsOutboundGateway; import org.springframework.integration.config.xml.AbstractConsumerEndpointParser; import org.springframework.integration.config.xml.IntegrationNamespaceUtils; import org.springframework.util.StringUtils; import org.w3c.dom.Element; final String replyChannel = gatewayElement .getAttribute("reply-channel"); if (StringUtils.hasText(replyChannel)) { sqsOutboundGatewayBuilder.addPropertyReference("outputChannel", replyChannel); } final BeanDefinitionBuilder sqsExecutorBuilder = SqsParserUtils .getSqsExecutorBuilder(gatewayElement, parserContext); final BeanDefinition sqsExecutorBuilderBeanDefinition = sqsExecutorBuilder .getBeanDefinition(); final String gatewayId = this .resolveId(gatewayElement, sqsOutboundGatewayBuilder.getRawBeanDefinition(), parserContext); final String sqsExecutorBeanName = SqsParserUtils .getExecutorBeanName(gatewayId); parserContext.registerBeanComponent(new BeanComponentDefinition( sqsExecutorBuilderBeanDefinition, sqsExecutorBeanName)); sqsOutboundGatewayBuilder.addPropertyReference("sqsExecutor", sqsExecutorBeanName); SqsParserUtils.registerExecutorProxy(gatewayElement, sqsExecutorBeanName, parserContext);
AwsParserUtils.registerPermissions(gatewayElement, sqsExecutorBuilder,
3pillarlabs/spring-integration-aws
spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/config/SnsOutboundGatewayParser.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/outbound/SnsOutboundGateway.java // public class SnsOutboundGateway extends AbstractReplyProducingMessageHandler // implements DisposableBean { // // private final Log log = LogFactory.getLog(SnsOutboundGateway.class); // // private volatile SnsExecutor snsExecutor; // private boolean producesReply = true; // false for outbound-channel-adapter, // // true for outbound-gateway // // public SnsOutboundGateway() { // super(); // } // // public void setSnsExecutor(SnsExecutor snsExecutor) { // this.snsExecutor = snsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(snsExecutor, "'snsExecutor' must not be null"); // // log.info(getComponentName() + "[" + this.getClass().getName() // + "] ready to send messages..."); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result; // // result = this.snsExecutor.executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // @Override // public void destroy() throws Exception { // // no op // } // // }
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sns.outbound.SnsOutboundGateway; import org.springframework.integration.config.xml.AbstractConsumerEndpointParser; import org.springframework.integration.config.xml.IntegrationNamespaceUtils; import org.springframework.util.StringUtils; import org.w3c.dom.Element;
package org.springframework.integration.aws.sns.config; /** * The Parser for Sns Outbound Gateway. * * @author Sayantam Dey * @since 1.0 * */ public class SnsOutboundGatewayParser extends AbstractConsumerEndpointParser { @Override protected BeanDefinitionBuilder parseHandler(Element gatewayElement, ParserContext parserContext) { final BeanDefinitionBuilder snsOutboundGatewayBuilder = BeanDefinitionBuilder
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/outbound/SnsOutboundGateway.java // public class SnsOutboundGateway extends AbstractReplyProducingMessageHandler // implements DisposableBean { // // private final Log log = LogFactory.getLog(SnsOutboundGateway.class); // // private volatile SnsExecutor snsExecutor; // private boolean producesReply = true; // false for outbound-channel-adapter, // // true for outbound-gateway // // public SnsOutboundGateway() { // super(); // } // // public void setSnsExecutor(SnsExecutor snsExecutor) { // this.snsExecutor = snsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(snsExecutor, "'snsExecutor' must not be null"); // // log.info(getComponentName() + "[" + this.getClass().getName() // + "] ready to send messages..."); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result; // // result = this.snsExecutor.executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // @Override // public void destroy() throws Exception { // // no op // } // // } // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/config/SnsOutboundGatewayParser.java import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sns.outbound.SnsOutboundGateway; import org.springframework.integration.config.xml.AbstractConsumerEndpointParser; import org.springframework.integration.config.xml.IntegrationNamespaceUtils; import org.springframework.util.StringUtils; import org.w3c.dom.Element; package org.springframework.integration.aws.sns.config; /** * The Parser for Sns Outbound Gateway. * * @author Sayantam Dey * @since 1.0 * */ public class SnsOutboundGatewayParser extends AbstractConsumerEndpointParser { @Override protected BeanDefinitionBuilder parseHandler(Element gatewayElement, ParserContext parserContext) { final BeanDefinitionBuilder snsOutboundGatewayBuilder = BeanDefinitionBuilder
.genericBeanDefinition(SnsOutboundGateway.class);
3pillarlabs/spring-integration-aws
spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/config/SnsOutboundGatewayParser.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/outbound/SnsOutboundGateway.java // public class SnsOutboundGateway extends AbstractReplyProducingMessageHandler // implements DisposableBean { // // private final Log log = LogFactory.getLog(SnsOutboundGateway.class); // // private volatile SnsExecutor snsExecutor; // private boolean producesReply = true; // false for outbound-channel-adapter, // // true for outbound-gateway // // public SnsOutboundGateway() { // super(); // } // // public void setSnsExecutor(SnsExecutor snsExecutor) { // this.snsExecutor = snsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(snsExecutor, "'snsExecutor' must not be null"); // // log.info(getComponentName() + "[" + this.getClass().getName() // + "] ready to send messages..."); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result; // // result = this.snsExecutor.executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // @Override // public void destroy() throws Exception { // // no op // } // // }
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sns.outbound.SnsOutboundGateway; import org.springframework.integration.config.xml.AbstractConsumerEndpointParser; import org.springframework.integration.config.xml.IntegrationNamespaceUtils; import org.springframework.util.StringUtils; import org.w3c.dom.Element;
.getAttribute("reply-channel"); if (StringUtils.hasText(replyChannel)) { snsOutboundGatewayBuilder.addPropertyReference("outputChannel", replyChannel); } final BeanDefinitionBuilder snsExecutorBuilder = SnsParserUtils .getSnsExecutorBuilder(gatewayElement, parserContext); final BeanDefinition snsExecutorBuilderBeanDefinition = snsExecutorBuilder .getBeanDefinition(); final String gatewayId = this .resolveId(gatewayElement, snsOutboundGatewayBuilder.getRawBeanDefinition(), parserContext); final String snsExecutorBeanName = gatewayId + ".snsExecutor"; SnsParserUtils.registerSubscriptions(gatewayElement, parserContext, snsExecutorBuilder, gatewayId); parserContext.registerBeanComponent(new BeanComponentDefinition( snsExecutorBuilderBeanDefinition, snsExecutorBeanName)); snsOutboundGatewayBuilder.addPropertyReference("snsExecutor", snsExecutorBeanName); SnsParserUtils.registerExecutorProxy(gatewayElement, snsExecutorBeanName, parserContext);
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/outbound/SnsOutboundGateway.java // public class SnsOutboundGateway extends AbstractReplyProducingMessageHandler // implements DisposableBean { // // private final Log log = LogFactory.getLog(SnsOutboundGateway.class); // // private volatile SnsExecutor snsExecutor; // private boolean producesReply = true; // false for outbound-channel-adapter, // // true for outbound-gateway // // public SnsOutboundGateway() { // super(); // } // // public void setSnsExecutor(SnsExecutor snsExecutor) { // this.snsExecutor = snsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(snsExecutor, "'snsExecutor' must not be null"); // // log.info(getComponentName() + "[" + this.getClass().getName() // + "] ready to send messages..."); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result; // // result = this.snsExecutor.executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // @Override // public void destroy() throws Exception { // // no op // } // // } // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/config/SnsOutboundGatewayParser.java import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sns.outbound.SnsOutboundGateway; import org.springframework.integration.config.xml.AbstractConsumerEndpointParser; import org.springframework.integration.config.xml.IntegrationNamespaceUtils; import org.springframework.util.StringUtils; import org.w3c.dom.Element; .getAttribute("reply-channel"); if (StringUtils.hasText(replyChannel)) { snsOutboundGatewayBuilder.addPropertyReference("outputChannel", replyChannel); } final BeanDefinitionBuilder snsExecutorBuilder = SnsParserUtils .getSnsExecutorBuilder(gatewayElement, parserContext); final BeanDefinition snsExecutorBuilderBeanDefinition = snsExecutorBuilder .getBeanDefinition(); final String gatewayId = this .resolveId(gatewayElement, snsOutboundGatewayBuilder.getRawBeanDefinition(), parserContext); final String snsExecutorBeanName = gatewayId + ".snsExecutor"; SnsParserUtils.registerSubscriptions(gatewayElement, parserContext, snsExecutorBuilder, gatewayId); parserContext.registerBeanComponent(new BeanComponentDefinition( snsExecutorBuilderBeanDefinition, snsExecutorBeanName)); snsOutboundGatewayBuilder.addPropertyReference("snsExecutor", snsExecutorBeanName); SnsParserUtils.registerExecutorProxy(gatewayElement, snsExecutorBeanName, parserContext);
AwsParserUtils.registerPermissions(gatewayElement, snsExecutorBuilder,
3pillarlabs/spring-integration-aws
spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/core/NotificationHandler.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/MessageMarshaller.java // public interface MessageMarshaller { // // /** // * Converts a Message to a String. // * // * @param message // * @return serialized string // * @throws MessageMarshallerException // */ // String serialize(Message<?> message) throws MessageMarshallerException; // // /** // * Converts input String to Message. // * // * @param input // * @return Message // * @throws MessageMarshallerException // */ // Message<?> deserialize(String input) throws MessageMarshallerException; // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/MessageMarshallerException.java // public class MessageMarshallerException extends Exception { // // private static final long serialVersionUID = 1L; // // public MessageMarshallerException(String message, Throwable cause) { // super(message, cause); // } // // public MessageMarshallerException(String message) { // super(message); // } // // }
import org.springframework.integration.Message; import org.springframework.integration.MessagingException; import org.springframework.integration.aws.MessageMarshaller; import org.springframework.integration.aws.MessageMarshallerException;
package org.springframework.integration.aws.sns.core; public abstract class NotificationHandler { private MessageMarshaller messageMarshaller; public void setMessageMarshaller(MessageMarshaller messageMarshaller) { this.messageMarshaller = messageMarshaller; } public void onNotification(String notification) { try { dispatch(messageMarshaller.deserialize(notification));
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/MessageMarshaller.java // public interface MessageMarshaller { // // /** // * Converts a Message to a String. // * // * @param message // * @return serialized string // * @throws MessageMarshallerException // */ // String serialize(Message<?> message) throws MessageMarshallerException; // // /** // * Converts input String to Message. // * // * @param input // * @return Message // * @throws MessageMarshallerException // */ // Message<?> deserialize(String input) throws MessageMarshallerException; // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/MessageMarshallerException.java // public class MessageMarshallerException extends Exception { // // private static final long serialVersionUID = 1L; // // public MessageMarshallerException(String message, Throwable cause) { // super(message, cause); // } // // public MessageMarshallerException(String message) { // super(message); // } // // } // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/core/NotificationHandler.java import org.springframework.integration.Message; import org.springframework.integration.MessagingException; import org.springframework.integration.aws.MessageMarshaller; import org.springframework.integration.aws.MessageMarshallerException; package org.springframework.integration.aws.sns.core; public abstract class NotificationHandler { private MessageMarshaller messageMarshaller; public void setMessageMarshaller(MessageMarshaller messageMarshaller) { this.messageMarshaller = messageMarshaller; } public void onNotification(String notification) { try { dispatch(messageMarshaller.deserialize(notification));
} catch (MessageMarshallerException e) {
3pillarlabs/spring-integration-aws
int-aws-demo/src/main/java/com/threepillar/labs/snssample/controller/UserMessageController.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/SnsExecutorProxy.java // public class SnsExecutorProxy { // // private final SnsExecutor snsExecutor; // // public SnsExecutorProxy(SnsExecutor snsExecutor) { // super(); // this.snsExecutor = snsExecutor; // } // // public String getTopicArn() { // return snsExecutor.getTopicArn(); // } // }
import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.integration.aws.sns.SnsExecutorProxy; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import com.amazonaws.auth.AWSCredentialsProvider; import com.amazonaws.services.sns.AmazonSNS; import com.amazonaws.services.sns.AmazonSNSClient; import com.amazonaws.services.sns.model.PublishRequest;
package com.threepillar.labs.snssample.controller; @Controller public class UserMessageController implements InitializingBean, DisposableBean { private final Log log = LogFactory.getLog(getClass()); private AWSCredentialsProvider awsCredentialsProvider;
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/SnsExecutorProxy.java // public class SnsExecutorProxy { // // private final SnsExecutor snsExecutor; // // public SnsExecutorProxy(SnsExecutor snsExecutor) { // super(); // this.snsExecutor = snsExecutor; // } // // public String getTopicArn() { // return snsExecutor.getTopicArn(); // } // } // Path: int-aws-demo/src/main/java/com/threepillar/labs/snssample/controller/UserMessageController.java import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.integration.aws.sns.SnsExecutorProxy; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import com.amazonaws.auth.AWSCredentialsProvider; import com.amazonaws.services.sns.AmazonSNS; import com.amazonaws.services.sns.AmazonSNSClient; import com.amazonaws.services.sns.model.PublishRequest; package com.threepillar.labs.snssample.controller; @Controller public class UserMessageController implements InitializingBean, DisposableBean { private final Log log = LogFactory.getLog(getClass()); private AWSCredentialsProvider awsCredentialsProvider;
private SnsExecutorProxy snsExecutorProxy;
3pillarlabs/spring-integration-aws
spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/config/SqsOutboundChannelAdapterParser.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/outbound/SqsOutboundGateway.java // public class SqsOutboundGateway extends AbstractReplyProducingMessageHandler { // // private SqsExecutor sqsExecutor; // private boolean producesReply = true; // false for // // outbound-channel-adapter, true // // for outbound-gateway // // public SqsOutboundGateway() { // super(); // } // // public void setSqsExecutor(SqsExecutor sqsExecutor) { // this.sqsExecutor = sqsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(sqsExecutor, "'sqsExecutor' must not be null"); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result = this.sqsExecutor // .executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // }
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sqs.outbound.SqsOutboundGateway; import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser; import org.w3c.dom.Element;
package org.springframework.integration.aws.sqs.config; /** * The parser for the Sqs Outbound Channel Adapter. * * @author Sayantam Dey * @since 1.0 * */ public class SqsOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser { @Override protected boolean shouldGenerateId() { return false; } @Override protected boolean shouldGenerateIdAsFallback() { return true; } @Override protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) { final BeanDefinitionBuilder sqsOutboundChannelAdapterBuilder = BeanDefinitionBuilder
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/outbound/SqsOutboundGateway.java // public class SqsOutboundGateway extends AbstractReplyProducingMessageHandler { // // private SqsExecutor sqsExecutor; // private boolean producesReply = true; // false for // // outbound-channel-adapter, true // // for outbound-gateway // // public SqsOutboundGateway() { // super(); // } // // public void setSqsExecutor(SqsExecutor sqsExecutor) { // this.sqsExecutor = sqsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(sqsExecutor, "'sqsExecutor' must not be null"); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result = this.sqsExecutor // .executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // } // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/config/SqsOutboundChannelAdapterParser.java import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sqs.outbound.SqsOutboundGateway; import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser; import org.w3c.dom.Element; package org.springframework.integration.aws.sqs.config; /** * The parser for the Sqs Outbound Channel Adapter. * * @author Sayantam Dey * @since 1.0 * */ public class SqsOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser { @Override protected boolean shouldGenerateId() { return false; } @Override protected boolean shouldGenerateIdAsFallback() { return true; } @Override protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) { final BeanDefinitionBuilder sqsOutboundChannelAdapterBuilder = BeanDefinitionBuilder
.genericBeanDefinition(SqsOutboundGateway.class);
3pillarlabs/spring-integration-aws
spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/config/SqsOutboundChannelAdapterParser.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/outbound/SqsOutboundGateway.java // public class SqsOutboundGateway extends AbstractReplyProducingMessageHandler { // // private SqsExecutor sqsExecutor; // private boolean producesReply = true; // false for // // outbound-channel-adapter, true // // for outbound-gateway // // public SqsOutboundGateway() { // super(); // } // // public void setSqsExecutor(SqsExecutor sqsExecutor) { // this.sqsExecutor = sqsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(sqsExecutor, "'sqsExecutor' must not be null"); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result = this.sqsExecutor // .executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // }
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sqs.outbound.SqsOutboundGateway; import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser; import org.w3c.dom.Element;
@Override protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) { final BeanDefinitionBuilder sqsOutboundChannelAdapterBuilder = BeanDefinitionBuilder .genericBeanDefinition(SqsOutboundGateway.class); final BeanDefinitionBuilder sqsExecutorBuilder = SqsParserUtils .getSqsExecutorBuilder(element, parserContext); final BeanDefinition sqsExecutorBuilderBeanDefinition = sqsExecutorBuilder .getBeanDefinition(); final String channelAdapterId = this.resolveId(element, sqsOutboundChannelAdapterBuilder.getRawBeanDefinition(), parserContext); final String sqsExecutorBeanName = SqsParserUtils .getExecutorBeanName(channelAdapterId); parserContext.registerBeanComponent(new BeanComponentDefinition( sqsExecutorBuilderBeanDefinition, sqsExecutorBeanName)); sqsOutboundChannelAdapterBuilder.addPropertyReference("sqsExecutor", sqsExecutorBeanName); SqsParserUtils.registerExecutorProxy(element, sqsExecutorBeanName, parserContext); sqsOutboundChannelAdapterBuilder.addPropertyValue("producesReply", Boolean.FALSE);
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/outbound/SqsOutboundGateway.java // public class SqsOutboundGateway extends AbstractReplyProducingMessageHandler { // // private SqsExecutor sqsExecutor; // private boolean producesReply = true; // false for // // outbound-channel-adapter, true // // for outbound-gateway // // public SqsOutboundGateway() { // super(); // } // // public void setSqsExecutor(SqsExecutor sqsExecutor) { // this.sqsExecutor = sqsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(sqsExecutor, "'sqsExecutor' must not be null"); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result = this.sqsExecutor // .executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // } // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sqs/config/SqsOutboundChannelAdapterParser.java import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sqs.outbound.SqsOutboundGateway; import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser; import org.w3c.dom.Element; @Override protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) { final BeanDefinitionBuilder sqsOutboundChannelAdapterBuilder = BeanDefinitionBuilder .genericBeanDefinition(SqsOutboundGateway.class); final BeanDefinitionBuilder sqsExecutorBuilder = SqsParserUtils .getSqsExecutorBuilder(element, parserContext); final BeanDefinition sqsExecutorBuilderBeanDefinition = sqsExecutorBuilder .getBeanDefinition(); final String channelAdapterId = this.resolveId(element, sqsOutboundChannelAdapterBuilder.getRawBeanDefinition(), parserContext); final String sqsExecutorBeanName = SqsParserUtils .getExecutorBeanName(channelAdapterId); parserContext.registerBeanComponent(new BeanComponentDefinition( sqsExecutorBuilderBeanDefinition, sqsExecutorBeanName)); sqsOutboundChannelAdapterBuilder.addPropertyReference("sqsExecutor", sqsExecutorBeanName); SqsParserUtils.registerExecutorProxy(element, sqsExecutorBeanName, parserContext); sqsOutboundChannelAdapterBuilder.addPropertyValue("producesReply", Boolean.FALSE);
AwsParserUtils.registerPermissions(element, sqsExecutorBuilder,
3pillarlabs/spring-integration-aws
spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/config/SnsOutboundChannelAdapterParser.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/outbound/SnsOutboundGateway.java // public class SnsOutboundGateway extends AbstractReplyProducingMessageHandler // implements DisposableBean { // // private final Log log = LogFactory.getLog(SnsOutboundGateway.class); // // private volatile SnsExecutor snsExecutor; // private boolean producesReply = true; // false for outbound-channel-adapter, // // true for outbound-gateway // // public SnsOutboundGateway() { // super(); // } // // public void setSnsExecutor(SnsExecutor snsExecutor) { // this.snsExecutor = snsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(snsExecutor, "'snsExecutor' must not be null"); // // log.info(getComponentName() + "[" + this.getClass().getName() // + "] ready to send messages..."); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result; // // result = this.snsExecutor.executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // @Override // public void destroy() throws Exception { // // no op // } // // }
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sns.outbound.SnsOutboundGateway; import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser; import org.w3c.dom.Element;
package org.springframework.integration.aws.sns.config; /** * The parser for the Sns Outbound Channel Adapter. * * @author Sayantam Dey * @since 1.0 * */ public class SnsOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser { @Override protected boolean shouldGenerateId() { return false; } @Override protected boolean shouldGenerateIdAsFallback() { return true; } @Override protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) { final BeanDefinitionBuilder snsOutboundChannelAdapterBuilder = BeanDefinitionBuilder
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/outbound/SnsOutboundGateway.java // public class SnsOutboundGateway extends AbstractReplyProducingMessageHandler // implements DisposableBean { // // private final Log log = LogFactory.getLog(SnsOutboundGateway.class); // // private volatile SnsExecutor snsExecutor; // private boolean producesReply = true; // false for outbound-channel-adapter, // // true for outbound-gateway // // public SnsOutboundGateway() { // super(); // } // // public void setSnsExecutor(SnsExecutor snsExecutor) { // this.snsExecutor = snsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(snsExecutor, "'snsExecutor' must not be null"); // // log.info(getComponentName() + "[" + this.getClass().getName() // + "] ready to send messages..."); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result; // // result = this.snsExecutor.executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // @Override // public void destroy() throws Exception { // // no op // } // // } // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/config/SnsOutboundChannelAdapterParser.java import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sns.outbound.SnsOutboundGateway; import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser; import org.w3c.dom.Element; package org.springframework.integration.aws.sns.config; /** * The parser for the Sns Outbound Channel Adapter. * * @author Sayantam Dey * @since 1.0 * */ public class SnsOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser { @Override protected boolean shouldGenerateId() { return false; } @Override protected boolean shouldGenerateIdAsFallback() { return true; } @Override protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) { final BeanDefinitionBuilder snsOutboundChannelAdapterBuilder = BeanDefinitionBuilder
.genericBeanDefinition(SnsOutboundGateway.class);
3pillarlabs/spring-integration-aws
spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/config/SnsOutboundChannelAdapterParser.java
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/outbound/SnsOutboundGateway.java // public class SnsOutboundGateway extends AbstractReplyProducingMessageHandler // implements DisposableBean { // // private final Log log = LogFactory.getLog(SnsOutboundGateway.class); // // private volatile SnsExecutor snsExecutor; // private boolean producesReply = true; // false for outbound-channel-adapter, // // true for outbound-gateway // // public SnsOutboundGateway() { // super(); // } // // public void setSnsExecutor(SnsExecutor snsExecutor) { // this.snsExecutor = snsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(snsExecutor, "'snsExecutor' must not be null"); // // log.info(getComponentName() + "[" + this.getClass().getName() // + "] ready to send messages..."); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result; // // result = this.snsExecutor.executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // @Override // public void destroy() throws Exception { // // no op // } // // }
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sns.outbound.SnsOutboundGateway; import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser; import org.w3c.dom.Element;
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) { final BeanDefinitionBuilder snsOutboundChannelAdapterBuilder = BeanDefinitionBuilder .genericBeanDefinition(SnsOutboundGateway.class); final BeanDefinitionBuilder snsExecutorBuilder = SnsParserUtils .getSnsExecutorBuilder(element, parserContext); final BeanDefinition snsExecutorBuilderBeanDefinition = snsExecutorBuilder .getBeanDefinition(); final String channelAdapterId = this.resolveId(element, snsOutboundChannelAdapterBuilder.getRawBeanDefinition(), parserContext); final String snsExecutorBeanName = channelAdapterId + ".snsExecutor"; SnsParserUtils.registerSubscriptions(element, parserContext, snsExecutorBuilder, channelAdapterId); parserContext.registerBeanComponent(new BeanComponentDefinition( snsExecutorBuilderBeanDefinition, snsExecutorBeanName)); snsOutboundChannelAdapterBuilder.addPropertyReference("snsExecutor", snsExecutorBeanName); SnsParserUtils.registerExecutorProxy(element, snsExecutorBeanName, parserContext); snsOutboundChannelAdapterBuilder.addPropertyValue("producesReply", Boolean.FALSE);
// Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/config/AwsParserUtils.java // public final class AwsParserUtils { // // private AwsParserUtils() { // } // // public static void registerPermissions(Element element, // BeanDefinitionBuilder executorBuilder, // ParserContext parserContext) { // // Element permissionsElement = DomUtils.getChildElementByTagName(element, // "permissions"); // if (permissionsElement != null) { // Set<Permission> permissions = new HashSet<Permission>(); // NodeList permNodes = permissionsElement.getChildNodes(); // for (int i = 0; i < permNodes.getLength(); i++) { // Node permNode = permNodes.item(i); // if (Node.ELEMENT_NODE == permNode.getNodeType()) { // Element permissionElement = (Element) permNode; // Permission permission = new Permission( // permissionElement.getAttribute("label"), // new HashSet<String>(), new HashSet<String>()); // // Element actionsElement = DomUtils.getChildElementByTagName( // permissionElement, "actions"); // NodeList actionNodes = actionsElement.getChildNodes(); // for (int j = 0; j < actionNodes.getLength(); j++) { // Node actionNode = actionNodes.item(j); // if (Node.ELEMENT_NODE == actionNode.getNodeType()) { // Element actionElement = (Element) actionNode; // permission.getActions().add( // actionElement.getTextContent()); // } // } // // Element accountsElement = DomUtils // .getChildElementByTagName(permissionElement, // "aws-accounts"); // NodeList accountNodes = accountsElement.getChildNodes(); // for (int j = 0; j < accountNodes.getLength(); j++) { // Node accountNode = accountNodes.item(j); // if (Node.ELEMENT_NODE == accountNode.getNodeType()) { // Element accountElement = (Element) accountNode; // permission.getAwsAccountIds().add( // accountElement.getTextContent()); // } // } // // permissions.add(permission); // } // } // // executorBuilder.addPropertyValue("permissions", permissions); // } // } // // } // // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/outbound/SnsOutboundGateway.java // public class SnsOutboundGateway extends AbstractReplyProducingMessageHandler // implements DisposableBean { // // private final Log log = LogFactory.getLog(SnsOutboundGateway.class); // // private volatile SnsExecutor snsExecutor; // private boolean producesReply = true; // false for outbound-channel-adapter, // // true for outbound-gateway // // public SnsOutboundGateway() { // super(); // } // // public void setSnsExecutor(SnsExecutor snsExecutor) { // this.snsExecutor = snsExecutor; // } // // @Override // protected void doInit() { // super.doInit(); // Assert.notNull(snsExecutor, "'snsExecutor' must not be null"); // // log.info(getComponentName() + "[" + this.getClass().getName() // + "] ready to send messages..."); // } // // @Override // protected Object handleRequestMessage(Message<?> requestMessage) { // // final Object result; // // result = this.snsExecutor.executeOutboundOperation(requestMessage); // // if (result == null || !producesReply) { // return null; // } // // return MessageBuilder.withPayload(result) // .copyHeaders(requestMessage.getHeaders()).build(); // // } // // /** // * If set to 'false', this component will act as an Outbound Channel // * Adapter. If not explicitly set this property will default to 'true'. // * // * @param producesReply // * Defaults to 'true'. // * // */ // public void setProducesReply(boolean producesReply) { // this.producesReply = producesReply; // } // // @Override // public void destroy() throws Exception { // // no op // } // // } // Path: spring-integration-aws/src/main/java/org/springframework/integration/aws/sns/config/SnsOutboundChannelAdapterParser.java import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.aws.config.AwsParserUtils; import org.springframework.integration.aws.sns.outbound.SnsOutboundGateway; import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser; import org.w3c.dom.Element; protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) { final BeanDefinitionBuilder snsOutboundChannelAdapterBuilder = BeanDefinitionBuilder .genericBeanDefinition(SnsOutboundGateway.class); final BeanDefinitionBuilder snsExecutorBuilder = SnsParserUtils .getSnsExecutorBuilder(element, parserContext); final BeanDefinition snsExecutorBuilderBeanDefinition = snsExecutorBuilder .getBeanDefinition(); final String channelAdapterId = this.resolveId(element, snsOutboundChannelAdapterBuilder.getRawBeanDefinition(), parserContext); final String snsExecutorBeanName = channelAdapterId + ".snsExecutor"; SnsParserUtils.registerSubscriptions(element, parserContext, snsExecutorBuilder, channelAdapterId); parserContext.registerBeanComponent(new BeanComponentDefinition( snsExecutorBuilderBeanDefinition, snsExecutorBeanName)); snsOutboundChannelAdapterBuilder.addPropertyReference("snsExecutor", snsExecutorBeanName); SnsParserUtils.registerExecutorProxy(element, snsExecutorBeanName, parserContext); snsOutboundChannelAdapterBuilder.addPropertyValue("producesReply", Boolean.FALSE);
AwsParserUtils.registerPermissions(element, snsExecutorBuilder,
atolcd/alfresco-auditsurf
module-alfresco/source/java/com/atolcd/alfresco/audit/web/scripts/DateInterval.java
// Path: module-alfresco/source/java/com/atolcd/alfresco/audit/cmr/EnumPeriod.java // public enum EnumPeriod { // day, week, month, year, none // };
import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.TreeMap; import com.atolcd.alfresco.audit.cmr.EnumPeriod;
/** * Copyright (C) 2011 Atol Conseils et Développements. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. **/ package com.atolcd.alfresco.audit.web.scripts; public abstract class DateInterval { public static GregorianCalendar setInterval(Date date, String period, int interval) { return offset(date, period, interval); } private static GregorianCalendar offset(Date date, String period, int interval) { GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(date);
// Path: module-alfresco/source/java/com/atolcd/alfresco/audit/cmr/EnumPeriod.java // public enum EnumPeriod { // day, week, month, year, none // }; // Path: module-alfresco/source/java/com/atolcd/alfresco/audit/web/scripts/DateInterval.java import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.TreeMap; import com.atolcd.alfresco.audit.cmr.EnumPeriod; /** * Copyright (C) 2011 Atol Conseils et Développements. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. **/ package com.atolcd.alfresco.audit.web.scripts; public abstract class DateInterval { public static GregorianCalendar setInterval(Date date, String period, int interval) { return offset(date, period, interval); } private static GregorianCalendar offset(Date date, String period, int interval) { GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(date);
switch (EnumPeriod.valueOf(period)) {
atolcd/alfresco-auditsurf
module-alfresco/source/java/com/atolcd/alfresco/audit/web/scripts/ExportGet.java
// Path: module-alfresco/source/java/com/atolcd/alfresco/audit/cmr/AuditQueriesService.java // public interface AuditQueriesService { // // public Map<Date, Integer> countConnections(final Calendar[] calendars, String period); // // public Map<Date, Integer> countCreateUsers(final Calendar[] calendars, String period); // // public Map<Date, Integer> countCreateDocs(final Calendar[] calendars, String period); // // public Map<Date, Integer> countReadDocs(final Calendar[] calendars, String period); // // public Map<Date, Integer> countCheckins(final Calendar[] calendars, String period); // // public Map<Date, Integer> countWorkflows(final Calendar[] calendars, String period); // // public List<Object[]> topRead(); // // public List<Object[]> topModif(); // // public List<Map<String, Object>> lastDocs(); // // public List<Map<String, Object>> lastModif(); // // public List<Map<String, Object>> lastUsers(); // // public List<Map<String, Object>> usersNeverLog(); // // public List<Object[]> getConnectionLogs(String method, Calendar start, Calendar end, boolean noAdmin, int maxdisplay); // } // // Path: module-alfresco/source/java/com/atolcd/alfresco/audit/cmr/EnumFonctionnalite.java // public enum EnumFonctionnalite { // createddocs, modifieddocs, readdocs, conn, createduser, createdwork; // }
import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; import org.springframework.beans.factory.InitializingBean; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptRequest; import org.springframework.util.Assert; import com.atolcd.alfresco.audit.cmr.AuditQueriesService; import com.atolcd.alfresco.audit.cmr.EnumFonctionnalite;
String start_date = req.getParameter("start"); String end_date = req.getParameter("stop"); // Map that will be passed to the template Map<String, Object> model = new HashMap<String, Object>(); Map<String, String> params = new HashMap<String, String>(); params.put("createddocs", req.getParameter("createddocs")); params.put("modifieddocs", req.getParameter("modifieddocs")); params.put("readdocs", req.getParameter("readdocs")); params.put("conn", req.getParameter("conn")); params.put("createduser", req.getParameter("createduser")); params.put("createdwork", req.getParameter("createdwork")); if (testParameters(start_date, end_date)) { // test parameters List<String> parameters = analyzeParameters(params); buildTree(parameters, model); } return model; } private void buildTree(List<String> parameters, Map<String, Object> model) { List<Functionality> functionalities = new ArrayList<Functionality>(); for (int i = 0; i < parameters.size(); i++) { SortedMap<Date, Integer> resQuery = new TreeMap<Date, Integer>();
// Path: module-alfresco/source/java/com/atolcd/alfresco/audit/cmr/AuditQueriesService.java // public interface AuditQueriesService { // // public Map<Date, Integer> countConnections(final Calendar[] calendars, String period); // // public Map<Date, Integer> countCreateUsers(final Calendar[] calendars, String period); // // public Map<Date, Integer> countCreateDocs(final Calendar[] calendars, String period); // // public Map<Date, Integer> countReadDocs(final Calendar[] calendars, String period); // // public Map<Date, Integer> countCheckins(final Calendar[] calendars, String period); // // public Map<Date, Integer> countWorkflows(final Calendar[] calendars, String period); // // public List<Object[]> topRead(); // // public List<Object[]> topModif(); // // public List<Map<String, Object>> lastDocs(); // // public List<Map<String, Object>> lastModif(); // // public List<Map<String, Object>> lastUsers(); // // public List<Map<String, Object>> usersNeverLog(); // // public List<Object[]> getConnectionLogs(String method, Calendar start, Calendar end, boolean noAdmin, int maxdisplay); // } // // Path: module-alfresco/source/java/com/atolcd/alfresco/audit/cmr/EnumFonctionnalite.java // public enum EnumFonctionnalite { // createddocs, modifieddocs, readdocs, conn, createduser, createdwork; // } // Path: module-alfresco/source/java/com/atolcd/alfresco/audit/web/scripts/ExportGet.java import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; import org.springframework.beans.factory.InitializingBean; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptRequest; import org.springframework.util.Assert; import com.atolcd.alfresco.audit.cmr.AuditQueriesService; import com.atolcd.alfresco.audit.cmr.EnumFonctionnalite; String start_date = req.getParameter("start"); String end_date = req.getParameter("stop"); // Map that will be passed to the template Map<String, Object> model = new HashMap<String, Object>(); Map<String, String> params = new HashMap<String, String>(); params.put("createddocs", req.getParameter("createddocs")); params.put("modifieddocs", req.getParameter("modifieddocs")); params.put("readdocs", req.getParameter("readdocs")); params.put("conn", req.getParameter("conn")); params.put("createduser", req.getParameter("createduser")); params.put("createdwork", req.getParameter("createdwork")); if (testParameters(start_date, end_date)) { // test parameters List<String> parameters = analyzeParameters(params); buildTree(parameters, model); } return model; } private void buildTree(List<String> parameters, Map<String, Object> model) { List<Functionality> functionalities = new ArrayList<Functionality>(); for (int i = 0; i < parameters.size(); i++) { SortedMap<Date, Integer> resQuery = new TreeMap<Date, Integer>();
switch (EnumFonctionnalite.valueOf(parameters.get(i))) {
HumBuch/HumBuch
src/main/java/de/dhbw/humbuch/model/entity/TeachingMaterial.java
// Path: src/main/java/de/dhbw/humbuch/model/entity/SchoolYear.java // public enum Term { // FIRST("1. Halbjahr"), // SECOND("2. Halbjahr"); // // private String value; // // private Term(String value) { // this.value = value; // } // // @Override // public String toString() { // return value; // } // }
import java.io.Serializable; import java.util.Date; import java.util.EnumSet; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.CollectionTable; import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.FetchType; 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 de.dhbw.humbuch.model.entity.SchoolYear.Term;
package de.dhbw.humbuch.model.entity; /** * @author David Vitt * */ @Entity @Table(name="teachingMaterial") public class TeachingMaterial implements de.dhbw.humbuch.model.entity.Entity, Serializable, Comparable<TeachingMaterial> { private static final long serialVersionUID = -6153270685462221761L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; @ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name="categoryId", referencedColumnName="id") private Category category; @ElementCollection(targetClass=Subject.class) @Enumerated(EnumType.STRING) @CollectionTable(name="teachingMaterialSubject", joinColumns = @JoinColumn(name="teachingMaterialId")) @Column(name="subject") private Set<Subject> profile = EnumSet.noneOf(Subject.class); private String name; private String producer; private String identifyingNumber; private double price; private String comment; private int fromGrade; private int toGrade; @Enumerated(EnumType.ORDINAL)
// Path: src/main/java/de/dhbw/humbuch/model/entity/SchoolYear.java // public enum Term { // FIRST("1. Halbjahr"), // SECOND("2. Halbjahr"); // // private String value; // // private Term(String value) { // this.value = value; // } // // @Override // public String toString() { // return value; // } // } // Path: src/main/java/de/dhbw/humbuch/model/entity/TeachingMaterial.java import java.io.Serializable; import java.util.Date; import java.util.EnumSet; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.CollectionTable; import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.FetchType; 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 de.dhbw.humbuch.model.entity.SchoolYear.Term; package de.dhbw.humbuch.model.entity; /** * @author David Vitt * */ @Entity @Table(name="teachingMaterial") public class TeachingMaterial implements de.dhbw.humbuch.model.entity.Entity, Serializable, Comparable<TeachingMaterial> { private static final long serialVersionUID = -6153270685462221761L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; @ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name="categoryId", referencedColumnName="id") private Category category; @ElementCollection(targetClass=Subject.class) @Enumerated(EnumType.STRING) @CollectionTable(name="teachingMaterialSubject", joinColumns = @JoinColumn(name="teachingMaterialId")) @Column(name="subject") private Set<Subject> profile = EnumSet.noneOf(Subject.class); private String name; private String producer; private String identifyingNumber; private double price; private String comment; private int fromGrade; private int toGrade; @Enumerated(EnumType.ORDINAL)
private Term fromTerm = Term.FIRST;
HumBuch/HumBuch
src/main/java/de/dhbw/humbuch/model/DAOImpl.java
// Path: src/main/java/de/dhbw/humbuch/event/EntityUpdateEvent.java // public class EntityUpdateEvent { // public final List<Class<? extends Entity>> updatedEntityTypes; // // /** // * Create a new {@link EntityUpdateEvent} with a list of updated // * {@link Entity} types // * // * @param updatedEntityTypes // * types of the {@link Entity}s which were updated // */ // @SafeVarargs // public EntityUpdateEvent(Class<? extends Entity>... updatedEntityTypes) { // this.updatedEntityTypes = new ArrayList<>( // Arrays.asList(updatedEntityTypes)); // } // // /** // * Check if the {@link EntityUpdateEvent} contains a certain {@link Entity} // * class which was updated // * // * @param entityType // * type of the {@link Entity} to be checked // * @return <code>true</code> if event contains the {@link Entity} type, // * otherwise <code>false</code> // */ // public boolean contains(Class<? extends Entity> entityType) { // return updatedEntityTypes.contains(entityType); // } // } // // Path: src/main/java/de/dhbw/humbuch/model/entity/Entity.java // public interface Entity { // // }
import java.util.ArrayList; import java.util.Collection; import java.util.List; import javax.persistence.EntityManager; import org.hibernate.Criteria; import org.hibernate.Session; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Order; import com.google.common.eventbus.EventBus; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.TypeLiteral; import com.google.inject.persist.Transactional; import de.dhbw.humbuch.event.EntityUpdateEvent; import de.dhbw.humbuch.model.entity.Entity;
@Override @Transactional public void delete(Collection<EntityType> entities) { delete(entities, FireUpdateEvent.NO); } @Override @Transactional public void delete(Collection<EntityType> entities, FireUpdateEvent fireUpdateEvent) { getEntityManager().clear(); for (EntityType entity : entities) { getEntityManager().remove(getEntityManager().merge(entity)); } if(fireUpdateEvent == FireUpdateEvent.YES) { fireUpdateEvent(); } } @Override public EntityManager getEntityManager() { return emProvider.get(); } @Override public Class<EntityType> getEntityClass() { return entityClass; } @Override public void fireUpdateEvent() {
// Path: src/main/java/de/dhbw/humbuch/event/EntityUpdateEvent.java // public class EntityUpdateEvent { // public final List<Class<? extends Entity>> updatedEntityTypes; // // /** // * Create a new {@link EntityUpdateEvent} with a list of updated // * {@link Entity} types // * // * @param updatedEntityTypes // * types of the {@link Entity}s which were updated // */ // @SafeVarargs // public EntityUpdateEvent(Class<? extends Entity>... updatedEntityTypes) { // this.updatedEntityTypes = new ArrayList<>( // Arrays.asList(updatedEntityTypes)); // } // // /** // * Check if the {@link EntityUpdateEvent} contains a certain {@link Entity} // * class which was updated // * // * @param entityType // * type of the {@link Entity} to be checked // * @return <code>true</code> if event contains the {@link Entity} type, // * otherwise <code>false</code> // */ // public boolean contains(Class<? extends Entity> entityType) { // return updatedEntityTypes.contains(entityType); // } // } // // Path: src/main/java/de/dhbw/humbuch/model/entity/Entity.java // public interface Entity { // // } // Path: src/main/java/de/dhbw/humbuch/model/DAOImpl.java import java.util.ArrayList; import java.util.Collection; import java.util.List; import javax.persistence.EntityManager; import org.hibernate.Criteria; import org.hibernate.Session; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Order; import com.google.common.eventbus.EventBus; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.TypeLiteral; import com.google.inject.persist.Transactional; import de.dhbw.humbuch.event.EntityUpdateEvent; import de.dhbw.humbuch.model.entity.Entity; @Override @Transactional public void delete(Collection<EntityType> entities) { delete(entities, FireUpdateEvent.NO); } @Override @Transactional public void delete(Collection<EntityType> entities, FireUpdateEvent fireUpdateEvent) { getEntityManager().clear(); for (EntityType entity : entities) { getEntityManager().remove(getEntityManager().merge(entity)); } if(fireUpdateEvent == FireUpdateEvent.YES) { fireUpdateEvent(); } } @Override public EntityManager getEntityManager() { return emProvider.get(); } @Override public Class<EntityType> getEntityClass() { return entityClass; } @Override public void fireUpdateEvent() {
eventBus.post(new EntityUpdateEvent(getEntityClass()));
HumBuch/HumBuch
src/main/java/de/dhbw/humbuch/view/LoginView.java
// Path: src/main/java/de/dhbw/humbuch/event/LoginEvent.java // public class LoginEvent { // private final String message; // // public LoginEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public class LoginViewModel { // // private final static Logger LOG = LoggerFactory.getLogger(MainUI.class); // // public interface IsLoggedIn extends State<Boolean> {} // // public interface DoLogout extends ActionHandler {} // public interface DoLogin extends ActionHandler {} // // private DAO<User> daoUser; // private EventBus eventBus; // private Properties properties; // // @ProvidesState(IsLoggedIn.class) // public final BasicState<Boolean> isLoggedIn = new BasicState<Boolean>(Boolean.class); // // /** // * Constructor // * // * @param daoUser // * @param properties // * @param eventBus // */ // @Inject // public LoginViewModel(DAO<User> daoUser, Properties properties, EventBus eventBus) { // this.properties = properties; // this.eventBus = eventBus; // this.daoUser = daoUser; // updateLoginStatus(); // } // // private void updateLoginStatus() { // isLoggedIn.set(properties.currentUser.get() != null); // } // // /** // * Validates {@code username} and {@code password}. Fires an event if something is wrong.<br> // * Sets the logged in {@link User} in the corresponding {@link Properties} state // * // * @param username // * @param password // */ // @HandlesAction(DoLogin.class) // public void doLogin(String username, String password) { // properties.currentUser.set(null); // updateLoginStatus(); // try { // if (username.equals("") || password.equals("")) { // eventBus.post(new LoginEvent("Bitte geben Sie einen Nutzernamen und Passwort an.")); // return; // } else { // List<User> user = (List<User>) daoUser.findAllWithCriteria(Restrictions.eq("username", username)); // if(!user.isEmpty()) { // if(PasswordHash.validatePassword(password, user.get(0).getPassword())) { // properties.currentUser.set(user.get(0)); // updateLoginStatus(); // return; // } // } // eventBus.post(new LoginEvent("Username oder Passwort stimmen nicht überein.")); // } // } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { // eventBus.post(new LoginEvent("Fehler bei Login. Bitte kontaktieren Sie einen Entwickler.")); // LOG.warn(e.getMessage()); // return; // } // } // // @HandlesAction(DoLogout.class) // public void doLogout(Object obj) { // properties.currentUser.set(null); // updateLoginStatus(); // } // // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface DoLogin extends ActionHandler {} // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface IsLoggedIn extends State<Boolean> {}
import java.util.NoSuchElementException; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; import com.google.inject.Inject; import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutListener; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.CssLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.PasswordField; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import de.davherrmann.mvvm.BasicState; import de.davherrmann.mvvm.StateChangeListener; import de.davherrmann.mvvm.ViewModelComposer; import de.davherrmann.mvvm.annotations.BindAction; import de.davherrmann.mvvm.annotations.BindState; import de.dhbw.humbuch.event.LoginEvent; import de.dhbw.humbuch.viewmodel.LoginViewModel; import de.dhbw.humbuch.viewmodel.LoginViewModel.DoLogin; import de.dhbw.humbuch.viewmodel.LoginViewModel.IsLoggedIn;
package de.dhbw.humbuch.view; /** * Provides the UI for the login and displays error messages, if the user uses * wrong credentials * * @author Johannes Idelhauser */ public class LoginView extends VerticalLayout implements View { private static final long serialVersionUID = 5187769743375079627L; private VerticalLayout loginLayout; private CssLayout loginPanel; private TextField username = new TextField("Username"); private PasswordField password = new PasswordField("Passwort");
// Path: src/main/java/de/dhbw/humbuch/event/LoginEvent.java // public class LoginEvent { // private final String message; // // public LoginEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public class LoginViewModel { // // private final static Logger LOG = LoggerFactory.getLogger(MainUI.class); // // public interface IsLoggedIn extends State<Boolean> {} // // public interface DoLogout extends ActionHandler {} // public interface DoLogin extends ActionHandler {} // // private DAO<User> daoUser; // private EventBus eventBus; // private Properties properties; // // @ProvidesState(IsLoggedIn.class) // public final BasicState<Boolean> isLoggedIn = new BasicState<Boolean>(Boolean.class); // // /** // * Constructor // * // * @param daoUser // * @param properties // * @param eventBus // */ // @Inject // public LoginViewModel(DAO<User> daoUser, Properties properties, EventBus eventBus) { // this.properties = properties; // this.eventBus = eventBus; // this.daoUser = daoUser; // updateLoginStatus(); // } // // private void updateLoginStatus() { // isLoggedIn.set(properties.currentUser.get() != null); // } // // /** // * Validates {@code username} and {@code password}. Fires an event if something is wrong.<br> // * Sets the logged in {@link User} in the corresponding {@link Properties} state // * // * @param username // * @param password // */ // @HandlesAction(DoLogin.class) // public void doLogin(String username, String password) { // properties.currentUser.set(null); // updateLoginStatus(); // try { // if (username.equals("") || password.equals("")) { // eventBus.post(new LoginEvent("Bitte geben Sie einen Nutzernamen und Passwort an.")); // return; // } else { // List<User> user = (List<User>) daoUser.findAllWithCriteria(Restrictions.eq("username", username)); // if(!user.isEmpty()) { // if(PasswordHash.validatePassword(password, user.get(0).getPassword())) { // properties.currentUser.set(user.get(0)); // updateLoginStatus(); // return; // } // } // eventBus.post(new LoginEvent("Username oder Passwort stimmen nicht überein.")); // } // } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { // eventBus.post(new LoginEvent("Fehler bei Login. Bitte kontaktieren Sie einen Entwickler.")); // LOG.warn(e.getMessage()); // return; // } // } // // @HandlesAction(DoLogout.class) // public void doLogout(Object obj) { // properties.currentUser.set(null); // updateLoginStatus(); // } // // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface DoLogin extends ActionHandler {} // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface IsLoggedIn extends State<Boolean> {} // Path: src/main/java/de/dhbw/humbuch/view/LoginView.java import java.util.NoSuchElementException; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; import com.google.inject.Inject; import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutListener; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.CssLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.PasswordField; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import de.davherrmann.mvvm.BasicState; import de.davherrmann.mvvm.StateChangeListener; import de.davherrmann.mvvm.ViewModelComposer; import de.davherrmann.mvvm.annotations.BindAction; import de.davherrmann.mvvm.annotations.BindState; import de.dhbw.humbuch.event.LoginEvent; import de.dhbw.humbuch.viewmodel.LoginViewModel; import de.dhbw.humbuch.viewmodel.LoginViewModel.DoLogin; import de.dhbw.humbuch.viewmodel.LoginViewModel.IsLoggedIn; package de.dhbw.humbuch.view; /** * Provides the UI for the login and displays error messages, if the user uses * wrong credentials * * @author Johannes Idelhauser */ public class LoginView extends VerticalLayout implements View { private static final long serialVersionUID = 5187769743375079627L; private VerticalLayout loginLayout; private CssLayout loginPanel; private TextField username = new TextField("Username"); private PasswordField password = new PasswordField("Passwort");
@BindAction(value = DoLogin.class, source = { "username", "password" })
HumBuch/HumBuch
src/main/java/de/dhbw/humbuch/view/LoginView.java
// Path: src/main/java/de/dhbw/humbuch/event/LoginEvent.java // public class LoginEvent { // private final String message; // // public LoginEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public class LoginViewModel { // // private final static Logger LOG = LoggerFactory.getLogger(MainUI.class); // // public interface IsLoggedIn extends State<Boolean> {} // // public interface DoLogout extends ActionHandler {} // public interface DoLogin extends ActionHandler {} // // private DAO<User> daoUser; // private EventBus eventBus; // private Properties properties; // // @ProvidesState(IsLoggedIn.class) // public final BasicState<Boolean> isLoggedIn = new BasicState<Boolean>(Boolean.class); // // /** // * Constructor // * // * @param daoUser // * @param properties // * @param eventBus // */ // @Inject // public LoginViewModel(DAO<User> daoUser, Properties properties, EventBus eventBus) { // this.properties = properties; // this.eventBus = eventBus; // this.daoUser = daoUser; // updateLoginStatus(); // } // // private void updateLoginStatus() { // isLoggedIn.set(properties.currentUser.get() != null); // } // // /** // * Validates {@code username} and {@code password}. Fires an event if something is wrong.<br> // * Sets the logged in {@link User} in the corresponding {@link Properties} state // * // * @param username // * @param password // */ // @HandlesAction(DoLogin.class) // public void doLogin(String username, String password) { // properties.currentUser.set(null); // updateLoginStatus(); // try { // if (username.equals("") || password.equals("")) { // eventBus.post(new LoginEvent("Bitte geben Sie einen Nutzernamen und Passwort an.")); // return; // } else { // List<User> user = (List<User>) daoUser.findAllWithCriteria(Restrictions.eq("username", username)); // if(!user.isEmpty()) { // if(PasswordHash.validatePassword(password, user.get(0).getPassword())) { // properties.currentUser.set(user.get(0)); // updateLoginStatus(); // return; // } // } // eventBus.post(new LoginEvent("Username oder Passwort stimmen nicht überein.")); // } // } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { // eventBus.post(new LoginEvent("Fehler bei Login. Bitte kontaktieren Sie einen Entwickler.")); // LOG.warn(e.getMessage()); // return; // } // } // // @HandlesAction(DoLogout.class) // public void doLogout(Object obj) { // properties.currentUser.set(null); // updateLoginStatus(); // } // // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface DoLogin extends ActionHandler {} // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface IsLoggedIn extends State<Boolean> {}
import java.util.NoSuchElementException; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; import com.google.inject.Inject; import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutListener; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.CssLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.PasswordField; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import de.davherrmann.mvvm.BasicState; import de.davherrmann.mvvm.StateChangeListener; import de.davherrmann.mvvm.ViewModelComposer; import de.davherrmann.mvvm.annotations.BindAction; import de.davherrmann.mvvm.annotations.BindState; import de.dhbw.humbuch.event.LoginEvent; import de.dhbw.humbuch.viewmodel.LoginViewModel; import de.dhbw.humbuch.viewmodel.LoginViewModel.DoLogin; import de.dhbw.humbuch.viewmodel.LoginViewModel.IsLoggedIn;
package de.dhbw.humbuch.view; /** * Provides the UI for the login and displays error messages, if the user uses * wrong credentials * * @author Johannes Idelhauser */ public class LoginView extends VerticalLayout implements View { private static final long serialVersionUID = 5187769743375079627L; private VerticalLayout loginLayout; private CssLayout loginPanel; private TextField username = new TextField("Username"); private PasswordField password = new PasswordField("Passwort"); @BindAction(value = DoLogin.class, source = { "username", "password" }) private Button btnLogin = new Button("Login");
// Path: src/main/java/de/dhbw/humbuch/event/LoginEvent.java // public class LoginEvent { // private final String message; // // public LoginEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public class LoginViewModel { // // private final static Logger LOG = LoggerFactory.getLogger(MainUI.class); // // public interface IsLoggedIn extends State<Boolean> {} // // public interface DoLogout extends ActionHandler {} // public interface DoLogin extends ActionHandler {} // // private DAO<User> daoUser; // private EventBus eventBus; // private Properties properties; // // @ProvidesState(IsLoggedIn.class) // public final BasicState<Boolean> isLoggedIn = new BasicState<Boolean>(Boolean.class); // // /** // * Constructor // * // * @param daoUser // * @param properties // * @param eventBus // */ // @Inject // public LoginViewModel(DAO<User> daoUser, Properties properties, EventBus eventBus) { // this.properties = properties; // this.eventBus = eventBus; // this.daoUser = daoUser; // updateLoginStatus(); // } // // private void updateLoginStatus() { // isLoggedIn.set(properties.currentUser.get() != null); // } // // /** // * Validates {@code username} and {@code password}. Fires an event if something is wrong.<br> // * Sets the logged in {@link User} in the corresponding {@link Properties} state // * // * @param username // * @param password // */ // @HandlesAction(DoLogin.class) // public void doLogin(String username, String password) { // properties.currentUser.set(null); // updateLoginStatus(); // try { // if (username.equals("") || password.equals("")) { // eventBus.post(new LoginEvent("Bitte geben Sie einen Nutzernamen und Passwort an.")); // return; // } else { // List<User> user = (List<User>) daoUser.findAllWithCriteria(Restrictions.eq("username", username)); // if(!user.isEmpty()) { // if(PasswordHash.validatePassword(password, user.get(0).getPassword())) { // properties.currentUser.set(user.get(0)); // updateLoginStatus(); // return; // } // } // eventBus.post(new LoginEvent("Username oder Passwort stimmen nicht überein.")); // } // } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { // eventBus.post(new LoginEvent("Fehler bei Login. Bitte kontaktieren Sie einen Entwickler.")); // LOG.warn(e.getMessage()); // return; // } // } // // @HandlesAction(DoLogout.class) // public void doLogout(Object obj) { // properties.currentUser.set(null); // updateLoginStatus(); // } // // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface DoLogin extends ActionHandler {} // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface IsLoggedIn extends State<Boolean> {} // Path: src/main/java/de/dhbw/humbuch/view/LoginView.java import java.util.NoSuchElementException; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; import com.google.inject.Inject; import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutListener; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.CssLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.PasswordField; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import de.davherrmann.mvvm.BasicState; import de.davherrmann.mvvm.StateChangeListener; import de.davherrmann.mvvm.ViewModelComposer; import de.davherrmann.mvvm.annotations.BindAction; import de.davherrmann.mvvm.annotations.BindState; import de.dhbw.humbuch.event.LoginEvent; import de.dhbw.humbuch.viewmodel.LoginViewModel; import de.dhbw.humbuch.viewmodel.LoginViewModel.DoLogin; import de.dhbw.humbuch.viewmodel.LoginViewModel.IsLoggedIn; package de.dhbw.humbuch.view; /** * Provides the UI for the login and displays error messages, if the user uses * wrong credentials * * @author Johannes Idelhauser */ public class LoginView extends VerticalLayout implements View { private static final long serialVersionUID = 5187769743375079627L; private VerticalLayout loginLayout; private CssLayout loginPanel; private TextField username = new TextField("Username"); private PasswordField password = new PasswordField("Passwort"); @BindAction(value = DoLogin.class, source = { "username", "password" }) private Button btnLogin = new Button("Login");
@BindState(IsLoggedIn.class)
HumBuch/HumBuch
src/main/java/de/dhbw/humbuch/view/LoginView.java
// Path: src/main/java/de/dhbw/humbuch/event/LoginEvent.java // public class LoginEvent { // private final String message; // // public LoginEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public class LoginViewModel { // // private final static Logger LOG = LoggerFactory.getLogger(MainUI.class); // // public interface IsLoggedIn extends State<Boolean> {} // // public interface DoLogout extends ActionHandler {} // public interface DoLogin extends ActionHandler {} // // private DAO<User> daoUser; // private EventBus eventBus; // private Properties properties; // // @ProvidesState(IsLoggedIn.class) // public final BasicState<Boolean> isLoggedIn = new BasicState<Boolean>(Boolean.class); // // /** // * Constructor // * // * @param daoUser // * @param properties // * @param eventBus // */ // @Inject // public LoginViewModel(DAO<User> daoUser, Properties properties, EventBus eventBus) { // this.properties = properties; // this.eventBus = eventBus; // this.daoUser = daoUser; // updateLoginStatus(); // } // // private void updateLoginStatus() { // isLoggedIn.set(properties.currentUser.get() != null); // } // // /** // * Validates {@code username} and {@code password}. Fires an event if something is wrong.<br> // * Sets the logged in {@link User} in the corresponding {@link Properties} state // * // * @param username // * @param password // */ // @HandlesAction(DoLogin.class) // public void doLogin(String username, String password) { // properties.currentUser.set(null); // updateLoginStatus(); // try { // if (username.equals("") || password.equals("")) { // eventBus.post(new LoginEvent("Bitte geben Sie einen Nutzernamen und Passwort an.")); // return; // } else { // List<User> user = (List<User>) daoUser.findAllWithCriteria(Restrictions.eq("username", username)); // if(!user.isEmpty()) { // if(PasswordHash.validatePassword(password, user.get(0).getPassword())) { // properties.currentUser.set(user.get(0)); // updateLoginStatus(); // return; // } // } // eventBus.post(new LoginEvent("Username oder Passwort stimmen nicht überein.")); // } // } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { // eventBus.post(new LoginEvent("Fehler bei Login. Bitte kontaktieren Sie einen Entwickler.")); // LOG.warn(e.getMessage()); // return; // } // } // // @HandlesAction(DoLogout.class) // public void doLogout(Object obj) { // properties.currentUser.set(null); // updateLoginStatus(); // } // // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface DoLogin extends ActionHandler {} // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface IsLoggedIn extends State<Boolean> {}
import java.util.NoSuchElementException; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; import com.google.inject.Inject; import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutListener; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.CssLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.PasswordField; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import de.davherrmann.mvvm.BasicState; import de.davherrmann.mvvm.StateChangeListener; import de.davherrmann.mvvm.ViewModelComposer; import de.davherrmann.mvvm.annotations.BindAction; import de.davherrmann.mvvm.annotations.BindState; import de.dhbw.humbuch.event.LoginEvent; import de.dhbw.humbuch.viewmodel.LoginViewModel; import de.dhbw.humbuch.viewmodel.LoginViewModel.DoLogin; import de.dhbw.humbuch.viewmodel.LoginViewModel.IsLoggedIn;
package de.dhbw.humbuch.view; /** * Provides the UI for the login and displays error messages, if the user uses * wrong credentials * * @author Johannes Idelhauser */ public class LoginView extends VerticalLayout implements View { private static final long serialVersionUID = 5187769743375079627L; private VerticalLayout loginLayout; private CssLayout loginPanel; private TextField username = new TextField("Username"); private PasswordField password = new PasswordField("Passwort"); @BindAction(value = DoLogin.class, source = { "username", "password" }) private Button btnLogin = new Button("Login"); @BindState(IsLoggedIn.class) private BasicState<Boolean> isLoggedIn = new BasicState<Boolean>(Boolean.class); @Inject
// Path: src/main/java/de/dhbw/humbuch/event/LoginEvent.java // public class LoginEvent { // private final String message; // // public LoginEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public class LoginViewModel { // // private final static Logger LOG = LoggerFactory.getLogger(MainUI.class); // // public interface IsLoggedIn extends State<Boolean> {} // // public interface DoLogout extends ActionHandler {} // public interface DoLogin extends ActionHandler {} // // private DAO<User> daoUser; // private EventBus eventBus; // private Properties properties; // // @ProvidesState(IsLoggedIn.class) // public final BasicState<Boolean> isLoggedIn = new BasicState<Boolean>(Boolean.class); // // /** // * Constructor // * // * @param daoUser // * @param properties // * @param eventBus // */ // @Inject // public LoginViewModel(DAO<User> daoUser, Properties properties, EventBus eventBus) { // this.properties = properties; // this.eventBus = eventBus; // this.daoUser = daoUser; // updateLoginStatus(); // } // // private void updateLoginStatus() { // isLoggedIn.set(properties.currentUser.get() != null); // } // // /** // * Validates {@code username} and {@code password}. Fires an event if something is wrong.<br> // * Sets the logged in {@link User} in the corresponding {@link Properties} state // * // * @param username // * @param password // */ // @HandlesAction(DoLogin.class) // public void doLogin(String username, String password) { // properties.currentUser.set(null); // updateLoginStatus(); // try { // if (username.equals("") || password.equals("")) { // eventBus.post(new LoginEvent("Bitte geben Sie einen Nutzernamen und Passwort an.")); // return; // } else { // List<User> user = (List<User>) daoUser.findAllWithCriteria(Restrictions.eq("username", username)); // if(!user.isEmpty()) { // if(PasswordHash.validatePassword(password, user.get(0).getPassword())) { // properties.currentUser.set(user.get(0)); // updateLoginStatus(); // return; // } // } // eventBus.post(new LoginEvent("Username oder Passwort stimmen nicht überein.")); // } // } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { // eventBus.post(new LoginEvent("Fehler bei Login. Bitte kontaktieren Sie einen Entwickler.")); // LOG.warn(e.getMessage()); // return; // } // } // // @HandlesAction(DoLogout.class) // public void doLogout(Object obj) { // properties.currentUser.set(null); // updateLoginStatus(); // } // // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface DoLogin extends ActionHandler {} // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface IsLoggedIn extends State<Boolean> {} // Path: src/main/java/de/dhbw/humbuch/view/LoginView.java import java.util.NoSuchElementException; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; import com.google.inject.Inject; import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutListener; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.CssLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.PasswordField; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import de.davherrmann.mvvm.BasicState; import de.davherrmann.mvvm.StateChangeListener; import de.davherrmann.mvvm.ViewModelComposer; import de.davherrmann.mvvm.annotations.BindAction; import de.davherrmann.mvvm.annotations.BindState; import de.dhbw.humbuch.event.LoginEvent; import de.dhbw.humbuch.viewmodel.LoginViewModel; import de.dhbw.humbuch.viewmodel.LoginViewModel.DoLogin; import de.dhbw.humbuch.viewmodel.LoginViewModel.IsLoggedIn; package de.dhbw.humbuch.view; /** * Provides the UI for the login and displays error messages, if the user uses * wrong credentials * * @author Johannes Idelhauser */ public class LoginView extends VerticalLayout implements View { private static final long serialVersionUID = 5187769743375079627L; private VerticalLayout loginLayout; private CssLayout loginPanel; private TextField username = new TextField("Username"); private PasswordField password = new PasswordField("Passwort"); @BindAction(value = DoLogin.class, source = { "username", "password" }) private Button btnLogin = new Button("Login"); @BindState(IsLoggedIn.class) private BasicState<Boolean> isLoggedIn = new BasicState<Boolean>(Boolean.class); @Inject
public LoginView(ViewModelComposer viewModelComposer, LoginViewModel loginViewModel, EventBus eventBus) {
HumBuch/HumBuch
src/main/java/de/dhbw/humbuch/view/LoginView.java
// Path: src/main/java/de/dhbw/humbuch/event/LoginEvent.java // public class LoginEvent { // private final String message; // // public LoginEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public class LoginViewModel { // // private final static Logger LOG = LoggerFactory.getLogger(MainUI.class); // // public interface IsLoggedIn extends State<Boolean> {} // // public interface DoLogout extends ActionHandler {} // public interface DoLogin extends ActionHandler {} // // private DAO<User> daoUser; // private EventBus eventBus; // private Properties properties; // // @ProvidesState(IsLoggedIn.class) // public final BasicState<Boolean> isLoggedIn = new BasicState<Boolean>(Boolean.class); // // /** // * Constructor // * // * @param daoUser // * @param properties // * @param eventBus // */ // @Inject // public LoginViewModel(DAO<User> daoUser, Properties properties, EventBus eventBus) { // this.properties = properties; // this.eventBus = eventBus; // this.daoUser = daoUser; // updateLoginStatus(); // } // // private void updateLoginStatus() { // isLoggedIn.set(properties.currentUser.get() != null); // } // // /** // * Validates {@code username} and {@code password}. Fires an event if something is wrong.<br> // * Sets the logged in {@link User} in the corresponding {@link Properties} state // * // * @param username // * @param password // */ // @HandlesAction(DoLogin.class) // public void doLogin(String username, String password) { // properties.currentUser.set(null); // updateLoginStatus(); // try { // if (username.equals("") || password.equals("")) { // eventBus.post(new LoginEvent("Bitte geben Sie einen Nutzernamen und Passwort an.")); // return; // } else { // List<User> user = (List<User>) daoUser.findAllWithCriteria(Restrictions.eq("username", username)); // if(!user.isEmpty()) { // if(PasswordHash.validatePassword(password, user.get(0).getPassword())) { // properties.currentUser.set(user.get(0)); // updateLoginStatus(); // return; // } // } // eventBus.post(new LoginEvent("Username oder Passwort stimmen nicht überein.")); // } // } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { // eventBus.post(new LoginEvent("Fehler bei Login. Bitte kontaktieren Sie einen Entwickler.")); // LOG.warn(e.getMessage()); // return; // } // } // // @HandlesAction(DoLogout.class) // public void doLogout(Object obj) { // properties.currentUser.set(null); // updateLoginStatus(); // } // // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface DoLogin extends ActionHandler {} // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface IsLoggedIn extends State<Boolean> {}
import java.util.NoSuchElementException; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; import com.google.inject.Inject; import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutListener; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.CssLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.PasswordField; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import de.davherrmann.mvvm.BasicState; import de.davherrmann.mvvm.StateChangeListener; import de.davherrmann.mvvm.ViewModelComposer; import de.davherrmann.mvvm.annotations.BindAction; import de.davherrmann.mvvm.annotations.BindState; import de.dhbw.humbuch.event.LoginEvent; import de.dhbw.humbuch.viewmodel.LoginViewModel; import de.dhbw.humbuch.viewmodel.LoginViewModel.DoLogin; import de.dhbw.humbuch.viewmodel.LoginViewModel.IsLoggedIn;
final ShortcutListener enter = new ShortcutListener("Sign In", KeyCode.ENTER, null) { private static final long serialVersionUID = 2980349254427801100L; @Override public void handleAction(Object sender, Object target) { btnLogin.click(); } }; username.addShortcutListener(enter); password.addShortcutListener(enter); } /** * Builds the layout by adding the components to the view */ private void buildLayout() { setSizeFull(); addComponent(loginLayout); } /** * Handles {@link LoginEvent}s posted via the {@link EventBus} * * @param loginEvent * a {@link LoginEvent} */ @Subscribe
// Path: src/main/java/de/dhbw/humbuch/event/LoginEvent.java // public class LoginEvent { // private final String message; // // public LoginEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public class LoginViewModel { // // private final static Logger LOG = LoggerFactory.getLogger(MainUI.class); // // public interface IsLoggedIn extends State<Boolean> {} // // public interface DoLogout extends ActionHandler {} // public interface DoLogin extends ActionHandler {} // // private DAO<User> daoUser; // private EventBus eventBus; // private Properties properties; // // @ProvidesState(IsLoggedIn.class) // public final BasicState<Boolean> isLoggedIn = new BasicState<Boolean>(Boolean.class); // // /** // * Constructor // * // * @param daoUser // * @param properties // * @param eventBus // */ // @Inject // public LoginViewModel(DAO<User> daoUser, Properties properties, EventBus eventBus) { // this.properties = properties; // this.eventBus = eventBus; // this.daoUser = daoUser; // updateLoginStatus(); // } // // private void updateLoginStatus() { // isLoggedIn.set(properties.currentUser.get() != null); // } // // /** // * Validates {@code username} and {@code password}. Fires an event if something is wrong.<br> // * Sets the logged in {@link User} in the corresponding {@link Properties} state // * // * @param username // * @param password // */ // @HandlesAction(DoLogin.class) // public void doLogin(String username, String password) { // properties.currentUser.set(null); // updateLoginStatus(); // try { // if (username.equals("") || password.equals("")) { // eventBus.post(new LoginEvent("Bitte geben Sie einen Nutzernamen und Passwort an.")); // return; // } else { // List<User> user = (List<User>) daoUser.findAllWithCriteria(Restrictions.eq("username", username)); // if(!user.isEmpty()) { // if(PasswordHash.validatePassword(password, user.get(0).getPassword())) { // properties.currentUser.set(user.get(0)); // updateLoginStatus(); // return; // } // } // eventBus.post(new LoginEvent("Username oder Passwort stimmen nicht überein.")); // } // } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { // eventBus.post(new LoginEvent("Fehler bei Login. Bitte kontaktieren Sie einen Entwickler.")); // LOG.warn(e.getMessage()); // return; // } // } // // @HandlesAction(DoLogout.class) // public void doLogout(Object obj) { // properties.currentUser.set(null); // updateLoginStatus(); // } // // } // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface DoLogin extends ActionHandler {} // // Path: src/main/java/de/dhbw/humbuch/viewmodel/LoginViewModel.java // public interface IsLoggedIn extends State<Boolean> {} // Path: src/main/java/de/dhbw/humbuch/view/LoginView.java import java.util.NoSuchElementException; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; import com.google.inject.Inject; import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutListener; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.CssLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.PasswordField; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import de.davherrmann.mvvm.BasicState; import de.davherrmann.mvvm.StateChangeListener; import de.davherrmann.mvvm.ViewModelComposer; import de.davherrmann.mvvm.annotations.BindAction; import de.davherrmann.mvvm.annotations.BindState; import de.dhbw.humbuch.event.LoginEvent; import de.dhbw.humbuch.viewmodel.LoginViewModel; import de.dhbw.humbuch.viewmodel.LoginViewModel.DoLogin; import de.dhbw.humbuch.viewmodel.LoginViewModel.IsLoggedIn; final ShortcutListener enter = new ShortcutListener("Sign In", KeyCode.ENTER, null) { private static final long serialVersionUID = 2980349254427801100L; @Override public void handleAction(Object sender, Object target) { btnLogin.click(); } }; username.addShortcutListener(enter); password.addShortcutListener(enter); } /** * Builds the layout by adding the components to the view */ private void buildLayout() { setSizeFull(); addComponent(loginLayout); } /** * Handles {@link LoginEvent}s posted via the {@link EventBus} * * @param loginEvent * a {@link LoginEvent} */ @Subscribe
public void handleLoginEvent(LoginEvent loginEvent) {
geomesa/geomesa-nifi
geomesa-datastore-bundle/geomesa-datastore-services/src/main/java/org/geomesa/nifi/datastore/impl/AccumuloDataStoreConfigControllerService.java
// Path: geomesa-datastore-bundle/geomesa-datastore-services-api/src/main/java/org/geomesa/nifi/datastore/services/DataStoreConfigService.java // public interface DataStoreConfigService extends ControllerService { // Map<String, Serializable> getDataStoreParameters(); // }
import org.apache.nifi.annotation.documentation.CapabilityDescription; import org.apache.nifi.annotation.documentation.SeeAlso; import org.apache.nifi.annotation.documentation.Tags; import org.apache.nifi.annotation.lifecycle.OnDisabled; import org.apache.nifi.annotation.lifecycle.OnEnabled; import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.controller.AbstractControllerService; import org.apache.nifi.controller.ConfigurationContext; import org.apache.nifi.processor.util.StandardValidators; import org.apache.nifi.reporting.InitializationException; import org.geomesa.nifi.datastore.services.DataStoreConfigService; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map;
/*********************************************************************** * Copyright (c) 2015-2022 Commonwealth Computer Research, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Apache License, Version 2.0 * which accompanies this distribution and is available at * http://www.opensource.org/licenses/apache2.0.php. ***********************************************************************/ package org.geomesa.nifi.datastore.impl; @CapabilityDescription("Defines credentials for GeoMesa Accumulo processors") @SeeAlso(classNames = { "org.geomesa.nifi.processors.accumulo.PutGeoMesaAccumulo" }) @Tags({ "geo", "geomesa","accumulo" }) public class AccumuloDataStoreConfigControllerService
// Path: geomesa-datastore-bundle/geomesa-datastore-services-api/src/main/java/org/geomesa/nifi/datastore/services/DataStoreConfigService.java // public interface DataStoreConfigService extends ControllerService { // Map<String, Serializable> getDataStoreParameters(); // } // Path: geomesa-datastore-bundle/geomesa-datastore-services/src/main/java/org/geomesa/nifi/datastore/impl/AccumuloDataStoreConfigControllerService.java import org.apache.nifi.annotation.documentation.CapabilityDescription; import org.apache.nifi.annotation.documentation.SeeAlso; import org.apache.nifi.annotation.documentation.Tags; import org.apache.nifi.annotation.lifecycle.OnDisabled; import org.apache.nifi.annotation.lifecycle.OnEnabled; import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.controller.AbstractControllerService; import org.apache.nifi.controller.ConfigurationContext; import org.apache.nifi.processor.util.StandardValidators; import org.apache.nifi.reporting.InitializationException; import org.geomesa.nifi.datastore.services.DataStoreConfigService; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; /*********************************************************************** * Copyright (c) 2015-2022 Commonwealth Computer Research, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Apache License, Version 2.0 * which accompanies this distribution and is available at * http://www.opensource.org/licenses/apache2.0.php. ***********************************************************************/ package org.geomesa.nifi.datastore.impl; @CapabilityDescription("Defines credentials for GeoMesa Accumulo processors") @SeeAlso(classNames = { "org.geomesa.nifi.processors.accumulo.PutGeoMesaAccumulo" }) @Tags({ "geo", "geomesa","accumulo" }) public class AccumuloDataStoreConfigControllerService
extends AbstractControllerService implements DataStoreConfigService {
finmath/finmath-experiments
src/main/java/net/finmath/experiments/montecarlo/MonteCarloIntegrationWithQuasiRandomNumbersExperiment.java
// Path: src/main/java/net/finmath/experiments/montecarlo/randomnumbers/HaltonSequence.java // public class HaltonSequence { // // private final int[] baseVector; // // /** // * Construct a Halton sequence with d = base.length dimensions where the i-th component // * uses base[i] as base of the corresponding van der Corput sequence. // * // * @param baseVector Vector of base integers for each component. // */ // public HaltonSequence(int[] baseVector) { // // Check base // for(final int base : baseVector) { // if(base < 2) { // throw new RuntimeException("Cannot create Halton sequence with base less than two."); // } // } // // this.baseVector = baseVector; // } // // /** // * Construct a one dimensional Halton sequence (Van der Corput sequence) with given base. // * // * @param base Base of the sequence. // */ // public HaltonSequence(int base) { // // Check base // if(base < 2) { // throw new RuntimeException("Cannot create Halton sequence with base less than two."); // } // // this.baseVector = new int[] { base }; // } // // /** // * Print the first 1000 Halton numbers for base b = (2,3). // * // * @param args // */ // public static void main(String[] args) { // System.out.println("Halton sequence (base b = (2,3)):"); // for(int i=0; i<1000; i++) { // System.out.println("" + getHaltonNumber(i, 2) + "\t" + getHaltonNumber(i, 3)); // } // } // // /** // * Get Halton number for given index. // * // * @param index Index of the Halton number. // * @return Halton number (vector). // */ // public double[] getHaltonNumber(long index) { // final double[] x = new double[baseVector.length]; // for(int baseIndex=0; baseIndex < baseVector.length; baseIndex++) { // x[baseIndex] = getHaltonNumber(index, baseVector[baseIndex]); // } // return x; // } // // /** // * Get Halton number for given index and base. // * // * @param index Index of the Halton number (starting at 0). // * @param base Base of the Halton number. // * @return Halton number. // */ // public static double getHaltonNumber(long index, int base) { // // Check base // if(base < 2) { // throw new RuntimeException("Cannot create Halton number with base less than two."); // } // if(index < 0) { // throw new RuntimeException("Cannot create Halton number with index less than zero."); // } // // // Index shift: counting of the function starts at 0, algorithm below starts at 1. // index++; // // // Calculate Halton number x // double x = 0; // double factor = 1.0/base; // while(index > 0) { // x += (index % base) * factor; // factor /= base; // index /= base; // } // return x; // } // }
import net.finmath.experiments.montecarlo.randomnumbers.HaltonSequence;
/* * (c) Copyright Christian P. Fries, Germany. All rights reserved. Contact: email@christianfries.com. * * Created on 12.10.2013 */ package net.finmath.experiments.montecarlo; /** * A simple class illustrating a Monte-Carlo integration using a Halton sequence (low discrepancy sequence) * * @author Christian Fries */ public class MonteCarloIntegrationWithQuasiRandomNumbersExperiment { /** * Main program to run the experiment. * * @param args Arguments, not used */ public static void main(String[] args) { final long numberOfSimulations = 20000000; // Measure calculation time - start final long millisStart = System.currentTimeMillis(); final double pi = getMonteCarloApproximationOfPi(numberOfSimulations); // Measure calculation time - end final long millisEnd = System.currentTimeMillis(); System.out.println("Simulation with n = " + numberOfSimulations + " resulted in approximation of pi = " + pi +"\n"); System.out.println("Approximation error is = " + Math.abs(pi-Math.PI)); System.out.println("Theoretical order of the (quasi) Monte-Carlo error is = " + Math.pow(Math.log(numberOfSimulations),2)/numberOfSimulations + "\n"); System.out.println("Calculation took " + (millisEnd-millisStart)/1000.0 + " sec."); } /** * Calculates an approximation of pi via Monte-Carlo integration. * * @param numberOfSimulations The number of elements to use from the random number sequence. * @return An approximation of pi. */ public static double getMonteCarloApproximationOfPi(long numberOfSimulations) { long numberOfPointsInsideUnitCircle = 0; for(long i=0; i<numberOfSimulations; i++) {
// Path: src/main/java/net/finmath/experiments/montecarlo/randomnumbers/HaltonSequence.java // public class HaltonSequence { // // private final int[] baseVector; // // /** // * Construct a Halton sequence with d = base.length dimensions where the i-th component // * uses base[i] as base of the corresponding van der Corput sequence. // * // * @param baseVector Vector of base integers for each component. // */ // public HaltonSequence(int[] baseVector) { // // Check base // for(final int base : baseVector) { // if(base < 2) { // throw new RuntimeException("Cannot create Halton sequence with base less than two."); // } // } // // this.baseVector = baseVector; // } // // /** // * Construct a one dimensional Halton sequence (Van der Corput sequence) with given base. // * // * @param base Base of the sequence. // */ // public HaltonSequence(int base) { // // Check base // if(base < 2) { // throw new RuntimeException("Cannot create Halton sequence with base less than two."); // } // // this.baseVector = new int[] { base }; // } // // /** // * Print the first 1000 Halton numbers for base b = (2,3). // * // * @param args // */ // public static void main(String[] args) { // System.out.println("Halton sequence (base b = (2,3)):"); // for(int i=0; i<1000; i++) { // System.out.println("" + getHaltonNumber(i, 2) + "\t" + getHaltonNumber(i, 3)); // } // } // // /** // * Get Halton number for given index. // * // * @param index Index of the Halton number. // * @return Halton number (vector). // */ // public double[] getHaltonNumber(long index) { // final double[] x = new double[baseVector.length]; // for(int baseIndex=0; baseIndex < baseVector.length; baseIndex++) { // x[baseIndex] = getHaltonNumber(index, baseVector[baseIndex]); // } // return x; // } // // /** // * Get Halton number for given index and base. // * // * @param index Index of the Halton number (starting at 0). // * @param base Base of the Halton number. // * @return Halton number. // */ // public static double getHaltonNumber(long index, int base) { // // Check base // if(base < 2) { // throw new RuntimeException("Cannot create Halton number with base less than two."); // } // if(index < 0) { // throw new RuntimeException("Cannot create Halton number with index less than zero."); // } // // // Index shift: counting of the function starts at 0, algorithm below starts at 1. // index++; // // // Calculate Halton number x // double x = 0; // double factor = 1.0/base; // while(index > 0) { // x += (index % base) * factor; // factor /= base; // index /= base; // } // return x; // } // } // Path: src/main/java/net/finmath/experiments/montecarlo/MonteCarloIntegrationWithQuasiRandomNumbersExperiment.java import net.finmath.experiments.montecarlo.randomnumbers.HaltonSequence; /* * (c) Copyright Christian P. Fries, Germany. All rights reserved. Contact: email@christianfries.com. * * Created on 12.10.2013 */ package net.finmath.experiments.montecarlo; /** * A simple class illustrating a Monte-Carlo integration using a Halton sequence (low discrepancy sequence) * * @author Christian Fries */ public class MonteCarloIntegrationWithQuasiRandomNumbersExperiment { /** * Main program to run the experiment. * * @param args Arguments, not used */ public static void main(String[] args) { final long numberOfSimulations = 20000000; // Measure calculation time - start final long millisStart = System.currentTimeMillis(); final double pi = getMonteCarloApproximationOfPi(numberOfSimulations); // Measure calculation time - end final long millisEnd = System.currentTimeMillis(); System.out.println("Simulation with n = " + numberOfSimulations + " resulted in approximation of pi = " + pi +"\n"); System.out.println("Approximation error is = " + Math.abs(pi-Math.PI)); System.out.println("Theoretical order of the (quasi) Monte-Carlo error is = " + Math.pow(Math.log(numberOfSimulations),2)/numberOfSimulations + "\n"); System.out.println("Calculation took " + (millisEnd-millisStart)/1000.0 + " sec."); } /** * Calculates an approximation of pi via Monte-Carlo integration. * * @param numberOfSimulations The number of elements to use from the random number sequence. * @return An approximation of pi. */ public static double getMonteCarloApproximationOfPi(long numberOfSimulations) { long numberOfPointsInsideUnitCircle = 0; for(long i=0; i<numberOfSimulations; i++) {
final double x = 2.0 * (HaltonSequence.getHaltonNumber(i, 2) - 0.5); // quasi random number between -1 and 1
finmath/finmath-experiments
src/main/java/net/finmath/experiments/reproduction/ReproductionSimulationExperiment.java
// Path: src/main/java/net/finmath/experiments/reproduction/ReproductionSimulationExperiment.java // public enum State { // UNINFECTED, // INFECTED_NOT_INFECTIOUS, // INFECTED_AND_INFECTIOUS, // IMMUNE // }
import java.awt.Color; import java.awt.Rectangle; import java.io.File; import java.io.IOException; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.IntStream; import net.finmath.experiments.reproduction.ReproductionSimulationExperiment.StateProbabilities.State; import net.finmath.plots.GraphStyle; import net.finmath.plots.Plot2D; import net.finmath.plots.Plotable2D; import net.finmath.plots.PlotablePoints2D; import net.finmath.plots.Point2D; import net.finmath.rootfinder.BisectionSearch; import net.finmath.rootfinder.RootFinder;
package net.finmath.experiments.reproduction; public class ReproductionSimulationExperiment { private static final int maxIncubation = 25; private final double incubationMean; private final double incubationStdDev; private final int timeInfectious; private int currentTime = 0; public static class StateProbabilities {
// Path: src/main/java/net/finmath/experiments/reproduction/ReproductionSimulationExperiment.java // public enum State { // UNINFECTED, // INFECTED_NOT_INFECTIOUS, // INFECTED_AND_INFECTIOUS, // IMMUNE // } // Path: src/main/java/net/finmath/experiments/reproduction/ReproductionSimulationExperiment.java import java.awt.Color; import java.awt.Rectangle; import java.io.File; import java.io.IOException; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.IntStream; import net.finmath.experiments.reproduction.ReproductionSimulationExperiment.StateProbabilities.State; import net.finmath.plots.GraphStyle; import net.finmath.plots.Plot2D; import net.finmath.plots.Plotable2D; import net.finmath.plots.PlotablePoints2D; import net.finmath.plots.Point2D; import net.finmath.rootfinder.BisectionSearch; import net.finmath.rootfinder.RootFinder; package net.finmath.experiments.reproduction; public class ReproductionSimulationExperiment { private static final int maxIncubation = 25; private final double incubationMean; private final double incubationStdDev; private final int timeInfectious; private int currentTime = 0; public static class StateProbabilities {
public enum State {
finmath/finmath-experiments
src/main/java/net/finmath/experiments/montecarlo/MonteCarloIntegrationParallelizedExperiment.java
// Path: src/main/java/net/finmath/experiments/montecarlo/randomnumbers/HaltonSequence.java // public class HaltonSequence { // // private final int[] baseVector; // // /** // * Construct a Halton sequence with d = base.length dimensions where the i-th component // * uses base[i] as base of the corresponding van der Corput sequence. // * // * @param baseVector Vector of base integers for each component. // */ // public HaltonSequence(int[] baseVector) { // // Check base // for(final int base : baseVector) { // if(base < 2) { // throw new RuntimeException("Cannot create Halton sequence with base less than two."); // } // } // // this.baseVector = baseVector; // } // // /** // * Construct a one dimensional Halton sequence (Van der Corput sequence) with given base. // * // * @param base Base of the sequence. // */ // public HaltonSequence(int base) { // // Check base // if(base < 2) { // throw new RuntimeException("Cannot create Halton sequence with base less than two."); // } // // this.baseVector = new int[] { base }; // } // // /** // * Print the first 1000 Halton numbers for base b = (2,3). // * // * @param args // */ // public static void main(String[] args) { // System.out.println("Halton sequence (base b = (2,3)):"); // for(int i=0; i<1000; i++) { // System.out.println("" + getHaltonNumber(i, 2) + "\t" + getHaltonNumber(i, 3)); // } // } // // /** // * Get Halton number for given index. // * // * @param index Index of the Halton number. // * @return Halton number (vector). // */ // public double[] getHaltonNumber(long index) { // final double[] x = new double[baseVector.length]; // for(int baseIndex=0; baseIndex < baseVector.length; baseIndex++) { // x[baseIndex] = getHaltonNumber(index, baseVector[baseIndex]); // } // return x; // } // // /** // * Get Halton number for given index and base. // * // * @param index Index of the Halton number (starting at 0). // * @param base Base of the Halton number. // * @return Halton number. // */ // public static double getHaltonNumber(long index, int base) { // // Check base // if(base < 2) { // throw new RuntimeException("Cannot create Halton number with base less than two."); // } // if(index < 0) { // throw new RuntimeException("Cannot create Halton number with index less than zero."); // } // // // Index shift: counting of the function starts at 0, algorithm below starts at 1. // index++; // // // Calculate Halton number x // double x = 0; // double factor = 1.0/base; // while(index > 0) { // x += (index % base) * factor; // factor /= base; // index /= base; // } // return x; // } // }
import java.util.ArrayList; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import net.finmath.experiments.montecarlo.randomnumbers.HaltonSequence;
System.out.print("done.\n"); final double pi = sumOfResults / numberOfTask; // Measure calculation time - end final long millisEnd = System.currentTimeMillis(); System.out.println("Simulation with n = " + numberOfSimulations + " resulted in approximation of pi = " + pi +"\n"); System.out.println("Approximation error is = " + Math.abs(pi-Math.PI)); System.out.println("Theoretical order of the (quasi) Monte-Carlo error is = " + Math.pow(Math.log(numberOfSimulations),2)/numberOfSimulations + "\n"); System.out.println("Calculation took " + (millisEnd-millisStart)/1000.0 + " sec."); /* * End/clean up thread pool */ executor.shutdown(); } /** * Calculates an approximation of pi via Monte-Carlo integration. * * @param indexStart The start index of the random number sequence. * @param numberOfSimulations The number of elements to use from the random number sequence. * @return An approximation of pi. */ public static double getMonteCarloApproximationOfPi(long indexStart, long numberOfSimulations) { long numberOfPointsInsideUnitCircle = 0; for(long i=indexStart; i<indexStart+numberOfSimulations; i++) {
// Path: src/main/java/net/finmath/experiments/montecarlo/randomnumbers/HaltonSequence.java // public class HaltonSequence { // // private final int[] baseVector; // // /** // * Construct a Halton sequence with d = base.length dimensions where the i-th component // * uses base[i] as base of the corresponding van der Corput sequence. // * // * @param baseVector Vector of base integers for each component. // */ // public HaltonSequence(int[] baseVector) { // // Check base // for(final int base : baseVector) { // if(base < 2) { // throw new RuntimeException("Cannot create Halton sequence with base less than two."); // } // } // // this.baseVector = baseVector; // } // // /** // * Construct a one dimensional Halton sequence (Van der Corput sequence) with given base. // * // * @param base Base of the sequence. // */ // public HaltonSequence(int base) { // // Check base // if(base < 2) { // throw new RuntimeException("Cannot create Halton sequence with base less than two."); // } // // this.baseVector = new int[] { base }; // } // // /** // * Print the first 1000 Halton numbers for base b = (2,3). // * // * @param args // */ // public static void main(String[] args) { // System.out.println("Halton sequence (base b = (2,3)):"); // for(int i=0; i<1000; i++) { // System.out.println("" + getHaltonNumber(i, 2) + "\t" + getHaltonNumber(i, 3)); // } // } // // /** // * Get Halton number for given index. // * // * @param index Index of the Halton number. // * @return Halton number (vector). // */ // public double[] getHaltonNumber(long index) { // final double[] x = new double[baseVector.length]; // for(int baseIndex=0; baseIndex < baseVector.length; baseIndex++) { // x[baseIndex] = getHaltonNumber(index, baseVector[baseIndex]); // } // return x; // } // // /** // * Get Halton number for given index and base. // * // * @param index Index of the Halton number (starting at 0). // * @param base Base of the Halton number. // * @return Halton number. // */ // public static double getHaltonNumber(long index, int base) { // // Check base // if(base < 2) { // throw new RuntimeException("Cannot create Halton number with base less than two."); // } // if(index < 0) { // throw new RuntimeException("Cannot create Halton number with index less than zero."); // } // // // Index shift: counting of the function starts at 0, algorithm below starts at 1. // index++; // // // Calculate Halton number x // double x = 0; // double factor = 1.0/base; // while(index > 0) { // x += (index % base) * factor; // factor /= base; // index /= base; // } // return x; // } // } // Path: src/main/java/net/finmath/experiments/montecarlo/MonteCarloIntegrationParallelizedExperiment.java import java.util.ArrayList; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import net.finmath.experiments.montecarlo.randomnumbers.HaltonSequence; System.out.print("done.\n"); final double pi = sumOfResults / numberOfTask; // Measure calculation time - end final long millisEnd = System.currentTimeMillis(); System.out.println("Simulation with n = " + numberOfSimulations + " resulted in approximation of pi = " + pi +"\n"); System.out.println("Approximation error is = " + Math.abs(pi-Math.PI)); System.out.println("Theoretical order of the (quasi) Monte-Carlo error is = " + Math.pow(Math.log(numberOfSimulations),2)/numberOfSimulations + "\n"); System.out.println("Calculation took " + (millisEnd-millisStart)/1000.0 + " sec."); /* * End/clean up thread pool */ executor.shutdown(); } /** * Calculates an approximation of pi via Monte-Carlo integration. * * @param indexStart The start index of the random number sequence. * @param numberOfSimulations The number of elements to use from the random number sequence. * @return An approximation of pi. */ public static double getMonteCarloApproximationOfPi(long indexStart, long numberOfSimulations) { long numberOfPointsInsideUnitCircle = 0; for(long i=indexStart; i<indexStart+numberOfSimulations; i++) {
final double x = 2.0 * (HaltonSequence.getHaltonNumber(i, 2) - 0.5); // quasi random number between -1 and 1
sosandstrom/mardao
mardao-maven-plugin/src/main/java/net/sf/mardao/plugin/GenerateSourcesMojo.java
// Path: mardao-maven-plugin/src/main/java/net/sf/mardao/domain/MergeTemplate.java // public class MergeTemplate { // private String templatePrefix = ""; // private String templateMiddle = ""; // private String templateSuffix = ".vm"; // private String destFolder = "targetDao"; // private String filePrefix = ""; // private String fileMiddle = ""; // private String fileSuffix = ".java"; // private boolean entity = true; // private boolean typeSpecific = false; // private boolean typeAppend = true; // private boolean listingEntities = false; // // /** // * @since 2.2.4 // */ // private String requiresOnClasspath = null; // // public void setListingEntities(boolean listingEntities) { // this.listingEntities = listingEntities; // } // public String getTemplatePrefix() { // return templatePrefix; // } // public void setTemplatePrefix(String templatePrefix) { // this.templatePrefix = templatePrefix; // } // public String getTemplateSuffix() { // return templateSuffix; // } // public void setTemplateSuffix(String templateSuffix) { // this.templateSuffix = templateSuffix; // } // public String getDestFolder() { // return destFolder; // } // public void setDestFolder(String destFolder) { // this.destFolder = destFolder; // } // public String getFilePrefix() { // return filePrefix; // } // public void setFilePrefix(String filePrefix) { // this.filePrefix = filePrefix; // } // public String getFileSuffix() { // return fileSuffix; // } // public void setFileSuffix(String fileSuffix) { // this.fileSuffix = fileSuffix; // } // public boolean isEntity() { // return entity; // } // public void setEntity(boolean entity) { // this.entity = entity; // } // public boolean isTypeSpecific() { // return typeSpecific; // } // public void setTypeSpecific(boolean typeSpecific) { // this.typeSpecific = typeSpecific; // } // public String getTemplateMiddle() { // return templateMiddle ; // } // public void setTemplateMiddle(String templateMiddle) { // this.templateMiddle = templateMiddle; // } // public void setFileMiddle(String fileMiddle) { // this.fileMiddle = fileMiddle; // } // public String getFileMiddle() { // return fileMiddle; // } // public boolean isListingEntities() { // return listingEntities; // } // public void setTypeAppend(boolean typeAppend) { // this.typeAppend = typeAppend; // } // public boolean isTypeAppend() { // return typeAppend; // } // // public String getRequiresOnClasspath() { // return requiresOnClasspath; // } // // public void setRequiresOnClasspath(String requiresOnClasspath) { // this.requiresOnClasspath = requiresOnClasspath; // } // // // }
import net.sf.mardao.domain.MergeTemplate; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.velocity.exception.ParseErrorException; import org.apache.velocity.exception.ResourceNotFoundException;
package net.sf.mardao.plugin; /* * #%L * net.sf.mardao:mardao-maven-plugin * %% * Copyright (C) 2010 - 2014 Wadpam * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ /** * This Mojo merges the generic (non-entity) templates into their sources, * to be ready for the maven <code>compile</code> phase. * @goal generate-sources * @author f94os * */ public class GenerateSourcesMojo extends AbstractMardaoMojo { private void mergeGeneric() throws ResourceNotFoundException, ParseErrorException, Exception {
// Path: mardao-maven-plugin/src/main/java/net/sf/mardao/domain/MergeTemplate.java // public class MergeTemplate { // private String templatePrefix = ""; // private String templateMiddle = ""; // private String templateSuffix = ".vm"; // private String destFolder = "targetDao"; // private String filePrefix = ""; // private String fileMiddle = ""; // private String fileSuffix = ".java"; // private boolean entity = true; // private boolean typeSpecific = false; // private boolean typeAppend = true; // private boolean listingEntities = false; // // /** // * @since 2.2.4 // */ // private String requiresOnClasspath = null; // // public void setListingEntities(boolean listingEntities) { // this.listingEntities = listingEntities; // } // public String getTemplatePrefix() { // return templatePrefix; // } // public void setTemplatePrefix(String templatePrefix) { // this.templatePrefix = templatePrefix; // } // public String getTemplateSuffix() { // return templateSuffix; // } // public void setTemplateSuffix(String templateSuffix) { // this.templateSuffix = templateSuffix; // } // public String getDestFolder() { // return destFolder; // } // public void setDestFolder(String destFolder) { // this.destFolder = destFolder; // } // public String getFilePrefix() { // return filePrefix; // } // public void setFilePrefix(String filePrefix) { // this.filePrefix = filePrefix; // } // public String getFileSuffix() { // return fileSuffix; // } // public void setFileSuffix(String fileSuffix) { // this.fileSuffix = fileSuffix; // } // public boolean isEntity() { // return entity; // } // public void setEntity(boolean entity) { // this.entity = entity; // } // public boolean isTypeSpecific() { // return typeSpecific; // } // public void setTypeSpecific(boolean typeSpecific) { // this.typeSpecific = typeSpecific; // } // public String getTemplateMiddle() { // return templateMiddle ; // } // public void setTemplateMiddle(String templateMiddle) { // this.templateMiddle = templateMiddle; // } // public void setFileMiddle(String fileMiddle) { // this.fileMiddle = fileMiddle; // } // public String getFileMiddle() { // return fileMiddle; // } // public boolean isListingEntities() { // return listingEntities; // } // public void setTypeAppend(boolean typeAppend) { // this.typeAppend = typeAppend; // } // public boolean isTypeAppend() { // return typeAppend; // } // // public String getRequiresOnClasspath() { // return requiresOnClasspath; // } // // public void setRequiresOnClasspath(String requiresOnClasspath) { // this.requiresOnClasspath = requiresOnClasspath; // } // // // } // Path: mardao-maven-plugin/src/main/java/net/sf/mardao/plugin/GenerateSourcesMojo.java import net.sf.mardao.domain.MergeTemplate; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.velocity.exception.ParseErrorException; import org.apache.velocity.exception.ResourceNotFoundException; package net.sf.mardao.plugin; /* * #%L * net.sf.mardao:mardao-maven-plugin * %% * Copyright (C) 2010 - 2014 Wadpam * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ /** * This Mojo merges the generic (non-entity) templates into their sources, * to be ready for the maven <code>compile</code> phase. * @goal generate-sources * @author f94os * */ public class GenerateSourcesMojo extends AbstractMardaoMojo { private void mergeGeneric() throws ResourceNotFoundException, ParseErrorException, Exception {
for (MergeTemplate mt : mergeScheme.getTemplates()) {
sosandstrom/mardao
mardao-core/src/main/java/net/sf/mardao/dao/InMemorySupplier.java
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // }
import java.util.concurrent.Future; import java.util.concurrent.FutureTask; import net.sf.mardao.core.CursorPage; import net.sf.mardao.core.filter.Filter; import java.io.IOException; import java.io.Serializable; import java.nio.ByteBuffer; import java.util.*; import java.util.concurrent.Callable;
package net.sf.mardao.dao; /* * #%L * mardao-core * %% * Copyright (C) 2010 - 2014 Wadpam * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ /** * Stores entities in-memory using a new TreeMap&lt;InMemoryKey, Map&lt;String, Object&gt;&gt;. * * @author osandstrom Date: 2014-09-03 Time: 20:48 */ public class InMemorySupplier extends AbstractSupplier<InMemoryKey, Map<String, Object>, Map<String, Object>, Object> { public static final String NAME_PARENT_KEY = "__parentKey"; public static final String NAME_KEY = "__Key"; private final Map<String, Map<String, Map<String, Object>>> store = new TreeMap<String, Map<String, Map<String, Object>>>(); @Override public Object beginTransaction() { return new Object(); } @Override public void commitTransaction(Object tx) { } @Override public void rollbackActiveTransaction(Object tx) { } @Override
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // } // Path: mardao-core/src/main/java/net/sf/mardao/dao/InMemorySupplier.java import java.util.concurrent.Future; import java.util.concurrent.FutureTask; import net.sf.mardao.core.CursorPage; import net.sf.mardao.core.filter.Filter; import java.io.IOException; import java.io.Serializable; import java.nio.ByteBuffer; import java.util.*; import java.util.concurrent.Callable; package net.sf.mardao.dao; /* * #%L * mardao-core * %% * Copyright (C) 2010 - 2014 Wadpam * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ /** * Stores entities in-memory using a new TreeMap&lt;InMemoryKey, Map&lt;String, Object&gt;&gt;. * * @author osandstrom Date: 2014-09-03 Time: 20:48 */ public class InMemorySupplier extends AbstractSupplier<InMemoryKey, Map<String, Object>, Map<String, Object>, Object> { public static final String NAME_PARENT_KEY = "__parentKey"; public static final String NAME_KEY = "__Key"; private final Map<String, Map<String, Map<String, Object>>> store = new TreeMap<String, Map<String, Map<String, Object>>>(); @Override public Object beginTransaction() { return new Object(); } @Override public void commitTransaction(Object tx) { } @Override public void rollbackActiveTransaction(Object tx) { } @Override
public int count(Object tx, Mapper mapper, InMemoryKey ancestorKey, InMemoryKey simpleKey, Filter... filters) {
sosandstrom/mardao
mardao-core/src/main/java/net/sf/mardao/dao/InMemorySupplier.java
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // }
import java.util.concurrent.Future; import java.util.concurrent.FutureTask; import net.sf.mardao.core.CursorPage; import net.sf.mardao.core.filter.Filter; import java.io.IOException; import java.io.Serializable; import java.nio.ByteBuffer; import java.util.*; import java.util.concurrent.Callable;
} private Collection<Map<String, Object>> filterValues(Collection<Map<String, Object>> values, Filter... filters) { Collection<Map<String, Object>> after = values; if (null != filters) { for (Filter f : filters) { after = new ArrayList<Map<String, Object>>(); for (Map<String, Object> v : values) { if (match(v, f)) { after.add(v); } } values = after; if (after.isEmpty()) { break; } } } return after; } @Override public Map<String, Object> queryUnique(Object tx, Mapper mapper, InMemoryKey parentKey, Filter... filters) { final Iterable<Map<String, Object>> iterable = queryIterable(tx, mapper, false, 0, 1, parentKey, null, null, false, null, false, filters); final Iterator<Map<String, Object>> iterator = iterable.iterator(); return iterator.hasNext() ? iterator.next() : null; } @Override
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // } // Path: mardao-core/src/main/java/net/sf/mardao/dao/InMemorySupplier.java import java.util.concurrent.Future; import java.util.concurrent.FutureTask; import net.sf.mardao.core.CursorPage; import net.sf.mardao.core.filter.Filter; import java.io.IOException; import java.io.Serializable; import java.nio.ByteBuffer; import java.util.*; import java.util.concurrent.Callable; } private Collection<Map<String, Object>> filterValues(Collection<Map<String, Object>> values, Filter... filters) { Collection<Map<String, Object>> after = values; if (null != filters) { for (Filter f : filters) { after = new ArrayList<Map<String, Object>>(); for (Map<String, Object> v : values) { if (match(v, f)) { after.add(v); } } values = after; if (after.isEmpty()) { break; } } } return after; } @Override public Map<String, Object> queryUnique(Object tx, Mapper mapper, InMemoryKey parentKey, Filter... filters) { final Iterable<Map<String, Object>> iterable = queryIterable(tx, mapper, false, 0, 1, parentKey, null, null, false, null, false, filters); final Iterator<Map<String, Object>> iterator = iterable.iterator(); return iterator.hasNext() ? iterator.next() : null; } @Override
public CursorPage<Map<String, Object>> queryPage(Object tx, Mapper mapper, boolean keysOnly,
sosandstrom/mardao
mardao-maven-plugin/src/test/java/net/sf/mardao/test/dao/DCachedEntityDaoBean.java
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // }
import com.google.inject.Inject; import net.sf.mardao.dao.Supplier; import javax.cache.annotation.CacheDefaults;
package net.sf.mardao.test.dao; /** * Implementation of Business Methods related to entity DCachedEntity. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2015-01-20T15:47:37.626+0100. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ @CacheDefaults(cacheName = "DCachedEntity") public class DCachedEntityDaoBean extends GeneratedDCachedEntityDaoImpl { @Inject
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // } // Path: mardao-maven-plugin/src/test/java/net/sf/mardao/test/dao/DCachedEntityDaoBean.java import com.google.inject.Inject; import net.sf.mardao.dao.Supplier; import javax.cache.annotation.CacheDefaults; package net.sf.mardao.test.dao; /** * Implementation of Business Methods related to entity DCachedEntity. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2015-01-20T15:47:37.626+0100. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ @CacheDefaults(cacheName = "DCachedEntity") public class DCachedEntityDaoBean extends GeneratedDCachedEntityDaoImpl { @Inject
public DCachedEntityDaoBean(Supplier supplier) {
sosandstrom/mardao
mardao-maven-plugin/src/test/java/net/sf/mardao/test/dao/DPageCachedEntityDaoBean.java
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // }
import com.google.inject.Inject; import net.sf.mardao.dao.Supplier; import javax.cache.annotation.CacheDefaults;
package net.sf.mardao.test.dao; /** * Implementation of Business Methods related to entity DPageCachedEntity. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2015-01-20T15:47:37.626+0100. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ @CacheDefaults(cacheName = "DPageCachedEntity") public class DPageCachedEntityDaoBean extends GeneratedDPageCachedEntityDaoImpl { @Inject
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // } // Path: mardao-maven-plugin/src/test/java/net/sf/mardao/test/dao/DPageCachedEntityDaoBean.java import com.google.inject.Inject; import net.sf.mardao.dao.Supplier; import javax.cache.annotation.CacheDefaults; package net.sf.mardao.test.dao; /** * Implementation of Business Methods related to entity DPageCachedEntity. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2015-01-20T15:47:37.626+0100. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ @CacheDefaults(cacheName = "DPageCachedEntity") public class DPageCachedEntityDaoBean extends GeneratedDPageCachedEntityDaoImpl { @Inject
public DPageCachedEntityDaoBean(Supplier supplier) {
sosandstrom/mardao
mardao-maven-plugin/src/test/java/net/sf/mardao/test/dao/DEntityDaoBean.java
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // }
import com.google.inject.Inject; import net.sf.mardao.dao.Supplier;
package net.sf.mardao.test.dao; /* * #%L * net.sf.mardao:mardao-maven-plugin * %% * Copyright (C) 2010 - 2014 Wadpam * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ /** * Implementation of Business Methods related to entity DEntity. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2014-09-14T18:41:01.737+0200. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ public class DEntityDaoBean extends GeneratedDEntityDaoImpl { @Inject
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // } // Path: mardao-maven-plugin/src/test/java/net/sf/mardao/test/dao/DEntityDaoBean.java import com.google.inject.Inject; import net.sf.mardao.dao.Supplier; package net.sf.mardao.test.dao; /* * #%L * net.sf.mardao:mardao-maven-plugin * %% * Copyright (C) 2010 - 2014 Wadpam * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ /** * Implementation of Business Methods related to entity DEntity. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2014-09-14T18:41:01.737+0200. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ public class DEntityDaoBean extends GeneratedDEntityDaoImpl { @Inject
public DEntityDaoBean(Supplier supplier) {
sosandstrom/mardao
mardao-core/src/main/java/net/sf/mardao/dao/SupplierAdapter.java
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // }
import net.sf.mardao.core.CursorPage; import net.sf.mardao.core.filter.Filter; import java.io.IOException; import java.io.Serializable; import java.util.Collection; import java.util.concurrent.Future;
package net.sf.mardao.dao; /** * Created by sosandstrom on 2015-02-27. */ public class SupplierAdapter<K, RV, WV, TR> extends AbstractSupplier<K, RV, WV, TR> { @Override protected Object getReadObject(RV value, String column) { return null; } @Override protected void setObject(WV value, String column, Object o) { } @Override
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // } // Path: mardao-core/src/main/java/net/sf/mardao/dao/SupplierAdapter.java import net.sf.mardao.core.CursorPage; import net.sf.mardao.core.filter.Filter; import java.io.IOException; import java.io.Serializable; import java.util.Collection; import java.util.concurrent.Future; package net.sf.mardao.dao; /** * Created by sosandstrom on 2015-02-27. */ public class SupplierAdapter<K, RV, WV, TR> extends AbstractSupplier<K, RV, WV, TR> { @Override protected Object getReadObject(RV value, String column) { return null; } @Override protected void setObject(WV value, String column, Object o) { } @Override
public int count(TR tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters) {
sosandstrom/mardao
mardao-core/src/main/java/net/sf/mardao/dao/SupplierAdapter.java
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // }
import net.sf.mardao.core.CursorPage; import net.sf.mardao.core.filter.Filter; import java.io.IOException; import java.io.Serializable; import java.util.Collection; import java.util.concurrent.Future;
public WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity) { return null; } @Override public TR beginTransaction() { return null; } @Override public void commitTransaction(TR transaction) { } @Override public void rollbackActiveTransaction(TR transaction) { } @Override public Iterable<RV> queryIterable(TR tx, Mapper mapper, boolean keysOnly, int offset, int limit, K ancestorKey, K simpleKey, String primaryOrderBy, boolean primaryIsAscending, String secondaryOrderBy, boolean secondaryIsAscending, Filter... filters) { return null; } @Override public RV queryUnique(TR tx, Mapper mapper, K parentKey, Filter... filters) { return null; } @Override
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // } // Path: mardao-core/src/main/java/net/sf/mardao/dao/SupplierAdapter.java import net.sf.mardao.core.CursorPage; import net.sf.mardao.core.filter.Filter; import java.io.IOException; import java.io.Serializable; import java.util.Collection; import java.util.concurrent.Future; public WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity) { return null; } @Override public TR beginTransaction() { return null; } @Override public void commitTransaction(TR transaction) { } @Override public void rollbackActiveTransaction(TR transaction) { } @Override public Iterable<RV> queryIterable(TR tx, Mapper mapper, boolean keysOnly, int offset, int limit, K ancestorKey, K simpleKey, String primaryOrderBy, boolean primaryIsAscending, String secondaryOrderBy, boolean secondaryIsAscending, Filter... filters) { return null; } @Override public RV queryUnique(TR tx, Mapper mapper, K parentKey, Filter... filters) { return null; } @Override
public CursorPage<RV> queryPage(TR tx, Mapper mapper, boolean keysOnly, int requestedPageSize, K ancestorKey, String primaryOrderBy, boolean primaryIsAscending, String secondaryOrderBy, boolean secondaryIsAscending, Collection<String> projections, String cursorString, Filter... filters) {
sosandstrom/mardao
mardao-core/src/test/java/net/sf/mardao/junit/dao/DFactoryDaoBean.java
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // }
import net.sf.mardao.dao.Supplier;
package net.sf.mardao.junit.dao; /** * Implementation of Business Methods related to entity DFactory. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2015-02-28T10:34:05.595+0100. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ public class DFactoryDaoBean extends GeneratedDFactoryDaoImpl {
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // } // Path: mardao-core/src/test/java/net/sf/mardao/junit/dao/DFactoryDaoBean.java import net.sf.mardao.dao.Supplier; package net.sf.mardao.junit.dao; /** * Implementation of Business Methods related to entity DFactory. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2015-02-28T10:34:05.595+0100. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ public class DFactoryDaoBean extends GeneratedDFactoryDaoImpl {
public DFactoryDaoBean(Supplier<Object, Object, Object, Object> supplier) {
sosandstrom/mardao
mardao-maven-plugin/src/main/java/net/sf/mardao/plugin/AbstractMardaoMojo.java
// Path: mardao-maven-plugin/src/main/java/net/sf/mardao/domain/MergeScheme.java // public class MergeScheme { // // private List<MergeTemplate> templates; // // public MergeScheme() { // this.templates = new ArrayList<MergeTemplate>(); // } // // public MergeScheme(MergeScheme parent) { // this(); // setTemplates(parent.templates); // } // // public List<MergeTemplate> getTemplates() { // return templates; // } // // public void setTemplates(List<MergeTemplate> templatesToAppend) { // templatesToAppend.addAll(templates); // templates = templatesToAppend; // // templates.addAll(templatesToAppend); // } // } // // Path: mardao-maven-plugin/src/main/java/net/sf/mardao/domain/MergeTemplate.java // public class MergeTemplate { // private String templatePrefix = ""; // private String templateMiddle = ""; // private String templateSuffix = ".vm"; // private String destFolder = "targetDao"; // private String filePrefix = ""; // private String fileMiddle = ""; // private String fileSuffix = ".java"; // private boolean entity = true; // private boolean typeSpecific = false; // private boolean typeAppend = true; // private boolean listingEntities = false; // // /** // * @since 2.2.4 // */ // private String requiresOnClasspath = null; // // public void setListingEntities(boolean listingEntities) { // this.listingEntities = listingEntities; // } // public String getTemplatePrefix() { // return templatePrefix; // } // public void setTemplatePrefix(String templatePrefix) { // this.templatePrefix = templatePrefix; // } // public String getTemplateSuffix() { // return templateSuffix; // } // public void setTemplateSuffix(String templateSuffix) { // this.templateSuffix = templateSuffix; // } // public String getDestFolder() { // return destFolder; // } // public void setDestFolder(String destFolder) { // this.destFolder = destFolder; // } // public String getFilePrefix() { // return filePrefix; // } // public void setFilePrefix(String filePrefix) { // this.filePrefix = filePrefix; // } // public String getFileSuffix() { // return fileSuffix; // } // public void setFileSuffix(String fileSuffix) { // this.fileSuffix = fileSuffix; // } // public boolean isEntity() { // return entity; // } // public void setEntity(boolean entity) { // this.entity = entity; // } // public boolean isTypeSpecific() { // return typeSpecific; // } // public void setTypeSpecific(boolean typeSpecific) { // this.typeSpecific = typeSpecific; // } // public String getTemplateMiddle() { // return templateMiddle ; // } // public void setTemplateMiddle(String templateMiddle) { // this.templateMiddle = templateMiddle; // } // public void setFileMiddle(String fileMiddle) { // this.fileMiddle = fileMiddle; // } // public String getFileMiddle() { // return fileMiddle; // } // public boolean isListingEntities() { // return listingEntities; // } // public void setTypeAppend(boolean typeAppend) { // this.typeAppend = typeAppend; // } // public boolean isTypeAppend() { // return typeAppend; // } // // public String getRequiresOnClasspath() { // return requiresOnClasspath; // } // // public void setRequiresOnClasspath(String requiresOnClasspath) { // this.requiresOnClasspath = requiresOnClasspath; // } // // // }
import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; import net.sf.mardao.domain.MergeScheme; import net.sf.mardao.domain.MergeTemplate; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; import org.apache.velocity.exception.ParseErrorException; import org.apache.velocity.exception.ResourceNotFoundException; import org.springframework.context.ApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext;
* @parameter expression="${project}" * @required * @readonly */ protected MavenProject project; /** * @parameter expression="${generate.sourceVersion}" default-value="${maven.compiler.source}" */ protected String sourceVersion; public static final java.text.DateFormat DATEFORMAT = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); protected URLClassLoader loader; protected String daoBasePackage; protected String domainBasePackage; protected String controllerBasePackage; protected final VelocityContext vc = new VelocityContext(); protected File targetDaoFolder; protected File targetControllerFolder; protected File targetJspFolder; protected File srcDaoFolder; protected File srcDomainFolder; protected File srcControllerFolder; protected File srcJspFolder;
// Path: mardao-maven-plugin/src/main/java/net/sf/mardao/domain/MergeScheme.java // public class MergeScheme { // // private List<MergeTemplate> templates; // // public MergeScheme() { // this.templates = new ArrayList<MergeTemplate>(); // } // // public MergeScheme(MergeScheme parent) { // this(); // setTemplates(parent.templates); // } // // public List<MergeTemplate> getTemplates() { // return templates; // } // // public void setTemplates(List<MergeTemplate> templatesToAppend) { // templatesToAppend.addAll(templates); // templates = templatesToAppend; // // templates.addAll(templatesToAppend); // } // } // // Path: mardao-maven-plugin/src/main/java/net/sf/mardao/domain/MergeTemplate.java // public class MergeTemplate { // private String templatePrefix = ""; // private String templateMiddle = ""; // private String templateSuffix = ".vm"; // private String destFolder = "targetDao"; // private String filePrefix = ""; // private String fileMiddle = ""; // private String fileSuffix = ".java"; // private boolean entity = true; // private boolean typeSpecific = false; // private boolean typeAppend = true; // private boolean listingEntities = false; // // /** // * @since 2.2.4 // */ // private String requiresOnClasspath = null; // // public void setListingEntities(boolean listingEntities) { // this.listingEntities = listingEntities; // } // public String getTemplatePrefix() { // return templatePrefix; // } // public void setTemplatePrefix(String templatePrefix) { // this.templatePrefix = templatePrefix; // } // public String getTemplateSuffix() { // return templateSuffix; // } // public void setTemplateSuffix(String templateSuffix) { // this.templateSuffix = templateSuffix; // } // public String getDestFolder() { // return destFolder; // } // public void setDestFolder(String destFolder) { // this.destFolder = destFolder; // } // public String getFilePrefix() { // return filePrefix; // } // public void setFilePrefix(String filePrefix) { // this.filePrefix = filePrefix; // } // public String getFileSuffix() { // return fileSuffix; // } // public void setFileSuffix(String fileSuffix) { // this.fileSuffix = fileSuffix; // } // public boolean isEntity() { // return entity; // } // public void setEntity(boolean entity) { // this.entity = entity; // } // public boolean isTypeSpecific() { // return typeSpecific; // } // public void setTypeSpecific(boolean typeSpecific) { // this.typeSpecific = typeSpecific; // } // public String getTemplateMiddle() { // return templateMiddle ; // } // public void setTemplateMiddle(String templateMiddle) { // this.templateMiddle = templateMiddle; // } // public void setFileMiddle(String fileMiddle) { // this.fileMiddle = fileMiddle; // } // public String getFileMiddle() { // return fileMiddle; // } // public boolean isListingEntities() { // return listingEntities; // } // public void setTypeAppend(boolean typeAppend) { // this.typeAppend = typeAppend; // } // public boolean isTypeAppend() { // return typeAppend; // } // // public String getRequiresOnClasspath() { // return requiresOnClasspath; // } // // public void setRequiresOnClasspath(String requiresOnClasspath) { // this.requiresOnClasspath = requiresOnClasspath; // } // // // } // Path: mardao-maven-plugin/src/main/java/net/sf/mardao/plugin/AbstractMardaoMojo.java import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; import net.sf.mardao.domain.MergeScheme; import net.sf.mardao.domain.MergeTemplate; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; import org.apache.velocity.exception.ParseErrorException; import org.apache.velocity.exception.ResourceNotFoundException; import org.springframework.context.ApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext; * @parameter expression="${project}" * @required * @readonly */ protected MavenProject project; /** * @parameter expression="${generate.sourceVersion}" default-value="${maven.compiler.source}" */ protected String sourceVersion; public static final java.text.DateFormat DATEFORMAT = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); protected URLClassLoader loader; protected String daoBasePackage; protected String domainBasePackage; protected String controllerBasePackage; protected final VelocityContext vc = new VelocityContext(); protected File targetDaoFolder; protected File targetControllerFolder; protected File targetJspFolder; protected File srcDaoFolder; protected File srcDomainFolder; protected File srcControllerFolder; protected File srcJspFolder;
protected MergeScheme mergeScheme;
sosandstrom/mardao
mardao-maven-plugin/src/test/java/net/sf/mardao/test/dao/DChildDaoBean.java
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // }
import com.google.inject.Inject; import net.sf.mardao.dao.Supplier;
package net.sf.mardao.test.dao; /* * #%L * net.sf.mardao:mardao-maven-plugin * %% * Copyright (C) 2010 - 2014 Wadpam * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ /** * Implementation of Business Methods related to entity DChild. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2014-10-01T19:57:05.382+0200. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ public class DChildDaoBean extends GeneratedDChildDaoImpl { @Inject
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // } // Path: mardao-maven-plugin/src/test/java/net/sf/mardao/test/dao/DChildDaoBean.java import com.google.inject.Inject; import net.sf.mardao.dao.Supplier; package net.sf.mardao.test.dao; /* * #%L * net.sf.mardao:mardao-maven-plugin * %% * Copyright (C) 2010 - 2014 Wadpam * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ /** * Implementation of Business Methods related to entity DChild. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2014-10-01T19:57:05.382+0200. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ public class DChildDaoBean extends GeneratedDChildDaoImpl { @Inject
public DChildDaoBean(Supplier supplier) {
sosandstrom/mardao
mardao-maven-plugin/src/test/java/net/sf/mardao/test/dao/DCachedEntityDaoTest.java
// Path: mardao-maven-plugin/src/test/java/net/sf/mardao/test/domain/DCachedEntity.java // @Entity // @Cached // public class DCachedEntity extends DEntity { // // }
import edu.emory.mathcs.backport.java.util.Arrays; import net.sf.mardao.core.CacheConfig; import net.sf.mardao.test.domain.DCachedEntity; import org.junit.After; import org.junit.Before; import org.junit.Test; import javax.cache.annotation.*; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Collection; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue;
package net.sf.mardao.test.dao; public class DCachedEntityDaoTest { @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } @Test public void testCrudAnnotations() throws Exception { // Check that jsr107 annotations were added to crud methods Method readMethod = DCachedEntityDaoBean.class.getMethod("get", Object.class, Long.class); assertTrue(readMethod.isAnnotationPresent(CacheResult.class)); Annotation[][] paramsAnnotations = readMethod.getParameterAnnotations(); assertTrue(hasAnnotation(Arrays.asList(paramsAnnotations[0]), CacheKey.class)); assertTrue(hasAnnotation(Arrays.asList(paramsAnnotations[1]), CacheKey.class));
// Path: mardao-maven-plugin/src/test/java/net/sf/mardao/test/domain/DCachedEntity.java // @Entity // @Cached // public class DCachedEntity extends DEntity { // // } // Path: mardao-maven-plugin/src/test/java/net/sf/mardao/test/dao/DCachedEntityDaoTest.java import edu.emory.mathcs.backport.java.util.Arrays; import net.sf.mardao.core.CacheConfig; import net.sf.mardao.test.domain.DCachedEntity; import org.junit.After; import org.junit.Before; import org.junit.Test; import javax.cache.annotation.*; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Collection; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; package net.sf.mardao.test.dao; public class DCachedEntityDaoTest { @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } @Test public void testCrudAnnotations() throws Exception { // Check that jsr107 annotations were added to crud methods Method readMethod = DCachedEntityDaoBean.class.getMethod("get", Object.class, Long.class); assertTrue(readMethod.isAnnotationPresent(CacheResult.class)); Annotation[][] paramsAnnotations = readMethod.getParameterAnnotations(); assertTrue(hasAnnotation(Arrays.asList(paramsAnnotations[0]), CacheKey.class)); assertTrue(hasAnnotation(Arrays.asList(paramsAnnotations[1]), CacheKey.class));
Method putMethod = DCachedEntityDaoBean.class.getMethod("put", Object.class, Long.class, DCachedEntity.class);
sosandstrom/mardao
mardao-jdbc/src/main/java/net/sf/mardao/dao/JdbcSupplier.java
// Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/FilterOperator.java // public enum FilterOperator { // EQUALS, // IN, // GREATER_THAN, // GREATER_THAN_OR_EQUALS, // LESS_THAN, // NOT_EQUALS // }
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import net.sf.mardao.core.*; import net.sf.mardao.core.filter.Filter; import net.sf.mardao.core.filter.FilterOperator; import org.springframework.dao.DataAccessException; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.simple.SimpleJdbcInsert; import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; import javax.persistence.Basic; import javax.persistence.Id; import javax.persistence.Table; import javax.sql.DataSource; import java.io.IOException; import java.io.Serializable; import java.lang.reflect.Array; import java.sql.Connection; import java.util.*; import java.util.concurrent.Future;
package net.sf.mardao.dao; /** * Created by sosandstrom on 2015-02-21. */ public class JdbcSupplier extends AbstractSupplier<JdbcKey, Object, JdbcWriteValue, Connection> { public static final String METHOD_SELECT = "SELECT "; public static final String CREATE_SEQUENCE = "CREATE_SEQUENCE"; public static final String INIT_SEQUENCE = "CREATE_SEQUENCE"; private final DataSource dataSource; private final JdbcTemplate jdbcTemplate; private final DataFieldMaxValueIncrementer incrementer; protected final JdbcDialect jdbcDialect; private static final Map<JdbcDialect, Properties> types = new HashMap<JdbcDialect, Properties>(); private static final Properties defaultTypes = new Properties(); private static final ObjectMapper MAPPER = new ObjectMapper(); public JdbcSupplier(DataSource dataSource, DataFieldMaxValueIncrementer incrementer, JdbcDialect jdbcDialect) { this.dataSource = dataSource; this.incrementer = incrementer; this.jdbcTemplate = new JdbcTemplate(dataSource); this.jdbcDialect = jdbcDialect; } @Override
// Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/FilterOperator.java // public enum FilterOperator { // EQUALS, // IN, // GREATER_THAN, // GREATER_THAN_OR_EQUALS, // LESS_THAN, // NOT_EQUALS // } // Path: mardao-jdbc/src/main/java/net/sf/mardao/dao/JdbcSupplier.java import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import net.sf.mardao.core.*; import net.sf.mardao.core.filter.Filter; import net.sf.mardao.core.filter.FilterOperator; import org.springframework.dao.DataAccessException; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.simple.SimpleJdbcInsert; import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; import javax.persistence.Basic; import javax.persistence.Id; import javax.persistence.Table; import javax.sql.DataSource; import java.io.IOException; import java.io.Serializable; import java.lang.reflect.Array; import java.sql.Connection; import java.util.*; import java.util.concurrent.Future; package net.sf.mardao.dao; /** * Created by sosandstrom on 2015-02-21. */ public class JdbcSupplier extends AbstractSupplier<JdbcKey, Object, JdbcWriteValue, Connection> { public static final String METHOD_SELECT = "SELECT "; public static final String CREATE_SEQUENCE = "CREATE_SEQUENCE"; public static final String INIT_SEQUENCE = "CREATE_SEQUENCE"; private final DataSource dataSource; private final JdbcTemplate jdbcTemplate; private final DataFieldMaxValueIncrementer incrementer; protected final JdbcDialect jdbcDialect; private static final Map<JdbcDialect, Properties> types = new HashMap<JdbcDialect, Properties>(); private static final Properties defaultTypes = new Properties(); private static final ObjectMapper MAPPER = new ObjectMapper(); public JdbcSupplier(DataSource dataSource, DataFieldMaxValueIncrementer incrementer, JdbcDialect jdbcDialect) { this.dataSource = dataSource; this.incrementer = incrementer; this.jdbcTemplate = new JdbcTemplate(dataSource); this.jdbcDialect = jdbcDialect; } @Override
public int count(Connection tx, Mapper mapper, JdbcKey ancestorKey, JdbcKey simpleKey, Filter... filters) {
sosandstrom/mardao
mardao-jdbc/src/main/java/net/sf/mardao/dao/JdbcSupplier.java
// Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/FilterOperator.java // public enum FilterOperator { // EQUALS, // IN, // GREATER_THAN, // GREATER_THAN_OR_EQUALS, // LESS_THAN, // NOT_EQUALS // }
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import net.sf.mardao.core.*; import net.sf.mardao.core.filter.Filter; import net.sf.mardao.core.filter.FilterOperator; import org.springframework.dao.DataAccessException; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.simple.SimpleJdbcInsert; import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; import javax.persistence.Basic; import javax.persistence.Id; import javax.persistence.Table; import javax.sql.DataSource; import java.io.IOException; import java.io.Serializable; import java.lang.reflect.Array; import java.sql.Connection; import java.util.*; import java.util.concurrent.Future;
} return filters; } private String buildSQL(Mapper mapper, String method, Iterable<String> projectionsList, Integer offset, Integer limit, Collection<Object> params, Filter... filters) { String projections = "*"; if (null != projectionsList) { StringBuilder sb = new StringBuilder(); for (String col : projectionsList) { if (0 < sb.length()) { sb.append(','); } sb.append(col); } projections = sb.toString(); } final StringBuilder sql = new StringBuilder(method) .append(projections) .append(" FROM ") .append(mapper.getKind()); if (null != filters) { boolean isFirst = true; for (Filter f : filters) { sql.append(isFirst ? " WHERE " : " AND "); isFirst = false; sql.append(f.getColumn()); sql.append(getOpsAsSQL(f.getOperator(), f.getOperand()));
// Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/FilterOperator.java // public enum FilterOperator { // EQUALS, // IN, // GREATER_THAN, // GREATER_THAN_OR_EQUALS, // LESS_THAN, // NOT_EQUALS // } // Path: mardao-jdbc/src/main/java/net/sf/mardao/dao/JdbcSupplier.java import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import net.sf.mardao.core.*; import net.sf.mardao.core.filter.Filter; import net.sf.mardao.core.filter.FilterOperator; import org.springframework.dao.DataAccessException; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.simple.SimpleJdbcInsert; import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; import javax.persistence.Basic; import javax.persistence.Id; import javax.persistence.Table; import javax.sql.DataSource; import java.io.IOException; import java.io.Serializable; import java.lang.reflect.Array; import java.sql.Connection; import java.util.*; import java.util.concurrent.Future; } return filters; } private String buildSQL(Mapper mapper, String method, Iterable<String> projectionsList, Integer offset, Integer limit, Collection<Object> params, Filter... filters) { String projections = "*"; if (null != projectionsList) { StringBuilder sb = new StringBuilder(); for (String col : projectionsList) { if (0 < sb.length()) { sb.append(','); } sb.append(col); } projections = sb.toString(); } final StringBuilder sql = new StringBuilder(method) .append(projections) .append(" FROM ") .append(mapper.getKind()); if (null != filters) { boolean isFirst = true; for (Filter f : filters) { sql.append(isFirst ? " WHERE " : " AND "); isFirst = false; sql.append(f.getColumn()); sql.append(getOpsAsSQL(f.getOperator(), f.getOperand()));
if (null != f.getOperand() || !FilterOperator.EQUALS.equals(f.getOperator())) {
sosandstrom/mardao
mardao-gae/src/main/java/net/sf/mardao/dao/DatastoreSupplier.java
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // }
import java.util.Collection; import java.util.Date; import java.util.List; import java.util.concurrent.Future; import com.google.appengine.api.datastore.*; import net.sf.mardao.core.CursorPage; import net.sf.mardao.core.filter.Filter; import java.io.IOException; import java.io.Serializable; import java.nio.ByteBuffer; import java.util.ArrayList;
package net.sf.mardao.dao; /* * #%L * mardao-gae * %% * Copyright (C) 2010 - 2014 Wadpam * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ /** * Stores entities in Google App Engine's Datastore. * * @author osandstrom Date: 2014-09-13 Time: 17:43 */ public class DatastoreSupplier extends AbstractSupplier<Key, Entity, Entity, Transaction> { private DatastoreService syncService; private AsyncDatastoreService asyncService; @Override public void rollbackActiveTransaction(Transaction tx) { if (tx.isActive()) { tx.rollback(); } } @Override public void commitTransaction(Transaction tx) { tx.commit(); } @Override public Transaction beginTransaction() { TransactionOptions options = TransactionOptions.Builder.withXG(true); return getSyncService().beginTransaction(options); } @Override
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // } // Path: mardao-gae/src/main/java/net/sf/mardao/dao/DatastoreSupplier.java import java.util.Collection; import java.util.Date; import java.util.List; import java.util.concurrent.Future; import com.google.appengine.api.datastore.*; import net.sf.mardao.core.CursorPage; import net.sf.mardao.core.filter.Filter; import java.io.IOException; import java.io.Serializable; import java.nio.ByteBuffer; import java.util.ArrayList; package net.sf.mardao.dao; /* * #%L * mardao-gae * %% * Copyright (C) 2010 - 2014 Wadpam * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ /** * Stores entities in Google App Engine's Datastore. * * @author osandstrom Date: 2014-09-13 Time: 17:43 */ public class DatastoreSupplier extends AbstractSupplier<Key, Entity, Entity, Transaction> { private DatastoreService syncService; private AsyncDatastoreService asyncService; @Override public void rollbackActiveTransaction(Transaction tx) { if (tx.isActive()) { tx.rollback(); } } @Override public void commitTransaction(Transaction tx) { tx.commit(); } @Override public Transaction beginTransaction() { TransactionOptions options = TransactionOptions.Builder.withXG(true); return getSyncService().beginTransaction(options); } @Override
public int count(Transaction tx, Mapper mapper, Key ancestorKey, Key simpleKey, Filter... filters) {
sosandstrom/mardao
mardao-gae/src/main/java/net/sf/mardao/dao/DatastoreSupplier.java
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // }
import java.util.Collection; import java.util.Date; import java.util.List; import java.util.concurrent.Future; import com.google.appengine.api.datastore.*; import net.sf.mardao.core.CursorPage; import net.sf.mardao.core.filter.Filter; import java.io.IOException; import java.io.Serializable; import java.nio.ByteBuffer; import java.util.ArrayList;
@Override public int count(Transaction tx, Mapper mapper, Key ancestorKey, Key simpleKey, Filter... filters) { final PreparedQuery pq = prepare(mapper.getKind(), true, ancestorKey, simpleKey, null, false, null, false, null, filters); return pq.countEntities(FetchOptions.Builder.withDefaults()); } @Override public void deleteValue(Transaction tx, Mapper mapper, Key key) throws IOException { getSyncService().delete(key); } @Override public void deleteValues(Transaction tx, Mapper mapper, Collection<Key> keys) throws IOException { getSyncService().delete(keys); } @Override public Iterable<Entity> queryIterable(Transaction tx, Mapper mapper, boolean keysOnly, int offset, int limit, Key ancestorKey, Key simpleKey, String primaryOrderBy, boolean primaryIsAscending, String secondaryOrderBy, boolean secondaryIsAscending, Filter... filters) { final PreparedQuery pq = prepare(mapper.getKind(), keysOnly, ancestorKey, simpleKey, primaryOrderBy, primaryIsAscending, secondaryOrderBy, secondaryIsAscending, null, filters); final QueryResultIterable<Entity> _iterable = asQueryResultIterable(pq, offset, limit); return _iterable; } @Override
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // } // Path: mardao-gae/src/main/java/net/sf/mardao/dao/DatastoreSupplier.java import java.util.Collection; import java.util.Date; import java.util.List; import java.util.concurrent.Future; import com.google.appengine.api.datastore.*; import net.sf.mardao.core.CursorPage; import net.sf.mardao.core.filter.Filter; import java.io.IOException; import java.io.Serializable; import java.nio.ByteBuffer; import java.util.ArrayList; @Override public int count(Transaction tx, Mapper mapper, Key ancestorKey, Key simpleKey, Filter... filters) { final PreparedQuery pq = prepare(mapper.getKind(), true, ancestorKey, simpleKey, null, false, null, false, null, filters); return pq.countEntities(FetchOptions.Builder.withDefaults()); } @Override public void deleteValue(Transaction tx, Mapper mapper, Key key) throws IOException { getSyncService().delete(key); } @Override public void deleteValues(Transaction tx, Mapper mapper, Collection<Key> keys) throws IOException { getSyncService().delete(keys); } @Override public Iterable<Entity> queryIterable(Transaction tx, Mapper mapper, boolean keysOnly, int offset, int limit, Key ancestorKey, Key simpleKey, String primaryOrderBy, boolean primaryIsAscending, String secondaryOrderBy, boolean secondaryIsAscending, Filter... filters) { final PreparedQuery pq = prepare(mapper.getKind(), keysOnly, ancestorKey, simpleKey, primaryOrderBy, primaryIsAscending, secondaryOrderBy, secondaryIsAscending, null, filters); final QueryResultIterable<Entity> _iterable = asQueryResultIterable(pq, offset, limit); return _iterable; } @Override
public CursorPage<Entity> queryPage(Transaction tx, Mapper mapper, boolean keysOnly,
sosandstrom/mardao
mardao-maven-plugin/src/test/java/net/sf/mardao/test/dao/DAuditedDaoBean.java
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // }
import com.google.inject.Inject; import net.sf.mardao.dao.Supplier;
package net.sf.mardao.test.dao; /* * #%L * net.sf.mardao:mardao-maven-plugin * %% * Copyright (C) 2010 - 2014 Wadpam * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ /** * Implementation of Business Methods related to entity DAudited. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2014-10-09T19:03:26.494+0200. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ public class DAuditedDaoBean extends GeneratedDAuditedDaoImpl { @Inject
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // } // Path: mardao-maven-plugin/src/test/java/net/sf/mardao/test/dao/DAuditedDaoBean.java import com.google.inject.Inject; import net.sf.mardao.dao.Supplier; package net.sf.mardao.test.dao; /* * #%L * net.sf.mardao:mardao-maven-plugin * %% * Copyright (C) 2010 - 2014 Wadpam * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ /** * Implementation of Business Methods related to entity DAudited. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2014-10-09T19:03:26.494+0200. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ public class DAuditedDaoBean extends GeneratedDAuditedDaoImpl { @Inject
public DAuditedDaoBean(Supplier supplier) {
sosandstrom/mardao
mardao-core/src/main/java/net/sf/mardao/dao/CrudDao.java
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // }
import net.sf.mardao.core.CursorPage; import java.io.IOException; import java.io.Serializable;
package net.sf.mardao.dao; /** * Core crud methods. * Created by sosandstrom on 2015-01-04. */ public interface CrudDao<T, ID extends Serializable> { int count(Object parentKey); ID insert(Object parentKey, ID id, T entity) throws IOException; ID put(Object parentKey, ID id, T entity) throws IOException; T get(Object parentKey, ID id) throws IOException; void delete(Object parentKey, ID id) throws IOException;
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // } // Path: mardao-core/src/main/java/net/sf/mardao/dao/CrudDao.java import net.sf.mardao.core.CursorPage; import java.io.IOException; import java.io.Serializable; package net.sf.mardao.dao; /** * Core crud methods. * Created by sosandstrom on 2015-01-04. */ public interface CrudDao<T, ID extends Serializable> { int count(Object parentKey); ID insert(Object parentKey, ID id, T entity) throws IOException; ID put(Object parentKey, ID id, T entity) throws IOException; T get(Object parentKey, ID id) throws IOException; void delete(Object parentKey, ID id) throws IOException;
CursorPage<T> queryPage(Object ancestorKey, int requestedPageSize, String cursorString);
sosandstrom/mardao
mardao-core/src/main/java/net/sf/mardao/dao/Mapper.java
// Path: mardao-core/src/main/java/net/sf/mardao/core/ColumnField.java // public class ColumnField { // private final String columnName; // private final Class clazz; // private final Class annotation; // // public ColumnField(String columnName, Class clazz, Class annotation) { // this.columnName = columnName; // this.clazz = clazz; // this.annotation = annotation; // } // // public String getColumnName() { // return columnName; // } // // public Class getClazz() { // return clazz; // } // // public Class getAnnotation() { // return annotation; // } // }
import java.io.Serializable; import java.util.Map; import net.sf.mardao.core.ColumnField;
package net.sf.mardao.dao; /* * #%L * mardao-core * %% * Copyright (C) 2010 - 2014 Wadpam * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ /** * Maps from Read to Domain to Write Key/Values. * * @author osandstrom Date: 2014-09-03 Time: 19:47 */ public interface Mapper<T, ID extends Serializable> { ID fromKey(Object key); T fromReadValue(Object value); <RV> T fromReadValue(RV value, Supplier<Object, RV, ?, ?> supplier); String getCreatedByColumnName(); String getCreatedDateColumnName(); ID getId(T entity); Object getParentKey(T entity); String getKind(); String getPrimaryKeyColumnName(); String getParentKeyColumnName(); String getUpdatedByColumnName(); String getUpdatedDateColumnName(); Object toKey(Object parentKey, ID id); void updateEntityPostWrite(T entity, Object key, Object value); void setParentKey(T entity, Object parentKey); void setPrimaryKey(Object writeValue, Object primaryKey); Object toWriteValue(T entity); // String getWriteSQL(Serializable id, Object writeValue, Collection arguments);
// Path: mardao-core/src/main/java/net/sf/mardao/core/ColumnField.java // public class ColumnField { // private final String columnName; // private final Class clazz; // private final Class annotation; // // public ColumnField(String columnName, Class clazz, Class annotation) { // this.columnName = columnName; // this.clazz = clazz; // this.annotation = annotation; // } // // public String getColumnName() { // return columnName; // } // // public Class getClazz() { // return clazz; // } // // public Class getAnnotation() { // return annotation; // } // } // Path: mardao-core/src/main/java/net/sf/mardao/dao/Mapper.java import java.io.Serializable; import java.util.Map; import net.sf.mardao.core.ColumnField; package net.sf.mardao.dao; /* * #%L * mardao-core * %% * Copyright (C) 2010 - 2014 Wadpam * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ /** * Maps from Read to Domain to Write Key/Values. * * @author osandstrom Date: 2014-09-03 Time: 19:47 */ public interface Mapper<T, ID extends Serializable> { ID fromKey(Object key); T fromReadValue(Object value); <RV> T fromReadValue(RV value, Supplier<Object, RV, ?, ?> supplier); String getCreatedByColumnName(); String getCreatedDateColumnName(); ID getId(T entity); Object getParentKey(T entity); String getKind(); String getPrimaryKeyColumnName(); String getParentKeyColumnName(); String getUpdatedByColumnName(); String getUpdatedDateColumnName(); Object toKey(Object parentKey, ID id); void updateEntityPostWrite(T entity, Object key, Object value); void setParentKey(T entity, Object parentKey); void setPrimaryKey(Object writeValue, Object primaryKey); Object toWriteValue(T entity); // String getWriteSQL(Serializable id, Object writeValue, Collection arguments);
Map<String, ColumnField> getBasicFields();
sosandstrom/mardao
mardao-core/src/test/java/net/sf/mardao/junit/dao/DUserDaoBean.java
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // }
import net.sf.mardao.dao.Supplier;
package net.sf.mardao.junit.dao; /** * Implementation of Business Methods related to entity DUser. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2015-02-28T10:34:05.595+0100. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ public class DUserDaoBean extends GeneratedDUserDaoImpl {
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // } // Path: mardao-core/src/test/java/net/sf/mardao/junit/dao/DUserDaoBean.java import net.sf.mardao.dao.Supplier; package net.sf.mardao.junit.dao; /** * Implementation of Business Methods related to entity DUser. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2015-02-28T10:34:05.595+0100. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ public class DUserDaoBean extends GeneratedDUserDaoImpl {
public DUserDaoBean(Supplier<Object, Object, Object, Object> supplier) {
sosandstrom/mardao
mardao-test/src/main/java/net/sf/mardao/test/dao/DBasicDaoBean.java
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // }
import net.sf.mardao.dao.Supplier;
package net.sf.mardao.test.dao; /** * Implementation of Business Methods related to entity DBasic. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2015-02-24T19:51:12.400+0100. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ public class DBasicDaoBean extends GeneratedDBasicDaoImpl {
// Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java // public interface Supplier<K, RV, WV, T> { // int count(T tx, Mapper mapper, K ancestorKey, K simpleKey, Filter... filters); // void deleteValue(T tx, Mapper mapper, K key) throws IOException; // void deleteValues(T tx, Mapper mapper, Collection<K> keys) throws IOException; // RV readValue(T tx, Mapper mapper, K key) throws IOException; // K writeValue(T tx, Mapper mapper, K key, WV value) throws IOException; // K insertValue(T tx, Mapper mapper, K key, WV value) throws IOException; // // Future<RV> readFuture(T tx, Mapper mapper, K key) throws IOException; // Future<K> writeFuture(T tx, Mapper mapper, K key, WV value) throws IOException; // // K toKey(K parentKey, String kind, Serializable id); // // K toKey(K parentKey, String kind, String sId); // // Long toLongKey(K key); // String toStringKey(K key); // K toParentKey(K key); // // Collection getCollection(RV value, String column); // Date getDate(RV value, String column); // Long getLong(RV value, String column); // K getKey(RV value, String column); // K getParentKey(RV value, String column); // String getString(RV value, String column); // Integer getInteger(RV value, String column); // Boolean getBoolean(RV value, String column); // Float getFloat(RV value, String column); // ByteBuffer getByteBuffer(RV value, String column); // // Object getWriteObject(Object value, String column); // Collection getWriteCollection(WV value, String column); // Date getWriteDate(WV value, String column); // Long getWriteLong(WV value, String column); // K getWriteKey(WV value, String column); // K getWriteParentKey(WV value, String column); // String getWriteString(WV value, String column); // Integer getWriteInteger(WV value, String column); // Boolean getWriteBoolean(WV value, String column); // Float getWriteFloat(WV value, String column); // ByteBuffer getWriteByteBuffer(WV value, String column); // // void setCollection(WV value, String column, Collection c); // void setDate(WV value, String column, Date d); // void setLong(WV value, String column, Long l); // void setString(WV value, String column, String s); // void setInteger(WV value, String column, Integer i); // void setBoolean(WV value, String column, Boolean b); // void setFloat(WV value, String column, Float f); // void setByteBuffer(WV value, String column, ByteBuffer b); // // Object createEntity(Mapper mapper, RV readValue); // WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); // WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); // void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); // void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // // // --- transaction methods --- // // T beginTransaction(); // void commitTransaction(T transaction); // void rollbackActiveTransaction(T transaction); // // // --- query methods --- // // Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, // int offset, int limit, // K ancestorKey, K simpleKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Filter... filters); // // RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters); // // CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly, // int requestedPageSize, K ancestorKey, // String primaryOrderBy, boolean primaryIsAscending, // String secondaryOrderBy, boolean secondaryIsAscending, // Collection<String> projections, // String cursorString, // Filter... filters); // // // --- manage db methods --- // void createTable(Mapper mapper); // } // Path: mardao-test/src/main/java/net/sf/mardao/test/dao/DBasicDaoBean.java import net.sf.mardao.dao.Supplier; package net.sf.mardao.test.dao; /** * Implementation of Business Methods related to entity DBasic. * This (empty) class is generated by mardao, but edited by developers. * It is not overwritten by the generator once it exists. * * Generated on 2015-02-24T19:51:12.400+0100. * @author mardao DAO generator (net.sf.mardao.plugin.ProcessDomainMojo) */ public class DBasicDaoBean extends GeneratedDBasicDaoImpl {
public DBasicDaoBean(Supplier<Object, Object, Object, Object> supplier) {
sosandstrom/mardao
mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // }
import net.sf.mardao.core.filter.Filter; import java.io.IOException; import java.io.Serializable; import java.nio.ByteBuffer; import java.util.Collection; import java.util.Date; import java.util.concurrent.Future; import net.sf.mardao.core.CursorPage;
void setLong(WV value, String column, Long l); void setString(WV value, String column, String s); void setInteger(WV value, String column, Integer i); void setBoolean(WV value, String column, Boolean b); void setFloat(WV value, String column, Float f); void setByteBuffer(WV value, String column, ByteBuffer b); Object createEntity(Mapper mapper, RV readValue); WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // --- transaction methods --- T beginTransaction(); void commitTransaction(T transaction); void rollbackActiveTransaction(T transaction); // --- query methods --- Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, int offset, int limit, K ancestorKey, K simpleKey, String primaryOrderBy, boolean primaryIsAscending, String secondaryOrderBy, boolean secondaryIsAscending, Filter... filters); RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters);
// Path: mardao-core/src/main/java/net/sf/mardao/core/CursorPage.java // public class CursorPage<T extends Object> implements Serializable { // // /** requested page size, not acutal */ // @Deprecated // private transient int requestedPageSize; // // /** provide this to get next page */ // private String cursorKey; // // /** the page of items */ // private Collection<T> items; // // /** // * The total number of items available. Use for progress indication. // */ // private Integer totalSize; // // public String getCursorKey() { // return cursorKey; // } // // public void setCursorKey(String cursorKey) { // this.cursorKey = cursorKey; // } // // public Collection<T> getItems() { // return items; // } // // public void setItems(Collection<T> items) { // this.items = items; // } // // @Deprecated // public int getRequestedPageSize() { // return requestedPageSize; // } // // @Deprecated // public void setRequestedPageSize(int requestedPageSize) { // this.requestedPageSize = requestedPageSize; // } // // public Integer getTotalSize() { // return totalSize; // } // // public void setTotalSize(Integer totalSize) { // this.totalSize = totalSize; // } // // } // // Path: mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java // public class Filter { // private final String column; // private final FilterOperator operator; // private final Object operand; // // private Filter(String column, FilterOperator operation, Object operand) { // this.column = column; // this.operator = operation; // this.operand = operand; // } // // /** Builds an EqualsFilter */ // public static Filter equalsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.EQUALS, operand); // } // // /** Builds an InFilter */ // public static Filter inFilter(String column, Object operand) { // return new Filter(column, FilterOperator.IN, operand); // } // // public static Filter greaterThan(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN, operand); // } // // public static Filter greaterThanOrEquals(String column, Object operand) { // return new Filter(column, FilterOperator.GREATER_THAN_OR_EQUALS, operand); // } // // public static Filter lessThan(String column, Object operand) { // return new Filter(column, FilterOperator.LESS_THAN, operand); // } // // public static Filter notEqualsFilter(String column, Object operand) { // return new Filter(column, FilterOperator.NOT_EQUALS, operand); // } // // public String toString() { // return column + " " + operator + " " + operand; // } // // public String getColumn() { // return column; // } // // public FilterOperator getOperator() { // return operator; // } // // public Object getOperand() { // return operand; // } // // } // Path: mardao-core/src/main/java/net/sf/mardao/dao/Supplier.java import net.sf.mardao.core.filter.Filter; import java.io.IOException; import java.io.Serializable; import java.nio.ByteBuffer; import java.util.Collection; import java.util.Date; import java.util.concurrent.Future; import net.sf.mardao.core.CursorPage; void setLong(WV value, String column, Long l); void setString(WV value, String column, String s); void setInteger(WV value, String column, Integer i); void setBoolean(WV value, String column, Boolean b); void setFloat(WV value, String column, Float f); void setByteBuffer(WV value, String column, ByteBuffer b); Object createEntity(Mapper mapper, RV readValue); WV createWriteValue(Mapper mapper, K parentKey, Long id, Object entity); WV createWriteValue(Mapper mapper, K parentKey, String id, Object entity); void setPrimaryKey(WV value, Mapper mapper, String column, K primaryKey, Object Entity); void setParentKey(WV value, Mapper mapper, String column, K parentKey, Object Entity); // --- transaction methods --- T beginTransaction(); void commitTransaction(T transaction); void rollbackActiveTransaction(T transaction); // --- query methods --- Iterable<RV> queryIterable(T tx, final Mapper mapper, boolean keysOnly, int offset, int limit, K ancestorKey, K simpleKey, String primaryOrderBy, boolean primaryIsAscending, String secondaryOrderBy, boolean secondaryIsAscending, Filter... filters); RV queryUnique(T tx, Mapper mapper, K parentKey, Filter... filters);
CursorPage<RV> queryPage(T tx, Mapper mapper, boolean keysOnly,
jpotts/alfresco-developer-series
webscripts/webscripts-tutorial/webscripts-tutorial-platform/src/main/java/com/someco/scripts/PostRating.java
// Path: webscripts/webscripts-tutorial/webscripts-tutorial-platform/src/main/java/com/someco/beans/RatingBean.java // public class RatingBean { // // // Dependencies // private NodeService nodeService; // // private Logger logger = Logger.getLogger(RatingBean.class); // // public void create(final NodeRef nodeRef, final int rating, final String user) { // logger.debug("Inside RatingBean.create()"); // // // add the aspect to this document if it needs it // if (nodeService.hasAspect(nodeRef, QName.createQName( // SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, // SomeCoRatingsModel.ASPECT_SCR_RATEABLE))) { // logger.debug("Document already has aspect"); // } else { // logger.debug("Adding rateable aspect"); // nodeService.addAspect(nodeRef, // QName.createQName( // SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, // SomeCoRatingsModel.ASPECT_SCR_RATEABLE), // null); // } // // Map<QName, Serializable> props = new HashMap<QName, Serializable>(); // props.put(QName.createQName( // SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, // "rating"), // rating); // props.put(QName.createQName( // SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, // "rater"), // user); // // nodeService.createNode(nodeRef, // QName.createQName( // SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, // SomeCoRatingsModel.ASSN_SCR_RATINGS), // QName.createQName( // SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, // "rating" + new Date().getTime()), // QName.createQName( // SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, // SomeCoRatingsModel.TYPE_SCR_RATING), // props); // } // // public NodeService getNodeService() { // return nodeService; // } // // public void setNodeService(NodeService nodeService) { // this.nodeService = nodeService; // } // // }
import java.util.HashMap; import java.util.Map; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.apache.log4j.Logger; import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptRequest; import com.someco.beans.RatingBean;
package com.someco.scripts; /** * This is the controller for the rating.post web script. * * @author jpotts * */ public class PostRating extends DeclarativeWebScript { Logger logger = Logger.getLogger(PostRating.class);
// Path: webscripts/webscripts-tutorial/webscripts-tutorial-platform/src/main/java/com/someco/beans/RatingBean.java // public class RatingBean { // // // Dependencies // private NodeService nodeService; // // private Logger logger = Logger.getLogger(RatingBean.class); // // public void create(final NodeRef nodeRef, final int rating, final String user) { // logger.debug("Inside RatingBean.create()"); // // // add the aspect to this document if it needs it // if (nodeService.hasAspect(nodeRef, QName.createQName( // SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, // SomeCoRatingsModel.ASPECT_SCR_RATEABLE))) { // logger.debug("Document already has aspect"); // } else { // logger.debug("Adding rateable aspect"); // nodeService.addAspect(nodeRef, // QName.createQName( // SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, // SomeCoRatingsModel.ASPECT_SCR_RATEABLE), // null); // } // // Map<QName, Serializable> props = new HashMap<QName, Serializable>(); // props.put(QName.createQName( // SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, // "rating"), // rating); // props.put(QName.createQName( // SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, // "rater"), // user); // // nodeService.createNode(nodeRef, // QName.createQName( // SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, // SomeCoRatingsModel.ASSN_SCR_RATINGS), // QName.createQName( // SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, // "rating" + new Date().getTime()), // QName.createQName( // SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, // SomeCoRatingsModel.TYPE_SCR_RATING), // props); // } // // public NodeService getNodeService() { // return nodeService; // } // // public void setNodeService(NodeService nodeService) { // this.nodeService = nodeService; // } // // } // Path: webscripts/webscripts-tutorial/webscripts-tutorial-platform/src/main/java/com/someco/scripts/PostRating.java import java.util.HashMap; import java.util.Map; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.apache.log4j.Logger; import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptRequest; import com.someco.beans.RatingBean; package com.someco.scripts; /** * This is the controller for the rating.post web script. * * @author jpotts * */ public class PostRating extends DeclarativeWebScript { Logger logger = Logger.getLogger(PostRating.class);
private RatingBean ratingBean;
jpotts/alfresco-developer-series
behaviors/behavior-tutorial/behavior-tutorial-integration-tests/src/test/java/com/someco/test/RatingBehaviorIT.java
// Path: behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/model/SomeCoRatingsModel.java // public interface SomeCoRatingsModel { // // Namespaces // public static final String NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL = "http://www.someco.com/model/ratings/1.0"; // // // Types // public static final String TYPE_SCR_RATING = "rating"; // // // Aspects // public static final String ASPECT_SCR_RATEABLE = "rateable"; // // // Properties // public static final String PROP_RATING = "rating"; // public static final String PROP_RATER = "rater"; // public static final String PROP_AVERAGE_RATING= "averageRating"; // public static final String PROP_TOTAL_RATING= "totalRating"; // public static final String PROP_RATING_COUNT= "ratingCount"; // // // Associations // public static final String ASSN_SCR_RATINGS = "ratings"; // }
import static org.alfresco.service.namespace.QName.createQName; import static org.junit.Assert.assertEquals; import java.io.Serializable; import java.util.HashMap; import java.util.Map; import com.someco.model.SomeCoRatingsModel; import org.alfresco.model.ContentModel; import org.alfresco.rad.test.AlfrescoTestRunner; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.apache.log4j.Logger; import org.junit.Test; import org.junit.runner.RunWith;
package com.someco.test; @RunWith(value = AlfrescoTestRunner.class) public class RatingBehaviorIT extends BaseIT { static Logger log = Logger.getLogger(RatingBehaviorIT.class); @Test public void ratingTypeTest() { final String RATER = "jpotts"; NodeService nodeService = getServiceRegistry().getNodeService(); Map<QName, Serializable> nodeProperties = new HashMap<>(); this.nodeRef = createNode(getFilename(), ContentModel.TYPE_CONTENT, nodeProperties);
// Path: behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/model/SomeCoRatingsModel.java // public interface SomeCoRatingsModel { // // Namespaces // public static final String NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL = "http://www.someco.com/model/ratings/1.0"; // // // Types // public static final String TYPE_SCR_RATING = "rating"; // // // Aspects // public static final String ASPECT_SCR_RATEABLE = "rateable"; // // // Properties // public static final String PROP_RATING = "rating"; // public static final String PROP_RATER = "rater"; // public static final String PROP_AVERAGE_RATING= "averageRating"; // public static final String PROP_TOTAL_RATING= "totalRating"; // public static final String PROP_RATING_COUNT= "ratingCount"; // // // Associations // public static final String ASSN_SCR_RATINGS = "ratings"; // } // Path: behaviors/behavior-tutorial/behavior-tutorial-integration-tests/src/test/java/com/someco/test/RatingBehaviorIT.java import static org.alfresco.service.namespace.QName.createQName; import static org.junit.Assert.assertEquals; import java.io.Serializable; import java.util.HashMap; import java.util.Map; import com.someco.model.SomeCoRatingsModel; import org.alfresco.model.ContentModel; import org.alfresco.rad.test.AlfrescoTestRunner; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.apache.log4j.Logger; import org.junit.Test; import org.junit.runner.RunWith; package com.someco.test; @RunWith(value = AlfrescoTestRunner.class) public class RatingBehaviorIT extends BaseIT { static Logger log = Logger.getLogger(RatingBehaviorIT.class); @Test public void ratingTypeTest() { final String RATER = "jpotts"; NodeService nodeService = getServiceRegistry().getNodeService(); Map<QName, Serializable> nodeProperties = new HashMap<>(); this.nodeRef = createNode(getFilename(), ContentModel.TYPE_CONTENT, nodeProperties);
QName aspectQName = createQName(SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, SomeCoRatingsModel.ASPECT_SCR_RATEABLE);
jpotts/alfresco-developer-series
content/content-tutorial-cmis/src/main/java/com/someco/cmis/examples/SomeCoCMISDataQueries.java
// Path: content/content-tutorial/content-tutorial-platform/src/main/java/com/someco/model/SomeCoModel.java // public interface SomeCoModel { // // // Types // public static final String NAMESPACE_SOMECO_CONTENT_MODEL = "http://www.someco.com/model/content/1.0"; // public static final String TYPE_SC_DOC = "doc"; // public static final String TYPE_SC_WHITEPAPER = "whitepaper"; // // // Aspects // public static final String ASPECT_SC_WEBABLE = "webable"; // public static final String ASPECT_SC_PRODUCT_RELATED = "productRelated"; // // // Properties // public static final String PROP_PRODUCT = "product"; // public static final String PROP_VERSION = "version"; // public static final String PROP_PUBLISHED = "published"; // public static final String PROP_IS_ACTIVE = "isActive"; // // // Associations // public static final String ASSN_RELATED_DOCUMENTS = "relatedDocuments"; // }
import java.text.DateFormat; import java.util.ArrayList; import java.util.List; import org.apache.chemistry.opencmis.client.api.CmisObject; import org.apache.chemistry.opencmis.client.api.ItemIterable; import org.apache.chemistry.opencmis.client.api.QueryResult; import org.apache.chemistry.opencmis.client.api.Session; import org.apache.chemistry.opencmis.commons.data.PropertyData; import com.someco.model.SomeCoModel;
package com.someco.cmis.examples; /** * This class shows various examples of CMIS query syntax. * This is a port of the SomeCoDataQueries class which uses the Alfresco Web Services API. This example * shows how to query for instances of custom content types via CMIS including how to do joins to query * against custom properties defined in custom aspects. * * @author jpotts */ public class SomeCoCMISDataQueries extends CMISExampleBase { private static final String RESULT_SEP = "======================"; private static final String USAGE = "java SomeCoCMISDataQueries <username> <password> <root folder>"; public static void main(String[] args) { if (args.length != 3) doUsage(SomeCoCMISDataQueries.USAGE); SomeCoCMISDataQueries sccdq = new SomeCoCMISDataQueries(); sccdq.setUser(args[0]); sccdq.setPassword(args[1]); sccdq.setFolderName(args[2]); sccdq.doExamples(); System.exit(0); } /** * Executes a series of CMIS Query Language queries and dumps the results. */ public void doExamples() { String queryString; System.out.println(RESULT_SEP);
// Path: content/content-tutorial/content-tutorial-platform/src/main/java/com/someco/model/SomeCoModel.java // public interface SomeCoModel { // // // Types // public static final String NAMESPACE_SOMECO_CONTENT_MODEL = "http://www.someco.com/model/content/1.0"; // public static final String TYPE_SC_DOC = "doc"; // public static final String TYPE_SC_WHITEPAPER = "whitepaper"; // // // Aspects // public static final String ASPECT_SC_WEBABLE = "webable"; // public static final String ASPECT_SC_PRODUCT_RELATED = "productRelated"; // // // Properties // public static final String PROP_PRODUCT = "product"; // public static final String PROP_VERSION = "version"; // public static final String PROP_PUBLISHED = "published"; // public static final String PROP_IS_ACTIVE = "isActive"; // // // Associations // public static final String ASSN_RELATED_DOCUMENTS = "relatedDocuments"; // } // Path: content/content-tutorial-cmis/src/main/java/com/someco/cmis/examples/SomeCoCMISDataQueries.java import java.text.DateFormat; import java.util.ArrayList; import java.util.List; import org.apache.chemistry.opencmis.client.api.CmisObject; import org.apache.chemistry.opencmis.client.api.ItemIterable; import org.apache.chemistry.opencmis.client.api.QueryResult; import org.apache.chemistry.opencmis.client.api.Session; import org.apache.chemistry.opencmis.commons.data.PropertyData; import com.someco.model.SomeCoModel; package com.someco.cmis.examples; /** * This class shows various examples of CMIS query syntax. * This is a port of the SomeCoDataQueries class which uses the Alfresco Web Services API. This example * shows how to query for instances of custom content types via CMIS including how to do joins to query * against custom properties defined in custom aspects. * * @author jpotts */ public class SomeCoCMISDataQueries extends CMISExampleBase { private static final String RESULT_SEP = "======================"; private static final String USAGE = "java SomeCoCMISDataQueries <username> <password> <root folder>"; public static void main(String[] args) { if (args.length != 3) doUsage(SomeCoCMISDataQueries.USAGE); SomeCoCMISDataQueries sccdq = new SomeCoCMISDataQueries(); sccdq.setUser(args[0]); sccdq.setPassword(args[1]); sccdq.setFolderName(args[2]); sccdq.doExamples(); System.exit(0); } /** * Executes a series of CMIS Query Language queries and dumps the results. */ public void doExamples() { String queryString; System.out.println(RESULT_SEP);
System.out.println("Finding content of type:" + SomeCoModel.TYPE_SC_DOC.toString());
jpotts/alfresco-developer-series
webscripts/webscripts-tutorial/webscripts-tutorial-platform/src/main/java/com/someco/beans/RatingBean.java
// Path: behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/model/SomeCoRatingsModel.java // public interface SomeCoRatingsModel { // // Namespaces // public static final String NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL = "http://www.someco.com/model/ratings/1.0"; // // // Types // public static final String TYPE_SCR_RATING = "rating"; // // // Aspects // public static final String ASPECT_SCR_RATEABLE = "rateable"; // // // Properties // public static final String PROP_RATING = "rating"; // public static final String PROP_RATER = "rater"; // public static final String PROP_AVERAGE_RATING= "averageRating"; // public static final String PROP_TOTAL_RATING= "totalRating"; // public static final String PROP_RATING_COUNT= "ratingCount"; // // // Associations // public static final String ASSN_SCR_RATINGS = "ratings"; // }
import java.io.Serializable; import java.util.Date; import java.util.HashMap; import java.util.Map; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.QName; import org.apache.log4j.Logger; import com.someco.model.SomeCoRatingsModel;
package com.someco.beans; public class RatingBean { // Dependencies private NodeService nodeService; private Logger logger = Logger.getLogger(RatingBean.class); public void create(final NodeRef nodeRef, final int rating, final String user) { logger.debug("Inside RatingBean.create()"); // add the aspect to this document if it needs it if (nodeService.hasAspect(nodeRef, QName.createQName(
// Path: behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/model/SomeCoRatingsModel.java // public interface SomeCoRatingsModel { // // Namespaces // public static final String NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL = "http://www.someco.com/model/ratings/1.0"; // // // Types // public static final String TYPE_SCR_RATING = "rating"; // // // Aspects // public static final String ASPECT_SCR_RATEABLE = "rateable"; // // // Properties // public static final String PROP_RATING = "rating"; // public static final String PROP_RATER = "rater"; // public static final String PROP_AVERAGE_RATING= "averageRating"; // public static final String PROP_TOTAL_RATING= "totalRating"; // public static final String PROP_RATING_COUNT= "ratingCount"; // // // Associations // public static final String ASSN_SCR_RATINGS = "ratings"; // } // Path: webscripts/webscripts-tutorial/webscripts-tutorial-platform/src/main/java/com/someco/beans/RatingBean.java import java.io.Serializable; import java.util.Date; import java.util.HashMap; import java.util.Map; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.QName; import org.apache.log4j.Logger; import com.someco.model.SomeCoRatingsModel; package com.someco.beans; public class RatingBean { // Dependencies private NodeService nodeService; private Logger logger = Logger.getLogger(RatingBean.class); public void create(final NodeRef nodeRef, final int rating, final String user) { logger.debug("Inside RatingBean.create()"); // add the aspect to this document if it needs it if (nodeService.hasAspect(nodeRef, QName.createQName(
SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL,
jpotts/alfresco-developer-series
workflow/workflow-tutorial/workflow-tutorial-platform/src/main/java/com/someco/scripts/GetReview.java
// Path: workflow/workflow-tutorial/workflow-tutorial-platform/src/main/java/com/someco/model/SomeCoWorkflowModel.java // public interface SomeCoWorkflowModel { // // // Types // public static final String NAMESPACE_SOMECO_WORKFLOW_CONTENT_MODEL = "http://www.someco.com/model/workflow/1.0"; // // // Properties // public static final String PROP_APPROVE_REJECT_OUTCOME = "approveRejectOutcome"; // // }
import java.io.Serializable; import java.util.HashMap; import java.util.Map; import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.namespace.QName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptRequest; import com.someco.model.SomeCoWorkflowModel;
package com.someco.scripts; /** * This is the controller for the review.get web script. * * @author jpotts */ public class GetReview extends DeclarativeWebScript { Log logger = LogFactory.getLog(GetReview.class); // Dependencies private WorkflowService workflowService; @Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) { final String id = req.getParameter("id"); final String action = req.getParameter("action"); if (id == null || action == null) { logger.debug("Email, ID, action, or secret not set"); status.setCode(400); status.setMessage("Required data has not been provided"); status.setRedirect(true); } Map<String, Object> model = new HashMap<String, Object>(); logger.debug("About to update task, id:" + id + " with outcome:" + action); Map<QName, Serializable> props = new HashMap<QName, Serializable>();
// Path: workflow/workflow-tutorial/workflow-tutorial-platform/src/main/java/com/someco/model/SomeCoWorkflowModel.java // public interface SomeCoWorkflowModel { // // // Types // public static final String NAMESPACE_SOMECO_WORKFLOW_CONTENT_MODEL = "http://www.someco.com/model/workflow/1.0"; // // // Properties // public static final String PROP_APPROVE_REJECT_OUTCOME = "approveRejectOutcome"; // // } // Path: workflow/workflow-tutorial/workflow-tutorial-platform/src/main/java/com/someco/scripts/GetReview.java import java.io.Serializable; import java.util.HashMap; import java.util.Map; import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.namespace.QName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptRequest; import com.someco.model.SomeCoWorkflowModel; package com.someco.scripts; /** * This is the controller for the review.get web script. * * @author jpotts */ public class GetReview extends DeclarativeWebScript { Log logger = LogFactory.getLog(GetReview.class); // Dependencies private WorkflowService workflowService; @Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) { final String id = req.getParameter("id"); final String action = req.getParameter("action"); if (id == null || action == null) { logger.debug("Email, ID, action, or secret not set"); status.setCode(400); status.setMessage("Required data has not been provided"); status.setRedirect(true); } Map<String, Object> model = new HashMap<String, Object>(); logger.debug("About to update task, id:" + id + " with outcome:" + action); Map<QName, Serializable> props = new HashMap<QName, Serializable>();
props.put(QName.createQName(SomeCoWorkflowModel.NAMESPACE_SOMECO_WORKFLOW_CONTENT_MODEL, SomeCoWorkflowModel.PROP_APPROVE_REJECT_OUTCOME), action);
jpotts/alfresco-developer-series
behaviors/behavior-tutorial/behavior-tutorial-integration-tests/src/test/java/com/someco/test/SomecoRatingModelIT.java
// Path: behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/model/SomeCoRatingsModel.java // public interface SomeCoRatingsModel { // // Namespaces // public static final String NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL = "http://www.someco.com/model/ratings/1.0"; // // // Types // public static final String TYPE_SCR_RATING = "rating"; // // // Aspects // public static final String ASPECT_SCR_RATEABLE = "rateable"; // // // Properties // public static final String PROP_RATING = "rating"; // public static final String PROP_RATER = "rater"; // public static final String PROP_AVERAGE_RATING= "averageRating"; // public static final String PROP_TOTAL_RATING= "totalRating"; // public static final String PROP_RATING_COUNT= "ratingCount"; // // // Associations // public static final String ASSN_SCR_RATINGS = "ratings"; // }
import com.someco.model.SomeCoRatingsModel; import org.alfresco.model.ContentModel; import org.alfresco.rad.test.AlfrescoTestRunner; import org.alfresco.service.cmr.repository.*; import org.alfresco.service.namespace.QName; import org.junit.Test; import org.junit.runner.RunWith; import java.io.Serializable; import java.util.Collection; import java.util.HashMap; import java.util.Map; import static org.alfresco.service.namespace.QName.createQName; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
package com.someco.test; /** * Created by jpotts, Metaversant on 4/11/18. */ @RunWith(value = AlfrescoTestRunner.class) public class SomecoRatingModelIT extends BaseIT { @Test public void testSomeCoRatingModel() { Collection<QName> allContentModels = getServiceRegistry().getDictionaryService().getAllModels();
// Path: behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/model/SomeCoRatingsModel.java // public interface SomeCoRatingsModel { // // Namespaces // public static final String NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL = "http://www.someco.com/model/ratings/1.0"; // // // Types // public static final String TYPE_SCR_RATING = "rating"; // // // Aspects // public static final String ASPECT_SCR_RATEABLE = "rateable"; // // // Properties // public static final String PROP_RATING = "rating"; // public static final String PROP_RATER = "rater"; // public static final String PROP_AVERAGE_RATING= "averageRating"; // public static final String PROP_TOTAL_RATING= "totalRating"; // public static final String PROP_RATING_COUNT= "ratingCount"; // // // Associations // public static final String ASSN_SCR_RATINGS = "ratings"; // } // Path: behaviors/behavior-tutorial/behavior-tutorial-integration-tests/src/test/java/com/someco/test/SomecoRatingModelIT.java import com.someco.model.SomeCoRatingsModel; import org.alfresco.model.ContentModel; import org.alfresco.rad.test.AlfrescoTestRunner; import org.alfresco.service.cmr.repository.*; import org.alfresco.service.namespace.QName; import org.junit.Test; import org.junit.runner.RunWith; import java.io.Serializable; import java.util.Collection; import java.util.HashMap; import java.util.Map; import static org.alfresco.service.namespace.QName.createQName; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; package com.someco.test; /** * Created by jpotts, Metaversant on 4/11/18. */ @RunWith(value = AlfrescoTestRunner.class) public class SomecoRatingModelIT extends BaseIT { @Test public void testSomeCoRatingModel() { Collection<QName> allContentModels = getServiceRegistry().getDictionaryService().getAllModels();
QName scModelQName = createQName(SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, "somecoratingsmodel");
jpotts/alfresco-developer-series
content/content-tutorial/content-tutorial-integration-tests/src/test/java/com/someco/test/SomecoContentModelIT.java
// Path: content/content-tutorial/content-tutorial-platform/src/main/java/com/someco/model/SomeCoModel.java // public interface SomeCoModel { // // // Types // public static final String NAMESPACE_SOMECO_CONTENT_MODEL = "http://www.someco.com/model/content/1.0"; // public static final String TYPE_SC_DOC = "doc"; // public static final String TYPE_SC_WHITEPAPER = "whitepaper"; // // // Aspects // public static final String ASPECT_SC_WEBABLE = "webable"; // public static final String ASPECT_SC_PRODUCT_RELATED = "productRelated"; // // // Properties // public static final String PROP_PRODUCT = "product"; // public static final String PROP_VERSION = "version"; // public static final String PROP_PUBLISHED = "published"; // public static final String PROP_IS_ACTIVE = "isActive"; // // // Associations // public static final String ASSN_RELATED_DOCUMENTS = "relatedDocuments"; // }
import com.someco.model.SomeCoModel; import org.alfresco.model.ContentModel; import org.alfresco.rad.test.AbstractAlfrescoIT; import org.alfresco.rad.test.AlfrescoTestRunner; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.nodelocator.CompanyHomeNodeLocator; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.apache.commons.io.IOUtils; import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; import java.io.IOException; import java.io.InputStream; import java.io.Serializable; import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.Map; import static org.alfresco.service.namespace.QName.createQName; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
package com.someco.test; /** * Created by jpotts, Metaversant on 4/11/18. */ @RunWith(value = AlfrescoTestRunner.class) public class SomecoContentModelIT extends AbstractAlfrescoIT { private NodeRef nodeRef; @After public void teardown() { // Clean up node if (nodeRef != null) { getServiceRegistry().getNodeService().deleteNode(nodeRef); } } @Test public void testSomeCoContentModel() { Collection<QName> allContentModels = getServiceRegistry().getDictionaryService().getAllModels();
// Path: content/content-tutorial/content-tutorial-platform/src/main/java/com/someco/model/SomeCoModel.java // public interface SomeCoModel { // // // Types // public static final String NAMESPACE_SOMECO_CONTENT_MODEL = "http://www.someco.com/model/content/1.0"; // public static final String TYPE_SC_DOC = "doc"; // public static final String TYPE_SC_WHITEPAPER = "whitepaper"; // // // Aspects // public static final String ASPECT_SC_WEBABLE = "webable"; // public static final String ASPECT_SC_PRODUCT_RELATED = "productRelated"; // // // Properties // public static final String PROP_PRODUCT = "product"; // public static final String PROP_VERSION = "version"; // public static final String PROP_PUBLISHED = "published"; // public static final String PROP_IS_ACTIVE = "isActive"; // // // Associations // public static final String ASSN_RELATED_DOCUMENTS = "relatedDocuments"; // } // Path: content/content-tutorial/content-tutorial-integration-tests/src/test/java/com/someco/test/SomecoContentModelIT.java import com.someco.model.SomeCoModel; import org.alfresco.model.ContentModel; import org.alfresco.rad.test.AbstractAlfrescoIT; import org.alfresco.rad.test.AlfrescoTestRunner; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.nodelocator.CompanyHomeNodeLocator; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.apache.commons.io.IOUtils; import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; import java.io.IOException; import java.io.InputStream; import java.io.Serializable; import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.Map; import static org.alfresco.service.namespace.QName.createQName; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; package com.someco.test; /** * Created by jpotts, Metaversant on 4/11/18. */ @RunWith(value = AlfrescoTestRunner.class) public class SomecoContentModelIT extends AbstractAlfrescoIT { private NodeRef nodeRef; @After public void teardown() { // Clean up node if (nodeRef != null) { getServiceRegistry().getNodeService().deleteNode(nodeRef); } } @Test public void testSomeCoContentModel() { Collection<QName> allContentModels = getServiceRegistry().getDictionaryService().getAllModels();
QName scModelQName = createQName(SomeCoModel.NAMESPACE_SOMECO_CONTENT_MODEL, "somecomodel");
jpotts/alfresco-developer-series
behaviors/behavior-tutorial/behavior-tutorial-integration-tests/src/test/java/com/someco/test/BaseIT.java
// Path: behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/model/SomeCoRatingsModel.java // public interface SomeCoRatingsModel { // // Namespaces // public static final String NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL = "http://www.someco.com/model/ratings/1.0"; // // // Types // public static final String TYPE_SCR_RATING = "rating"; // // // Aspects // public static final String ASPECT_SCR_RATEABLE = "rateable"; // // // Properties // public static final String PROP_RATING = "rating"; // public static final String PROP_RATER = "rater"; // public static final String PROP_AVERAGE_RATING= "averageRating"; // public static final String PROP_TOTAL_RATING= "totalRating"; // public static final String PROP_RATING_COUNT= "ratingCount"; // // // Associations // public static final String ASSN_SCR_RATINGS = "ratings"; // }
import com.someco.model.SomeCoRatingsModel; import org.alfresco.model.ContentModel; import org.alfresco.rad.test.AbstractAlfrescoIT; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.nodelocator.CompanyHomeNodeLocator; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.apache.commons.io.IOUtils; import org.junit.After; import java.io.IOException; import java.io.InputStream; import java.io.Serializable; import java.util.Map; import static org.alfresco.service.namespace.QName.createQName;
package com.someco.test; /** * Created by jpotts, Metaversant on 4/11/18. */ public class BaseIT extends AbstractAlfrescoIT { NodeRef nodeRef; final QName PROP_RATING_QNAME = QName.createQName(
// Path: behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/model/SomeCoRatingsModel.java // public interface SomeCoRatingsModel { // // Namespaces // public static final String NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL = "http://www.someco.com/model/ratings/1.0"; // // // Types // public static final String TYPE_SCR_RATING = "rating"; // // // Aspects // public static final String ASPECT_SCR_RATEABLE = "rateable"; // // // Properties // public static final String PROP_RATING = "rating"; // public static final String PROP_RATER = "rater"; // public static final String PROP_AVERAGE_RATING= "averageRating"; // public static final String PROP_TOTAL_RATING= "totalRating"; // public static final String PROP_RATING_COUNT= "ratingCount"; // // // Associations // public static final String ASSN_SCR_RATINGS = "ratings"; // } // Path: behaviors/behavior-tutorial/behavior-tutorial-integration-tests/src/test/java/com/someco/test/BaseIT.java import com.someco.model.SomeCoRatingsModel; import org.alfresco.model.ContentModel; import org.alfresco.rad.test.AbstractAlfrescoIT; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.nodelocator.CompanyHomeNodeLocator; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.apache.commons.io.IOUtils; import org.junit.After; import java.io.IOException; import java.io.InputStream; import java.io.Serializable; import java.util.Map; import static org.alfresco.service.namespace.QName.createQName; package com.someco.test; /** * Created by jpotts, Metaversant on 4/11/18. */ public class BaseIT extends AbstractAlfrescoIT { NodeRef nodeRef; final QName PROP_RATING_QNAME = QName.createQName(
SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL,
jpotts/alfresco-developer-series
behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/behavior/Rating.java
// Path: behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/model/SomeCoRatingsModel.java // public interface SomeCoRatingsModel { // // Namespaces // public static final String NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL = "http://www.someco.com/model/ratings/1.0"; // // // Types // public static final String TYPE_SCR_RATING = "rating"; // // // Aspects // public static final String ASPECT_SCR_RATEABLE = "rateable"; // // // Properties // public static final String PROP_RATING = "rating"; // public static final String PROP_RATER = "rater"; // public static final String PROP_AVERAGE_RATING= "averageRating"; // public static final String PROP_TOTAL_RATING= "totalRating"; // public static final String PROP_RATING_COUNT= "ratingCount"; // // // Associations // public static final String ASSN_SCR_RATINGS = "ratings"; // }
import java.util.List; import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.policy.Behaviour; import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.apache.log4j.Logger; import com.someco.model.SomeCoRatingsModel;
package com.someco.behavior; public class Rating implements NodeServicePolicies.OnDeleteNodePolicy, NodeServicePolicies.OnCreateNodePolicy { // Dependencies private NodeService nodeService; private PolicyComponent policyComponent; // Behaviours private Behaviour onCreateNode; private Behaviour onDeleteNode; private Logger logger = Logger.getLogger(Rating.class); public void init() { if (logger.isDebugEnabled()) logger.debug("Initializing rateable behaviors"); // Create behaviours this.onCreateNode = new JavaBehaviour(this, "onCreateNode", NotificationFrequency.EVERY_EVENT); this.onDeleteNode = new JavaBehaviour(this, "onDeleteNode", NotificationFrequency.EVERY_EVENT); // Bind behaviours to node policies
// Path: behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/model/SomeCoRatingsModel.java // public interface SomeCoRatingsModel { // // Namespaces // public static final String NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL = "http://www.someco.com/model/ratings/1.0"; // // // Types // public static final String TYPE_SCR_RATING = "rating"; // // // Aspects // public static final String ASPECT_SCR_RATEABLE = "rateable"; // // // Properties // public static final String PROP_RATING = "rating"; // public static final String PROP_RATER = "rater"; // public static final String PROP_AVERAGE_RATING= "averageRating"; // public static final String PROP_TOTAL_RATING= "totalRating"; // public static final String PROP_RATING_COUNT= "ratingCount"; // // // Associations // public static final String ASSN_SCR_RATINGS = "ratings"; // } // Path: behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/behavior/Rating.java import java.util.List; import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.policy.Behaviour; import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.apache.log4j.Logger; import com.someco.model.SomeCoRatingsModel; package com.someco.behavior; public class Rating implements NodeServicePolicies.OnDeleteNodePolicy, NodeServicePolicies.OnCreateNodePolicy { // Dependencies private NodeService nodeService; private PolicyComponent policyComponent; // Behaviours private Behaviour onCreateNode; private Behaviour onDeleteNode; private Logger logger = Logger.getLogger(Rating.class); public void init() { if (logger.isDebugEnabled()) logger.debug("Initializing rateable behaviors"); // Create behaviours this.onCreateNode = new JavaBehaviour(this, "onCreateNode", NotificationFrequency.EVERY_EVENT); this.onDeleteNode = new JavaBehaviour(this, "onDeleteNode", NotificationFrequency.EVERY_EVENT); // Bind behaviours to node policies
this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), QName.createQName(SomeCoRatingsModel.NAMESPACE_SOMECO_RATINGS_CONTENT_MODEL, SomeCoRatingsModel.TYPE_SCR_RATING), this.onCreateNode);
Kickflip/kickflip-android-sdk
sdk/src/main/java/io/kickflip/sdk/api/KickflipCallback.java
// Path: sdk/src/main/java/io/kickflip/sdk/api/json/Response.java // public class Response { // // @Key("success") // private boolean mSuccess; // // @Key("reason") // private String mReason; // // public Response() { // // Required default Constructor // } // // public boolean isSuccessful() { // return mSuccess; // } // // public String getReason() { // return mReason; // } // } // // Path: sdk/src/main/java/io/kickflip/sdk/exception/KickflipException.java // public class KickflipException extends IOException{ // private String mMessage; // private int mCode; // // public KickflipException(){ // mMessage = "An unknown error occurred"; // mCode = 0; // } // // public KickflipException(String message, int code){ // mMessage = message; // mCode = code; // } // // public String getMessage() { // return mMessage; // } // // public int getCode() { // return mCode; // } // }
import io.kickflip.sdk.api.json.Response; import io.kickflip.sdk.exception.KickflipException;
package io.kickflip.sdk.api; /** * Callback interface for Kickflip API calls * */ public interface KickflipCallback { void onSuccess(Response response);
// Path: sdk/src/main/java/io/kickflip/sdk/api/json/Response.java // public class Response { // // @Key("success") // private boolean mSuccess; // // @Key("reason") // private String mReason; // // public Response() { // // Required default Constructor // } // // public boolean isSuccessful() { // return mSuccess; // } // // public String getReason() { // return mReason; // } // } // // Path: sdk/src/main/java/io/kickflip/sdk/exception/KickflipException.java // public class KickflipException extends IOException{ // private String mMessage; // private int mCode; // // public KickflipException(){ // mMessage = "An unknown error occurred"; // mCode = 0; // } // // public KickflipException(String message, int code){ // mMessage = message; // mCode = code; // } // // public String getMessage() { // return mMessage; // } // // public int getCode() { // return mCode; // } // } // Path: sdk/src/main/java/io/kickflip/sdk/api/KickflipCallback.java import io.kickflip.sdk.api.json.Response; import io.kickflip.sdk.exception.KickflipException; package io.kickflip.sdk.api; /** * Callback interface for Kickflip API calls * */ public interface KickflipCallback { void onSuccess(Response response);
void onError(KickflipException error);
Kickflip/kickflip-android-sdk
sdk/src/main/java/io/kickflip/sdk/av/AVRecorder.java
// Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraView.java // public class GLCameraView extends GLSurfaceView { // private static final String TAG = "GLCameraView"; // // protected ScaleGestureDetector mScaleGestureDetector; // private Camera mCamera; // private int mMaxZoom; // // public GLCameraView(Context context) { // super(context); // init(context); // } // // public GLCameraView(Context context, AttributeSet attrs) { // super(context, attrs); // init(context); // } // // private void init(Context context){ // mMaxZoom = 0; // // } // // public void setCamera(Camera camera){ // mCamera = camera; // Camera.Parameters camParams = mCamera.getParameters(); // if(camParams.isZoomSupported()){ // mMaxZoom = camParams.getMaxZoom(); // mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener); // } // } // // public void releaseCamera(){ // mCamera = null; // mScaleGestureDetector = null; // } // // private ScaleGestureDetector.SimpleOnScaleGestureListener mScaleListener = new ScaleGestureDetector.SimpleOnScaleGestureListener(){ // // int mZoomWhenScaleBegan = 0; // int mCurrentZoom = 0; // // @Override // public boolean onScale(ScaleGestureDetector detector) { // if(mCamera != null){ // Camera.Parameters params = mCamera.getParameters(); // mCurrentZoom = (int) (mZoomWhenScaleBegan + (mMaxZoom * (detector.getScaleFactor() - 1))); // mCurrentZoom = Math.min(mCurrentZoom, mMaxZoom); // mCurrentZoom = Math.max(0, mCurrentZoom); // params.setZoom(mCurrentZoom); // mCamera.setParameters(params); // } // // return false; // } // // @Override // public boolean onScaleBegin(ScaleGestureDetector detector) { // mZoomWhenScaleBegan = mCamera.getParameters().getZoom(); // return true; // } // // @Override // public void onScaleEnd(ScaleGestureDetector detector) { // } // }; // // @Override // public boolean onTouchEvent(MotionEvent ev) { // if(mScaleGestureDetector != null){ // if(!mScaleGestureDetector.onTouchEvent(ev)){ // // No scale gesture detected // // } // } // return true; // } // // // }
import java.io.IOException; import io.kickflip.sdk.view.GLCameraView;
package io.kickflip.sdk.av; /** * Records an Audio / Video stream to disk. * * Example usage: * <ul> * <li>AVRecorder recorder = new AVRecorder(mSessionConfig);</li> * <li>recorder.setPreviewDisplay(mPreviewDisplay);</li> * <li>recorder.startRecording();</li> * <li>recorder.stopRecording();</li> * <li>(Optional) recorder.reset(mNewSessionConfig);</li> * <li>(Optional) recorder.startRecording();</li> * <li>(Optional) recorder.stopRecording();</li> * <li>recorder.release();</li> * </ul> * @hide */ public class AVRecorder { protected CameraEncoder mCamEncoder; protected MicrophoneEncoder mMicEncoder; private SessionConfig mConfig; private boolean mIsRecording; public AVRecorder(SessionConfig config) throws IOException { init(config); } private void init(SessionConfig config) throws IOException { mCamEncoder = new CameraEncoder(config); mMicEncoder = new MicrophoneEncoder(config); mConfig = config; mIsRecording = false; }
// Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraView.java // public class GLCameraView extends GLSurfaceView { // private static final String TAG = "GLCameraView"; // // protected ScaleGestureDetector mScaleGestureDetector; // private Camera mCamera; // private int mMaxZoom; // // public GLCameraView(Context context) { // super(context); // init(context); // } // // public GLCameraView(Context context, AttributeSet attrs) { // super(context, attrs); // init(context); // } // // private void init(Context context){ // mMaxZoom = 0; // // } // // public void setCamera(Camera camera){ // mCamera = camera; // Camera.Parameters camParams = mCamera.getParameters(); // if(camParams.isZoomSupported()){ // mMaxZoom = camParams.getMaxZoom(); // mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener); // } // } // // public void releaseCamera(){ // mCamera = null; // mScaleGestureDetector = null; // } // // private ScaleGestureDetector.SimpleOnScaleGestureListener mScaleListener = new ScaleGestureDetector.SimpleOnScaleGestureListener(){ // // int mZoomWhenScaleBegan = 0; // int mCurrentZoom = 0; // // @Override // public boolean onScale(ScaleGestureDetector detector) { // if(mCamera != null){ // Camera.Parameters params = mCamera.getParameters(); // mCurrentZoom = (int) (mZoomWhenScaleBegan + (mMaxZoom * (detector.getScaleFactor() - 1))); // mCurrentZoom = Math.min(mCurrentZoom, mMaxZoom); // mCurrentZoom = Math.max(0, mCurrentZoom); // params.setZoom(mCurrentZoom); // mCamera.setParameters(params); // } // // return false; // } // // @Override // public boolean onScaleBegin(ScaleGestureDetector detector) { // mZoomWhenScaleBegan = mCamera.getParameters().getZoom(); // return true; // } // // @Override // public void onScaleEnd(ScaleGestureDetector detector) { // } // }; // // @Override // public boolean onTouchEvent(MotionEvent ev) { // if(mScaleGestureDetector != null){ // if(!mScaleGestureDetector.onTouchEvent(ev)){ // // No scale gesture detected // // } // } // return true; // } // // // } // Path: sdk/src/main/java/io/kickflip/sdk/av/AVRecorder.java import java.io.IOException; import io.kickflip.sdk.view.GLCameraView; package io.kickflip.sdk.av; /** * Records an Audio / Video stream to disk. * * Example usage: * <ul> * <li>AVRecorder recorder = new AVRecorder(mSessionConfig);</li> * <li>recorder.setPreviewDisplay(mPreviewDisplay);</li> * <li>recorder.startRecording();</li> * <li>recorder.stopRecording();</li> * <li>(Optional) recorder.reset(mNewSessionConfig);</li> * <li>(Optional) recorder.startRecording();</li> * <li>(Optional) recorder.stopRecording();</li> * <li>recorder.release();</li> * </ul> * @hide */ public class AVRecorder { protected CameraEncoder mCamEncoder; protected MicrophoneEncoder mMicEncoder; private SessionConfig mConfig; private boolean mIsRecording; public AVRecorder(SessionConfig config) throws IOException { init(config); } private void init(SessionConfig config) throws IOException { mCamEncoder = new CameraEncoder(config); mMicEncoder = new MicrophoneEncoder(config); mConfig = config; mIsRecording = false; }
public void setPreviewDisplay(GLCameraView display){
Kickflip/kickflip-android-sdk
sdk/src/main/java/io/kickflip/sdk/av/HlsFileObserver.java
// Path: sdk/src/main/java/io/kickflip/sdk/event/HlsManifestWrittenEvent.java // public class HlsManifestWrittenEvent extends BroadcastEvent { // // private File mManifest; // // public HlsManifestWrittenEvent(String manifestLocation) { // mManifest = new File(manifestLocation); // } // // public File getManifestFile() { // return mManifest; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/event/HlsSegmentWrittenEvent.java // public class HlsSegmentWrittenEvent extends BroadcastEvent { // // private File mSegment; // // public HlsSegmentWrittenEvent(String segmentLocation) { // mSegment = new File(segmentLocation); // } // // public File getSegment() { // return mSegment; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/event/ThumbnailWrittenEvent.java // public class ThumbnailWrittenEvent extends BroadcastEvent { // // private File mThumbnail; // // public ThumbnailWrittenEvent(String thumbLocation) { // this.mThumbnail = new File(thumbLocation); // } // // public File getThumbnailFile() { // return mThumbnail; // } // // }
import android.os.FileObserver; import android.util.Log; import com.google.common.eventbus.EventBus; import java.io.File; import io.kickflip.sdk.event.HlsManifestWrittenEvent; import io.kickflip.sdk.event.HlsSegmentWrittenEvent; import io.kickflip.sdk.event.ThumbnailWrittenEvent;
/* * Copyright (c) 2013, David Brodsky. All rights reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package io.kickflip.sdk.av; /** * A FileObserver that listens for actions * specific to the creation of an HLS stream * e.g: A .ts segment is written * or a .m3u8 manifest is modified * * @author davidbrodsky * @hide */ public class HlsFileObserver extends FileObserver { private static final String TAG = "HlsFileObserver"; private static final boolean VERBOSE = false; private static final String M3U8_EXT = "m3u8"; private static final String TS_EXT = "ts"; private static final String JPG_EXT = "jpg"; private String mObservedPath; private EventBus mEventBus; /** * Begin observing the given path for changes * to .ts, .m3u8 and .jpg files * * @param path the absolute path to observe. * @param eventBus an EventBus to post events to */ public HlsFileObserver(String path, EventBus eventBus) { super(path, CLOSE_WRITE | MOVED_TO); mEventBus = eventBus; mObservedPath = path; } @Override public void onEvent(int event, String path) { if (path == null) return; // If the directory was deleted. String ext = path.substring(path.lastIndexOf('.') + 1); String absolutePath = mObservedPath + File.separator + path; Log.d(TAG, String.format("Event %d at %s ext %s", event, path, ext)); if (event == MOVED_TO && ext.equals(M3U8_EXT)) { if (VERBOSE) Log.i(TAG, "posting manifest written " + absolutePath);
// Path: sdk/src/main/java/io/kickflip/sdk/event/HlsManifestWrittenEvent.java // public class HlsManifestWrittenEvent extends BroadcastEvent { // // private File mManifest; // // public HlsManifestWrittenEvent(String manifestLocation) { // mManifest = new File(manifestLocation); // } // // public File getManifestFile() { // return mManifest; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/event/HlsSegmentWrittenEvent.java // public class HlsSegmentWrittenEvent extends BroadcastEvent { // // private File mSegment; // // public HlsSegmentWrittenEvent(String segmentLocation) { // mSegment = new File(segmentLocation); // } // // public File getSegment() { // return mSegment; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/event/ThumbnailWrittenEvent.java // public class ThumbnailWrittenEvent extends BroadcastEvent { // // private File mThumbnail; // // public ThumbnailWrittenEvent(String thumbLocation) { // this.mThumbnail = new File(thumbLocation); // } // // public File getThumbnailFile() { // return mThumbnail; // } // // } // Path: sdk/src/main/java/io/kickflip/sdk/av/HlsFileObserver.java import android.os.FileObserver; import android.util.Log; import com.google.common.eventbus.EventBus; import java.io.File; import io.kickflip.sdk.event.HlsManifestWrittenEvent; import io.kickflip.sdk.event.HlsSegmentWrittenEvent; import io.kickflip.sdk.event.ThumbnailWrittenEvent; /* * Copyright (c) 2013, David Brodsky. All rights reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package io.kickflip.sdk.av; /** * A FileObserver that listens for actions * specific to the creation of an HLS stream * e.g: A .ts segment is written * or a .m3u8 manifest is modified * * @author davidbrodsky * @hide */ public class HlsFileObserver extends FileObserver { private static final String TAG = "HlsFileObserver"; private static final boolean VERBOSE = false; private static final String M3U8_EXT = "m3u8"; private static final String TS_EXT = "ts"; private static final String JPG_EXT = "jpg"; private String mObservedPath; private EventBus mEventBus; /** * Begin observing the given path for changes * to .ts, .m3u8 and .jpg files * * @param path the absolute path to observe. * @param eventBus an EventBus to post events to */ public HlsFileObserver(String path, EventBus eventBus) { super(path, CLOSE_WRITE | MOVED_TO); mEventBus = eventBus; mObservedPath = path; } @Override public void onEvent(int event, String path) { if (path == null) return; // If the directory was deleted. String ext = path.substring(path.lastIndexOf('.') + 1); String absolutePath = mObservedPath + File.separator + path; Log.d(TAG, String.format("Event %d at %s ext %s", event, path, ext)); if (event == MOVED_TO && ext.equals(M3U8_EXT)) { if (VERBOSE) Log.i(TAG, "posting manifest written " + absolutePath);
mEventBus.post(new HlsManifestWrittenEvent(absolutePath));
Kickflip/kickflip-android-sdk
sdk/src/main/java/io/kickflip/sdk/av/HlsFileObserver.java
// Path: sdk/src/main/java/io/kickflip/sdk/event/HlsManifestWrittenEvent.java // public class HlsManifestWrittenEvent extends BroadcastEvent { // // private File mManifest; // // public HlsManifestWrittenEvent(String manifestLocation) { // mManifest = new File(manifestLocation); // } // // public File getManifestFile() { // return mManifest; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/event/HlsSegmentWrittenEvent.java // public class HlsSegmentWrittenEvent extends BroadcastEvent { // // private File mSegment; // // public HlsSegmentWrittenEvent(String segmentLocation) { // mSegment = new File(segmentLocation); // } // // public File getSegment() { // return mSegment; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/event/ThumbnailWrittenEvent.java // public class ThumbnailWrittenEvent extends BroadcastEvent { // // private File mThumbnail; // // public ThumbnailWrittenEvent(String thumbLocation) { // this.mThumbnail = new File(thumbLocation); // } // // public File getThumbnailFile() { // return mThumbnail; // } // // }
import android.os.FileObserver; import android.util.Log; import com.google.common.eventbus.EventBus; import java.io.File; import io.kickflip.sdk.event.HlsManifestWrittenEvent; import io.kickflip.sdk.event.HlsSegmentWrittenEvent; import io.kickflip.sdk.event.ThumbnailWrittenEvent;
/* * Copyright (c) 2013, David Brodsky. All rights reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package io.kickflip.sdk.av; /** * A FileObserver that listens for actions * specific to the creation of an HLS stream * e.g: A .ts segment is written * or a .m3u8 manifest is modified * * @author davidbrodsky * @hide */ public class HlsFileObserver extends FileObserver { private static final String TAG = "HlsFileObserver"; private static final boolean VERBOSE = false; private static final String M3U8_EXT = "m3u8"; private static final String TS_EXT = "ts"; private static final String JPG_EXT = "jpg"; private String mObservedPath; private EventBus mEventBus; /** * Begin observing the given path for changes * to .ts, .m3u8 and .jpg files * * @param path the absolute path to observe. * @param eventBus an EventBus to post events to */ public HlsFileObserver(String path, EventBus eventBus) { super(path, CLOSE_WRITE | MOVED_TO); mEventBus = eventBus; mObservedPath = path; } @Override public void onEvent(int event, String path) { if (path == null) return; // If the directory was deleted. String ext = path.substring(path.lastIndexOf('.') + 1); String absolutePath = mObservedPath + File.separator + path; Log.d(TAG, String.format("Event %d at %s ext %s", event, path, ext)); if (event == MOVED_TO && ext.equals(M3U8_EXT)) { if (VERBOSE) Log.i(TAG, "posting manifest written " + absolutePath); mEventBus.post(new HlsManifestWrittenEvent(absolutePath)); } else if (event == CLOSE_WRITE && ext.equals(TS_EXT)) { if (VERBOSE) Log.i(TAG, "posting hls segment written " + absolutePath);
// Path: sdk/src/main/java/io/kickflip/sdk/event/HlsManifestWrittenEvent.java // public class HlsManifestWrittenEvent extends BroadcastEvent { // // private File mManifest; // // public HlsManifestWrittenEvent(String manifestLocation) { // mManifest = new File(manifestLocation); // } // // public File getManifestFile() { // return mManifest; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/event/HlsSegmentWrittenEvent.java // public class HlsSegmentWrittenEvent extends BroadcastEvent { // // private File mSegment; // // public HlsSegmentWrittenEvent(String segmentLocation) { // mSegment = new File(segmentLocation); // } // // public File getSegment() { // return mSegment; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/event/ThumbnailWrittenEvent.java // public class ThumbnailWrittenEvent extends BroadcastEvent { // // private File mThumbnail; // // public ThumbnailWrittenEvent(String thumbLocation) { // this.mThumbnail = new File(thumbLocation); // } // // public File getThumbnailFile() { // return mThumbnail; // } // // } // Path: sdk/src/main/java/io/kickflip/sdk/av/HlsFileObserver.java import android.os.FileObserver; import android.util.Log; import com.google.common.eventbus.EventBus; import java.io.File; import io.kickflip.sdk.event.HlsManifestWrittenEvent; import io.kickflip.sdk.event.HlsSegmentWrittenEvent; import io.kickflip.sdk.event.ThumbnailWrittenEvent; /* * Copyright (c) 2013, David Brodsky. All rights reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package io.kickflip.sdk.av; /** * A FileObserver that listens for actions * specific to the creation of an HLS stream * e.g: A .ts segment is written * or a .m3u8 manifest is modified * * @author davidbrodsky * @hide */ public class HlsFileObserver extends FileObserver { private static final String TAG = "HlsFileObserver"; private static final boolean VERBOSE = false; private static final String M3U8_EXT = "m3u8"; private static final String TS_EXT = "ts"; private static final String JPG_EXT = "jpg"; private String mObservedPath; private EventBus mEventBus; /** * Begin observing the given path for changes * to .ts, .m3u8 and .jpg files * * @param path the absolute path to observe. * @param eventBus an EventBus to post events to */ public HlsFileObserver(String path, EventBus eventBus) { super(path, CLOSE_WRITE | MOVED_TO); mEventBus = eventBus; mObservedPath = path; } @Override public void onEvent(int event, String path) { if (path == null) return; // If the directory was deleted. String ext = path.substring(path.lastIndexOf('.') + 1); String absolutePath = mObservedPath + File.separator + path; Log.d(TAG, String.format("Event %d at %s ext %s", event, path, ext)); if (event == MOVED_TO && ext.equals(M3U8_EXT)) { if (VERBOSE) Log.i(TAG, "posting manifest written " + absolutePath); mEventBus.post(new HlsManifestWrittenEvent(absolutePath)); } else if (event == CLOSE_WRITE && ext.equals(TS_EXT)) { if (VERBOSE) Log.i(TAG, "posting hls segment written " + absolutePath);
mEventBus.post(new HlsSegmentWrittenEvent(absolutePath));
Kickflip/kickflip-android-sdk
sdk/src/main/java/io/kickflip/sdk/av/HlsFileObserver.java
// Path: sdk/src/main/java/io/kickflip/sdk/event/HlsManifestWrittenEvent.java // public class HlsManifestWrittenEvent extends BroadcastEvent { // // private File mManifest; // // public HlsManifestWrittenEvent(String manifestLocation) { // mManifest = new File(manifestLocation); // } // // public File getManifestFile() { // return mManifest; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/event/HlsSegmentWrittenEvent.java // public class HlsSegmentWrittenEvent extends BroadcastEvent { // // private File mSegment; // // public HlsSegmentWrittenEvent(String segmentLocation) { // mSegment = new File(segmentLocation); // } // // public File getSegment() { // return mSegment; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/event/ThumbnailWrittenEvent.java // public class ThumbnailWrittenEvent extends BroadcastEvent { // // private File mThumbnail; // // public ThumbnailWrittenEvent(String thumbLocation) { // this.mThumbnail = new File(thumbLocation); // } // // public File getThumbnailFile() { // return mThumbnail; // } // // }
import android.os.FileObserver; import android.util.Log; import com.google.common.eventbus.EventBus; import java.io.File; import io.kickflip.sdk.event.HlsManifestWrittenEvent; import io.kickflip.sdk.event.HlsSegmentWrittenEvent; import io.kickflip.sdk.event.ThumbnailWrittenEvent;
/* * Copyright (c) 2013, David Brodsky. All rights reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package io.kickflip.sdk.av; /** * A FileObserver that listens for actions * specific to the creation of an HLS stream * e.g: A .ts segment is written * or a .m3u8 manifest is modified * * @author davidbrodsky * @hide */ public class HlsFileObserver extends FileObserver { private static final String TAG = "HlsFileObserver"; private static final boolean VERBOSE = false; private static final String M3U8_EXT = "m3u8"; private static final String TS_EXT = "ts"; private static final String JPG_EXT = "jpg"; private String mObservedPath; private EventBus mEventBus; /** * Begin observing the given path for changes * to .ts, .m3u8 and .jpg files * * @param path the absolute path to observe. * @param eventBus an EventBus to post events to */ public HlsFileObserver(String path, EventBus eventBus) { super(path, CLOSE_WRITE | MOVED_TO); mEventBus = eventBus; mObservedPath = path; } @Override public void onEvent(int event, String path) { if (path == null) return; // If the directory was deleted. String ext = path.substring(path.lastIndexOf('.') + 1); String absolutePath = mObservedPath + File.separator + path; Log.d(TAG, String.format("Event %d at %s ext %s", event, path, ext)); if (event == MOVED_TO && ext.equals(M3U8_EXT)) { if (VERBOSE) Log.i(TAG, "posting manifest written " + absolutePath); mEventBus.post(new HlsManifestWrittenEvent(absolutePath)); } else if (event == CLOSE_WRITE && ext.equals(TS_EXT)) { if (VERBOSE) Log.i(TAG, "posting hls segment written " + absolutePath); mEventBus.post(new HlsSegmentWrittenEvent(absolutePath)); } else if (event == CLOSE_WRITE && ext.equals(JPG_EXT)) { if (VERBOSE) Log.i(TAG, "posting thumbnail written " + absolutePath);
// Path: sdk/src/main/java/io/kickflip/sdk/event/HlsManifestWrittenEvent.java // public class HlsManifestWrittenEvent extends BroadcastEvent { // // private File mManifest; // // public HlsManifestWrittenEvent(String manifestLocation) { // mManifest = new File(manifestLocation); // } // // public File getManifestFile() { // return mManifest; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/event/HlsSegmentWrittenEvent.java // public class HlsSegmentWrittenEvent extends BroadcastEvent { // // private File mSegment; // // public HlsSegmentWrittenEvent(String segmentLocation) { // mSegment = new File(segmentLocation); // } // // public File getSegment() { // return mSegment; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/event/ThumbnailWrittenEvent.java // public class ThumbnailWrittenEvent extends BroadcastEvent { // // private File mThumbnail; // // public ThumbnailWrittenEvent(String thumbLocation) { // this.mThumbnail = new File(thumbLocation); // } // // public File getThumbnailFile() { // return mThumbnail; // } // // } // Path: sdk/src/main/java/io/kickflip/sdk/av/HlsFileObserver.java import android.os.FileObserver; import android.util.Log; import com.google.common.eventbus.EventBus; import java.io.File; import io.kickflip.sdk.event.HlsManifestWrittenEvent; import io.kickflip.sdk.event.HlsSegmentWrittenEvent; import io.kickflip.sdk.event.ThumbnailWrittenEvent; /* * Copyright (c) 2013, David Brodsky. All rights reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package io.kickflip.sdk.av; /** * A FileObserver that listens for actions * specific to the creation of an HLS stream * e.g: A .ts segment is written * or a .m3u8 manifest is modified * * @author davidbrodsky * @hide */ public class HlsFileObserver extends FileObserver { private static final String TAG = "HlsFileObserver"; private static final boolean VERBOSE = false; private static final String M3U8_EXT = "m3u8"; private static final String TS_EXT = "ts"; private static final String JPG_EXT = "jpg"; private String mObservedPath; private EventBus mEventBus; /** * Begin observing the given path for changes * to .ts, .m3u8 and .jpg files * * @param path the absolute path to observe. * @param eventBus an EventBus to post events to */ public HlsFileObserver(String path, EventBus eventBus) { super(path, CLOSE_WRITE | MOVED_TO); mEventBus = eventBus; mObservedPath = path; } @Override public void onEvent(int event, String path) { if (path == null) return; // If the directory was deleted. String ext = path.substring(path.lastIndexOf('.') + 1); String absolutePath = mObservedPath + File.separator + path; Log.d(TAG, String.format("Event %d at %s ext %s", event, path, ext)); if (event == MOVED_TO && ext.equals(M3U8_EXT)) { if (VERBOSE) Log.i(TAG, "posting manifest written " + absolutePath); mEventBus.post(new HlsManifestWrittenEvent(absolutePath)); } else if (event == CLOSE_WRITE && ext.equals(TS_EXT)) { if (VERBOSE) Log.i(TAG, "posting hls segment written " + absolutePath); mEventBus.post(new HlsSegmentWrittenEvent(absolutePath)); } else if (event == CLOSE_WRITE && ext.equals(JPG_EXT)) { if (VERBOSE) Log.i(TAG, "posting thumbnail written " + absolutePath);
mEventBus.post(new ThumbnailWrittenEvent(absolutePath));
Kickflip/kickflip-android-sdk
sdk/src/main/java/io/kickflip/sdk/av/CameraEncoder.java
// Path: sdk/src/main/java/io/kickflip/sdk/event/CameraOpenedEvent.java // public class CameraOpenedEvent { // // public Parameters params; // // public CameraOpenedEvent(Parameters params) { // this.params = params; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraEncoderView.java // public class GLCameraEncoderView extends GLCameraView { // private static final String TAG = "GLCameraEncoderView"; // // protected CameraEncoder mCameraEncoder; // // public GLCameraEncoderView(Context context) { // super(context); // } // // public GLCameraEncoderView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public void setCameraEncoder(CameraEncoder encoder){ // mCameraEncoder = encoder; // setCamera(mCameraEncoder.getCamera()); // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // if(mScaleGestureDetector != null){ // mScaleGestureDetector.onTouchEvent(ev); // } // if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_MOVE)){ // mCameraEncoder.handleCameraPreviewTouchEvent(ev); // }else if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_DOWN)){ // mCameraEncoder.handleCameraPreviewTouchEvent(ev); // } // return true; // } // // // } // // Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraView.java // public class GLCameraView extends GLSurfaceView { // private static final String TAG = "GLCameraView"; // // protected ScaleGestureDetector mScaleGestureDetector; // private Camera mCamera; // private int mMaxZoom; // // public GLCameraView(Context context) { // super(context); // init(context); // } // // public GLCameraView(Context context, AttributeSet attrs) { // super(context, attrs); // init(context); // } // // private void init(Context context){ // mMaxZoom = 0; // // } // // public void setCamera(Camera camera){ // mCamera = camera; // Camera.Parameters camParams = mCamera.getParameters(); // if(camParams.isZoomSupported()){ // mMaxZoom = camParams.getMaxZoom(); // mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener); // } // } // // public void releaseCamera(){ // mCamera = null; // mScaleGestureDetector = null; // } // // private ScaleGestureDetector.SimpleOnScaleGestureListener mScaleListener = new ScaleGestureDetector.SimpleOnScaleGestureListener(){ // // int mZoomWhenScaleBegan = 0; // int mCurrentZoom = 0; // // @Override // public boolean onScale(ScaleGestureDetector detector) { // if(mCamera != null){ // Camera.Parameters params = mCamera.getParameters(); // mCurrentZoom = (int) (mZoomWhenScaleBegan + (mMaxZoom * (detector.getScaleFactor() - 1))); // mCurrentZoom = Math.min(mCurrentZoom, mMaxZoom); // mCurrentZoom = Math.max(0, mCurrentZoom); // params.setZoom(mCurrentZoom); // mCamera.setParameters(params); // } // // return false; // } // // @Override // public boolean onScaleBegin(ScaleGestureDetector detector) { // mZoomWhenScaleBegan = mCamera.getParameters().getZoom(); // return true; // } // // @Override // public void onScaleEnd(ScaleGestureDetector detector) { // } // }; // // @Override // public boolean onTouchEvent(MotionEvent ev) { // if(mScaleGestureDetector != null){ // if(!mScaleGestureDetector.onTouchEvent(ev)){ // // No scale gesture detected // // } // } // return true; // } // // // }
import android.graphics.SurfaceTexture; import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.opengl.EGLContext; import android.opengl.GLSurfaceView; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.Trace; import android.util.Log; import android.view.MotionEvent; import com.google.common.eventbus.EventBus; import java.io.File; import java.io.IOException; import java.lang.ref.WeakReference; import java.util.List; import io.kickflip.sdk.event.CameraOpenedEvent; import io.kickflip.sdk.view.GLCameraEncoderView; import io.kickflip.sdk.view.GLCameraView; import static com.google.common.base.Preconditions.checkNotNull;
ppsfv.width + "x" + ppsfv.height); } for (Camera.Size size : parms.getSupportedPreviewSizes()) { if (size.width == width && size.height == height) { parms.setPreviewSize(width, height); return; } } Log.w(TAG, "Unable to set preview size to " + width + "x" + height); if (ppsfv != null) { parms.setPreviewSize(ppsfv.width, ppsfv.height); } // else use whatever the default size is } public void adjustBitrate(int targetBitrate) { mVideoEncoder.adjustBitrate(targetBitrate); } public void signalVerticalVideo(FullFrameRect.SCREEN_ROTATION orientation) { if (mFullScreen != null) mFullScreen.adjustForVerticalVideo(orientation, true); mDisplayRenderer.signalVertialVideo(orientation); } public void logSavedEglState() { mEglSaver.logState(); }
// Path: sdk/src/main/java/io/kickflip/sdk/event/CameraOpenedEvent.java // public class CameraOpenedEvent { // // public Parameters params; // // public CameraOpenedEvent(Parameters params) { // this.params = params; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraEncoderView.java // public class GLCameraEncoderView extends GLCameraView { // private static final String TAG = "GLCameraEncoderView"; // // protected CameraEncoder mCameraEncoder; // // public GLCameraEncoderView(Context context) { // super(context); // } // // public GLCameraEncoderView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public void setCameraEncoder(CameraEncoder encoder){ // mCameraEncoder = encoder; // setCamera(mCameraEncoder.getCamera()); // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // if(mScaleGestureDetector != null){ // mScaleGestureDetector.onTouchEvent(ev); // } // if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_MOVE)){ // mCameraEncoder.handleCameraPreviewTouchEvent(ev); // }else if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_DOWN)){ // mCameraEncoder.handleCameraPreviewTouchEvent(ev); // } // return true; // } // // // } // // Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraView.java // public class GLCameraView extends GLSurfaceView { // private static final String TAG = "GLCameraView"; // // protected ScaleGestureDetector mScaleGestureDetector; // private Camera mCamera; // private int mMaxZoom; // // public GLCameraView(Context context) { // super(context); // init(context); // } // // public GLCameraView(Context context, AttributeSet attrs) { // super(context, attrs); // init(context); // } // // private void init(Context context){ // mMaxZoom = 0; // // } // // public void setCamera(Camera camera){ // mCamera = camera; // Camera.Parameters camParams = mCamera.getParameters(); // if(camParams.isZoomSupported()){ // mMaxZoom = camParams.getMaxZoom(); // mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener); // } // } // // public void releaseCamera(){ // mCamera = null; // mScaleGestureDetector = null; // } // // private ScaleGestureDetector.SimpleOnScaleGestureListener mScaleListener = new ScaleGestureDetector.SimpleOnScaleGestureListener(){ // // int mZoomWhenScaleBegan = 0; // int mCurrentZoom = 0; // // @Override // public boolean onScale(ScaleGestureDetector detector) { // if(mCamera != null){ // Camera.Parameters params = mCamera.getParameters(); // mCurrentZoom = (int) (mZoomWhenScaleBegan + (mMaxZoom * (detector.getScaleFactor() - 1))); // mCurrentZoom = Math.min(mCurrentZoom, mMaxZoom); // mCurrentZoom = Math.max(0, mCurrentZoom); // params.setZoom(mCurrentZoom); // mCamera.setParameters(params); // } // // return false; // } // // @Override // public boolean onScaleBegin(ScaleGestureDetector detector) { // mZoomWhenScaleBegan = mCamera.getParameters().getZoom(); // return true; // } // // @Override // public void onScaleEnd(ScaleGestureDetector detector) { // } // }; // // @Override // public boolean onTouchEvent(MotionEvent ev) { // if(mScaleGestureDetector != null){ // if(!mScaleGestureDetector.onTouchEvent(ev)){ // // No scale gesture detected // // } // } // return true; // } // // // } // Path: sdk/src/main/java/io/kickflip/sdk/av/CameraEncoder.java import android.graphics.SurfaceTexture; import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.opengl.EGLContext; import android.opengl.GLSurfaceView; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.Trace; import android.util.Log; import android.view.MotionEvent; import com.google.common.eventbus.EventBus; import java.io.File; import java.io.IOException; import java.lang.ref.WeakReference; import java.util.List; import io.kickflip.sdk.event.CameraOpenedEvent; import io.kickflip.sdk.view.GLCameraEncoderView; import io.kickflip.sdk.view.GLCameraView; import static com.google.common.base.Preconditions.checkNotNull; ppsfv.width + "x" + ppsfv.height); } for (Camera.Size size : parms.getSupportedPreviewSizes()) { if (size.width == width && size.height == height) { parms.setPreviewSize(width, height); return; } } Log.w(TAG, "Unable to set preview size to " + width + "x" + height); if (ppsfv != null) { parms.setPreviewSize(ppsfv.width, ppsfv.height); } // else use whatever the default size is } public void adjustBitrate(int targetBitrate) { mVideoEncoder.adjustBitrate(targetBitrate); } public void signalVerticalVideo(FullFrameRect.SCREEN_ROTATION orientation) { if (mFullScreen != null) mFullScreen.adjustForVerticalVideo(orientation, true); mDisplayRenderer.signalVertialVideo(orientation); } public void logSavedEglState() { mEglSaver.logState(); }
public void setPreviewDisplay(GLCameraView display) {
Kickflip/kickflip-android-sdk
sdk/src/main/java/io/kickflip/sdk/av/CameraEncoder.java
// Path: sdk/src/main/java/io/kickflip/sdk/event/CameraOpenedEvent.java // public class CameraOpenedEvent { // // public Parameters params; // // public CameraOpenedEvent(Parameters params) { // this.params = params; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraEncoderView.java // public class GLCameraEncoderView extends GLCameraView { // private static final String TAG = "GLCameraEncoderView"; // // protected CameraEncoder mCameraEncoder; // // public GLCameraEncoderView(Context context) { // super(context); // } // // public GLCameraEncoderView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public void setCameraEncoder(CameraEncoder encoder){ // mCameraEncoder = encoder; // setCamera(mCameraEncoder.getCamera()); // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // if(mScaleGestureDetector != null){ // mScaleGestureDetector.onTouchEvent(ev); // } // if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_MOVE)){ // mCameraEncoder.handleCameraPreviewTouchEvent(ev); // }else if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_DOWN)){ // mCameraEncoder.handleCameraPreviewTouchEvent(ev); // } // return true; // } // // // } // // Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraView.java // public class GLCameraView extends GLSurfaceView { // private static final String TAG = "GLCameraView"; // // protected ScaleGestureDetector mScaleGestureDetector; // private Camera mCamera; // private int mMaxZoom; // // public GLCameraView(Context context) { // super(context); // init(context); // } // // public GLCameraView(Context context, AttributeSet attrs) { // super(context, attrs); // init(context); // } // // private void init(Context context){ // mMaxZoom = 0; // // } // // public void setCamera(Camera camera){ // mCamera = camera; // Camera.Parameters camParams = mCamera.getParameters(); // if(camParams.isZoomSupported()){ // mMaxZoom = camParams.getMaxZoom(); // mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener); // } // } // // public void releaseCamera(){ // mCamera = null; // mScaleGestureDetector = null; // } // // private ScaleGestureDetector.SimpleOnScaleGestureListener mScaleListener = new ScaleGestureDetector.SimpleOnScaleGestureListener(){ // // int mZoomWhenScaleBegan = 0; // int mCurrentZoom = 0; // // @Override // public boolean onScale(ScaleGestureDetector detector) { // if(mCamera != null){ // Camera.Parameters params = mCamera.getParameters(); // mCurrentZoom = (int) (mZoomWhenScaleBegan + (mMaxZoom * (detector.getScaleFactor() - 1))); // mCurrentZoom = Math.min(mCurrentZoom, mMaxZoom); // mCurrentZoom = Math.max(0, mCurrentZoom); // params.setZoom(mCurrentZoom); // mCamera.setParameters(params); // } // // return false; // } // // @Override // public boolean onScaleBegin(ScaleGestureDetector detector) { // mZoomWhenScaleBegan = mCamera.getParameters().getZoom(); // return true; // } // // @Override // public void onScaleEnd(ScaleGestureDetector detector) { // } // }; // // @Override // public boolean onTouchEvent(MotionEvent ev) { // if(mScaleGestureDetector != null){ // if(!mScaleGestureDetector.onTouchEvent(ev)){ // // No scale gesture detected // // } // } // return true; // } // // // }
import android.graphics.SurfaceTexture; import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.opengl.EGLContext; import android.opengl.GLSurfaceView; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.Trace; import android.util.Log; import android.view.MotionEvent; import com.google.common.eventbus.EventBus; import java.io.File; import java.io.IOException; import java.lang.ref.WeakReference; import java.util.List; import io.kickflip.sdk.event.CameraOpenedEvent; import io.kickflip.sdk.view.GLCameraEncoderView; import io.kickflip.sdk.view.GLCameraView; import static com.google.common.base.Preconditions.checkNotNull;
previewFacts += " @" + (fpsRange[0] / 1000.0) + "fps"; } else { previewFacts += " @" + (fpsRange[0] / 1000.0) + " - " + (fpsRange[1] / 1000.0) + "fps"; } if (VERBOSE) Log.i(TAG, "Camera preview set: " + previewFacts); } public Camera getCamera() { return mCamera; } /** * Stops camera preview, and releases the camera to the system. */ private void releaseCamera() { if (mDisplayView != null) releaseDisplayView(); if (mCamera != null) { if (VERBOSE) Log.d(TAG, "releasing camera"); mCamera.stopPreview(); mCamera.release(); mCamera = null; } } /** * Communicate camera-ready state to our display view. * This method allows us to handle custom subclasses */ private void configureDisplayView() {
// Path: sdk/src/main/java/io/kickflip/sdk/event/CameraOpenedEvent.java // public class CameraOpenedEvent { // // public Parameters params; // // public CameraOpenedEvent(Parameters params) { // this.params = params; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraEncoderView.java // public class GLCameraEncoderView extends GLCameraView { // private static final String TAG = "GLCameraEncoderView"; // // protected CameraEncoder mCameraEncoder; // // public GLCameraEncoderView(Context context) { // super(context); // } // // public GLCameraEncoderView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public void setCameraEncoder(CameraEncoder encoder){ // mCameraEncoder = encoder; // setCamera(mCameraEncoder.getCamera()); // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // if(mScaleGestureDetector != null){ // mScaleGestureDetector.onTouchEvent(ev); // } // if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_MOVE)){ // mCameraEncoder.handleCameraPreviewTouchEvent(ev); // }else if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_DOWN)){ // mCameraEncoder.handleCameraPreviewTouchEvent(ev); // } // return true; // } // // // } // // Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraView.java // public class GLCameraView extends GLSurfaceView { // private static final String TAG = "GLCameraView"; // // protected ScaleGestureDetector mScaleGestureDetector; // private Camera mCamera; // private int mMaxZoom; // // public GLCameraView(Context context) { // super(context); // init(context); // } // // public GLCameraView(Context context, AttributeSet attrs) { // super(context, attrs); // init(context); // } // // private void init(Context context){ // mMaxZoom = 0; // // } // // public void setCamera(Camera camera){ // mCamera = camera; // Camera.Parameters camParams = mCamera.getParameters(); // if(camParams.isZoomSupported()){ // mMaxZoom = camParams.getMaxZoom(); // mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener); // } // } // // public void releaseCamera(){ // mCamera = null; // mScaleGestureDetector = null; // } // // private ScaleGestureDetector.SimpleOnScaleGestureListener mScaleListener = new ScaleGestureDetector.SimpleOnScaleGestureListener(){ // // int mZoomWhenScaleBegan = 0; // int mCurrentZoom = 0; // // @Override // public boolean onScale(ScaleGestureDetector detector) { // if(mCamera != null){ // Camera.Parameters params = mCamera.getParameters(); // mCurrentZoom = (int) (mZoomWhenScaleBegan + (mMaxZoom * (detector.getScaleFactor() - 1))); // mCurrentZoom = Math.min(mCurrentZoom, mMaxZoom); // mCurrentZoom = Math.max(0, mCurrentZoom); // params.setZoom(mCurrentZoom); // mCamera.setParameters(params); // } // // return false; // } // // @Override // public boolean onScaleBegin(ScaleGestureDetector detector) { // mZoomWhenScaleBegan = mCamera.getParameters().getZoom(); // return true; // } // // @Override // public void onScaleEnd(ScaleGestureDetector detector) { // } // }; // // @Override // public boolean onTouchEvent(MotionEvent ev) { // if(mScaleGestureDetector != null){ // if(!mScaleGestureDetector.onTouchEvent(ev)){ // // No scale gesture detected // // } // } // return true; // } // // // } // Path: sdk/src/main/java/io/kickflip/sdk/av/CameraEncoder.java import android.graphics.SurfaceTexture; import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.opengl.EGLContext; import android.opengl.GLSurfaceView; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.Trace; import android.util.Log; import android.view.MotionEvent; import com.google.common.eventbus.EventBus; import java.io.File; import java.io.IOException; import java.lang.ref.WeakReference; import java.util.List; import io.kickflip.sdk.event.CameraOpenedEvent; import io.kickflip.sdk.view.GLCameraEncoderView; import io.kickflip.sdk.view.GLCameraView; import static com.google.common.base.Preconditions.checkNotNull; previewFacts += " @" + (fpsRange[0] / 1000.0) + "fps"; } else { previewFacts += " @" + (fpsRange[0] / 1000.0) + " - " + (fpsRange[1] / 1000.0) + "fps"; } if (VERBOSE) Log.i(TAG, "Camera preview set: " + previewFacts); } public Camera getCamera() { return mCamera; } /** * Stops camera preview, and releases the camera to the system. */ private void releaseCamera() { if (mDisplayView != null) releaseDisplayView(); if (mCamera != null) { if (VERBOSE) Log.d(TAG, "releasing camera"); mCamera.stopPreview(); mCamera.release(); mCamera = null; } } /** * Communicate camera-ready state to our display view. * This method allows us to handle custom subclasses */ private void configureDisplayView() {
if (mDisplayView instanceof GLCameraEncoderView)
Kickflip/kickflip-android-sdk
sdk/src/main/java/io/kickflip/sdk/av/CameraEncoder.java
// Path: sdk/src/main/java/io/kickflip/sdk/event/CameraOpenedEvent.java // public class CameraOpenedEvent { // // public Parameters params; // // public CameraOpenedEvent(Parameters params) { // this.params = params; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraEncoderView.java // public class GLCameraEncoderView extends GLCameraView { // private static final String TAG = "GLCameraEncoderView"; // // protected CameraEncoder mCameraEncoder; // // public GLCameraEncoderView(Context context) { // super(context); // } // // public GLCameraEncoderView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public void setCameraEncoder(CameraEncoder encoder){ // mCameraEncoder = encoder; // setCamera(mCameraEncoder.getCamera()); // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // if(mScaleGestureDetector != null){ // mScaleGestureDetector.onTouchEvent(ev); // } // if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_MOVE)){ // mCameraEncoder.handleCameraPreviewTouchEvent(ev); // }else if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_DOWN)){ // mCameraEncoder.handleCameraPreviewTouchEvent(ev); // } // return true; // } // // // } // // Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraView.java // public class GLCameraView extends GLSurfaceView { // private static final String TAG = "GLCameraView"; // // protected ScaleGestureDetector mScaleGestureDetector; // private Camera mCamera; // private int mMaxZoom; // // public GLCameraView(Context context) { // super(context); // init(context); // } // // public GLCameraView(Context context, AttributeSet attrs) { // super(context, attrs); // init(context); // } // // private void init(Context context){ // mMaxZoom = 0; // // } // // public void setCamera(Camera camera){ // mCamera = camera; // Camera.Parameters camParams = mCamera.getParameters(); // if(camParams.isZoomSupported()){ // mMaxZoom = camParams.getMaxZoom(); // mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener); // } // } // // public void releaseCamera(){ // mCamera = null; // mScaleGestureDetector = null; // } // // private ScaleGestureDetector.SimpleOnScaleGestureListener mScaleListener = new ScaleGestureDetector.SimpleOnScaleGestureListener(){ // // int mZoomWhenScaleBegan = 0; // int mCurrentZoom = 0; // // @Override // public boolean onScale(ScaleGestureDetector detector) { // if(mCamera != null){ // Camera.Parameters params = mCamera.getParameters(); // mCurrentZoom = (int) (mZoomWhenScaleBegan + (mMaxZoom * (detector.getScaleFactor() - 1))); // mCurrentZoom = Math.min(mCurrentZoom, mMaxZoom); // mCurrentZoom = Math.max(0, mCurrentZoom); // params.setZoom(mCurrentZoom); // mCamera.setParameters(params); // } // // return false; // } // // @Override // public boolean onScaleBegin(ScaleGestureDetector detector) { // mZoomWhenScaleBegan = mCamera.getParameters().getZoom(); // return true; // } // // @Override // public void onScaleEnd(ScaleGestureDetector detector) { // } // }; // // @Override // public boolean onTouchEvent(MotionEvent ev) { // if(mScaleGestureDetector != null){ // if(!mScaleGestureDetector.onTouchEvent(ev)){ // // No scale gesture detected // // } // } // return true; // } // // // }
import android.graphics.SurfaceTexture; import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.opengl.EGLContext; import android.opengl.GLSurfaceView; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.Trace; import android.util.Log; import android.view.MotionEvent; import com.google.common.eventbus.EventBus; import java.io.File; import java.io.IOException; import java.lang.ref.WeakReference; import java.util.List; import io.kickflip.sdk.event.CameraOpenedEvent; import io.kickflip.sdk.view.GLCameraEncoderView; import io.kickflip.sdk.view.GLCameraView; import static com.google.common.base.Preconditions.checkNotNull;
Log.i(TAG, "Changed flash successfully!"); } } catch (RuntimeException e) { Log.d(TAG, "Unable to set flash" + e); } } } /** * @param flashModes * @param flashMode * @return returns true if flashModes aren't null AND they contain the flashMode, * else returns false */ private boolean isValidFlashMode(List<String> flashModes, String flashMode) { if (flashModes != null && flashModes.contains(flashMode)) { return true; } return false; } /** * @return returns the flash mode set in the camera */ public String getFlashMode() { return (mDesiredFlash != null) ? mDesiredFlash : mCurrentFlash; } private void postCameraOpenedEvent(Parameters params) { if (mEventBus != null) {
// Path: sdk/src/main/java/io/kickflip/sdk/event/CameraOpenedEvent.java // public class CameraOpenedEvent { // // public Parameters params; // // public CameraOpenedEvent(Parameters params) { // this.params = params; // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraEncoderView.java // public class GLCameraEncoderView extends GLCameraView { // private static final String TAG = "GLCameraEncoderView"; // // protected CameraEncoder mCameraEncoder; // // public GLCameraEncoderView(Context context) { // super(context); // } // // public GLCameraEncoderView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public void setCameraEncoder(CameraEncoder encoder){ // mCameraEncoder = encoder; // setCamera(mCameraEncoder.getCamera()); // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // if(mScaleGestureDetector != null){ // mScaleGestureDetector.onTouchEvent(ev); // } // if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_MOVE)){ // mCameraEncoder.handleCameraPreviewTouchEvent(ev); // }else if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_DOWN)){ // mCameraEncoder.handleCameraPreviewTouchEvent(ev); // } // return true; // } // // // } // // Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraView.java // public class GLCameraView extends GLSurfaceView { // private static final String TAG = "GLCameraView"; // // protected ScaleGestureDetector mScaleGestureDetector; // private Camera mCamera; // private int mMaxZoom; // // public GLCameraView(Context context) { // super(context); // init(context); // } // // public GLCameraView(Context context, AttributeSet attrs) { // super(context, attrs); // init(context); // } // // private void init(Context context){ // mMaxZoom = 0; // // } // // public void setCamera(Camera camera){ // mCamera = camera; // Camera.Parameters camParams = mCamera.getParameters(); // if(camParams.isZoomSupported()){ // mMaxZoom = camParams.getMaxZoom(); // mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener); // } // } // // public void releaseCamera(){ // mCamera = null; // mScaleGestureDetector = null; // } // // private ScaleGestureDetector.SimpleOnScaleGestureListener mScaleListener = new ScaleGestureDetector.SimpleOnScaleGestureListener(){ // // int mZoomWhenScaleBegan = 0; // int mCurrentZoom = 0; // // @Override // public boolean onScale(ScaleGestureDetector detector) { // if(mCamera != null){ // Camera.Parameters params = mCamera.getParameters(); // mCurrentZoom = (int) (mZoomWhenScaleBegan + (mMaxZoom * (detector.getScaleFactor() - 1))); // mCurrentZoom = Math.min(mCurrentZoom, mMaxZoom); // mCurrentZoom = Math.max(0, mCurrentZoom); // params.setZoom(mCurrentZoom); // mCamera.setParameters(params); // } // // return false; // } // // @Override // public boolean onScaleBegin(ScaleGestureDetector detector) { // mZoomWhenScaleBegan = mCamera.getParameters().getZoom(); // return true; // } // // @Override // public void onScaleEnd(ScaleGestureDetector detector) { // } // }; // // @Override // public boolean onTouchEvent(MotionEvent ev) { // if(mScaleGestureDetector != null){ // if(!mScaleGestureDetector.onTouchEvent(ev)){ // // No scale gesture detected // // } // } // return true; // } // // // } // Path: sdk/src/main/java/io/kickflip/sdk/av/CameraEncoder.java import android.graphics.SurfaceTexture; import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.opengl.EGLContext; import android.opengl.GLSurfaceView; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.Trace; import android.util.Log; import android.view.MotionEvent; import com.google.common.eventbus.EventBus; import java.io.File; import java.io.IOException; import java.lang.ref.WeakReference; import java.util.List; import io.kickflip.sdk.event.CameraOpenedEvent; import io.kickflip.sdk.view.GLCameraEncoderView; import io.kickflip.sdk.view.GLCameraView; import static com.google.common.base.Preconditions.checkNotNull; Log.i(TAG, "Changed flash successfully!"); } } catch (RuntimeException e) { Log.d(TAG, "Unable to set flash" + e); } } } /** * @param flashModes * @param flashMode * @return returns true if flashModes aren't null AND they contain the flashMode, * else returns false */ private boolean isValidFlashMode(List<String> flashModes, String flashMode) { if (flashModes != null && flashModes.contains(flashMode)) { return true; } return false; } /** * @return returns the flash mode set in the camera */ public String getFlashMode() { return (mDesiredFlash != null) ? mDesiredFlash : mCurrentFlash; } private void postCameraOpenedEvent(Parameters params) { if (mEventBus != null) {
mEventBus.post(new CameraOpenedEvent(params));
Kickflip/kickflip-android-sdk
sdk/src/main/java/io/kickflip/sdk/av/SessionConfig.java
// Path: sdk/src/main/java/io/kickflip/sdk/api/json/Stream.java // public class Stream extends Response implements Comparable<Stream>, Serializable { // // @Key("stream_id") // private String mStreamId; // // @Key("stream_type") // private String mStreamType; // // @Key("chat_url") // private String mChatUrl; // // @Key("upload_url") // private String mUploadUrl; // // @Key("stream_url") // private String mStreamUrl; // // @Key("kickflip_url") // private String mKickflipUrl; // // @Key("lat") // private double mLatitude; // // @Key("lon") // private double mLongitude; // // @Key("city") // private String mCity; // // @Key("state") // private String mState; // // @Key("country") // private String mCountry; // // @Key("private") // private boolean mPrivate; // // @Key("title") // private String mTitle; // // @Key("description") // private String mDescription; // // @Key("extra_info") // private String mExtraInfo; // // @Key("thumbnail_url") // private String mThumbnailUrl; // // @Key("time_started") // private String mTimeStarted; // // @Key("length") // private int mLength; // // @Key("user_username") // private String mOwnerName; // // @Key("user_avatar") // private String mOwnerAvatar; // // @Key("deleted") // private boolean mDeleted; // // public boolean isDeleted() { // return mDeleted; // } // // public void setDeleted(boolean deleted) { // mDeleted = deleted; // } // // public String getOwnerName() { // return mOwnerName; // } // // public String getOwnerAvatar() { // return mOwnerAvatar; // } // // public String getThumbnailUrl() { // return mThumbnailUrl; // } // // public void setThumbnailUrl(String url) { // mThumbnailUrl = url; // } // // public String getStreamId() { // return mStreamId; // } // // public String getStreamType() { // return mStreamType; // } // // public String getChatUrl() { // return mChatUrl; // } // // public String getUploadUrl() { // return mUploadUrl; // } // // public String getStreamUrl() { // return mStreamUrl; // } // // public String getKickflipUrl() { // return mKickflipUrl; // } // // public String getTimeStarted() { // return mTimeStarted; // } // // public int getLengthInSeconds() { // return mLength; // } // // public Map getExtraInfo() { // if (mExtraInfo != null && !mExtraInfo.equals("")) { // return new Gson().fromJson(mExtraInfo, Map.class); // } // return null; // } // // public void setExtraInfo(Map mExtraInfo) { // this.mExtraInfo = new Gson().toJson(mExtraInfo); // } // // public double getLatitude() { // return mLatitude; // } // // public void setLatitude(double mLatitude) { // this.mLatitude = mLatitude; // } // // public double getLongitude() { // return mLongitude; // } // // public void setLongitude(double mLongitude) { // this.mLongitude = mLongitude; // } // // public String getCity() { // return mCity; // } // // public void setCity(String mCity) { // this.mCity = mCity; // } // // public String getState() { // return mState; // } // // public void setState(String mState) { // this.mState = mState; // } // // public String getCountry() { // return mCountry; // } // // public void setCountry(String mCountry) { // this.mCountry = mCountry; // } // // public boolean isPrivate() { // return mPrivate; // } // // public void setIsPrivate(boolean mPrivate) { // this.mPrivate = mPrivate; // } // // public String getTitle() { // return mTitle; // } // // public void setTitle(String mTitle) { // this.mTitle = mTitle; // } // // public String getDescription() { // return mDescription; // } // // public void setDescription(String mDescription) { // this.mDescription = mDescription; // } // // @Override // public int compareTo(Stream another) { // return another.getTimeStarted().compareTo(getTimeStarted()); // } // // @Override // public String toString() { // return new GsonBuilder().setPrettyPrinting().create().toJson(this); // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/Kickflip.java // public static boolean isKitKat() { // return Build.VERSION.SDK_INT >= 19; // }
import android.os.Environment; import java.io.File; import java.util.Map; import java.util.UUID; import io.kickflip.sdk.api.json.Stream; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static io.kickflip.sdk.Kickflip.isKitKat;
package io.kickflip.sdk.av; /** * Configuration information for a Broadcasting or Recording session. * Includes meta data, video + audio encoding * and muxing parameters */ public class SessionConfig { private final VideoEncoderConfig mVideoConfig; private final AudioEncoderConfig mAudioConfig; private File mOutputDirectory; private final UUID mUUID; private Muxer mMuxer;
// Path: sdk/src/main/java/io/kickflip/sdk/api/json/Stream.java // public class Stream extends Response implements Comparable<Stream>, Serializable { // // @Key("stream_id") // private String mStreamId; // // @Key("stream_type") // private String mStreamType; // // @Key("chat_url") // private String mChatUrl; // // @Key("upload_url") // private String mUploadUrl; // // @Key("stream_url") // private String mStreamUrl; // // @Key("kickflip_url") // private String mKickflipUrl; // // @Key("lat") // private double mLatitude; // // @Key("lon") // private double mLongitude; // // @Key("city") // private String mCity; // // @Key("state") // private String mState; // // @Key("country") // private String mCountry; // // @Key("private") // private boolean mPrivate; // // @Key("title") // private String mTitle; // // @Key("description") // private String mDescription; // // @Key("extra_info") // private String mExtraInfo; // // @Key("thumbnail_url") // private String mThumbnailUrl; // // @Key("time_started") // private String mTimeStarted; // // @Key("length") // private int mLength; // // @Key("user_username") // private String mOwnerName; // // @Key("user_avatar") // private String mOwnerAvatar; // // @Key("deleted") // private boolean mDeleted; // // public boolean isDeleted() { // return mDeleted; // } // // public void setDeleted(boolean deleted) { // mDeleted = deleted; // } // // public String getOwnerName() { // return mOwnerName; // } // // public String getOwnerAvatar() { // return mOwnerAvatar; // } // // public String getThumbnailUrl() { // return mThumbnailUrl; // } // // public void setThumbnailUrl(String url) { // mThumbnailUrl = url; // } // // public String getStreamId() { // return mStreamId; // } // // public String getStreamType() { // return mStreamType; // } // // public String getChatUrl() { // return mChatUrl; // } // // public String getUploadUrl() { // return mUploadUrl; // } // // public String getStreamUrl() { // return mStreamUrl; // } // // public String getKickflipUrl() { // return mKickflipUrl; // } // // public String getTimeStarted() { // return mTimeStarted; // } // // public int getLengthInSeconds() { // return mLength; // } // // public Map getExtraInfo() { // if (mExtraInfo != null && !mExtraInfo.equals("")) { // return new Gson().fromJson(mExtraInfo, Map.class); // } // return null; // } // // public void setExtraInfo(Map mExtraInfo) { // this.mExtraInfo = new Gson().toJson(mExtraInfo); // } // // public double getLatitude() { // return mLatitude; // } // // public void setLatitude(double mLatitude) { // this.mLatitude = mLatitude; // } // // public double getLongitude() { // return mLongitude; // } // // public void setLongitude(double mLongitude) { // this.mLongitude = mLongitude; // } // // public String getCity() { // return mCity; // } // // public void setCity(String mCity) { // this.mCity = mCity; // } // // public String getState() { // return mState; // } // // public void setState(String mState) { // this.mState = mState; // } // // public String getCountry() { // return mCountry; // } // // public void setCountry(String mCountry) { // this.mCountry = mCountry; // } // // public boolean isPrivate() { // return mPrivate; // } // // public void setIsPrivate(boolean mPrivate) { // this.mPrivate = mPrivate; // } // // public String getTitle() { // return mTitle; // } // // public void setTitle(String mTitle) { // this.mTitle = mTitle; // } // // public String getDescription() { // return mDescription; // } // // public void setDescription(String mDescription) { // this.mDescription = mDescription; // } // // @Override // public int compareTo(Stream another) { // return another.getTimeStarted().compareTo(getTimeStarted()); // } // // @Override // public String toString() { // return new GsonBuilder().setPrettyPrinting().create().toJson(this); // } // // } // // Path: sdk/src/main/java/io/kickflip/sdk/Kickflip.java // public static boolean isKitKat() { // return Build.VERSION.SDK_INT >= 19; // } // Path: sdk/src/main/java/io/kickflip/sdk/av/SessionConfig.java import android.os.Environment; import java.io.File; import java.util.Map; import java.util.UUID; import io.kickflip.sdk.api.json.Stream; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static io.kickflip.sdk.Kickflip.isKitKat; package io.kickflip.sdk.av; /** * Configuration information for a Broadcasting or Recording session. * Includes meta data, video + audio encoding * and muxing parameters */ public class SessionConfig { private final VideoEncoderConfig mVideoConfig; private final AudioEncoderConfig mAudioConfig; private File mOutputDirectory; private final UUID mUUID; private Muxer mMuxer;
private Stream mStream;
Kickflip/kickflip-android-sdk
sdk/src/main/java/io/kickflip/sdk/activity/ImmersiveActivity.java
// Path: sdk/src/main/java/io/kickflip/sdk/Kickflip.java // public static boolean isKitKat() { // return Build.VERSION.SDK_INT >= 19; // }
import android.annotation.TargetApi; import android.app.Activity; import android.os.Build; import android.os.Bundle; import android.view.View; import android.view.Window; import android.view.WindowManager; import static io.kickflip.sdk.Kickflip.isKitKat;
package io.kickflip.sdk.activity; /** * @hide */ public abstract class ImmersiveActivity extends Activity { public static final String TAG = "ImmersiveActivity"; private boolean mUseImmersiveMode = true; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); } @Override protected void onResume() { super.onResume(); hideSystemUi(); } /** * If true, use Android's Immersive Mode. If false * use the "Lean Back" experience. * @see <a href="https://developer.android.com/design/patterns/fullscreen.html">Android Full Screen docs</a> * @param useIt */ public void setUseImmersiveMode(boolean useIt) { mUseImmersiveMode = useIt; } private void hideSystemUi() {
// Path: sdk/src/main/java/io/kickflip/sdk/Kickflip.java // public static boolean isKitKat() { // return Build.VERSION.SDK_INT >= 19; // } // Path: sdk/src/main/java/io/kickflip/sdk/activity/ImmersiveActivity.java import android.annotation.TargetApi; import android.app.Activity; import android.os.Build; import android.os.Bundle; import android.view.View; import android.view.Window; import android.view.WindowManager; import static io.kickflip.sdk.Kickflip.isKitKat; package io.kickflip.sdk.activity; /** * @hide */ public abstract class ImmersiveActivity extends Activity { public static final String TAG = "ImmersiveActivity"; private boolean mUseImmersiveMode = true; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); } @Override protected void onResume() { super.onResume(); hideSystemUi(); } /** * If true, use Android's Immersive Mode. If false * use the "Lean Back" experience. * @see <a href="https://developer.android.com/design/patterns/fullscreen.html">Android Full Screen docs</a> * @param useIt */ public void setUseImmersiveMode(boolean useIt) { mUseImmersiveMode = useIt; } private void hideSystemUi() {
if (!isKitKat() || !mUseImmersiveMode) {
Kickflip/kickflip-android-sdk
sdk/src/main/java/io/kickflip/sdk/av/Muxer.java
// Path: sdk/src/main/java/io/kickflip/sdk/event/MuxerFinishedEvent.java // public class MuxerFinishedEvent { // }
import android.media.MediaCodec; import android.media.MediaFormat; import android.os.Build; import android.util.Log; import com.google.common.eventbus.EventBus; import java.nio.ByteBuffer; import io.kickflip.sdk.event.MuxerFinishedEvent; import static com.google.common.base.Preconditions.checkNotNull;
* e.g /sdcard/app/uuid/index.m3u8 * @return */ public String getOutputPath(){ return mOutputPath; } /** * Adds the specified track and returns the track index * * @param trackFormat MediaFormat of the track to add. Gotten from MediaCodec#dequeueOutputBuffer * when returned status is INFO_OUTPUT_FORMAT_CHANGED * @return index of track in output file */ public int addTrack(MediaFormat trackFormat){ mNumTracks++; return mNumTracks - 1; } /** * Called by the hosting Encoder * to notify the Muxer that it should no * longer assume the Encoder resources are available. * */ public void onEncoderReleased(int trackIndex){ } public void release(){ if(mEventBus != null)
// Path: sdk/src/main/java/io/kickflip/sdk/event/MuxerFinishedEvent.java // public class MuxerFinishedEvent { // } // Path: sdk/src/main/java/io/kickflip/sdk/av/Muxer.java import android.media.MediaCodec; import android.media.MediaFormat; import android.os.Build; import android.util.Log; import com.google.common.eventbus.EventBus; import java.nio.ByteBuffer; import io.kickflip.sdk.event.MuxerFinishedEvent; import static com.google.common.base.Preconditions.checkNotNull; * e.g /sdcard/app/uuid/index.m3u8 * @return */ public String getOutputPath(){ return mOutputPath; } /** * Adds the specified track and returns the track index * * @param trackFormat MediaFormat of the track to add. Gotten from MediaCodec#dequeueOutputBuffer * when returned status is INFO_OUTPUT_FORMAT_CHANGED * @return index of track in output file */ public int addTrack(MediaFormat trackFormat){ mNumTracks++; return mNumTracks - 1; } /** * Called by the hosting Encoder * to notify the Muxer that it should no * longer assume the Encoder resources are available. * */ public void onEncoderReleased(int trackIndex){ } public void release(){ if(mEventBus != null)
mEventBus.post(new MuxerFinishedEvent());
schaloner/deadbolt
app/controllers/deadbolt/RestrictedResourcesHandler.java
// Path: app/models/deadbolt/AccessResult.java // public enum AccessResult // { // ALLOWED, // DENIED, // NOT_SPECIFIED // }
import models.deadbolt.AccessResult; import java.util.List; import java.util.Map;
/* * Copyright 2010-2011 Steve Chaloner * * 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.deadbolt; /** * @author Steve Chaloner (steve@objectify.be) */ public interface RestrictedResourcesHandler { /** * Check the access of someone, typically the current user, for the named resource. * * <ul> * <li>If {@link AccessResult#NOT_SPECIFIED} is returned and * {@link controllers.deadbolt.RestrictedResource#staticFallback()} is false, access is denied.</li> * <li>If {@link AccessResult#NOT_SPECIFIED} is returned and * {@link controllers.deadbolt.RestrictedResource#staticFallback()} is true, any further Restrict or * Restrictions annotations are processed. Note that if no Restrict or Restrictions annotations are present, * access will be allowed.</li> * </ul> * * @param resourceNames the names of the resource * @param resourceParameters additional information on the resource * @return {@link AccessResult#ALLOWED} if access is permitted. {@link AccessResult#DENIED} if access is denied. * {@link AccessResult#NOT_SPECIFIED} if access is not specified. */
// Path: app/models/deadbolt/AccessResult.java // public enum AccessResult // { // ALLOWED, // DENIED, // NOT_SPECIFIED // } // Path: app/controllers/deadbolt/RestrictedResourcesHandler.java import models.deadbolt.AccessResult; import java.util.List; import java.util.Map; /* * Copyright 2010-2011 Steve Chaloner * * 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.deadbolt; /** * @author Steve Chaloner (steve@objectify.be) */ public interface RestrictedResourcesHandler { /** * Check the access of someone, typically the current user, for the named resource. * * <ul> * <li>If {@link AccessResult#NOT_SPECIFIED} is returned and * {@link controllers.deadbolt.RestrictedResource#staticFallback()} is false, access is denied.</li> * <li>If {@link AccessResult#NOT_SPECIFIED} is returned and * {@link controllers.deadbolt.RestrictedResource#staticFallback()} is true, any further Restrict or * Restrictions annotations are processed. Note that if no Restrict or Restrictions annotations are present, * access will be allowed.</li> * </ul> * * @param resourceNames the names of the resource * @param resourceParameters additional information on the resource * @return {@link AccessResult#ALLOWED} if access is permitted. {@link AccessResult#DENIED} if access is denied. * {@link AccessResult#NOT_SPECIFIED} if access is not specified. */
AccessResult checkAccess(List<String> resourceNames,
schaloner/deadbolt
samples-and-tests/integration-with-secure/app/models/User.java
// Path: app/models/deadbolt/Role.java // public interface Role // { // /** // * The name of the role. // * // * @return the role name // */ // String getRoleName(); // } // // Path: app/models/deadbolt/RoleHolder.java // public interface RoleHolder // { // /** // * A list of {@link Role}s held by the role holder. // * // * @return a list of roles // */ // List<? extends Role> getRoles(); // }
import models.deadbolt.Role; import models.deadbolt.RoleHolder; import play.data.validation.Required; import play.db.jpa.Model; import javax.persistence.Entity; import javax.persistence.ManyToOne; import java.util.Arrays; import java.util.List;
/* * Copyright 2010-2011 Steve Chaloner * * 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 models; /** * @author Steve Chaloner (steve@objectify.be) */ @Entity public class User extends Model implements RoleHolder { @Required public String userName; public String fullName; @Required @ManyToOne public ApplicationRole role; public User(String userName, String fullName, ApplicationRole role) { this.userName = userName; this.fullName = fullName; this.role = role; } public static User getByUserName(String userName) { return find("byUserName", userName).first(); } @Override public String toString() { return this.userName; }
// Path: app/models/deadbolt/Role.java // public interface Role // { // /** // * The name of the role. // * // * @return the role name // */ // String getRoleName(); // } // // Path: app/models/deadbolt/RoleHolder.java // public interface RoleHolder // { // /** // * A list of {@link Role}s held by the role holder. // * // * @return a list of roles // */ // List<? extends Role> getRoles(); // } // Path: samples-and-tests/integration-with-secure/app/models/User.java import models.deadbolt.Role; import models.deadbolt.RoleHolder; import play.data.validation.Required; import play.db.jpa.Model; import javax.persistence.Entity; import javax.persistence.ManyToOne; import java.util.Arrays; import java.util.List; /* * Copyright 2010-2011 Steve Chaloner * * 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 models; /** * @author Steve Chaloner (steve@objectify.be) */ @Entity public class User extends Model implements RoleHolder { @Required public String userName; public String fullName; @Required @ManyToOne public ApplicationRole role; public User(String userName, String fullName, ApplicationRole role) { this.userName = userName; this.fullName = fullName; this.role = role; } public static User getByUserName(String userName) { return find("byUserName", userName).first(); } @Override public String toString() { return this.userName; }
public List<? extends Role> getRoles()