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 |
|---|---|---|---|---|---|---|
igd-geo/mongomvcc | src/main/java/de/fhg/igd/mongomvcc/impl/MongoDBVLargeCollection.java | // Path: src/main/java/de/fhg/igd/mongomvcc/VCounter.java
// public interface VCounter {
// /**
// * A thread safe method to get the next unique id
// * @return a unique id
// */
// public long getNextId();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VLargeCollection.java
// public interface VLargeCollection extends VCollection {
// //nothing to add yet
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/Filter.java
// public interface Filter<T> {
// /**
// * Checks if the given element passes the filter
// * @param t the element
// * @return true if the element passes the filter, false otherwise
// */
// boolean filter(T t);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/TransformingIterator.java
// public abstract class TransformingIterator<I, O> implements Iterator<O> {
// /**
// * The wrapped iterator
// */
// private final Iterator<I> _delegate;
//
// /**
// * Constructs a new transforming iterator
// * @param delegate the iterator to wrap
// */
// public TransformingIterator(Iterator<I> delegate) {
// _delegate = delegate;
// }
//
// @Override
// public boolean hasNext() {
// return _delegate.hasNext();
// }
//
// @Override
// public O next() {
// return transform(_delegate.next());
// }
//
// /**
// * Transforms an element
// * @param input the element
// * @return the transformed element
// */
// abstract protected O transform(I input);
//
// @Override
// public void remove() {
// _delegate.remove();
// }
// }
| import de.fhg.igd.mongomvcc.helper.Filter;
import de.fhg.igd.mongomvcc.helper.TransformingIterator;
import java.io.InputStream;
import java.util.Iterator;
import java.util.Map;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.gridfs.GridFS;
import com.mongodb.gridfs.GridFSInputFile;
import de.fhg.igd.mongomvcc.VCounter;
import de.fhg.igd.mongomvcc.VCursor;
import de.fhg.igd.mongomvcc.VLargeCollection; | // This file is part of MongoMVCC.
//
// Copyright (c) 2012 Fraunhofer IGD
//
// MongoMVCC 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, either version 3 of the
// License, or (at your option) any later version.
//
// MongoMVCC 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 MongoMVCC. If not, see <http://www.gnu.org/licenses/>.
package de.fhg.igd.mongomvcc.impl;
/**
* Saves primitive byte arrays and {@link InputStream}s in MongoDB's
* {@link GridFS}.
* @author Michel Kraemer
*/
public class MongoDBVLargeCollection extends MongoDBVCollection implements
VLargeCollection {
/**
* A cursor which calls {@link AccessStrategy#onResolve(Map)} for
* each object
*/
private class MongoDBVLargeCursor extends MongoDBVCursor {
/**
* @see MongoDBVCursor#MongoDBVCursor(DBCursor, Filter)
*/
public MongoDBVLargeCursor(DBCursor delegate, Filter<DBObject> filter) {
super(delegate, filter);
}
@Override
public Iterator<Map<String, Object>> iterator() {
DefaultConvertStrategy cs = new DefaultConvertStrategy(_gridFS, getCounter());
_accessStrategy.setConvertStrategy(cs); | // Path: src/main/java/de/fhg/igd/mongomvcc/VCounter.java
// public interface VCounter {
// /**
// * A thread safe method to get the next unique id
// * @return a unique id
// */
// public long getNextId();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VLargeCollection.java
// public interface VLargeCollection extends VCollection {
// //nothing to add yet
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/Filter.java
// public interface Filter<T> {
// /**
// * Checks if the given element passes the filter
// * @param t the element
// * @return true if the element passes the filter, false otherwise
// */
// boolean filter(T t);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/TransformingIterator.java
// public abstract class TransformingIterator<I, O> implements Iterator<O> {
// /**
// * The wrapped iterator
// */
// private final Iterator<I> _delegate;
//
// /**
// * Constructs a new transforming iterator
// * @param delegate the iterator to wrap
// */
// public TransformingIterator(Iterator<I> delegate) {
// _delegate = delegate;
// }
//
// @Override
// public boolean hasNext() {
// return _delegate.hasNext();
// }
//
// @Override
// public O next() {
// return transform(_delegate.next());
// }
//
// /**
// * Transforms an element
// * @param input the element
// * @return the transformed element
// */
// abstract protected O transform(I input);
//
// @Override
// public void remove() {
// _delegate.remove();
// }
// }
// Path: src/main/java/de/fhg/igd/mongomvcc/impl/MongoDBVLargeCollection.java
import de.fhg.igd.mongomvcc.helper.Filter;
import de.fhg.igd.mongomvcc.helper.TransformingIterator;
import java.io.InputStream;
import java.util.Iterator;
import java.util.Map;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.gridfs.GridFS;
import com.mongodb.gridfs.GridFSInputFile;
import de.fhg.igd.mongomvcc.VCounter;
import de.fhg.igd.mongomvcc.VCursor;
import de.fhg.igd.mongomvcc.VLargeCollection;
// This file is part of MongoMVCC.
//
// Copyright (c) 2012 Fraunhofer IGD
//
// MongoMVCC 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, either version 3 of the
// License, or (at your option) any later version.
//
// MongoMVCC 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 MongoMVCC. If not, see <http://www.gnu.org/licenses/>.
package de.fhg.igd.mongomvcc.impl;
/**
* Saves primitive byte arrays and {@link InputStream}s in MongoDB's
* {@link GridFS}.
* @author Michel Kraemer
*/
public class MongoDBVLargeCollection extends MongoDBVCollection implements
VLargeCollection {
/**
* A cursor which calls {@link AccessStrategy#onResolve(Map)} for
* each object
*/
private class MongoDBVLargeCursor extends MongoDBVCursor {
/**
* @see MongoDBVCursor#MongoDBVCursor(DBCursor, Filter)
*/
public MongoDBVLargeCursor(DBCursor delegate, Filter<DBObject> filter) {
super(delegate, filter);
}
@Override
public Iterator<Map<String, Object>> iterator() {
DefaultConvertStrategy cs = new DefaultConvertStrategy(_gridFS, getCounter());
_accessStrategy.setConvertStrategy(cs); | return new TransformingIterator<Map<String, Object>, Map<String, Object>>(super.iterator()) { |
igd-geo/mongomvcc | src/main/java/de/fhg/igd/mongomvcc/impl/MongoDBVLargeCollection.java | // Path: src/main/java/de/fhg/igd/mongomvcc/VCounter.java
// public interface VCounter {
// /**
// * A thread safe method to get the next unique id
// * @return a unique id
// */
// public long getNextId();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VLargeCollection.java
// public interface VLargeCollection extends VCollection {
// //nothing to add yet
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/Filter.java
// public interface Filter<T> {
// /**
// * Checks if the given element passes the filter
// * @param t the element
// * @return true if the element passes the filter, false otherwise
// */
// boolean filter(T t);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/TransformingIterator.java
// public abstract class TransformingIterator<I, O> implements Iterator<O> {
// /**
// * The wrapped iterator
// */
// private final Iterator<I> _delegate;
//
// /**
// * Constructs a new transforming iterator
// * @param delegate the iterator to wrap
// */
// public TransformingIterator(Iterator<I> delegate) {
// _delegate = delegate;
// }
//
// @Override
// public boolean hasNext() {
// return _delegate.hasNext();
// }
//
// @Override
// public O next() {
// return transform(_delegate.next());
// }
//
// /**
// * Transforms an element
// * @param input the element
// * @return the transformed element
// */
// abstract protected O transform(I input);
//
// @Override
// public void remove() {
// _delegate.remove();
// }
// }
| import de.fhg.igd.mongomvcc.helper.Filter;
import de.fhg.igd.mongomvcc.helper.TransformingIterator;
import java.io.InputStream;
import java.util.Iterator;
import java.util.Map;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.gridfs.GridFS;
import com.mongodb.gridfs.GridFSInputFile;
import de.fhg.igd.mongomvcc.VCounter;
import de.fhg.igd.mongomvcc.VCursor;
import de.fhg.igd.mongomvcc.VLargeCollection; | // This file is part of MongoMVCC.
//
// Copyright (c) 2012 Fraunhofer IGD
//
// MongoMVCC 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, either version 3 of the
// License, or (at your option) any later version.
//
// MongoMVCC 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 MongoMVCC. If not, see <http://www.gnu.org/licenses/>.
package de.fhg.igd.mongomvcc.impl;
/**
* Saves primitive byte arrays and {@link InputStream}s in MongoDB's
* {@link GridFS}.
* @author Michel Kraemer
*/
public class MongoDBVLargeCollection extends MongoDBVCollection implements
VLargeCollection {
/**
* A cursor which calls {@link AccessStrategy#onResolve(Map)} for
* each object
*/
private class MongoDBVLargeCursor extends MongoDBVCursor {
/**
* @see MongoDBVCursor#MongoDBVCursor(DBCursor, Filter)
*/
public MongoDBVLargeCursor(DBCursor delegate, Filter<DBObject> filter) {
super(delegate, filter);
}
@Override
public Iterator<Map<String, Object>> iterator() {
DefaultConvertStrategy cs = new DefaultConvertStrategy(_gridFS, getCounter());
_accessStrategy.setConvertStrategy(cs);
return new TransformingIterator<Map<String, Object>, Map<String, Object>>(super.iterator()) {
@Override
protected Map<String, Object> transform(Map<String, Object> input) {
_accessStrategy.onResolve(input);
return input;
}
};
}
}
/**
* The attribute that references a GridFS file's parent object
*/
private static final String PARENT = "parent";
/**
* The MongoDB GridFS storing binary data
*/
private final GridFS _gridFS;
/**
* A strategy used to access large objects
*/
private final AccessStrategy _accessStrategy;
/**
* Creates a new MongoDBVLargeCollection.
* @param delegate the actual MongoDB collection
* @param gridFS the MongoDB GridFS storing binary data
* @param branch the branch currently checked out
* @param counter a counter to generate unique IDs
*/
public MongoDBVLargeCollection(DBCollection delegate, GridFS gridFS, | // Path: src/main/java/de/fhg/igd/mongomvcc/VCounter.java
// public interface VCounter {
// /**
// * A thread safe method to get the next unique id
// * @return a unique id
// */
// public long getNextId();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VLargeCollection.java
// public interface VLargeCollection extends VCollection {
// //nothing to add yet
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/Filter.java
// public interface Filter<T> {
// /**
// * Checks if the given element passes the filter
// * @param t the element
// * @return true if the element passes the filter, false otherwise
// */
// boolean filter(T t);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/TransformingIterator.java
// public abstract class TransformingIterator<I, O> implements Iterator<O> {
// /**
// * The wrapped iterator
// */
// private final Iterator<I> _delegate;
//
// /**
// * Constructs a new transforming iterator
// * @param delegate the iterator to wrap
// */
// public TransformingIterator(Iterator<I> delegate) {
// _delegate = delegate;
// }
//
// @Override
// public boolean hasNext() {
// return _delegate.hasNext();
// }
//
// @Override
// public O next() {
// return transform(_delegate.next());
// }
//
// /**
// * Transforms an element
// * @param input the element
// * @return the transformed element
// */
// abstract protected O transform(I input);
//
// @Override
// public void remove() {
// _delegate.remove();
// }
// }
// Path: src/main/java/de/fhg/igd/mongomvcc/impl/MongoDBVLargeCollection.java
import de.fhg.igd.mongomvcc.helper.Filter;
import de.fhg.igd.mongomvcc.helper.TransformingIterator;
import java.io.InputStream;
import java.util.Iterator;
import java.util.Map;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.gridfs.GridFS;
import com.mongodb.gridfs.GridFSInputFile;
import de.fhg.igd.mongomvcc.VCounter;
import de.fhg.igd.mongomvcc.VCursor;
import de.fhg.igd.mongomvcc.VLargeCollection;
// This file is part of MongoMVCC.
//
// Copyright (c) 2012 Fraunhofer IGD
//
// MongoMVCC 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, either version 3 of the
// License, or (at your option) any later version.
//
// MongoMVCC 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 MongoMVCC. If not, see <http://www.gnu.org/licenses/>.
package de.fhg.igd.mongomvcc.impl;
/**
* Saves primitive byte arrays and {@link InputStream}s in MongoDB's
* {@link GridFS}.
* @author Michel Kraemer
*/
public class MongoDBVLargeCollection extends MongoDBVCollection implements
VLargeCollection {
/**
* A cursor which calls {@link AccessStrategy#onResolve(Map)} for
* each object
*/
private class MongoDBVLargeCursor extends MongoDBVCursor {
/**
* @see MongoDBVCursor#MongoDBVCursor(DBCursor, Filter)
*/
public MongoDBVLargeCursor(DBCursor delegate, Filter<DBObject> filter) {
super(delegate, filter);
}
@Override
public Iterator<Map<String, Object>> iterator() {
DefaultConvertStrategy cs = new DefaultConvertStrategy(_gridFS, getCounter());
_accessStrategy.setConvertStrategy(cs);
return new TransformingIterator<Map<String, Object>, Map<String, Object>>(super.iterator()) {
@Override
protected Map<String, Object> transform(Map<String, Object> input) {
_accessStrategy.onResolve(input);
return input;
}
};
}
}
/**
* The attribute that references a GridFS file's parent object
*/
private static final String PARENT = "parent";
/**
* The MongoDB GridFS storing binary data
*/
private final GridFS _gridFS;
/**
* A strategy used to access large objects
*/
private final AccessStrategy _accessStrategy;
/**
* Creates a new MongoDBVLargeCollection.
* @param delegate the actual MongoDB collection
* @param gridFS the MongoDB GridFS storing binary data
* @param branch the branch currently checked out
* @param counter a counter to generate unique IDs
*/
public MongoDBVLargeCollection(DBCollection delegate, GridFS gridFS, | MongoDBVBranch branch, VCounter counter) { |
igd-geo/mongomvcc | src/main/java/de/fhg/igd/mongomvcc/impl/MongoDBVLargeCollection.java | // Path: src/main/java/de/fhg/igd/mongomvcc/VCounter.java
// public interface VCounter {
// /**
// * A thread safe method to get the next unique id
// * @return a unique id
// */
// public long getNextId();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VLargeCollection.java
// public interface VLargeCollection extends VCollection {
// //nothing to add yet
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/Filter.java
// public interface Filter<T> {
// /**
// * Checks if the given element passes the filter
// * @param t the element
// * @return true if the element passes the filter, false otherwise
// */
// boolean filter(T t);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/TransformingIterator.java
// public abstract class TransformingIterator<I, O> implements Iterator<O> {
// /**
// * The wrapped iterator
// */
// private final Iterator<I> _delegate;
//
// /**
// * Constructs a new transforming iterator
// * @param delegate the iterator to wrap
// */
// public TransformingIterator(Iterator<I> delegate) {
// _delegate = delegate;
// }
//
// @Override
// public boolean hasNext() {
// return _delegate.hasNext();
// }
//
// @Override
// public O next() {
// return transform(_delegate.next());
// }
//
// /**
// * Transforms an element
// * @param input the element
// * @return the transformed element
// */
// abstract protected O transform(I input);
//
// @Override
// public void remove() {
// _delegate.remove();
// }
// }
| import de.fhg.igd.mongomvcc.helper.Filter;
import de.fhg.igd.mongomvcc.helper.TransformingIterator;
import java.io.InputStream;
import java.util.Iterator;
import java.util.Map;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.gridfs.GridFS;
import com.mongodb.gridfs.GridFSInputFile;
import de.fhg.igd.mongomvcc.VCounter;
import de.fhg.igd.mongomvcc.VCursor;
import de.fhg.igd.mongomvcc.VLargeCollection; | * @param delegate the actual MongoDB collection
* @param gridFS the MongoDB GridFS storing binary data
* @param branch the branch currently checked out
* @param counter a counter to generate unique IDs
* @param accessStrategy the strategy that should be used to access large objects
*/
public MongoDBVLargeCollection(DBCollection delegate, GridFS gridFS,
MongoDBVBranch branch, VCounter counter, AccessStrategy accessStrategy) {
super(delegate, branch, counter);
_gridFS = gridFS;
_accessStrategy = accessStrategy;
}
@Override
public void insert(Map<String, Object> obj) {
DefaultConvertStrategy cs = new DefaultConvertStrategy(_gridFS, getCounter());
_accessStrategy.setConvertStrategy(cs);
_accessStrategy.onInsert(obj);
//save original object
super.insert(obj);
//save GridFS files
for (GridFSInputFile file : cs.getConvertedFiles()) {
file.put(PARENT, obj.get(OID));
file.save();
}
}
@Override | // Path: src/main/java/de/fhg/igd/mongomvcc/VCounter.java
// public interface VCounter {
// /**
// * A thread safe method to get the next unique id
// * @return a unique id
// */
// public long getNextId();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VLargeCollection.java
// public interface VLargeCollection extends VCollection {
// //nothing to add yet
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/Filter.java
// public interface Filter<T> {
// /**
// * Checks if the given element passes the filter
// * @param t the element
// * @return true if the element passes the filter, false otherwise
// */
// boolean filter(T t);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/TransformingIterator.java
// public abstract class TransformingIterator<I, O> implements Iterator<O> {
// /**
// * The wrapped iterator
// */
// private final Iterator<I> _delegate;
//
// /**
// * Constructs a new transforming iterator
// * @param delegate the iterator to wrap
// */
// public TransformingIterator(Iterator<I> delegate) {
// _delegate = delegate;
// }
//
// @Override
// public boolean hasNext() {
// return _delegate.hasNext();
// }
//
// @Override
// public O next() {
// return transform(_delegate.next());
// }
//
// /**
// * Transforms an element
// * @param input the element
// * @return the transformed element
// */
// abstract protected O transform(I input);
//
// @Override
// public void remove() {
// _delegate.remove();
// }
// }
// Path: src/main/java/de/fhg/igd/mongomvcc/impl/MongoDBVLargeCollection.java
import de.fhg.igd.mongomvcc.helper.Filter;
import de.fhg.igd.mongomvcc.helper.TransformingIterator;
import java.io.InputStream;
import java.util.Iterator;
import java.util.Map;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.gridfs.GridFS;
import com.mongodb.gridfs.GridFSInputFile;
import de.fhg.igd.mongomvcc.VCounter;
import de.fhg.igd.mongomvcc.VCursor;
import de.fhg.igd.mongomvcc.VLargeCollection;
* @param delegate the actual MongoDB collection
* @param gridFS the MongoDB GridFS storing binary data
* @param branch the branch currently checked out
* @param counter a counter to generate unique IDs
* @param accessStrategy the strategy that should be used to access large objects
*/
public MongoDBVLargeCollection(DBCollection delegate, GridFS gridFS,
MongoDBVBranch branch, VCounter counter, AccessStrategy accessStrategy) {
super(delegate, branch, counter);
_gridFS = gridFS;
_accessStrategy = accessStrategy;
}
@Override
public void insert(Map<String, Object> obj) {
DefaultConvertStrategy cs = new DefaultConvertStrategy(_gridFS, getCounter());
_accessStrategy.setConvertStrategy(cs);
_accessStrategy.onInsert(obj);
//save original object
super.insert(obj);
//save GridFS files
for (GridFSInputFile file : cs.getConvertedFiles()) {
file.put(PARENT, obj.get(OID));
file.save();
}
}
@Override | protected VCursor createCursor(DBCursor delegate, Filter<DBObject> filter) { |
igd-geo/mongomvcc | src/main/java/de/fhg/igd/mongomvcc/impl/MongoDBVCursor.java | // Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/Filter.java
// public interface Filter<T> {
// /**
// * Checks if the given element passes the filter
// * @param t the element
// * @return true if the element passes the filter, false otherwise
// */
// boolean filter(T t);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/FilteringIterator.java
// public class FilteringIterator<T> implements Iterator<T> {
// /**
// * The wrapped iterator
// */
// private final Iterator<T> _delegate;
//
// /**
// * The filter that shall be applied to all elements
// * in the wrapped iterator
// */
// private final Filter<T> _filter;
//
// /**
// * True if this iterator has been initialized--i.e. if the
// * first element has been fetched
// */
// private boolean _initialized = false;
//
// /**
// * True if this iterator will return another element
// */
// private boolean _hasNext = false;
//
// /**
// * The next element that will be returned by {@link #next()}
// */
// private T _nextElement = null;
//
// /**
// * Creates a new filtering iterator
// * @param delegate the iterator to wrap around
// * @param filter the filter
// */
// public FilteringIterator(Iterator<T> delegate, Filter<T> filter) {
// _delegate = delegate;
// _filter = filter;
// }
//
// private void advanceToNext() {
// _hasNext = false;
// while (_delegate.hasNext()) {
// T o = _delegate.next();
// if (_filter.filter(o)) {
// _hasNext = true;
// _nextElement = o;
// break;
// }
// }
// }
//
// private void initialize() {
// if (_initialized) {
// return;
// }
// advanceToNext();
// _initialized = true;
// }
//
// @Override
// public boolean hasNext() {
// initialize();
// return _hasNext;
// }
//
// @Override
// public T next() {
// initialize();
// if (!_hasNext) {
// throw new NoSuchElementException();
// }
// T r = _nextElement;
// advanceToNext();
// return r;
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/TransformingIterator.java
// public abstract class TransformingIterator<I, O> implements Iterator<O> {
// /**
// * The wrapped iterator
// */
// private final Iterator<I> _delegate;
//
// /**
// * Constructs a new transforming iterator
// * @param delegate the iterator to wrap
// */
// public TransformingIterator(Iterator<I> delegate) {
// _delegate = delegate;
// }
//
// @Override
// public boolean hasNext() {
// return _delegate.hasNext();
// }
//
// @Override
// public O next() {
// return transform(_delegate.next());
// }
//
// /**
// * Transforms an element
// * @param input the element
// * @return the transformed element
// */
// abstract protected O transform(I input);
//
// @Override
// public void remove() {
// _delegate.remove();
// }
// }
| import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import de.fhg.igd.mongomvcc.VCursor;
import de.fhg.igd.mongomvcc.helper.Filter;
import de.fhg.igd.mongomvcc.helper.FilteringIterator;
import de.fhg.igd.mongomvcc.helper.TransformingIterator; | // This file is part of MongoMVCC.
//
// Copyright (c) 2012 Fraunhofer IGD
//
// MongoMVCC 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, either version 3 of the
// License, or (at your option) any later version.
//
// MongoMVCC 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 MongoMVCC. If not, see <http://www.gnu.org/licenses/>.
package de.fhg.igd.mongomvcc.impl;
/**
* Implementation of {@link VCursor} for MongoDB
* @author Michel Kraemer
*/
public class MongoDBVCursor implements VCursor {
private final DBCursor _delegate; | // Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/Filter.java
// public interface Filter<T> {
// /**
// * Checks if the given element passes the filter
// * @param t the element
// * @return true if the element passes the filter, false otherwise
// */
// boolean filter(T t);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/FilteringIterator.java
// public class FilteringIterator<T> implements Iterator<T> {
// /**
// * The wrapped iterator
// */
// private final Iterator<T> _delegate;
//
// /**
// * The filter that shall be applied to all elements
// * in the wrapped iterator
// */
// private final Filter<T> _filter;
//
// /**
// * True if this iterator has been initialized--i.e. if the
// * first element has been fetched
// */
// private boolean _initialized = false;
//
// /**
// * True if this iterator will return another element
// */
// private boolean _hasNext = false;
//
// /**
// * The next element that will be returned by {@link #next()}
// */
// private T _nextElement = null;
//
// /**
// * Creates a new filtering iterator
// * @param delegate the iterator to wrap around
// * @param filter the filter
// */
// public FilteringIterator(Iterator<T> delegate, Filter<T> filter) {
// _delegate = delegate;
// _filter = filter;
// }
//
// private void advanceToNext() {
// _hasNext = false;
// while (_delegate.hasNext()) {
// T o = _delegate.next();
// if (_filter.filter(o)) {
// _hasNext = true;
// _nextElement = o;
// break;
// }
// }
// }
//
// private void initialize() {
// if (_initialized) {
// return;
// }
// advanceToNext();
// _initialized = true;
// }
//
// @Override
// public boolean hasNext() {
// initialize();
// return _hasNext;
// }
//
// @Override
// public T next() {
// initialize();
// if (!_hasNext) {
// throw new NoSuchElementException();
// }
// T r = _nextElement;
// advanceToNext();
// return r;
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/TransformingIterator.java
// public abstract class TransformingIterator<I, O> implements Iterator<O> {
// /**
// * The wrapped iterator
// */
// private final Iterator<I> _delegate;
//
// /**
// * Constructs a new transforming iterator
// * @param delegate the iterator to wrap
// */
// public TransformingIterator(Iterator<I> delegate) {
// _delegate = delegate;
// }
//
// @Override
// public boolean hasNext() {
// return _delegate.hasNext();
// }
//
// @Override
// public O next() {
// return transform(_delegate.next());
// }
//
// /**
// * Transforms an element
// * @param input the element
// * @return the transformed element
// */
// abstract protected O transform(I input);
//
// @Override
// public void remove() {
// _delegate.remove();
// }
// }
// Path: src/main/java/de/fhg/igd/mongomvcc/impl/MongoDBVCursor.java
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import de.fhg.igd.mongomvcc.VCursor;
import de.fhg.igd.mongomvcc.helper.Filter;
import de.fhg.igd.mongomvcc.helper.FilteringIterator;
import de.fhg.igd.mongomvcc.helper.TransformingIterator;
// This file is part of MongoMVCC.
//
// Copyright (c) 2012 Fraunhofer IGD
//
// MongoMVCC 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, either version 3 of the
// License, or (at your option) any later version.
//
// MongoMVCC 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 MongoMVCC. If not, see <http://www.gnu.org/licenses/>.
package de.fhg.igd.mongomvcc.impl;
/**
* Implementation of {@link VCursor} for MongoDB
* @author Michel Kraemer
*/
public class MongoDBVCursor implements VCursor {
private final DBCursor _delegate; | private final Filter<DBObject> _filter; |
igd-geo/mongomvcc | src/main/java/de/fhg/igd/mongomvcc/impl/MongoDBVCursor.java | // Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/Filter.java
// public interface Filter<T> {
// /**
// * Checks if the given element passes the filter
// * @param t the element
// * @return true if the element passes the filter, false otherwise
// */
// boolean filter(T t);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/FilteringIterator.java
// public class FilteringIterator<T> implements Iterator<T> {
// /**
// * The wrapped iterator
// */
// private final Iterator<T> _delegate;
//
// /**
// * The filter that shall be applied to all elements
// * in the wrapped iterator
// */
// private final Filter<T> _filter;
//
// /**
// * True if this iterator has been initialized--i.e. if the
// * first element has been fetched
// */
// private boolean _initialized = false;
//
// /**
// * True if this iterator will return another element
// */
// private boolean _hasNext = false;
//
// /**
// * The next element that will be returned by {@link #next()}
// */
// private T _nextElement = null;
//
// /**
// * Creates a new filtering iterator
// * @param delegate the iterator to wrap around
// * @param filter the filter
// */
// public FilteringIterator(Iterator<T> delegate, Filter<T> filter) {
// _delegate = delegate;
// _filter = filter;
// }
//
// private void advanceToNext() {
// _hasNext = false;
// while (_delegate.hasNext()) {
// T o = _delegate.next();
// if (_filter.filter(o)) {
// _hasNext = true;
// _nextElement = o;
// break;
// }
// }
// }
//
// private void initialize() {
// if (_initialized) {
// return;
// }
// advanceToNext();
// _initialized = true;
// }
//
// @Override
// public boolean hasNext() {
// initialize();
// return _hasNext;
// }
//
// @Override
// public T next() {
// initialize();
// if (!_hasNext) {
// throw new NoSuchElementException();
// }
// T r = _nextElement;
// advanceToNext();
// return r;
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/TransformingIterator.java
// public abstract class TransformingIterator<I, O> implements Iterator<O> {
// /**
// * The wrapped iterator
// */
// private final Iterator<I> _delegate;
//
// /**
// * Constructs a new transforming iterator
// * @param delegate the iterator to wrap
// */
// public TransformingIterator(Iterator<I> delegate) {
// _delegate = delegate;
// }
//
// @Override
// public boolean hasNext() {
// return _delegate.hasNext();
// }
//
// @Override
// public O next() {
// return transform(_delegate.next());
// }
//
// /**
// * Transforms an element
// * @param input the element
// * @return the transformed element
// */
// abstract protected O transform(I input);
//
// @Override
// public void remove() {
// _delegate.remove();
// }
// }
| import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import de.fhg.igd.mongomvcc.VCursor;
import de.fhg.igd.mongomvcc.helper.Filter;
import de.fhg.igd.mongomvcc.helper.FilteringIterator;
import de.fhg.igd.mongomvcc.helper.TransformingIterator; |
@Override
public int size() {
return 0;
}
};
/**
* Constructs a new cursor (without a filter)
* @param delegate the actual MongoDB cursor
*/
public MongoDBVCursor(DBCursor delegate) {
this(delegate, null);
}
/**
* Constructs a new cursor
* @param delegate the actual MongoDB cursor
* @param filter a filter which decides if a DBObject should be included
* into the cursor's result or not (can be null)
*/
public MongoDBVCursor(DBCursor delegate, Filter<DBObject> filter) {
_delegate = delegate;
_filter = filter;
}
@Override
public Iterator<Map<String, Object>> iterator() {
Iterator<DBObject> it = _delegate.iterator();
if (_filter != null) { | // Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/Filter.java
// public interface Filter<T> {
// /**
// * Checks if the given element passes the filter
// * @param t the element
// * @return true if the element passes the filter, false otherwise
// */
// boolean filter(T t);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/FilteringIterator.java
// public class FilteringIterator<T> implements Iterator<T> {
// /**
// * The wrapped iterator
// */
// private final Iterator<T> _delegate;
//
// /**
// * The filter that shall be applied to all elements
// * in the wrapped iterator
// */
// private final Filter<T> _filter;
//
// /**
// * True if this iterator has been initialized--i.e. if the
// * first element has been fetched
// */
// private boolean _initialized = false;
//
// /**
// * True if this iterator will return another element
// */
// private boolean _hasNext = false;
//
// /**
// * The next element that will be returned by {@link #next()}
// */
// private T _nextElement = null;
//
// /**
// * Creates a new filtering iterator
// * @param delegate the iterator to wrap around
// * @param filter the filter
// */
// public FilteringIterator(Iterator<T> delegate, Filter<T> filter) {
// _delegate = delegate;
// _filter = filter;
// }
//
// private void advanceToNext() {
// _hasNext = false;
// while (_delegate.hasNext()) {
// T o = _delegate.next();
// if (_filter.filter(o)) {
// _hasNext = true;
// _nextElement = o;
// break;
// }
// }
// }
//
// private void initialize() {
// if (_initialized) {
// return;
// }
// advanceToNext();
// _initialized = true;
// }
//
// @Override
// public boolean hasNext() {
// initialize();
// return _hasNext;
// }
//
// @Override
// public T next() {
// initialize();
// if (!_hasNext) {
// throw new NoSuchElementException();
// }
// T r = _nextElement;
// advanceToNext();
// return r;
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/TransformingIterator.java
// public abstract class TransformingIterator<I, O> implements Iterator<O> {
// /**
// * The wrapped iterator
// */
// private final Iterator<I> _delegate;
//
// /**
// * Constructs a new transforming iterator
// * @param delegate the iterator to wrap
// */
// public TransformingIterator(Iterator<I> delegate) {
// _delegate = delegate;
// }
//
// @Override
// public boolean hasNext() {
// return _delegate.hasNext();
// }
//
// @Override
// public O next() {
// return transform(_delegate.next());
// }
//
// /**
// * Transforms an element
// * @param input the element
// * @return the transformed element
// */
// abstract protected O transform(I input);
//
// @Override
// public void remove() {
// _delegate.remove();
// }
// }
// Path: src/main/java/de/fhg/igd/mongomvcc/impl/MongoDBVCursor.java
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import de.fhg.igd.mongomvcc.VCursor;
import de.fhg.igd.mongomvcc.helper.Filter;
import de.fhg.igd.mongomvcc.helper.FilteringIterator;
import de.fhg.igd.mongomvcc.helper.TransformingIterator;
@Override
public int size() {
return 0;
}
};
/**
* Constructs a new cursor (without a filter)
* @param delegate the actual MongoDB cursor
*/
public MongoDBVCursor(DBCursor delegate) {
this(delegate, null);
}
/**
* Constructs a new cursor
* @param delegate the actual MongoDB cursor
* @param filter a filter which decides if a DBObject should be included
* into the cursor's result or not (can be null)
*/
public MongoDBVCursor(DBCursor delegate, Filter<DBObject> filter) {
_delegate = delegate;
_filter = filter;
}
@Override
public Iterator<Map<String, Object>> iterator() {
Iterator<DBObject> it = _delegate.iterator();
if (_filter != null) { | it = new FilteringIterator<DBObject>(it, _filter); |
igd-geo/mongomvcc | src/main/java/de/fhg/igd/mongomvcc/impl/MongoDBVCursor.java | // Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/Filter.java
// public interface Filter<T> {
// /**
// * Checks if the given element passes the filter
// * @param t the element
// * @return true if the element passes the filter, false otherwise
// */
// boolean filter(T t);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/FilteringIterator.java
// public class FilteringIterator<T> implements Iterator<T> {
// /**
// * The wrapped iterator
// */
// private final Iterator<T> _delegate;
//
// /**
// * The filter that shall be applied to all elements
// * in the wrapped iterator
// */
// private final Filter<T> _filter;
//
// /**
// * True if this iterator has been initialized--i.e. if the
// * first element has been fetched
// */
// private boolean _initialized = false;
//
// /**
// * True if this iterator will return another element
// */
// private boolean _hasNext = false;
//
// /**
// * The next element that will be returned by {@link #next()}
// */
// private T _nextElement = null;
//
// /**
// * Creates a new filtering iterator
// * @param delegate the iterator to wrap around
// * @param filter the filter
// */
// public FilteringIterator(Iterator<T> delegate, Filter<T> filter) {
// _delegate = delegate;
// _filter = filter;
// }
//
// private void advanceToNext() {
// _hasNext = false;
// while (_delegate.hasNext()) {
// T o = _delegate.next();
// if (_filter.filter(o)) {
// _hasNext = true;
// _nextElement = o;
// break;
// }
// }
// }
//
// private void initialize() {
// if (_initialized) {
// return;
// }
// advanceToNext();
// _initialized = true;
// }
//
// @Override
// public boolean hasNext() {
// initialize();
// return _hasNext;
// }
//
// @Override
// public T next() {
// initialize();
// if (!_hasNext) {
// throw new NoSuchElementException();
// }
// T r = _nextElement;
// advanceToNext();
// return r;
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/TransformingIterator.java
// public abstract class TransformingIterator<I, O> implements Iterator<O> {
// /**
// * The wrapped iterator
// */
// private final Iterator<I> _delegate;
//
// /**
// * Constructs a new transforming iterator
// * @param delegate the iterator to wrap
// */
// public TransformingIterator(Iterator<I> delegate) {
// _delegate = delegate;
// }
//
// @Override
// public boolean hasNext() {
// return _delegate.hasNext();
// }
//
// @Override
// public O next() {
// return transform(_delegate.next());
// }
//
// /**
// * Transforms an element
// * @param input the element
// * @return the transformed element
// */
// abstract protected O transform(I input);
//
// @Override
// public void remove() {
// _delegate.remove();
// }
// }
| import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import de.fhg.igd.mongomvcc.VCursor;
import de.fhg.igd.mongomvcc.helper.Filter;
import de.fhg.igd.mongomvcc.helper.FilteringIterator;
import de.fhg.igd.mongomvcc.helper.TransformingIterator; | public int size() {
return 0;
}
};
/**
* Constructs a new cursor (without a filter)
* @param delegate the actual MongoDB cursor
*/
public MongoDBVCursor(DBCursor delegate) {
this(delegate, null);
}
/**
* Constructs a new cursor
* @param delegate the actual MongoDB cursor
* @param filter a filter which decides if a DBObject should be included
* into the cursor's result or not (can be null)
*/
public MongoDBVCursor(DBCursor delegate, Filter<DBObject> filter) {
_delegate = delegate;
_filter = filter;
}
@Override
public Iterator<Map<String, Object>> iterator() {
Iterator<DBObject> it = _delegate.iterator();
if (_filter != null) {
it = new FilteringIterator<DBObject>(it, _filter);
} | // Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/Filter.java
// public interface Filter<T> {
// /**
// * Checks if the given element passes the filter
// * @param t the element
// * @return true if the element passes the filter, false otherwise
// */
// boolean filter(T t);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/FilteringIterator.java
// public class FilteringIterator<T> implements Iterator<T> {
// /**
// * The wrapped iterator
// */
// private final Iterator<T> _delegate;
//
// /**
// * The filter that shall be applied to all elements
// * in the wrapped iterator
// */
// private final Filter<T> _filter;
//
// /**
// * True if this iterator has been initialized--i.e. if the
// * first element has been fetched
// */
// private boolean _initialized = false;
//
// /**
// * True if this iterator will return another element
// */
// private boolean _hasNext = false;
//
// /**
// * The next element that will be returned by {@link #next()}
// */
// private T _nextElement = null;
//
// /**
// * Creates a new filtering iterator
// * @param delegate the iterator to wrap around
// * @param filter the filter
// */
// public FilteringIterator(Iterator<T> delegate, Filter<T> filter) {
// _delegate = delegate;
// _filter = filter;
// }
//
// private void advanceToNext() {
// _hasNext = false;
// while (_delegate.hasNext()) {
// T o = _delegate.next();
// if (_filter.filter(o)) {
// _hasNext = true;
// _nextElement = o;
// break;
// }
// }
// }
//
// private void initialize() {
// if (_initialized) {
// return;
// }
// advanceToNext();
// _initialized = true;
// }
//
// @Override
// public boolean hasNext() {
// initialize();
// return _hasNext;
// }
//
// @Override
// public T next() {
// initialize();
// if (!_hasNext) {
// throw new NoSuchElementException();
// }
// T r = _nextElement;
// advanceToNext();
// return r;
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/TransformingIterator.java
// public abstract class TransformingIterator<I, O> implements Iterator<O> {
// /**
// * The wrapped iterator
// */
// private final Iterator<I> _delegate;
//
// /**
// * Constructs a new transforming iterator
// * @param delegate the iterator to wrap
// */
// public TransformingIterator(Iterator<I> delegate) {
// _delegate = delegate;
// }
//
// @Override
// public boolean hasNext() {
// return _delegate.hasNext();
// }
//
// @Override
// public O next() {
// return transform(_delegate.next());
// }
//
// /**
// * Transforms an element
// * @param input the element
// * @return the transformed element
// */
// abstract protected O transform(I input);
//
// @Override
// public void remove() {
// _delegate.remove();
// }
// }
// Path: src/main/java/de/fhg/igd/mongomvcc/impl/MongoDBVCursor.java
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import de.fhg.igd.mongomvcc.VCursor;
import de.fhg.igd.mongomvcc.helper.Filter;
import de.fhg.igd.mongomvcc.helper.FilteringIterator;
import de.fhg.igd.mongomvcc.helper.TransformingIterator;
public int size() {
return 0;
}
};
/**
* Constructs a new cursor (without a filter)
* @param delegate the actual MongoDB cursor
*/
public MongoDBVCursor(DBCursor delegate) {
this(delegate, null);
}
/**
* Constructs a new cursor
* @param delegate the actual MongoDB cursor
* @param filter a filter which decides if a DBObject should be included
* into the cursor's result or not (can be null)
*/
public MongoDBVCursor(DBCursor delegate, Filter<DBObject> filter) {
_delegate = delegate;
_filter = filter;
}
@Override
public Iterator<Map<String, Object>> iterator() {
Iterator<DBObject> it = _delegate.iterator();
if (_filter != null) {
it = new FilteringIterator<DBObject>(it, _filter);
} | return new TransformingIterator<DBObject, Map<String, Object>>(it) { |
igd-geo/mongomvcc | src/main/java/de/fhg/igd/mongomvcc/impl/DefaultConvertStrategy.java | // Path: src/main/java/de/fhg/igd/mongomvcc/VCounter.java
// public interface VCounter {
// /**
// * A thread safe method to get the next unique id
// * @return a unique id
// */
// public long getNextId();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/FloatArrayInputStream.java
// public class FloatArrayInputStream extends InputStream {
// /**
// * The array this input stream wraps around
// */
// private final float[] _arr;
//
// /**
// * The current position in the wrapped array
// */
// private int _pos = 0;
//
// /**
// * The position of the current byte in the bit representation
// * of the float value at the current position in the array.
// */
// private int _subpos = 0;
//
// /**
// * The bits of the float value at the current position
// */
// private int _currentBits;
//
// /**
// * True if {@link Float#floatToRawIntBits(float)} shall be used
// * to convert float values to bytes or false if {@link Float#floatToIntBits(float)}
// * shall be used.
// */
// private final boolean _rawBits;
//
// /**
// * Creates a new input stream
// * @param arr the array to wrap
// */
// public FloatArrayInputStream(float[] arr) {
// this(arr, true);
// }
//
// /**
// * Creates a new input stream
// * @param arr the array to wrap
// * @param rawBits true if {@link Float#floatToRawIntBits(float)} shall be used
// * to convert float values to bytes or false if {@link Float#floatToIntBits(float)}
// * shall be used
// */
// public FloatArrayInputStream(float[] arr, boolean rawBits) {
// _arr = arr;
// _rawBits = rawBits;
// }
//
// @Override
// public int read() throws IOException {
// if (_pos >= _arr.length) {
// //end of stream
// return -1;
// }
//
// if (_subpos == 0) {
// //receive next float value
// _currentBits = makeBits(_arr[_pos]);
// }
//
// //calculate current value
// int s = Float.SIZE - (_subpos + 1) * Byte.SIZE;
// int result = (_currentBits >> s) & 0xff;
//
// //increase position(s)
// ++_subpos;
// if (_subpos == Float.SIZE / Byte.SIZE) {
// _subpos = 0;
// ++_pos;
// }
//
// return result;
// }
//
// private int makeBits(float f) {
// if (_rawBits) {
// return Float.floatToRawIntBits(f);
// }
// return Float.floatToIntBits(f);
// }
// }
| import de.fhg.igd.mongomvcc.VCounter;
import de.fhg.igd.mongomvcc.helper.FloatArrayInputStream;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;
import com.mongodb.BasicDBObject;
import com.mongodb.gridfs.GridFS;
import com.mongodb.gridfs.GridFSDBFile;
import com.mongodb.gridfs.GridFSInputFile; | // This file is part of MongoMVCC.
//
// Copyright (c) 2012 Fraunhofer IGD
//
// MongoMVCC 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, either version 3 of the
// License, or (at your option) any later version.
//
// MongoMVCC 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 MongoMVCC. If not, see <http://www.gnu.org/licenses/>.
package de.fhg.igd.mongomvcc.impl;
/**
* The default convert strategy handles different types of binary data
* which is stores in a MongoDB GridFS
* @author Michel Kraemer
*/
public class DefaultConvertStrategy implements ConvertStrategy {
/**
* Binary types
*/
private static final int BYTEARRAY = 0;
private static final int INPUTSTREAM = 1;
private static final int BYTEBUFFER = 2;
private static final int FLOATARRAY = 3;
private static final int FLOATBUFFER = 4;
/**
* The metadata attribute that denotes the binary type
*/
private static final String BINARY_TYPE = "binary_type";
/**
* The MongoDB GridFS storing binary data
*/
private final GridFS _gridFS;
/**
* A counter to generate replacement OIDs
*/ | // Path: src/main/java/de/fhg/igd/mongomvcc/VCounter.java
// public interface VCounter {
// /**
// * A thread safe method to get the next unique id
// * @return a unique id
// */
// public long getNextId();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/FloatArrayInputStream.java
// public class FloatArrayInputStream extends InputStream {
// /**
// * The array this input stream wraps around
// */
// private final float[] _arr;
//
// /**
// * The current position in the wrapped array
// */
// private int _pos = 0;
//
// /**
// * The position of the current byte in the bit representation
// * of the float value at the current position in the array.
// */
// private int _subpos = 0;
//
// /**
// * The bits of the float value at the current position
// */
// private int _currentBits;
//
// /**
// * True if {@link Float#floatToRawIntBits(float)} shall be used
// * to convert float values to bytes or false if {@link Float#floatToIntBits(float)}
// * shall be used.
// */
// private final boolean _rawBits;
//
// /**
// * Creates a new input stream
// * @param arr the array to wrap
// */
// public FloatArrayInputStream(float[] arr) {
// this(arr, true);
// }
//
// /**
// * Creates a new input stream
// * @param arr the array to wrap
// * @param rawBits true if {@link Float#floatToRawIntBits(float)} shall be used
// * to convert float values to bytes or false if {@link Float#floatToIntBits(float)}
// * shall be used
// */
// public FloatArrayInputStream(float[] arr, boolean rawBits) {
// _arr = arr;
// _rawBits = rawBits;
// }
//
// @Override
// public int read() throws IOException {
// if (_pos >= _arr.length) {
// //end of stream
// return -1;
// }
//
// if (_subpos == 0) {
// //receive next float value
// _currentBits = makeBits(_arr[_pos]);
// }
//
// //calculate current value
// int s = Float.SIZE - (_subpos + 1) * Byte.SIZE;
// int result = (_currentBits >> s) & 0xff;
//
// //increase position(s)
// ++_subpos;
// if (_subpos == Float.SIZE / Byte.SIZE) {
// _subpos = 0;
// ++_pos;
// }
//
// return result;
// }
//
// private int makeBits(float f) {
// if (_rawBits) {
// return Float.floatToRawIntBits(f);
// }
// return Float.floatToIntBits(f);
// }
// }
// Path: src/main/java/de/fhg/igd/mongomvcc/impl/DefaultConvertStrategy.java
import de.fhg.igd.mongomvcc.VCounter;
import de.fhg.igd.mongomvcc.helper.FloatArrayInputStream;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;
import com.mongodb.BasicDBObject;
import com.mongodb.gridfs.GridFS;
import com.mongodb.gridfs.GridFSDBFile;
import com.mongodb.gridfs.GridFSInputFile;
// This file is part of MongoMVCC.
//
// Copyright (c) 2012 Fraunhofer IGD
//
// MongoMVCC 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, either version 3 of the
// License, or (at your option) any later version.
//
// MongoMVCC 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 MongoMVCC. If not, see <http://www.gnu.org/licenses/>.
package de.fhg.igd.mongomvcc.impl;
/**
* The default convert strategy handles different types of binary data
* which is stores in a MongoDB GridFS
* @author Michel Kraemer
*/
public class DefaultConvertStrategy implements ConvertStrategy {
/**
* Binary types
*/
private static final int BYTEARRAY = 0;
private static final int INPUTSTREAM = 1;
private static final int BYTEBUFFER = 2;
private static final int FLOATARRAY = 3;
private static final int FLOATBUFFER = 4;
/**
* The metadata attribute that denotes the binary type
*/
private static final String BINARY_TYPE = "binary_type";
/**
* The MongoDB GridFS storing binary data
*/
private final GridFS _gridFS;
/**
* A counter to generate replacement OIDs
*/ | private final VCounter _counter; |
igd-geo/mongomvcc | src/main/java/de/fhg/igd/mongomvcc/impl/DefaultConvertStrategy.java | // Path: src/main/java/de/fhg/igd/mongomvcc/VCounter.java
// public interface VCounter {
// /**
// * A thread safe method to get the next unique id
// * @return a unique id
// */
// public long getNextId();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/FloatArrayInputStream.java
// public class FloatArrayInputStream extends InputStream {
// /**
// * The array this input stream wraps around
// */
// private final float[] _arr;
//
// /**
// * The current position in the wrapped array
// */
// private int _pos = 0;
//
// /**
// * The position of the current byte in the bit representation
// * of the float value at the current position in the array.
// */
// private int _subpos = 0;
//
// /**
// * The bits of the float value at the current position
// */
// private int _currentBits;
//
// /**
// * True if {@link Float#floatToRawIntBits(float)} shall be used
// * to convert float values to bytes or false if {@link Float#floatToIntBits(float)}
// * shall be used.
// */
// private final boolean _rawBits;
//
// /**
// * Creates a new input stream
// * @param arr the array to wrap
// */
// public FloatArrayInputStream(float[] arr) {
// this(arr, true);
// }
//
// /**
// * Creates a new input stream
// * @param arr the array to wrap
// * @param rawBits true if {@link Float#floatToRawIntBits(float)} shall be used
// * to convert float values to bytes or false if {@link Float#floatToIntBits(float)}
// * shall be used
// */
// public FloatArrayInputStream(float[] arr, boolean rawBits) {
// _arr = arr;
// _rawBits = rawBits;
// }
//
// @Override
// public int read() throws IOException {
// if (_pos >= _arr.length) {
// //end of stream
// return -1;
// }
//
// if (_subpos == 0) {
// //receive next float value
// _currentBits = makeBits(_arr[_pos]);
// }
//
// //calculate current value
// int s = Float.SIZE - (_subpos + 1) * Byte.SIZE;
// int result = (_currentBits >> s) & 0xff;
//
// //increase position(s)
// ++_subpos;
// if (_subpos == Float.SIZE / Byte.SIZE) {
// _subpos = 0;
// ++_pos;
// }
//
// return result;
// }
//
// private int makeBits(float f) {
// if (_rawBits) {
// return Float.floatToRawIntBits(f);
// }
// return Float.floatToIntBits(f);
// }
// }
| import de.fhg.igd.mongomvcc.VCounter;
import de.fhg.igd.mongomvcc.helper.FloatArrayInputStream;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;
import com.mongodb.BasicDBObject;
import com.mongodb.gridfs.GridFS;
import com.mongodb.gridfs.GridFSDBFile;
import com.mongodb.gridfs.GridFSInputFile; | // This file is part of MongoMVCC.
//
// Copyright (c) 2012 Fraunhofer IGD
//
// MongoMVCC 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, either version 3 of the
// License, or (at your option) any later version.
//
// MongoMVCC 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 MongoMVCC. If not, see <http://www.gnu.org/licenses/>.
package de.fhg.igd.mongomvcc.impl;
/**
* The default convert strategy handles different types of binary data
* which is stores in a MongoDB GridFS
* @author Michel Kraemer
*/
public class DefaultConvertStrategy implements ConvertStrategy {
/**
* Binary types
*/
private static final int BYTEARRAY = 0;
private static final int INPUTSTREAM = 1;
private static final int BYTEBUFFER = 2;
private static final int FLOATARRAY = 3;
private static final int FLOATBUFFER = 4;
/**
* The metadata attribute that denotes the binary type
*/
private static final String BINARY_TYPE = "binary_type";
/**
* The MongoDB GridFS storing binary data
*/
private final GridFS _gridFS;
/**
* A counter to generate replacement OIDs
*/
private final VCounter _counter;
/**
* The files that have been created by this convert strategy
*/
private final List<GridFSInputFile> _convertedFiles = new ArrayList<GridFSInputFile>();
/**
* Constructs a new convert strategy
* @param gridFS the MongoDB GridFS storing binary data
* @param counter a counter to generate replacement OIDs
*/
public DefaultConvertStrategy(GridFS gridFS, VCounter counter) {
_gridFS = gridFS;
_counter = counter;
}
/**
* @return the files that have been created by this convert strategy
*/
public List<GridFSInputFile> getConvertedFiles() {
return _convertedFiles;
}
@Override
public long convert(Object data) {
GridFSInputFile file;
if (data instanceof byte[]) {
file = _gridFS.createFile((byte[])data);
file.put(BINARY_TYPE, BYTEARRAY);
} else if (data instanceof float[]) { | // Path: src/main/java/de/fhg/igd/mongomvcc/VCounter.java
// public interface VCounter {
// /**
// * A thread safe method to get the next unique id
// * @return a unique id
// */
// public long getNextId();
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/helper/FloatArrayInputStream.java
// public class FloatArrayInputStream extends InputStream {
// /**
// * The array this input stream wraps around
// */
// private final float[] _arr;
//
// /**
// * The current position in the wrapped array
// */
// private int _pos = 0;
//
// /**
// * The position of the current byte in the bit representation
// * of the float value at the current position in the array.
// */
// private int _subpos = 0;
//
// /**
// * The bits of the float value at the current position
// */
// private int _currentBits;
//
// /**
// * True if {@link Float#floatToRawIntBits(float)} shall be used
// * to convert float values to bytes or false if {@link Float#floatToIntBits(float)}
// * shall be used.
// */
// private final boolean _rawBits;
//
// /**
// * Creates a new input stream
// * @param arr the array to wrap
// */
// public FloatArrayInputStream(float[] arr) {
// this(arr, true);
// }
//
// /**
// * Creates a new input stream
// * @param arr the array to wrap
// * @param rawBits true if {@link Float#floatToRawIntBits(float)} shall be used
// * to convert float values to bytes or false if {@link Float#floatToIntBits(float)}
// * shall be used
// */
// public FloatArrayInputStream(float[] arr, boolean rawBits) {
// _arr = arr;
// _rawBits = rawBits;
// }
//
// @Override
// public int read() throws IOException {
// if (_pos >= _arr.length) {
// //end of stream
// return -1;
// }
//
// if (_subpos == 0) {
// //receive next float value
// _currentBits = makeBits(_arr[_pos]);
// }
//
// //calculate current value
// int s = Float.SIZE - (_subpos + 1) * Byte.SIZE;
// int result = (_currentBits >> s) & 0xff;
//
// //increase position(s)
// ++_subpos;
// if (_subpos == Float.SIZE / Byte.SIZE) {
// _subpos = 0;
// ++_pos;
// }
//
// return result;
// }
//
// private int makeBits(float f) {
// if (_rawBits) {
// return Float.floatToRawIntBits(f);
// }
// return Float.floatToIntBits(f);
// }
// }
// Path: src/main/java/de/fhg/igd/mongomvcc/impl/DefaultConvertStrategy.java
import de.fhg.igd.mongomvcc.VCounter;
import de.fhg.igd.mongomvcc.helper.FloatArrayInputStream;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;
import com.mongodb.BasicDBObject;
import com.mongodb.gridfs.GridFS;
import com.mongodb.gridfs.GridFSDBFile;
import com.mongodb.gridfs.GridFSInputFile;
// This file is part of MongoMVCC.
//
// Copyright (c) 2012 Fraunhofer IGD
//
// MongoMVCC 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, either version 3 of the
// License, or (at your option) any later version.
//
// MongoMVCC 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 MongoMVCC. If not, see <http://www.gnu.org/licenses/>.
package de.fhg.igd.mongomvcc.impl;
/**
* The default convert strategy handles different types of binary data
* which is stores in a MongoDB GridFS
* @author Michel Kraemer
*/
public class DefaultConvertStrategy implements ConvertStrategy {
/**
* Binary types
*/
private static final int BYTEARRAY = 0;
private static final int INPUTSTREAM = 1;
private static final int BYTEBUFFER = 2;
private static final int FLOATARRAY = 3;
private static final int FLOATBUFFER = 4;
/**
* The metadata attribute that denotes the binary type
*/
private static final String BINARY_TYPE = "binary_type";
/**
* The MongoDB GridFS storing binary data
*/
private final GridFS _gridFS;
/**
* A counter to generate replacement OIDs
*/
private final VCounter _counter;
/**
* The files that have been created by this convert strategy
*/
private final List<GridFSInputFile> _convertedFiles = new ArrayList<GridFSInputFile>();
/**
* Constructs a new convert strategy
* @param gridFS the MongoDB GridFS storing binary data
* @param counter a counter to generate replacement OIDs
*/
public DefaultConvertStrategy(GridFS gridFS, VCounter counter) {
_gridFS = gridFS;
_counter = counter;
}
/**
* @return the files that have been created by this convert strategy
*/
public List<GridFSInputFile> getConvertedFiles() {
return _convertedFiles;
}
@Override
public long convert(Object data) {
GridFSInputFile file;
if (data instanceof byte[]) {
file = _gridFS.createFile((byte[])data);
file.put(BINARY_TYPE, BYTEARRAY);
} else if (data instanceof float[]) { | file = _gridFS.createFile(new FloatArrayInputStream((float[])data)); |
igd-geo/mongomvcc | src/test/java/de/fhg/igd/mongomvcc/impl/MongoDBVLargeCollectionTest.java | // Path: src/main/java/de/fhg/igd/mongomvcc/VCollection.java
// public interface VCollection {
// /**
// * @return the collection's name
// */
// String getName();
//
// /**
// * Inserts a new object to the collection. If the object does not have
// * a UID yet, a new one will be generated and saved in the object's
// * <code>uid</code> attribute.
// * @param obj the object to add to the collection
// */
// void insert(Map<String, Object> obj);
//
// /**
// * Deletes the object with the given UID from the collection (if it exists)
// * @param uid the UID of the object to delete
// */
// void delete(long uid);
//
// /**
// * Deletes all objects from the collection that match the given example object
// * @param example the example object
// */
// void delete(Map<String, Object> example);
//
// /**
// * @return a cursor which iterates over all objects in this collection
// */
// VCursor find();
//
// /**
// * Find by example. Returns all objects that match the given example.
// * @param example the example object
// * @return a cursor iterating over all matching objects
// */
// VCursor find(Map<String, Object> example);
//
// /**
// * Find by example. Returns all objects that match the given example, but
// * only return the requested fields. Omit all other fields, thus return
// * partial objects only.
// * @param example the example object
// * @param fields the names of the fields to return
// * @return a cursor iterating over all matching objects
// */
// VCursor find(Map<String, Object> example, String... fields);
//
// /**
// * Finds an object that matches the given example
// * @param example the example object
// * @return the object or null if there is no such object
// */
// Map<String, Object> findOne(Map<String, Object> example);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
| import de.fhg.igd.mongomvcc.VCollection;
import de.fhg.igd.mongomvcc.VCursor;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test; | // This file is part of MongoMVCC.
//
// Copyright (c) 2012 Fraunhofer IGD
//
// MongoMVCC 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, either version 3 of the
// License, or (at your option) any later version.
//
// MongoMVCC 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 MongoMVCC. If not, see <http://www.gnu.org/licenses/>.
package de.fhg.igd.mongomvcc.impl;
/**
* Tests {@link MongoDBVLargeCollection}
* @author Michel Kraemer
*/
public class MongoDBVLargeCollectionTest extends AbstractMongoDBVDatabaseTest {
/**
* Tests if large objects with byte arrays/streams/buffers can be saved in the database
* @throws Exception if something goes wrong
*/
@Test
public void largeObjectByte() throws Exception { | // Path: src/main/java/de/fhg/igd/mongomvcc/VCollection.java
// public interface VCollection {
// /**
// * @return the collection's name
// */
// String getName();
//
// /**
// * Inserts a new object to the collection. If the object does not have
// * a UID yet, a new one will be generated and saved in the object's
// * <code>uid</code> attribute.
// * @param obj the object to add to the collection
// */
// void insert(Map<String, Object> obj);
//
// /**
// * Deletes the object with the given UID from the collection (if it exists)
// * @param uid the UID of the object to delete
// */
// void delete(long uid);
//
// /**
// * Deletes all objects from the collection that match the given example object
// * @param example the example object
// */
// void delete(Map<String, Object> example);
//
// /**
// * @return a cursor which iterates over all objects in this collection
// */
// VCursor find();
//
// /**
// * Find by example. Returns all objects that match the given example.
// * @param example the example object
// * @return a cursor iterating over all matching objects
// */
// VCursor find(Map<String, Object> example);
//
// /**
// * Find by example. Returns all objects that match the given example, but
// * only return the requested fields. Omit all other fields, thus return
// * partial objects only.
// * @param example the example object
// * @param fields the names of the fields to return
// * @return a cursor iterating over all matching objects
// */
// VCursor find(Map<String, Object> example, String... fields);
//
// /**
// * Finds an object that matches the given example
// * @param example the example object
// * @return the object or null if there is no such object
// */
// Map<String, Object> findOne(Map<String, Object> example);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
// Path: src/test/java/de/fhg/igd/mongomvcc/impl/MongoDBVLargeCollectionTest.java
import de.fhg.igd.mongomvcc.VCollection;
import de.fhg.igd.mongomvcc.VCursor;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
// This file is part of MongoMVCC.
//
// Copyright (c) 2012 Fraunhofer IGD
//
// MongoMVCC 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, either version 3 of the
// License, or (at your option) any later version.
//
// MongoMVCC 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 MongoMVCC. If not, see <http://www.gnu.org/licenses/>.
package de.fhg.igd.mongomvcc.impl;
/**
* Tests {@link MongoDBVLargeCollection}
* @author Michel Kraemer
*/
public class MongoDBVLargeCollectionTest extends AbstractMongoDBVDatabaseTest {
/**
* Tests if large objects with byte arrays/streams/buffers can be saved in the database
* @throws Exception if something goes wrong
*/
@Test
public void largeObjectByte() throws Exception { | VCollection coll = _master.getLargeCollection("images"); |
igd-geo/mongomvcc | src/test/java/de/fhg/igd/mongomvcc/impl/MongoDBVLargeCollectionTest.java | // Path: src/main/java/de/fhg/igd/mongomvcc/VCollection.java
// public interface VCollection {
// /**
// * @return the collection's name
// */
// String getName();
//
// /**
// * Inserts a new object to the collection. If the object does not have
// * a UID yet, a new one will be generated and saved in the object's
// * <code>uid</code> attribute.
// * @param obj the object to add to the collection
// */
// void insert(Map<String, Object> obj);
//
// /**
// * Deletes the object with the given UID from the collection (if it exists)
// * @param uid the UID of the object to delete
// */
// void delete(long uid);
//
// /**
// * Deletes all objects from the collection that match the given example object
// * @param example the example object
// */
// void delete(Map<String, Object> example);
//
// /**
// * @return a cursor which iterates over all objects in this collection
// */
// VCursor find();
//
// /**
// * Find by example. Returns all objects that match the given example.
// * @param example the example object
// * @return a cursor iterating over all matching objects
// */
// VCursor find(Map<String, Object> example);
//
// /**
// * Find by example. Returns all objects that match the given example, but
// * only return the requested fields. Omit all other fields, thus return
// * partial objects only.
// * @param example the example object
// * @param fields the names of the fields to return
// * @return a cursor iterating over all matching objects
// */
// VCursor find(Map<String, Object> example, String... fields);
//
// /**
// * Finds an object that matches the given example
// * @param example the example object
// * @return the object or null if there is no such object
// */
// Map<String, Object> findOne(Map<String, Object> example);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
| import de.fhg.igd.mongomvcc.VCollection;
import de.fhg.igd.mongomvcc.VCursor;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test; | // This file is part of MongoMVCC.
//
// Copyright (c) 2012 Fraunhofer IGD
//
// MongoMVCC 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, either version 3 of the
// License, or (at your option) any later version.
//
// MongoMVCC 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 MongoMVCC. If not, see <http://www.gnu.org/licenses/>.
package de.fhg.igd.mongomvcc.impl;
/**
* Tests {@link MongoDBVLargeCollection}
* @author Michel Kraemer
*/
public class MongoDBVLargeCollectionTest extends AbstractMongoDBVDatabaseTest {
/**
* Tests if large objects with byte arrays/streams/buffers can be saved in the database
* @throws Exception if something goes wrong
*/
@Test
public void largeObjectByte() throws Exception {
VCollection coll = _master.getLargeCollection("images");
byte[] test = new byte[1024 * 1024];
for (int i = 0; i < test.length; ++i) {
test[i] = (byte)(i & 0xFF);
}
Map<String, Object> obj = new HashMap<String, Object>();
obj.put("name", "Mona Lisa");
obj.put("data", test);
coll.insert(obj);
| // Path: src/main/java/de/fhg/igd/mongomvcc/VCollection.java
// public interface VCollection {
// /**
// * @return the collection's name
// */
// String getName();
//
// /**
// * Inserts a new object to the collection. If the object does not have
// * a UID yet, a new one will be generated and saved in the object's
// * <code>uid</code> attribute.
// * @param obj the object to add to the collection
// */
// void insert(Map<String, Object> obj);
//
// /**
// * Deletes the object with the given UID from the collection (if it exists)
// * @param uid the UID of the object to delete
// */
// void delete(long uid);
//
// /**
// * Deletes all objects from the collection that match the given example object
// * @param example the example object
// */
// void delete(Map<String, Object> example);
//
// /**
// * @return a cursor which iterates over all objects in this collection
// */
// VCursor find();
//
// /**
// * Find by example. Returns all objects that match the given example.
// * @param example the example object
// * @return a cursor iterating over all matching objects
// */
// VCursor find(Map<String, Object> example);
//
// /**
// * Find by example. Returns all objects that match the given example, but
// * only return the requested fields. Omit all other fields, thus return
// * partial objects only.
// * @param example the example object
// * @param fields the names of the fields to return
// * @return a cursor iterating over all matching objects
// */
// VCursor find(Map<String, Object> example, String... fields);
//
// /**
// * Finds an object that matches the given example
// * @param example the example object
// * @return the object or null if there is no such object
// */
// Map<String, Object> findOne(Map<String, Object> example);
// }
//
// Path: src/main/java/de/fhg/igd/mongomvcc/VCursor.java
// public interface VCursor extends Iterable<Map<String, Object>> {
// /**
// * @return the number of database objects this cursor points to
// */
// int size();
// }
// Path: src/test/java/de/fhg/igd/mongomvcc/impl/MongoDBVLargeCollectionTest.java
import de.fhg.igd.mongomvcc.VCollection;
import de.fhg.igd.mongomvcc.VCursor;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
// This file is part of MongoMVCC.
//
// Copyright (c) 2012 Fraunhofer IGD
//
// MongoMVCC 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, either version 3 of the
// License, or (at your option) any later version.
//
// MongoMVCC 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 MongoMVCC. If not, see <http://www.gnu.org/licenses/>.
package de.fhg.igd.mongomvcc.impl;
/**
* Tests {@link MongoDBVLargeCollection}
* @author Michel Kraemer
*/
public class MongoDBVLargeCollectionTest extends AbstractMongoDBVDatabaseTest {
/**
* Tests if large objects with byte arrays/streams/buffers can be saved in the database
* @throws Exception if something goes wrong
*/
@Test
public void largeObjectByte() throws Exception {
VCollection coll = _master.getLargeCollection("images");
byte[] test = new byte[1024 * 1024];
for (int i = 0; i < test.length; ++i) {
test[i] = (byte)(i & 0xFF);
}
Map<String, Object> obj = new HashMap<String, Object>();
obj.put("name", "Mona Lisa");
obj.put("data", test);
coll.insert(obj);
| VCursor vc = coll.find(); |
usethesource/capsule | src/main/java/io/usethesource/capsule/Set.java | // Path: src/main/java/io/usethesource/capsule/factory/DefaultSetFactory.java
// public static final DefaultSetFactory FACTORY = new DefaultSetFactory();
| import static io.usethesource.capsule.factory.DefaultSetFactory.FACTORY;
import java.util.Collection;
import java.util.Iterator;
import java.util.Optional; |
interface Immutable<K> extends Set<K>, SetEq.Immutable<K> {
Set.Immutable<K> __insert(final K key);
Set.Immutable<K> __remove(final K key);
Set.Immutable<K> __insertAll(final java.util.Set<? extends K> set);
Set.Immutable<K> __removeAll(final java.util.Set<? extends K> set);
Set.Immutable<K> __retainAll(final java.util.Set<? extends K> set);
default Set.Immutable<K> union(Set.Immutable<K> other) {
return union(this, other);
}
default Set.Immutable<K> subtract(Set.Immutable<K> other) {
return subtract(this, other);
}
default Set.Immutable<K> intersect(Set.Immutable<K> other) {
return intersect(this, other);
}
boolean isTransientSupported();
Set.Transient<K> asTransient();
static <K> Set.Immutable<K> of() { | // Path: src/main/java/io/usethesource/capsule/factory/DefaultSetFactory.java
// public static final DefaultSetFactory FACTORY = new DefaultSetFactory();
// Path: src/main/java/io/usethesource/capsule/Set.java
import static io.usethesource.capsule.factory.DefaultSetFactory.FACTORY;
import java.util.Collection;
import java.util.Iterator;
import java.util.Optional;
interface Immutable<K> extends Set<K>, SetEq.Immutable<K> {
Set.Immutable<K> __insert(final K key);
Set.Immutable<K> __remove(final K key);
Set.Immutable<K> __insertAll(final java.util.Set<? extends K> set);
Set.Immutable<K> __removeAll(final java.util.Set<? extends K> set);
Set.Immutable<K> __retainAll(final java.util.Set<? extends K> set);
default Set.Immutable<K> union(Set.Immutable<K> other) {
return union(this, other);
}
default Set.Immutable<K> subtract(Set.Immutable<K> other) {
return subtract(this, other);
}
default Set.Immutable<K> intersect(Set.Immutable<K> other) {
return intersect(this, other);
}
boolean isTransientSupported();
Set.Transient<K> asTransient();
static <K> Set.Immutable<K> of() { | return FACTORY.of(); |
usethesource/capsule | src/test/java/io/usethesource/capsule/generators/MapEntryGenerator.java | // Path: src/main/java/io/usethesource/capsule/util/collection/AbstractSpecialisedImmutableMap.java
// public static final <K, V> Map.Entry<K, V> entryOf(final K key, final V val) {
// return new MapEntry<K, V>(key, val);
// }
| import java.util.Map;
import com.pholser.junit.quickcheck.generator.ComponentizedGenerator;
import com.pholser.junit.quickcheck.generator.GenerationStatus;
import com.pholser.junit.quickcheck.random.SourceOfRandomness;
import static io.usethesource.capsule.util.collection.AbstractSpecialisedImmutableMap.entryOf; | /**
* Copyright (c) Michael Steindorfer <Centrum Wiskunde & Informatica> and Contributors.
* All rights reserved.
*
* This file is licensed under the BSD 2-Clause License, which accompanies this project
* and is available under https://opensource.org/licenses/BSD-2-Clause.
*/
package io.usethesource.capsule.generators;
@SuppressWarnings({"rawtypes", "unchecked"})
public final class MapEntryGenerator<T extends Map.Entry>
extends ComponentizedGenerator<T> {
public MapEntryGenerator() {
super((Class<T>) Map.Entry.class);
}
@Override
public int numberOfNeededComponents() {
return 2;
}
@Override
public T generate(SourceOfRandomness random, GenerationStatus status) {
Object item0 = componentGenerators().get(0).generate(random, status);
Object item1 = componentGenerators().get(1).generate(random, status);
| // Path: src/main/java/io/usethesource/capsule/util/collection/AbstractSpecialisedImmutableMap.java
// public static final <K, V> Map.Entry<K, V> entryOf(final K key, final V val) {
// return new MapEntry<K, V>(key, val);
// }
// Path: src/test/java/io/usethesource/capsule/generators/MapEntryGenerator.java
import java.util.Map;
import com.pholser.junit.quickcheck.generator.ComponentizedGenerator;
import com.pholser.junit.quickcheck.generator.GenerationStatus;
import com.pholser.junit.quickcheck.random.SourceOfRandomness;
import static io.usethesource.capsule.util.collection.AbstractSpecialisedImmutableMap.entryOf;
/**
* Copyright (c) Michael Steindorfer <Centrum Wiskunde & Informatica> and Contributors.
* All rights reserved.
*
* This file is licensed under the BSD 2-Clause License, which accompanies this project
* and is available under https://opensource.org/licenses/BSD-2-Clause.
*/
package io.usethesource.capsule.generators;
@SuppressWarnings({"rawtypes", "unchecked"})
public final class MapEntryGenerator<T extends Map.Entry>
extends ComponentizedGenerator<T> {
public MapEntryGenerator() {
super((Class<T>) Map.Entry.class);
}
@Override
public int numberOfNeededComponents() {
return 2;
}
@Override
public T generate(SourceOfRandomness random, GenerationStatus status) {
Object item0 = componentGenerators().get(0).generate(random, status);
Object item1 = componentGenerators().get(1).generate(random, status);
| return (T) entryOf(item0, item1); |
usethesource/capsule | src/main/java/io/usethesource/capsule/util/EqualityComparator.java | // Path: src/main/java/io/usethesource/capsule/util/function/ToBooleanBiFunction.java
// @FunctionalInterface
// public interface ToBooleanBiFunction<T, U> {
//
// /**
// * Applies this function to the given two arguments.
// *
// * @param t the first function argument
// * @param u the second function argument
// * @return the function result
// */
// boolean applyAsBoolean(T t, U u);
// }
| import java.util.Comparator;
import java.util.Objects;
import io.usethesource.capsule.util.function.ToBooleanBiFunction; | /**
* Copyright (c) Michael Steindorfer <Centrum Wiskunde & Informatica> and Contributors.
* All rights reserved.
*
* This file is licensed under the BSD 2-Clause License, which accompanies this project
* and is available under https://opensource.org/licenses/BSD-2-Clause.
*/
package io.usethesource.capsule.util;
/*
* TODO: remove {@link java.io.Serializable} capability after removing comparator from
* multi-map base classes.
*/
@FunctionalInterface
public interface EqualityComparator<T> extends java.io.Serializable {
static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
return (a, b) -> comparator.compare(a, b) == 0;
}
static <T> boolean equals(T a, T b, | // Path: src/main/java/io/usethesource/capsule/util/function/ToBooleanBiFunction.java
// @FunctionalInterface
// public interface ToBooleanBiFunction<T, U> {
//
// /**
// * Applies this function to the given two arguments.
// *
// * @param t the first function argument
// * @param u the second function argument
// * @return the function result
// */
// boolean applyAsBoolean(T t, U u);
// }
// Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
import java.util.Comparator;
import java.util.Objects;
import io.usethesource.capsule.util.function.ToBooleanBiFunction;
/**
* Copyright (c) Michael Steindorfer <Centrum Wiskunde & Informatica> and Contributors.
* All rights reserved.
*
* This file is licensed under the BSD 2-Clause License, which accompanies this project
* and is available under https://opensource.org/licenses/BSD-2-Clause.
*/
package io.usethesource.capsule.util;
/*
* TODO: remove {@link java.io.Serializable} capability after removing comparator from
* multi-map base classes.
*/
@FunctionalInterface
public interface EqualityComparator<T> extends java.io.Serializable {
static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
return (a, b) -> comparator.compare(a, b) == 0;
}
static <T> boolean equals(T a, T b, | ToBooleanBiFunction<T, T> comparator) { |
usethesource/capsule | src/main/java/io/usethesource/capsule/core/trie/SetNode.java | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
| import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
import io.usethesource.capsule.util.EqualityComparator; | /**
* Copyright (c) Michael Steindorfer <Centrum Wiskunde & Informatica> and Contributors.
* All rights reserved.
*
* This file is licensed under the BSD 2-Clause License, which accompanies this project
* and is available under https://opensource.org/licenses/BSD-2-Clause.
*/
package io.usethesource.capsule.core.trie;
public interface SetNode<K, R extends SetNode<K, R>> extends Node {
boolean contains(final K key, final int keyHash, final int shift, | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
// Path: src/main/java/io/usethesource/capsule/core/trie/SetNode.java
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
import io.usethesource.capsule.util.EqualityComparator;
/**
* Copyright (c) Michael Steindorfer <Centrum Wiskunde & Informatica> and Contributors.
* All rights reserved.
*
* This file is licensed under the BSD 2-Clause License, which accompanies this project
* and is available under https://opensource.org/licenses/BSD-2-Clause.
*/
package io.usethesource.capsule.core.trie;
public interface SetNode<K, R extends SetNode<K, R>> extends Node {
boolean contains(final K key, final int keyHash, final int shift, | final EqualityComparator<Object> cmp); |
usethesource/capsule | src/main/java/io/usethesource/capsule/util/collection/AbstractSpecialisedImmutableSet.java | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/EmptySupplierIterator.java
// public class EmptySupplierIterator<K, V> implements SupplierIterator<K, V> {
//
// private static final SupplierIterator EMPTY_ITERATOR = new EmptySupplierIterator();
//
// public static <K, V> SupplierIterator<K, V> emptyIterator() {
// return EMPTY_ITERATOR;
// }
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
// @Override
// public K next() {
// throw new NoSuchElementException();
// }
//
// @Override
// public V get() {
// throw new NoSuchElementException();
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/SupplierIterator.java
// public interface SupplierIterator<K, V> extends Iterator<K>, Supplier<V> {
//
// }
| import java.util.Collection;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import io.usethesource.capsule.util.EqualityComparator;
import io.usethesource.capsule.util.iterator.EmptySupplierIterator;
import io.usethesource.capsule.util.iterator.SupplierIterator; | public boolean removeAll(Collection<?> c) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(Collection<?> c) {
throw new UnsupportedOperationException();
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public boolean isEmpty() {
return size() == 0;
}
@Override
public Iterator<K> iterator() {
return keyIterator();
}
@Override
public boolean equals(final Object other) {
return equivalent(other, Object::equals);
}
@Override | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/EmptySupplierIterator.java
// public class EmptySupplierIterator<K, V> implements SupplierIterator<K, V> {
//
// private static final SupplierIterator EMPTY_ITERATOR = new EmptySupplierIterator();
//
// public static <K, V> SupplierIterator<K, V> emptyIterator() {
// return EMPTY_ITERATOR;
// }
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
// @Override
// public K next() {
// throw new NoSuchElementException();
// }
//
// @Override
// public V get() {
// throw new NoSuchElementException();
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/SupplierIterator.java
// public interface SupplierIterator<K, V> extends Iterator<K>, Supplier<V> {
//
// }
// Path: src/main/java/io/usethesource/capsule/util/collection/AbstractSpecialisedImmutableSet.java
import java.util.Collection;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import io.usethesource.capsule.util.EqualityComparator;
import io.usethesource.capsule.util.iterator.EmptySupplierIterator;
import io.usethesource.capsule.util.iterator.SupplierIterator;
public boolean removeAll(Collection<?> c) {
throw new UnsupportedOperationException();
}
@Override
public boolean retainAll(Collection<?> c) {
throw new UnsupportedOperationException();
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public boolean isEmpty() {
return size() == 0;
}
@Override
public Iterator<K> iterator() {
return keyIterator();
}
@Override
public boolean equals(final Object other) {
return equivalent(other, Object::equals);
}
@Override | public boolean equivalent(final Object other, final EqualityComparator<Object> cmp) { |
usethesource/capsule | src/main/java/io/usethesource/capsule/util/collection/AbstractSpecialisedImmutableSet.java | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/EmptySupplierIterator.java
// public class EmptySupplierIterator<K, V> implements SupplierIterator<K, V> {
//
// private static final SupplierIterator EMPTY_ITERATOR = new EmptySupplierIterator();
//
// public static <K, V> SupplierIterator<K, V> emptyIterator() {
// return EMPTY_ITERATOR;
// }
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
// @Override
// public K next() {
// throw new NoSuchElementException();
// }
//
// @Override
// public V get() {
// throw new NoSuchElementException();
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/SupplierIterator.java
// public interface SupplierIterator<K, V> extends Iterator<K>, Supplier<V> {
//
// }
| import java.util.Collection;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import io.usethesource.capsule.util.EqualityComparator;
import io.usethesource.capsule.util.iterator.EmptySupplierIterator;
import io.usethesource.capsule.util.iterator.SupplierIterator; | Set0() {
}
@Override
public boolean contains(Object key) {
return false;
}
@Override
public boolean containsEquivalent(Object key, EqualityComparator<Object> cmp) {
return false;
}
@Override
public K get(Object key) {
return null;
}
@Override
public K getEquivalent(Object key, EqualityComparator<Object> cmp) {
return null;
}
@Override
public int size() {
return 0;
}
@Override | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/EmptySupplierIterator.java
// public class EmptySupplierIterator<K, V> implements SupplierIterator<K, V> {
//
// private static final SupplierIterator EMPTY_ITERATOR = new EmptySupplierIterator();
//
// public static <K, V> SupplierIterator<K, V> emptyIterator() {
// return EMPTY_ITERATOR;
// }
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
// @Override
// public K next() {
// throw new NoSuchElementException();
// }
//
// @Override
// public V get() {
// throw new NoSuchElementException();
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/SupplierIterator.java
// public interface SupplierIterator<K, V> extends Iterator<K>, Supplier<V> {
//
// }
// Path: src/main/java/io/usethesource/capsule/util/collection/AbstractSpecialisedImmutableSet.java
import java.util.Collection;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import io.usethesource.capsule.util.EqualityComparator;
import io.usethesource.capsule.util.iterator.EmptySupplierIterator;
import io.usethesource.capsule.util.iterator.SupplierIterator;
Set0() {
}
@Override
public boolean contains(Object key) {
return false;
}
@Override
public boolean containsEquivalent(Object key, EqualityComparator<Object> cmp) {
return false;
}
@Override
public K get(Object key) {
return null;
}
@Override
public K getEquivalent(Object key, EqualityComparator<Object> cmp) {
return null;
}
@Override
public int size() {
return 0;
}
@Override | public SupplierIterator<K, K> keyIterator() { |
usethesource/capsule | src/main/java/io/usethesource/capsule/util/collection/AbstractSpecialisedImmutableSet.java | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/EmptySupplierIterator.java
// public class EmptySupplierIterator<K, V> implements SupplierIterator<K, V> {
//
// private static final SupplierIterator EMPTY_ITERATOR = new EmptySupplierIterator();
//
// public static <K, V> SupplierIterator<K, V> emptyIterator() {
// return EMPTY_ITERATOR;
// }
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
// @Override
// public K next() {
// throw new NoSuchElementException();
// }
//
// @Override
// public V get() {
// throw new NoSuchElementException();
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/SupplierIterator.java
// public interface SupplierIterator<K, V> extends Iterator<K>, Supplier<V> {
//
// }
| import java.util.Collection;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import io.usethesource.capsule.util.EqualityComparator;
import io.usethesource.capsule.util.iterator.EmptySupplierIterator;
import io.usethesource.capsule.util.iterator.SupplierIterator; |
}
@Override
public boolean contains(Object key) {
return false;
}
@Override
public boolean containsEquivalent(Object key, EqualityComparator<Object> cmp) {
return false;
}
@Override
public K get(Object key) {
return null;
}
@Override
public K getEquivalent(Object key, EqualityComparator<Object> cmp) {
return null;
}
@Override
public int size() {
return 0;
}
@Override
public SupplierIterator<K, K> keyIterator() { | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/EmptySupplierIterator.java
// public class EmptySupplierIterator<K, V> implements SupplierIterator<K, V> {
//
// private static final SupplierIterator EMPTY_ITERATOR = new EmptySupplierIterator();
//
// public static <K, V> SupplierIterator<K, V> emptyIterator() {
// return EMPTY_ITERATOR;
// }
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
// @Override
// public K next() {
// throw new NoSuchElementException();
// }
//
// @Override
// public V get() {
// throw new NoSuchElementException();
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/SupplierIterator.java
// public interface SupplierIterator<K, V> extends Iterator<K>, Supplier<V> {
//
// }
// Path: src/main/java/io/usethesource/capsule/util/collection/AbstractSpecialisedImmutableSet.java
import java.util.Collection;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import io.usethesource.capsule.util.EqualityComparator;
import io.usethesource.capsule.util.iterator.EmptySupplierIterator;
import io.usethesource.capsule.util.iterator.SupplierIterator;
}
@Override
public boolean contains(Object key) {
return false;
}
@Override
public boolean containsEquivalent(Object key, EqualityComparator<Object> cmp) {
return false;
}
@Override
public K get(Object key) {
return null;
}
@Override
public K getEquivalent(Object key, EqualityComparator<Object> cmp) {
return null;
}
@Override
public int size() {
return 0;
}
@Override
public SupplierIterator<K, K> keyIterator() { | return EmptySupplierIterator.emptyIterator(); |
usethesource/capsule | src/main/java/io/usethesource/capsule/SetMultimapEq.java | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
| import java.util.Comparator;
import io.usethesource.capsule.util.EqualityComparator; | /**
* Copyright (c) Michael Steindorfer <Centrum Wiskunde & Informatica> and Contributors.
* All rights reserved.
*
* This file is licensed under the BSD 2-Clause License, which accompanies this project
* and is available under https://opensource.org/licenses/BSD-2-Clause.
*/
package io.usethesource.capsule;
/**
* This interface extends multi-maps for usage with custom data element comparators.
*/
@Deprecated
public interface SetMultimapEq<K, V> extends SetMultimap<K, V> {
| // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
// Path: src/main/java/io/usethesource/capsule/SetMultimapEq.java
import java.util.Comparator;
import io.usethesource.capsule.util.EqualityComparator;
/**
* Copyright (c) Michael Steindorfer <Centrum Wiskunde & Informatica> and Contributors.
* All rights reserved.
*
* This file is licensed under the BSD 2-Clause License, which accompanies this project
* and is available under https://opensource.org/licenses/BSD-2-Clause.
*/
package io.usethesource.capsule;
/**
* This interface extends multi-maps for usage with custom data element comparators.
*/
@Deprecated
public interface SetMultimapEq<K, V> extends SetMultimap<K, V> {
| default boolean containsKeyEquivalent(final Object o, final EqualityComparator<Object> cmp) { |
usethesource/capsule | src/main/java/io/usethesource/capsule/util/collection/AbstractSpecialisedImmutableMap.java | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/EmptySupplierIterator.java
// public class EmptySupplierIterator<K, V> implements SupplierIterator<K, V> {
//
// private static final SupplierIterator EMPTY_ITERATOR = new EmptySupplierIterator();
//
// public static <K, V> SupplierIterator<K, V> emptyIterator() {
// return EMPTY_ITERATOR;
// }
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
// @Override
// public K next() {
// throw new NoSuchElementException();
// }
//
// @Override
// public V get() {
// throw new NoSuchElementException();
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/SupplierIterator.java
// public interface SupplierIterator<K, V> extends Iterator<K>, Supplier<V> {
//
// }
| import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import io.usethesource.capsule.util.EqualityComparator;
import io.usethesource.capsule.util.iterator.EmptySupplierIterator;
import io.usethesource.capsule.util.iterator.SupplierIterator; | public V remove(Object key) {
throw new UnsupportedOperationException();
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public V put(K key, V value) {
throw new UnsupportedOperationException();
}
@Override
public void putAll(Map<? extends K, ? extends V> m) {
throw new UnsupportedOperationException();
}
@Override
public boolean isEmpty() {
return size() == 0;
}
@Override
public boolean equals(final Object other) {
return equivalent(other, Object::equals);
}
@Override | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/EmptySupplierIterator.java
// public class EmptySupplierIterator<K, V> implements SupplierIterator<K, V> {
//
// private static final SupplierIterator EMPTY_ITERATOR = new EmptySupplierIterator();
//
// public static <K, V> SupplierIterator<K, V> emptyIterator() {
// return EMPTY_ITERATOR;
// }
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
// @Override
// public K next() {
// throw new NoSuchElementException();
// }
//
// @Override
// public V get() {
// throw new NoSuchElementException();
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/SupplierIterator.java
// public interface SupplierIterator<K, V> extends Iterator<K>, Supplier<V> {
//
// }
// Path: src/main/java/io/usethesource/capsule/util/collection/AbstractSpecialisedImmutableMap.java
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import io.usethesource.capsule.util.EqualityComparator;
import io.usethesource.capsule.util.iterator.EmptySupplierIterator;
import io.usethesource.capsule.util.iterator.SupplierIterator;
public V remove(Object key) {
throw new UnsupportedOperationException();
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public V put(K key, V value) {
throw new UnsupportedOperationException();
}
@Override
public void putAll(Map<? extends K, ? extends V> m) {
throw new UnsupportedOperationException();
}
@Override
public boolean isEmpty() {
return size() == 0;
}
@Override
public boolean equals(final Object other) {
return equivalent(other, Object::equals);
}
@Override | public boolean equivalent(final Object other, final EqualityComparator<Object> cmp) { |
usethesource/capsule | src/main/java/io/usethesource/capsule/util/collection/AbstractSpecialisedImmutableMap.java | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/EmptySupplierIterator.java
// public class EmptySupplierIterator<K, V> implements SupplierIterator<K, V> {
//
// private static final SupplierIterator EMPTY_ITERATOR = new EmptySupplierIterator();
//
// public static <K, V> SupplierIterator<K, V> emptyIterator() {
// return EMPTY_ITERATOR;
// }
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
// @Override
// public K next() {
// throw new NoSuchElementException();
// }
//
// @Override
// public V get() {
// throw new NoSuchElementException();
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/SupplierIterator.java
// public interface SupplierIterator<K, V> extends Iterator<K>, Supplier<V> {
//
// }
| import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import io.usethesource.capsule.util.EqualityComparator;
import io.usethesource.capsule.util.iterator.EmptySupplierIterator;
import io.usethesource.capsule.util.iterator.SupplierIterator; | public V get(Object key) {
return null;
}
@Override
public V getEquivalent(Object key, EqualityComparator<Object> cmp) {
return null;
}
@Override
public int size() {
return 0;
}
@Override
public Set<Entry<K, V>> entrySet() {
return Collections.emptySet();
}
@Override
public Set<K> keySet() {
return Collections.emptySet();
}
@Override
public Collection<V> values() {
return Collections.emptySet();
}
@Override | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/EmptySupplierIterator.java
// public class EmptySupplierIterator<K, V> implements SupplierIterator<K, V> {
//
// private static final SupplierIterator EMPTY_ITERATOR = new EmptySupplierIterator();
//
// public static <K, V> SupplierIterator<K, V> emptyIterator() {
// return EMPTY_ITERATOR;
// }
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
// @Override
// public K next() {
// throw new NoSuchElementException();
// }
//
// @Override
// public V get() {
// throw new NoSuchElementException();
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/SupplierIterator.java
// public interface SupplierIterator<K, V> extends Iterator<K>, Supplier<V> {
//
// }
// Path: src/main/java/io/usethesource/capsule/util/collection/AbstractSpecialisedImmutableMap.java
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import io.usethesource.capsule.util.EqualityComparator;
import io.usethesource.capsule.util.iterator.EmptySupplierIterator;
import io.usethesource.capsule.util.iterator.SupplierIterator;
public V get(Object key) {
return null;
}
@Override
public V getEquivalent(Object key, EqualityComparator<Object> cmp) {
return null;
}
@Override
public int size() {
return 0;
}
@Override
public Set<Entry<K, V>> entrySet() {
return Collections.emptySet();
}
@Override
public Set<K> keySet() {
return Collections.emptySet();
}
@Override
public Collection<V> values() {
return Collections.emptySet();
}
@Override | public SupplierIterator<K, V> keyIterator() { |
usethesource/capsule | src/main/java/io/usethesource/capsule/util/collection/AbstractSpecialisedImmutableMap.java | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/EmptySupplierIterator.java
// public class EmptySupplierIterator<K, V> implements SupplierIterator<K, V> {
//
// private static final SupplierIterator EMPTY_ITERATOR = new EmptySupplierIterator();
//
// public static <K, V> SupplierIterator<K, V> emptyIterator() {
// return EMPTY_ITERATOR;
// }
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
// @Override
// public K next() {
// throw new NoSuchElementException();
// }
//
// @Override
// public V get() {
// throw new NoSuchElementException();
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/SupplierIterator.java
// public interface SupplierIterator<K, V> extends Iterator<K>, Supplier<V> {
//
// }
| import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import io.usethesource.capsule.util.EqualityComparator;
import io.usethesource.capsule.util.iterator.EmptySupplierIterator;
import io.usethesource.capsule.util.iterator.SupplierIterator; | return null;
}
@Override
public V getEquivalent(Object key, EqualityComparator<Object> cmp) {
return null;
}
@Override
public int size() {
return 0;
}
@Override
public Set<Entry<K, V>> entrySet() {
return Collections.emptySet();
}
@Override
public Set<K> keySet() {
return Collections.emptySet();
}
@Override
public Collection<V> values() {
return Collections.emptySet();
}
@Override
public SupplierIterator<K, V> keyIterator() { | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/EmptySupplierIterator.java
// public class EmptySupplierIterator<K, V> implements SupplierIterator<K, V> {
//
// private static final SupplierIterator EMPTY_ITERATOR = new EmptySupplierIterator();
//
// public static <K, V> SupplierIterator<K, V> emptyIterator() {
// return EMPTY_ITERATOR;
// }
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
// @Override
// public K next() {
// throw new NoSuchElementException();
// }
//
// @Override
// public V get() {
// throw new NoSuchElementException();
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
//
// }
//
// Path: src/main/java/io/usethesource/capsule/util/iterator/SupplierIterator.java
// public interface SupplierIterator<K, V> extends Iterator<K>, Supplier<V> {
//
// }
// Path: src/main/java/io/usethesource/capsule/util/collection/AbstractSpecialisedImmutableMap.java
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import io.usethesource.capsule.util.EqualityComparator;
import io.usethesource.capsule.util.iterator.EmptySupplierIterator;
import io.usethesource.capsule.util.iterator.SupplierIterator;
return null;
}
@Override
public V getEquivalent(Object key, EqualityComparator<Object> cmp) {
return null;
}
@Override
public int size() {
return 0;
}
@Override
public Set<Entry<K, V>> entrySet() {
return Collections.emptySet();
}
@Override
public Set<K> keySet() {
return Collections.emptySet();
}
@Override
public Collection<V> values() {
return Collections.emptySet();
}
@Override
public SupplierIterator<K, V> keyIterator() { | return EmptySupplierIterator.emptyIterator(); |
usethesource/capsule | src/main/java/io/usethesource/capsule/SetEq.java | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
| import java.util.Collection;
import java.util.Comparator;
import io.usethesource.capsule.util.EqualityComparator; | /**
* Copyright (c) Michael Steindorfer <Centrum Wiskunde & Informatica> and Contributors.
* All rights reserved.
*
* This file is licensed under the BSD 2-Clause License, which accompanies this project
* and is available under https://opensource.org/licenses/BSD-2-Clause.
*/
package io.usethesource.capsule;
/**
* Set extension providing methods that take a comparator. Closes over base (and not extended) set.
*/
@Deprecated
public interface SetEq<K> extends java.util.Set<K> {
| // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
// Path: src/main/java/io/usethesource/capsule/SetEq.java
import java.util.Collection;
import java.util.Comparator;
import io.usethesource.capsule.util.EqualityComparator;
/**
* Copyright (c) Michael Steindorfer <Centrum Wiskunde & Informatica> and Contributors.
* All rights reserved.
*
* This file is licensed under the BSD 2-Clause License, which accompanies this project
* and is available under https://opensource.org/licenses/BSD-2-Clause.
*/
package io.usethesource.capsule;
/**
* Set extension providing methods that take a comparator. Closes over base (and not extended) set.
*/
@Deprecated
public interface SetEq<K> extends java.util.Set<K> {
| default boolean containsEquivalent(final Object o, final EqualityComparator<Object> cmp) { |
usethesource/capsule | src/main/java/io/usethesource/capsule/core/trie/MapNode.java | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
| import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
import io.usethesource.capsule.util.EqualityComparator; | /**
* Copyright (c) Michael Steindorfer <Centrum Wiskunde & Informatica> and Contributors.
* All rights reserved.
*
* This file is licensed under the BSD 2-Clause License, which accompanies this project
* and is available under https://opensource.org/licenses/BSD-2-Clause.
*/
package io.usethesource.capsule.core.trie;
public interface MapNode<K, V, R extends MapNode<K, V, R>> extends Node {
boolean containsKey(final K key, final int keyHash, final int shift, | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
// Path: src/main/java/io/usethesource/capsule/core/trie/MapNode.java
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
import io.usethesource.capsule.util.EqualityComparator;
/**
* Copyright (c) Michael Steindorfer <Centrum Wiskunde & Informatica> and Contributors.
* All rights reserved.
*
* This file is licensed under the BSD 2-Clause License, which accompanies this project
* and is available under https://opensource.org/licenses/BSD-2-Clause.
*/
package io.usethesource.capsule.core.trie;
public interface MapNode<K, V, R extends MapNode<K, V, R>> extends Node {
boolean containsKey(final K key, final int keyHash, final int shift, | final EqualityComparator<Object> cmp); |
usethesource/capsule | src/main/java/io/usethesource/capsule/MapEq.java | // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
| import io.usethesource.capsule.util.EqualityComparator; | /**
* Copyright (c) Michael Steindorfer <Centrum Wiskunde & Informatica> and Contributors.
* All rights reserved.
*
* This file is licensed under the BSD 2-Clause License, which accompanies this project
* and is available under https://opensource.org/licenses/BSD-2-Clause.
*/
package io.usethesource.capsule;
/**
* Map extension providing methods that take a comparator. Closes over base (and not extended) map.
*/
@Deprecated
public interface MapEq<K, V> extends java.util.Map<K, V> {
| // Path: src/main/java/io/usethesource/capsule/util/EqualityComparator.java
// @FunctionalInterface
// public interface EqualityComparator<T> extends java.io.Serializable {
//
// static <T> EqualityComparator<T> fromComparator(Comparator<T> comparator) {
// return (a, b) -> comparator.compare(a, b) == 0;
// }
//
// static <T> boolean equals(T a, T b,
// ToBooleanBiFunction<T, T> comparator) {
// return (a == b) || (a != null && comparator.applyAsBoolean(a, b));
// }
//
// @Deprecated // substitute with Object::equals
// EqualityComparator<Object> EQUALS = (a, b) -> Objects.equals(a, b);
//
// boolean equals(T o1, T o2);
//
// @Deprecated // limit use of Comparator interface (prefer EqualityComparator)
// default Comparator<T> toComparator() {
// return ((o1, o2) -> equals(o1, o2) == true ? 0 : -1);
// }
//
// }
// Path: src/main/java/io/usethesource/capsule/MapEq.java
import io.usethesource.capsule.util.EqualityComparator;
/**
* Copyright (c) Michael Steindorfer <Centrum Wiskunde & Informatica> and Contributors.
* All rights reserved.
*
* This file is licensed under the BSD 2-Clause License, which accompanies this project
* and is available under https://opensource.org/licenses/BSD-2-Clause.
*/
package io.usethesource.capsule;
/**
* Map extension providing methods that take a comparator. Closes over base (and not extended) map.
*/
@Deprecated
public interface MapEq<K, V> extends java.util.Map<K, V> {
| default boolean containsKeyEquivalent(final Object o, final EqualityComparator<Object> cmp) { |
premium-minds/pm-wicket-utils | core/src/main/java/com/premiumminds/webapp/wicket/bootstrap/BootstrapDateTimePicker.java | // Path: core/src/main/java/com/premiumminds/webapp/wicket/bootstrap/datetimepicker/BootstrapDateTimePickerBehaviour.java
// public class BootstrapDateTimePickerBehaviour extends Behavior
// {
// private static final long serialVersionUID = 1L;
//
// private static final ResourceReference DATETIME_PICKER_CSS = new CssResourceReference(BootstrapDateTimePickerBehaviour.class, "bootstrap-datetimepicker.min.css");
// private static final ResourceReference DATETIME_PICKER_JAVASCRIPT = new JavaScriptResourceReference(BootstrapDateTimePickerBehaviour.class, "bootstrap-datetimepicker.js");
// private static final ResourceReference MOMENT_JAVASCRIPT = new JavaScriptResourceReference(BootstrapDateTimePickerBehaviour.class, "moment-with-locales.min.js");
//
// @Override
// public void onConfigure(Component component)
// {
// super.onConfigure(component);
//
// component.setOutputMarkupId(true);
// }
//
// @Override
// public void renderHead(Component component, IHeaderResponse response)
// {
// super.renderHead(component, response);
//
// if(component.isEnabledInHierarchy()) {
//
// response.render(CssReferenceHeaderItem.forReference(DATETIME_PICKER_CSS));
// response.render(JavaScriptHeaderItem.forReference(MOMENT_JAVASCRIPT));
// response.render(JavaScriptHeaderItem.forReference(DATETIME_PICKER_JAVASCRIPT));
//
// if(!component.getLocale().getLanguage().equals("en")) {
//
// response.render(JavaScriptHeaderItem.forReference(
// new JavaScriptResourceReference(BootstrapDateTimePickerBehaviour.class
// , "locales/" + component.getLocale().getLanguage() + ".js")));
// }
//
// /** Not supporting special dates at the moment **/
//
// response.render(OnDomReadyHeaderItem.forScript("$(\"#" + component.getMarkupId() + "\").datetimepicker({ "
// + " format: 'DD/MM/YYYY HH:mm:ss',"
// + " icons: { "
// + " time: 'fa fa-clock-o',"
// + " date: 'fa fa-calendar',"
// + " up: 'fa fa-arrow-up',"
// + " down: 'fa fa-arrow-down',"
// + " previous: 'fa fa-arrow-left',"
// + " next: 'fa fa-arrow-right'"
// + "}"
// + "});"
//
// ));
// }
// }
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag)
// {
// super.onComponentTag(component, tag);
//
// if(component.isEnabledInHierarchy()) {
//
// tag.put("data-date-language", component.getLocale().getLanguage());
// }
// }
// }
| import com.premiumminds.webapp.wicket.bootstrap.datetimepicker.BootstrapDateTimePickerBehaviour;
import java.util.Date;
import org.apache.wicket.IGenericComponent;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.extensions.markup.html.form.DateTextField;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.IModel;
import org.apache.wicket.util.visit.IVisit;
import org.apache.wicket.util.visit.IVisitor; | /**
* Copyright (C) 2016 Premium Minds.
*
* This file is part of pm-wicket-utils.
*
* pm-wicket-utils 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, either version 3 of the License, or (at your option) any
* later version.
*
* pm-wicket-utils 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 pm-wicket-utils. If not, see <http://www.gnu.org/licenses/>.
*/
package com.premiumminds.webapp.wicket.bootstrap;
/**
* Bootstrap DateTime picker for Wicket.
*
* Requires jQuery, BootStrap and Font Awesome. Warning: make sure your jQuery is loaded as a priority header item!
*
* @author npires
* @see <a href="https://eonasdan.github.io/bootstrap-datetimepicker/">Bootstrap 3 DateTime picker</a>
*/
public class BootstrapDateTimePicker extends WebMarkupContainer implements IGenericComponent<Date, TextField<Date>>
{
private static final long serialVersionUID = 1L;
private DateTextField dateField;
/**
* Instantiates a new bootstrap datetimepicker.
*
* @param id the wicket:id
*/
public BootstrapDateTimePicker(String id)
{
super(id);
| // Path: core/src/main/java/com/premiumminds/webapp/wicket/bootstrap/datetimepicker/BootstrapDateTimePickerBehaviour.java
// public class BootstrapDateTimePickerBehaviour extends Behavior
// {
// private static final long serialVersionUID = 1L;
//
// private static final ResourceReference DATETIME_PICKER_CSS = new CssResourceReference(BootstrapDateTimePickerBehaviour.class, "bootstrap-datetimepicker.min.css");
// private static final ResourceReference DATETIME_PICKER_JAVASCRIPT = new JavaScriptResourceReference(BootstrapDateTimePickerBehaviour.class, "bootstrap-datetimepicker.js");
// private static final ResourceReference MOMENT_JAVASCRIPT = new JavaScriptResourceReference(BootstrapDateTimePickerBehaviour.class, "moment-with-locales.min.js");
//
// @Override
// public void onConfigure(Component component)
// {
// super.onConfigure(component);
//
// component.setOutputMarkupId(true);
// }
//
// @Override
// public void renderHead(Component component, IHeaderResponse response)
// {
// super.renderHead(component, response);
//
// if(component.isEnabledInHierarchy()) {
//
// response.render(CssReferenceHeaderItem.forReference(DATETIME_PICKER_CSS));
// response.render(JavaScriptHeaderItem.forReference(MOMENT_JAVASCRIPT));
// response.render(JavaScriptHeaderItem.forReference(DATETIME_PICKER_JAVASCRIPT));
//
// if(!component.getLocale().getLanguage().equals("en")) {
//
// response.render(JavaScriptHeaderItem.forReference(
// new JavaScriptResourceReference(BootstrapDateTimePickerBehaviour.class
// , "locales/" + component.getLocale().getLanguage() + ".js")));
// }
//
// /** Not supporting special dates at the moment **/
//
// response.render(OnDomReadyHeaderItem.forScript("$(\"#" + component.getMarkupId() + "\").datetimepicker({ "
// + " format: 'DD/MM/YYYY HH:mm:ss',"
// + " icons: { "
// + " time: 'fa fa-clock-o',"
// + " date: 'fa fa-calendar',"
// + " up: 'fa fa-arrow-up',"
// + " down: 'fa fa-arrow-down',"
// + " previous: 'fa fa-arrow-left',"
// + " next: 'fa fa-arrow-right'"
// + "}"
// + "});"
//
// ));
// }
// }
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag)
// {
// super.onComponentTag(component, tag);
//
// if(component.isEnabledInHierarchy()) {
//
// tag.put("data-date-language", component.getLocale().getLanguage());
// }
// }
// }
// Path: core/src/main/java/com/premiumminds/webapp/wicket/bootstrap/BootstrapDateTimePicker.java
import com.premiumminds.webapp.wicket.bootstrap.datetimepicker.BootstrapDateTimePickerBehaviour;
import java.util.Date;
import org.apache.wicket.IGenericComponent;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.extensions.markup.html.form.DateTextField;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.IModel;
import org.apache.wicket.util.visit.IVisit;
import org.apache.wicket.util.visit.IVisitor;
/**
* Copyright (C) 2016 Premium Minds.
*
* This file is part of pm-wicket-utils.
*
* pm-wicket-utils 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, either version 3 of the License, or (at your option) any
* later version.
*
* pm-wicket-utils 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 pm-wicket-utils. If not, see <http://www.gnu.org/licenses/>.
*/
package com.premiumminds.webapp.wicket.bootstrap;
/**
* Bootstrap DateTime picker for Wicket.
*
* Requires jQuery, BootStrap and Font Awesome. Warning: make sure your jQuery is loaded as a priority header item!
*
* @author npires
* @see <a href="https://eonasdan.github.io/bootstrap-datetimepicker/">Bootstrap 3 DateTime picker</a>
*/
public class BootstrapDateTimePicker extends WebMarkupContainer implements IGenericComponent<Date, TextField<Date>>
{
private static final long serialVersionUID = 1L;
private DateTextField dateField;
/**
* Instantiates a new bootstrap datetimepicker.
*
* @param id the wicket:id
*/
public BootstrapDateTimePicker(String id)
{
super(id);
| add(new BootstrapDateTimePickerBehaviour()); |
premium-minds/pm-wicket-utils | core/src/test/java/com/premiumminds/webapp/wicket/validators/HibernateValidatorPropertyTest.java | // Path: core/src/main/java/com/premiumminds/webapp/wicket/validators/HibernateValidatorProperty.java
// public class HibernateValidatorProperty implements IValidator<Object> {
// private static final long serialVersionUID = -4761422631335653016L;
//
// private IModel<?> beanModel;
// private String propertyName;
//
// public static final ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
//
// public HibernateValidatorProperty(IModel<?> beanModel, String propertyName){
// this.beanModel = beanModel;
// this.propertyName = propertyName;
// }
//
// public void validate(IValidatable<Object> validatable) {
// Validator validator = HibernateValidatorProperty.validatorFactory.getValidator();
//
// @SuppressWarnings("unchecked")
// Set<ConstraintViolation<Object>> violations = validator.validateValue((Class<Object>)beanModel.getObject().getClass(), propertyName, validatable.getValue());
//
// if(!violations.isEmpty()){
// for(ConstraintViolation<?> violation : violations){
// ValidationError error = new ValidationError(violation.getMessage());
//
// String key = violation.getConstraintDescriptor().getAnnotation().annotationType().getSimpleName();
// if(getValidatorPrefix()!=null) key = getValidatorPrefix()+"."+key;
//
// error.addKey(key);
// error.setVariables(new HashMap<String, Object>(violation.getConstraintDescriptor().getAttributes()));
//
// //remove garbage from the attributes
// error.getVariables().remove("payload");
// error.getVariables().remove("message");
// error.getVariables().remove("groups");
//
// validatable.error(error);
// }
// }
// }
//
// protected String getValidatorPrefix(){
// return null;
// }
//
// }
| import com.premiumminds.webapp.wicket.validators.HibernateValidatorProperty;
import static org.junit.Assert.*;
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.apache.wicket.model.Model;
import org.apache.wicket.validation.IValidator;
import org.apache.wicket.validation.Validatable;
import org.apache.wicket.validation.ValidationError;
import org.junit.Test; | /**
* Copyright (C) 2016 Premium Minds.
*
* This file is part of pm-wicket-utils.
*
* pm-wicket-utils 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, either version 3 of the License, or (at your option) any
* later version.
*
* pm-wicket-utils 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 pm-wicket-utils. If not, see <http://www.gnu.org/licenses/>.
*/
package com.premiumminds.webapp.wicket.validators;
public class HibernateValidatorPropertyTest {
@Test
public void testNotNull() { | // Path: core/src/main/java/com/premiumminds/webapp/wicket/validators/HibernateValidatorProperty.java
// public class HibernateValidatorProperty implements IValidator<Object> {
// private static final long serialVersionUID = -4761422631335653016L;
//
// private IModel<?> beanModel;
// private String propertyName;
//
// public static final ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
//
// public HibernateValidatorProperty(IModel<?> beanModel, String propertyName){
// this.beanModel = beanModel;
// this.propertyName = propertyName;
// }
//
// public void validate(IValidatable<Object> validatable) {
// Validator validator = HibernateValidatorProperty.validatorFactory.getValidator();
//
// @SuppressWarnings("unchecked")
// Set<ConstraintViolation<Object>> violations = validator.validateValue((Class<Object>)beanModel.getObject().getClass(), propertyName, validatable.getValue());
//
// if(!violations.isEmpty()){
// for(ConstraintViolation<?> violation : violations){
// ValidationError error = new ValidationError(violation.getMessage());
//
// String key = violation.getConstraintDescriptor().getAnnotation().annotationType().getSimpleName();
// if(getValidatorPrefix()!=null) key = getValidatorPrefix()+"."+key;
//
// error.addKey(key);
// error.setVariables(new HashMap<String, Object>(violation.getConstraintDescriptor().getAttributes()));
//
// //remove garbage from the attributes
// error.getVariables().remove("payload");
// error.getVariables().remove("message");
// error.getVariables().remove("groups");
//
// validatable.error(error);
// }
// }
// }
//
// protected String getValidatorPrefix(){
// return null;
// }
//
// }
// Path: core/src/test/java/com/premiumminds/webapp/wicket/validators/HibernateValidatorPropertyTest.java
import com.premiumminds.webapp.wicket.validators.HibernateValidatorProperty;
import static org.junit.Assert.*;
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.apache.wicket.model.Model;
import org.apache.wicket.validation.IValidator;
import org.apache.wicket.validation.Validatable;
import org.apache.wicket.validation.ValidationError;
import org.junit.Test;
/**
* Copyright (C) 2016 Premium Minds.
*
* This file is part of pm-wicket-utils.
*
* pm-wicket-utils 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, either version 3 of the License, or (at your option) any
* later version.
*
* pm-wicket-utils 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 pm-wicket-utils. If not, see <http://www.gnu.org/licenses/>.
*/
package com.premiumminds.webapp.wicket.validators;
public class HibernateValidatorPropertyTest {
@Test
public void testNotNull() { | IValidator<Object> validator = new HibernateValidatorProperty(new Model<TestBean>(new TestBean("aaa", "aaa")), "a"); |
premium-minds/pm-wicket-utils | core/src/test/java/com/premiumminds/webapp/wicket/validators/PortugueseNIFValidatorTest.java | // Path: core/src/main/java/com/premiumminds/webapp/wicket/validators/PortugueseNIFValidator.java
// public class PortugueseNIFValidator extends StringValidator {
// private static final long serialVersionUID = -8262152957585701745L;
//
// @Override
// public void validate(IValidatable<String> validatable) {
// super.validate(validatable);
//
// final String value = validatable.getValue();
//
// if(value==null || value.length()==0) return;
//
// try {
// if(!isNIFValid(value)) validatable.error(new ValidationError(this));
// } catch(NumberFormatException e){
// validatable.error(new ValidationError(this));
// }
// }
//
// public static boolean isNIFValid(String number){
// // 9 digits required
// if(number.length() != 9) {
// return false;
// }
//
// boolean validFirstDigit = "123568".chars().mapToObj(c -> number.charAt(0) == c).filter(b -> b).findAny().orElse(false);
//
// List<String> firstDoubleDigits = Arrays.asList("45", "70", "71", "72", "74", "75", "77", "79", "90", "91", "98", "99");
// boolean validDoubleDigits = firstDoubleDigits.stream().map(c -> number.substring(0, 2).equals(c)).filter(b -> b).findAny().orElse(false);
//
// if(!validFirstDigit && !validDoubleDigits){
// return false;
// }
//
// int[] numbers = new int[9];
// char[] chars = number.toCharArray();
// for(int i = 0; i < 9; i++) {
// numbers[i] = Integer.parseInt(Character.toString(chars[i]));
// }
//
// // The weighted sum of all digits, including the control digit, should be multiple of 11
// int result = 0;
// for(int i = 0, j = 9; i < 8; i++, j--) {
// result += (j*numbers[i]);
// }
//
// // The infamous bug:
// // When the weighted sum of all digits, excluding the control digit,
// // equals 1 module 11, the control digit should be 10 (sic).
// // Then, we replace 10 by 0:
// if (result % 11 == 1) {
// return numbers[8] == 0;
// }
//
// return (result + numbers[8]) % 11 == 0;
// }
// }
| import static org.junit.Assert.*;
import org.apache.wicket.validation.IValidator;
import org.apache.wicket.validation.Validatable;
import org.junit.Test;
import com.premiumminds.webapp.wicket.validators.PortugueseNIFValidator; | /**
* Copyright (C) 2016 Premium Minds.
*
* This file is part of pm-wicket-utils.
*
* pm-wicket-utils 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, either version 3 of the License, or (at your option) any
* later version.
*
* pm-wicket-utils 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 pm-wicket-utils. If not, see <http://www.gnu.org/licenses/>.
*/
package com.premiumminds.webapp.wicket.validators;
public class PortugueseNIFValidatorTest {
@Test
public void testValidNif() { | // Path: core/src/main/java/com/premiumminds/webapp/wicket/validators/PortugueseNIFValidator.java
// public class PortugueseNIFValidator extends StringValidator {
// private static final long serialVersionUID = -8262152957585701745L;
//
// @Override
// public void validate(IValidatable<String> validatable) {
// super.validate(validatable);
//
// final String value = validatable.getValue();
//
// if(value==null || value.length()==0) return;
//
// try {
// if(!isNIFValid(value)) validatable.error(new ValidationError(this));
// } catch(NumberFormatException e){
// validatable.error(new ValidationError(this));
// }
// }
//
// public static boolean isNIFValid(String number){
// // 9 digits required
// if(number.length() != 9) {
// return false;
// }
//
// boolean validFirstDigit = "123568".chars().mapToObj(c -> number.charAt(0) == c).filter(b -> b).findAny().orElse(false);
//
// List<String> firstDoubleDigits = Arrays.asList("45", "70", "71", "72", "74", "75", "77", "79", "90", "91", "98", "99");
// boolean validDoubleDigits = firstDoubleDigits.stream().map(c -> number.substring(0, 2).equals(c)).filter(b -> b).findAny().orElse(false);
//
// if(!validFirstDigit && !validDoubleDigits){
// return false;
// }
//
// int[] numbers = new int[9];
// char[] chars = number.toCharArray();
// for(int i = 0; i < 9; i++) {
// numbers[i] = Integer.parseInt(Character.toString(chars[i]));
// }
//
// // The weighted sum of all digits, including the control digit, should be multiple of 11
// int result = 0;
// for(int i = 0, j = 9; i < 8; i++, j--) {
// result += (j*numbers[i]);
// }
//
// // The infamous bug:
// // When the weighted sum of all digits, excluding the control digit,
// // equals 1 module 11, the control digit should be 10 (sic).
// // Then, we replace 10 by 0:
// if (result % 11 == 1) {
// return numbers[8] == 0;
// }
//
// return (result + numbers[8]) % 11 == 0;
// }
// }
// Path: core/src/test/java/com/premiumminds/webapp/wicket/validators/PortugueseNIFValidatorTest.java
import static org.junit.Assert.*;
import org.apache.wicket.validation.IValidator;
import org.apache.wicket.validation.Validatable;
import org.junit.Test;
import com.premiumminds.webapp.wicket.validators.PortugueseNIFValidator;
/**
* Copyright (C) 2016 Premium Minds.
*
* This file is part of pm-wicket-utils.
*
* pm-wicket-utils 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, either version 3 of the License, or (at your option) any
* later version.
*
* pm-wicket-utils 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 pm-wicket-utils. If not, see <http://www.gnu.org/licenses/>.
*/
package com.premiumminds.webapp.wicket.validators;
public class PortugueseNIFValidatorTest {
@Test
public void testValidNif() { | IValidator<String> validator = new PortugueseNIFValidator(); |
premium-minds/pm-wicket-utils | core/src/main/java/com/premiumminds/webapp/wicket/bootstrap/BootstrapFeedbackPanel.java | // Path: core/src/main/java/com/premiumminds/webapp/wicket/UniqueFeedbackMessageFilter.java
// public class UniqueFeedbackMessageFilter implements IFeedbackMessageFilter {
// private static final long serialVersionUID = 1230282488271953295L;
//
// private List<FeedbackMessage> messages = new ArrayList<FeedbackMessage>();
//
// public void clearMessages(){
// messages.clear();
// }
//
// @Override
// public boolean accept(FeedbackMessage message) {
// // too bad that FeedbackMessage doesnt have an equals implementation
// for(FeedbackMessage m : messages){
// if(m.getMessage().toString().equals(message.getMessage())) return false;
// }
// return true;
// }
//
// }
| import org.apache.wicket.Component;
import org.apache.wicket.feedback.ComponentFeedbackMessageFilter;
import org.apache.wicket.feedback.FeedbackMessage;
import org.apache.wicket.feedback.IFeedbackMessageFilter;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.util.visit.IVisitor;
import org.apache.wicket.util.visit.IVisit;
import com.premiumminds.webapp.wicket.UniqueFeedbackMessageFilter; |
add(new WebMarkupContainer("close"){
private static final long serialVersionUID = 1566780832755857170L;
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
StringBuilder sb = new StringBuilder();
sb.append("$('#"+this.getMarkupId()+"').click(function(){");
sb.append(" $('#"+BootstrapFeedbackPanel.this.getMarkupId()+"').hide();");
sb.append("})");
response.render(OnDomReadyHeaderItem.forScript(sb.toString()));
}
});
}
@Override
protected void onConfigure() {
super.onConfigure();
setVisible(anyMessage());
}
/**
* Enable filter to only display unique feedback messages (enabled by default)
* @return this panel for fluent api
*/
public BootstrapFeedbackPanel uniqueMessages(){
if(filter!=null){ | // Path: core/src/main/java/com/premiumminds/webapp/wicket/UniqueFeedbackMessageFilter.java
// public class UniqueFeedbackMessageFilter implements IFeedbackMessageFilter {
// private static final long serialVersionUID = 1230282488271953295L;
//
// private List<FeedbackMessage> messages = new ArrayList<FeedbackMessage>();
//
// public void clearMessages(){
// messages.clear();
// }
//
// @Override
// public boolean accept(FeedbackMessage message) {
// // too bad that FeedbackMessage doesnt have an equals implementation
// for(FeedbackMessage m : messages){
// if(m.getMessage().toString().equals(message.getMessage())) return false;
// }
// return true;
// }
//
// }
// Path: core/src/main/java/com/premiumminds/webapp/wicket/bootstrap/BootstrapFeedbackPanel.java
import org.apache.wicket.Component;
import org.apache.wicket.feedback.ComponentFeedbackMessageFilter;
import org.apache.wicket.feedback.FeedbackMessage;
import org.apache.wicket.feedback.IFeedbackMessageFilter;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.util.visit.IVisitor;
import org.apache.wicket.util.visit.IVisit;
import com.premiumminds.webapp.wicket.UniqueFeedbackMessageFilter;
add(new WebMarkupContainer("close"){
private static final long serialVersionUID = 1566780832755857170L;
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
StringBuilder sb = new StringBuilder();
sb.append("$('#"+this.getMarkupId()+"').click(function(){");
sb.append(" $('#"+BootstrapFeedbackPanel.this.getMarkupId()+"').hide();");
sb.append("})");
response.render(OnDomReadyHeaderItem.forScript(sb.toString()));
}
});
}
@Override
protected void onConfigure() {
super.onConfigure();
setVisible(anyMessage());
}
/**
* Enable filter to only display unique feedback messages (enabled by default)
* @return this panel for fluent api
*/
public BootstrapFeedbackPanel uniqueMessages(){
if(filter!=null){ | setFilter(new AndComposedFeedbackMessageFilter(new UniqueFeedbackMessageFilter(), new ExcludePopoverMessageFilter(), filter)); |
premium-minds/pm-wicket-utils | core/src/main/java/com/premiumminds/webapp/wicket/bootstrap/datepicker/BootstrapDatePickerBehaviour.java | // Path: core/src/main/java/com/premiumminds/webapp/wicket/bootstrap/SpecialDate.java
// public final class SpecialDate implements Serializable {
// private static final long serialVersionUID = 1L;
//
// private Date dt;
// private String cssClass, tooltip;
//
// public SpecialDate(Date dt, String cssClass, String tooltip) {
// this.dt = dt;
// this.cssClass = cssClass;
// this.tooltip = tooltip;
// }
// public Date getDt() {
// return dt;
// }
// public String getCssClass() {
// return cssClass;
// }
// public String getTooltip() {
// return tooltip;
// }
// }
| import org.apache.wicket.request.resource.ResourceReference;
import com.premiumminds.webapp.wicket.bootstrap.SpecialDate;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collection;
import org.apache.wicket.Component;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.head.CssReferenceHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.request.resource.CssResourceReference;
import org.apache.wicket.request.resource.JavaScriptResourceReference; | /**
* Copyright (C) 2016 Premium Minds.
*
* This file is part of pm-wicket-utils.
*
* pm-wicket-utils 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, either version 3 of the License, or (at your option) any
* later version.
*
* pm-wicket-utils 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 pm-wicket-utils. If not, see <http://www.gnu.org/licenses/>.
*/
package com.premiumminds.webapp.wicket.bootstrap.datepicker;
public class BootstrapDatePickerBehaviour extends Behavior {
private static final long serialVersionUID = 6150624915791893034L;
private static final ResourceReference DATE_PICKER_CSS = new CssResourceReference(BootstrapDatePickerBehaviour.class, "bootstrap-datepicker.css");
private static final ResourceReference DATE_PICKER_JAVASCRIPT = new JavaScriptResourceReference(BootstrapDatePickerBehaviour.class, "bootstrap-datepicker.js");
private static final ResourceReference DATE_PICKER_EXTENSION_JAVASCRIPT = new JavaScriptResourceReference(BootstrapDatePickerBehaviour.class, "bootstrap-datepicker-extension.js");
@Override
public void onConfigure(Component component) {
super.onConfigure(component);
component.setOutputMarkupId(true);
}
@Override
public void renderHead(Component component, IHeaderResponse response) {
super.renderHead(component, response); | // Path: core/src/main/java/com/premiumminds/webapp/wicket/bootstrap/SpecialDate.java
// public final class SpecialDate implements Serializable {
// private static final long serialVersionUID = 1L;
//
// private Date dt;
// private String cssClass, tooltip;
//
// public SpecialDate(Date dt, String cssClass, String tooltip) {
// this.dt = dt;
// this.cssClass = cssClass;
// this.tooltip = tooltip;
// }
// public Date getDt() {
// return dt;
// }
// public String getCssClass() {
// return cssClass;
// }
// public String getTooltip() {
// return tooltip;
// }
// }
// Path: core/src/main/java/com/premiumminds/webapp/wicket/bootstrap/datepicker/BootstrapDatePickerBehaviour.java
import org.apache.wicket.request.resource.ResourceReference;
import com.premiumminds.webapp.wicket.bootstrap.SpecialDate;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collection;
import org.apache.wicket.Component;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.head.CssReferenceHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.request.resource.CssResourceReference;
import org.apache.wicket.request.resource.JavaScriptResourceReference;
/**
* Copyright (C) 2016 Premium Minds.
*
* This file is part of pm-wicket-utils.
*
* pm-wicket-utils 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, either version 3 of the License, or (at your option) any
* later version.
*
* pm-wicket-utils 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 pm-wicket-utils. If not, see <http://www.gnu.org/licenses/>.
*/
package com.premiumminds.webapp.wicket.bootstrap.datepicker;
public class BootstrapDatePickerBehaviour extends Behavior {
private static final long serialVersionUID = 6150624915791893034L;
private static final ResourceReference DATE_PICKER_CSS = new CssResourceReference(BootstrapDatePickerBehaviour.class, "bootstrap-datepicker.css");
private static final ResourceReference DATE_PICKER_JAVASCRIPT = new JavaScriptResourceReference(BootstrapDatePickerBehaviour.class, "bootstrap-datepicker.js");
private static final ResourceReference DATE_PICKER_EXTENSION_JAVASCRIPT = new JavaScriptResourceReference(BootstrapDatePickerBehaviour.class, "bootstrap-datepicker-extension.js");
@Override
public void onConfigure(Component component) {
super.onConfigure(component);
component.setOutputMarkupId(true);
}
@Override
public void renderHead(Component component, IHeaderResponse response) {
super.renderHead(component, response); | Collection<SpecialDate> specialDates = getSpecialDates(); |
premium-minds/pm-wicket-utils | core/src/main/java/com/premiumminds/webapp/wicket/bootstrap/BootstrapDatePicker.java | // Path: core/src/main/java/com/premiumminds/webapp/wicket/bootstrap/datepicker/BootstrapDatePickerBehaviour.java
// public class BootstrapDatePickerBehaviour extends Behavior {
// private static final long serialVersionUID = 6150624915791893034L;
//
// private static final ResourceReference DATE_PICKER_CSS = new CssResourceReference(BootstrapDatePickerBehaviour.class, "bootstrap-datepicker.css");
//
// private static final ResourceReference DATE_PICKER_JAVASCRIPT = new JavaScriptResourceReference(BootstrapDatePickerBehaviour.class, "bootstrap-datepicker.js");
// private static final ResourceReference DATE_PICKER_EXTENSION_JAVASCRIPT = new JavaScriptResourceReference(BootstrapDatePickerBehaviour.class, "bootstrap-datepicker-extension.js");
//
// @Override
// public void onConfigure(Component component) {
// super.onConfigure(component);
//
// component.setOutputMarkupId(true);
// }
//
// @Override
// public void renderHead(Component component, IHeaderResponse response) {
// super.renderHead(component, response);
// Collection<SpecialDate> specialDates = getSpecialDates();
//
// if(component.isEnabledInHierarchy()){
// response.render(CssReferenceHeaderItem.forReference(DATE_PICKER_CSS));
// response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_JAVASCRIPT));
// response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_EXTENSION_JAVASCRIPT));
// if(!component.getLocale().getLanguage().equals("en")){
// response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(BootstrapDatePickerBehaviour.class, "locales/bootstrap-datepicker."+component.getLocale().getLanguage()+".min.js")));
// }
//
// if(null != specialDates && !specialDates.isEmpty()) {
// StringBuilder sb = new StringBuilder();
// sb.append("[");
// DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
// SpecialDate[] sdArray = specialDates.toArray(new SpecialDate[20]);
// for(int i = 0; i < specialDates.size(); ++i) {
// SpecialDate sd = sdArray[i];
// sb.append("{dt:new Date('"+df.format(sd.getDt())+"'), css:'"+sd.getCssClass()+"', tooltip:'"+ sd.getTooltip() +"'}");
// if(i < specialDates.size() - 1) {
// sb.append(",");
// }
// }
// sb.append("]");
//
// response.render(OnDomReadyHeaderItem.forScript("$(\"#"+component.getMarkupId()+"\").datepicker(null, "+sb.toString()+")"));
// } else {
// response.render(OnDomReadyHeaderItem.forScript("$(\"#"+component.getMarkupId()+"\").datepicker()"));
// }
// }
// }
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag) {
// super.onComponentTag(component, tag);
//
// if(component.isEnabledInHierarchy()){
// tag.put("data-date-language", component.getLocale().getLanguage());
// }
// }
//
// public Collection<SpecialDate> getSpecialDates() {
// return null;
// }
// }
| import com.premiumminds.webapp.wicket.bootstrap.datepicker.BootstrapDatePickerBehaviour;
import java.util.Collection;
import java.util.Date;
import org.apache.wicket.IGenericComponent;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.extensions.markup.html.form.DateTextField;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.IModel;
import org.apache.wicket.util.visit.IVisit;
import org.apache.wicket.util.visit.IVisitor; | /**
* Copyright (C) 2016 Premium Minds.
*
* This file is part of pm-wicket-utils.
*
* pm-wicket-utils 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, either version 3 of the License, or (at your option) any
* later version.
*
* pm-wicket-utils 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 pm-wicket-utils. If not, see <http://www.gnu.org/licenses/>.
*/
package com.premiumminds.webapp.wicket.bootstrap;
/**
* Bootstrap Datepicker for Wicket.
*
* @author acamilo
* @see <a href="https://github.com/eternicode/bootstrap-datepicker">https://github.com/eternicode/bootstrap-datepicker</a>
*/
public class BootstrapDatePicker extends WebMarkupContainer implements IGenericComponent<Date, TextField<Date>> {
private static final long serialVersionUID = -117683073963817461L;
private DateTextField dateField;
/**
* Instantiates a new bootstrap datepicker.
*
* @param id the wicket:id
*/
public BootstrapDatePicker(String id) {
super(id); | // Path: core/src/main/java/com/premiumminds/webapp/wicket/bootstrap/datepicker/BootstrapDatePickerBehaviour.java
// public class BootstrapDatePickerBehaviour extends Behavior {
// private static final long serialVersionUID = 6150624915791893034L;
//
// private static final ResourceReference DATE_PICKER_CSS = new CssResourceReference(BootstrapDatePickerBehaviour.class, "bootstrap-datepicker.css");
//
// private static final ResourceReference DATE_PICKER_JAVASCRIPT = new JavaScriptResourceReference(BootstrapDatePickerBehaviour.class, "bootstrap-datepicker.js");
// private static final ResourceReference DATE_PICKER_EXTENSION_JAVASCRIPT = new JavaScriptResourceReference(BootstrapDatePickerBehaviour.class, "bootstrap-datepicker-extension.js");
//
// @Override
// public void onConfigure(Component component) {
// super.onConfigure(component);
//
// component.setOutputMarkupId(true);
// }
//
// @Override
// public void renderHead(Component component, IHeaderResponse response) {
// super.renderHead(component, response);
// Collection<SpecialDate> specialDates = getSpecialDates();
//
// if(component.isEnabledInHierarchy()){
// response.render(CssReferenceHeaderItem.forReference(DATE_PICKER_CSS));
// response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_JAVASCRIPT));
// response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_EXTENSION_JAVASCRIPT));
// if(!component.getLocale().getLanguage().equals("en")){
// response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(BootstrapDatePickerBehaviour.class, "locales/bootstrap-datepicker."+component.getLocale().getLanguage()+".min.js")));
// }
//
// if(null != specialDates && !specialDates.isEmpty()) {
// StringBuilder sb = new StringBuilder();
// sb.append("[");
// DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
// SpecialDate[] sdArray = specialDates.toArray(new SpecialDate[20]);
// for(int i = 0; i < specialDates.size(); ++i) {
// SpecialDate sd = sdArray[i];
// sb.append("{dt:new Date('"+df.format(sd.getDt())+"'), css:'"+sd.getCssClass()+"', tooltip:'"+ sd.getTooltip() +"'}");
// if(i < specialDates.size() - 1) {
// sb.append(",");
// }
// }
// sb.append("]");
//
// response.render(OnDomReadyHeaderItem.forScript("$(\"#"+component.getMarkupId()+"\").datepicker(null, "+sb.toString()+")"));
// } else {
// response.render(OnDomReadyHeaderItem.forScript("$(\"#"+component.getMarkupId()+"\").datepicker()"));
// }
// }
// }
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag) {
// super.onComponentTag(component, tag);
//
// if(component.isEnabledInHierarchy()){
// tag.put("data-date-language", component.getLocale().getLanguage());
// }
// }
//
// public Collection<SpecialDate> getSpecialDates() {
// return null;
// }
// }
// Path: core/src/main/java/com/premiumminds/webapp/wicket/bootstrap/BootstrapDatePicker.java
import com.premiumminds.webapp.wicket.bootstrap.datepicker.BootstrapDatePickerBehaviour;
import java.util.Collection;
import java.util.Date;
import org.apache.wicket.IGenericComponent;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.extensions.markup.html.form.DateTextField;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.IModel;
import org.apache.wicket.util.visit.IVisit;
import org.apache.wicket.util.visit.IVisitor;
/**
* Copyright (C) 2016 Premium Minds.
*
* This file is part of pm-wicket-utils.
*
* pm-wicket-utils 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, either version 3 of the License, or (at your option) any
* later version.
*
* pm-wicket-utils 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 pm-wicket-utils. If not, see <http://www.gnu.org/licenses/>.
*/
package com.premiumminds.webapp.wicket.bootstrap;
/**
* Bootstrap Datepicker for Wicket.
*
* @author acamilo
* @see <a href="https://github.com/eternicode/bootstrap-datepicker">https://github.com/eternicode/bootstrap-datepicker</a>
*/
public class BootstrapDatePicker extends WebMarkupContainer implements IGenericComponent<Date, TextField<Date>> {
private static final long serialVersionUID = -117683073963817461L;
private DateTextField dateField;
/**
* Instantiates a new bootstrap datepicker.
*
* @param id the wicket:id
*/
public BootstrapDatePicker(String id) {
super(id); | add(new BootstrapDatePickerBehaviour() { |
iychoi/libra | src/libra/group/GroupCmdArgs.java | // Path: src/libra/common/cmdargs/CommandArgumentsBase.java
// public class CommandArgumentsBase {
//
// private static final Log LOG = LogFactory.getLog(CommandArgumentsBase.class);
//
// @Option(name = "-h", aliases = "--help", usage = "print help")
// protected boolean help = false;
//
// @Option(name = "--report", usage = "specify a report file to be created")
// protected String reportfile;
//
// public boolean isHelp() {
// return this.help;
// }
//
// public boolean needReport() {
// return (reportfile != null);
// }
//
// public String getReportFilename() {
// return reportfile;
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
//
// public boolean checkValidity() {
// return true;
// }
// }
//
// Path: src/libra/group/common/GroupConfig.java
// public class GroupConfig {
//
// public static final long DEFAULT_GROUPSIZE = PreprocessorConfig.DEFAULT_GROUPSIZE;
// public static final int DEFAULT_MAX_GROUPNUM = PreprocessorConfig.DEFAULT_MAX_GROUPNUM;
//
// protected static final String HADOOP_CONFIG_KEY = "libra.group.common.groupconfig";
//
// private long groupSize = DEFAULT_GROUPSIZE;
// private int maxGroupNum = DEFAULT_MAX_GROUPNUM;
// private List<String> samplePaths = new ArrayList<String>();
//
// public static GroupConfig createInstance(File file) throws IOException {
// JsonSerializer serializer = new JsonSerializer();
// return (GroupConfig) serializer.fromJsonFile(file, GroupConfig.class);
// }
//
// public static GroupConfig createInstance(String json) throws IOException {
// JsonSerializer serializer = new JsonSerializer();
// return (GroupConfig) serializer.fromJson(json, GroupConfig.class);
// }
//
// public static GroupConfig createInstance(Configuration conf) throws IOException {
// JsonSerializer serializer = new JsonSerializer();
// return (GroupConfig) serializer.fromJsonConfiguration(conf, HADOOP_CONFIG_KEY, GroupConfig.class);
// }
//
// public static GroupConfig createInstance(FileSystem fs, Path file) throws IOException {
// JsonSerializer serializer = new JsonSerializer();
// return (GroupConfig) serializer.fromJsonFile(fs, file, GroupConfig.class);
// }
//
// public GroupConfig() {
//
// }
//
// public GroupConfig(GroupConfig config) {
// this.groupSize = config.groupSize;
// this.maxGroupNum = config.maxGroupNum;
// this.samplePaths = new ArrayList<String>();
// this.samplePaths.addAll(config.samplePaths);
// }
//
// @JsonProperty("group_size")
// public long getGroupSize() {
// return this.groupSize;
// }
//
// @JsonProperty("group_size")
// public void setGroupSize(long groupSize) {
// this.groupSize = groupSize;
// }
//
// @JsonProperty("max_group_num")
// public int getMaxGroupNum() {
// return this.maxGroupNum;
// }
//
// @JsonProperty("max_group_num")
// public void setMaxGroupNum(int maxGroupNum) {
// this.maxGroupNum = maxGroupNum;
// }
//
// @JsonProperty("sample_paths")
// public Collection<String> getSamplePaths() {
// return this.samplePaths;
// }
//
// @JsonProperty("sample_paths")
// public void addSamplePath(Collection<String> samplePaths) {
// this.samplePaths.addAll(samplePaths);
// }
//
// @JsonIgnore
// public void addSamplePath(String samplePath) {
// this.samplePaths.add(samplePath);
// }
//
// @JsonIgnore
// public void clearSamplePath() {
// this.samplePaths.clear();
// }
//
// @JsonIgnore
// public void saveTo(Configuration conf) throws IOException {
// JsonSerializer serializer = new JsonSerializer();
// serializer.toJsonConfiguration(conf, HADOOP_CONFIG_KEY, this);
// }
//
// @JsonIgnore
// public void saveTo(FileSystem fs, Path file) throws IOException {
// JsonSerializer serializer = new JsonSerializer();
// serializer.toJsonFile(fs, file, this);
// }
// }
| import java.util.ArrayList;
import java.util.List;
import libra.common.cmdargs.CommandArgumentsBase;
import libra.group.common.GroupConfig;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option; | /*
* Copyright 2016 iychoi.
*
* 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 libra.group;
/**
*
* @author iychoi
*/
public class GroupCmdArgs extends CommandArgumentsBase {
public GroupCmdArgs() {
}
@Option(name = "-s", aliases = "--groupsize", usage = "specify size of group") | // Path: src/libra/common/cmdargs/CommandArgumentsBase.java
// public class CommandArgumentsBase {
//
// private static final Log LOG = LogFactory.getLog(CommandArgumentsBase.class);
//
// @Option(name = "-h", aliases = "--help", usage = "print help")
// protected boolean help = false;
//
// @Option(name = "--report", usage = "specify a report file to be created")
// protected String reportfile;
//
// public boolean isHelp() {
// return this.help;
// }
//
// public boolean needReport() {
// return (reportfile != null);
// }
//
// public String getReportFilename() {
// return reportfile;
// }
//
// @Override
// public String toString() {
// return super.toString();
// }
//
// public boolean checkValidity() {
// return true;
// }
// }
//
// Path: src/libra/group/common/GroupConfig.java
// public class GroupConfig {
//
// public static final long DEFAULT_GROUPSIZE = PreprocessorConfig.DEFAULT_GROUPSIZE;
// public static final int DEFAULT_MAX_GROUPNUM = PreprocessorConfig.DEFAULT_MAX_GROUPNUM;
//
// protected static final String HADOOP_CONFIG_KEY = "libra.group.common.groupconfig";
//
// private long groupSize = DEFAULT_GROUPSIZE;
// private int maxGroupNum = DEFAULT_MAX_GROUPNUM;
// private List<String> samplePaths = new ArrayList<String>();
//
// public static GroupConfig createInstance(File file) throws IOException {
// JsonSerializer serializer = new JsonSerializer();
// return (GroupConfig) serializer.fromJsonFile(file, GroupConfig.class);
// }
//
// public static GroupConfig createInstance(String json) throws IOException {
// JsonSerializer serializer = new JsonSerializer();
// return (GroupConfig) serializer.fromJson(json, GroupConfig.class);
// }
//
// public static GroupConfig createInstance(Configuration conf) throws IOException {
// JsonSerializer serializer = new JsonSerializer();
// return (GroupConfig) serializer.fromJsonConfiguration(conf, HADOOP_CONFIG_KEY, GroupConfig.class);
// }
//
// public static GroupConfig createInstance(FileSystem fs, Path file) throws IOException {
// JsonSerializer serializer = new JsonSerializer();
// return (GroupConfig) serializer.fromJsonFile(fs, file, GroupConfig.class);
// }
//
// public GroupConfig() {
//
// }
//
// public GroupConfig(GroupConfig config) {
// this.groupSize = config.groupSize;
// this.maxGroupNum = config.maxGroupNum;
// this.samplePaths = new ArrayList<String>();
// this.samplePaths.addAll(config.samplePaths);
// }
//
// @JsonProperty("group_size")
// public long getGroupSize() {
// return this.groupSize;
// }
//
// @JsonProperty("group_size")
// public void setGroupSize(long groupSize) {
// this.groupSize = groupSize;
// }
//
// @JsonProperty("max_group_num")
// public int getMaxGroupNum() {
// return this.maxGroupNum;
// }
//
// @JsonProperty("max_group_num")
// public void setMaxGroupNum(int maxGroupNum) {
// this.maxGroupNum = maxGroupNum;
// }
//
// @JsonProperty("sample_paths")
// public Collection<String> getSamplePaths() {
// return this.samplePaths;
// }
//
// @JsonProperty("sample_paths")
// public void addSamplePath(Collection<String> samplePaths) {
// this.samplePaths.addAll(samplePaths);
// }
//
// @JsonIgnore
// public void addSamplePath(String samplePath) {
// this.samplePaths.add(samplePath);
// }
//
// @JsonIgnore
// public void clearSamplePath() {
// this.samplePaths.clear();
// }
//
// @JsonIgnore
// public void saveTo(Configuration conf) throws IOException {
// JsonSerializer serializer = new JsonSerializer();
// serializer.toJsonConfiguration(conf, HADOOP_CONFIG_KEY, this);
// }
//
// @JsonIgnore
// public void saveTo(FileSystem fs, Path file) throws IOException {
// JsonSerializer serializer = new JsonSerializer();
// serializer.toJsonFile(fs, file, this);
// }
// }
// Path: src/libra/group/GroupCmdArgs.java
import java.util.ArrayList;
import java.util.List;
import libra.common.cmdargs.CommandArgumentsBase;
import libra.group.common.GroupConfig;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
/*
* Copyright 2016 iychoi.
*
* 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 libra.group;
/**
*
* @author iychoi
*/
public class GroupCmdArgs extends CommandArgumentsBase {
public GroupCmdArgs() {
}
@Option(name = "-s", aliases = "--groupsize", usage = "specify size of group") | protected long groupSize = GroupConfig.DEFAULT_GROUPSIZE; |
iychoi/libra | src/libra/preprocess/common/kmerindex/KmerIndexTable.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
| import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerindex;
/**
*
* @author iychoi
*/
public class KmerIndexTable {
private static final Log LOG = LogFactory.getLog(KmerIndexTable.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerindex.kmerindextable";
private String name;
private List<KmerIndexTableRecord> records = new ArrayList<KmerIndexTableRecord>();
public static KmerIndexTable createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
// Path: src/libra/preprocess/common/kmerindex/KmerIndexTable.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerindex;
/**
*
* @author iychoi
*/
public class KmerIndexTable {
private static final Log LOG = LogFactory.getLog(KmerIndexTable.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerindex.kmerindextable";
private String name;
private List<KmerIndexTableRecord> records = new ArrayList<KmerIndexTableRecord>();
public static KmerIndexTable createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/preprocess/common/samplegroup/SampleInfo.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
| import java.io.File;
import java.io.IOException;
import java.util.Comparator;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.samplegroup;
/**
*
* @author iychoi
*/
public class SampleInfo {
private static final Log LOG = LogFactory.getLog(SampleInfo.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.samplegroup.sampleinfo";
private String path;
private long size;
public static SampleInfo createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
// Path: src/libra/preprocess/common/samplegroup/SampleInfo.java
import java.io.File;
import java.io.IOException;
import java.util.Comparator;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.samplegroup;
/**
*
* @author iychoi
*/
public class SampleInfo {
private static final Log LOG = LogFactory.getLog(SampleInfo.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.samplegroup.sampleinfo";
private String path;
private long size;
public static SampleInfo createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/common/report/Report.java | // Path: src/libra/common/helpers/TimeHelper.java
// public class TimeHelper {
// public static long getCurrentTime() {
// return System.currentTimeMillis();
// }
//
// public static String getDiffTimeString(long begin, long end) {
// long diff = end - begin;
// long remain = diff;
//
// int msec = (int) (remain % 1000);
// remain /= 1000;
// int sec = (int) (remain % 60);
// remain /= 60;
// int min = (int) (remain % 60);
// remain /= 60;
// int hour = (int) (remain);
//
// return hour + "h " + min + "m " + sec + "s";
// }
//
// public static String getTimeString(long time) {
// Date date = new Date(time);
// Format format = new SimpleDateFormat("yyyy MM dd HH:mm:ss");
// return format.format(date);
// }
// }
| import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import libra.common.helpers.TimeHelper; | }
public void writeTo(String filename) throws IOException {
writeTo(new File("./", filename));
}
public void writeTo(File f) throws IOException {
if(f.getParentFile() != null) {
if(!f.getParentFile().exists()) {
f.getParentFile().mkdirs();
}
}
Writer writer = new FileWriter(f, true);
boolean first = true;
for(Job job : this.jobs) {
if(first) {
first = false;
}
writer.write(makeText(job));
writer.write("\n\n");
}
writer.close();
}
private String makeText(Job job) {
return "Job : " + job.getName() + "\n" +
"JobID : " + job.getID() + "\n" +
"Status : " + job.getStatus() + "\n" + | // Path: src/libra/common/helpers/TimeHelper.java
// public class TimeHelper {
// public static long getCurrentTime() {
// return System.currentTimeMillis();
// }
//
// public static String getDiffTimeString(long begin, long end) {
// long diff = end - begin;
// long remain = diff;
//
// int msec = (int) (remain % 1000);
// remain /= 1000;
// int sec = (int) (remain % 60);
// remain /= 60;
// int min = (int) (remain % 60);
// remain /= 60;
// int hour = (int) (remain);
//
// return hour + "h " + min + "m " + sec + "s";
// }
//
// public static String getTimeString(long time) {
// Date date = new Date(time);
// Format format = new SimpleDateFormat("yyyy MM dd HH:mm:ss");
// return format.format(date);
// }
// }
// Path: src/libra/common/report/Report.java
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import libra.common.helpers.TimeHelper;
}
public void writeTo(String filename) throws IOException {
writeTo(new File("./", filename));
}
public void writeTo(File f) throws IOException {
if(f.getParentFile() != null) {
if(!f.getParentFile().exists()) {
f.getParentFile().mkdirs();
}
}
Writer writer = new FileWriter(f, true);
boolean first = true;
for(Job job : this.jobs) {
if(first) {
first = false;
}
writer.write(makeText(job));
writer.write("\n\n");
}
writer.close();
}
private String makeText(Job job) {
return "Job : " + job.getName() + "\n" +
"JobID : " + job.getID() + "\n" +
"Status : " + job.getStatus() + "\n" + | "StartTime : " + TimeHelper.getTimeString(job.getStartTime()) + "\n" + |
iychoi/libra | src/libra/common/kmermatch/KmerMatchFileMapping.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
| import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty; | /*
* Copyright 2016 iychoi.
*
* 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 libra.common.kmermatch;
/**
*
* @author iychoi
*/
public class KmerMatchFileMapping {
private static final Log LOG = LogFactory.getLog(KmerMatchFileMapping.class);
private static final String HADOOP_CONFIG_KEY = "libra.common.kmermatch.kmermatcherfilemapping";
private Hashtable<String, Integer> idTable;
private List<String> objList;
public static KmerMatchFileMapping createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
// Path: src/libra/common/kmermatch/KmerMatchFileMapping.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/*
* Copyright 2016 iychoi.
*
* 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 libra.common.kmermatch;
/**
*
* @author iychoi
*/
public class KmerMatchFileMapping {
private static final Log LOG = LogFactory.getLog(KmerMatchFileMapping.class);
private static final String HADOOP_CONFIG_KEY = "libra.common.kmermatch.kmermatcherfilemapping";
private Hashtable<String, Integer> idTable;
private List<String> objList;
public static KmerMatchFileMapping createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/common/helpers/FileSystemHelper.java | // Path: src/libra/common/sequence/SamplePathFilter.java
// public class SamplePathFilter implements PathFilter {
//
// private List<PathFilter> filters;
//
// public SamplePathFilter() {
// this.filters = new ArrayList<PathFilter>();
//
// setFilters();
// }
//
// protected void setFilters() {
// this.filters.add(new FastaPathFilter());
// this.filters.add(new FastqPathFilter());
// }
//
// @Override
// public boolean accept(Path path) {
// for(PathFilter f : this.filters) {
// if(f.accept(path)) {
// return true;
// }
// }
// return false;
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import libra.common.sequence.SamplePathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; | }
} else {
paths.add(new Path(path));
}
}
return paths.toArray(new Path[0]);
}
public static String[] makeStringFromPath(Path[] paths) {
String[] pathStrings = new String[paths.length];
for(int i=0;i<paths.length;i++) {
pathStrings[i] = paths[i].toString();
}
return pathStrings;
}
public static Path[] getAllSamplePaths(Configuration conf, String inputPathsCommaSeparated) throws IOException {
return FileSystemHelper.getAllSamplePaths(conf, makePathFromString(conf, splitCommaSeparated(inputPathsCommaSeparated)));
}
public static Path[] getAllSamplePaths(Configuration conf, String[] inputPaths) throws IOException {
return FileSystemHelper.getAllSamplePaths(conf, makePathFromString(conf, inputPaths));
}
public static Path[] getAllSamplePaths(Configuration conf, Collection<String> inputPaths) throws IOException {
return FileSystemHelper.getAllSamplePaths(conf, makePathFromString(conf, inputPaths));
}
public static Path[] getAllSamplePaths(Configuration conf, Path[] inputPaths) throws IOException {
List<Path> inputFiles = new ArrayList<Path>(); | // Path: src/libra/common/sequence/SamplePathFilter.java
// public class SamplePathFilter implements PathFilter {
//
// private List<PathFilter> filters;
//
// public SamplePathFilter() {
// this.filters = new ArrayList<PathFilter>();
//
// setFilters();
// }
//
// protected void setFilters() {
// this.filters.add(new FastaPathFilter());
// this.filters.add(new FastqPathFilter());
// }
//
// @Override
// public boolean accept(Path path) {
// for(PathFilter f : this.filters) {
// if(f.accept(path)) {
// return true;
// }
// }
// return false;
// }
// }
// Path: src/libra/common/helpers/FileSystemHelper.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import libra.common.sequence.SamplePathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
}
} else {
paths.add(new Path(path));
}
}
return paths.toArray(new Path[0]);
}
public static String[] makeStringFromPath(Path[] paths) {
String[] pathStrings = new String[paths.length];
for(int i=0;i<paths.length;i++) {
pathStrings[i] = paths[i].toString();
}
return pathStrings;
}
public static Path[] getAllSamplePaths(Configuration conf, String inputPathsCommaSeparated) throws IOException {
return FileSystemHelper.getAllSamplePaths(conf, makePathFromString(conf, splitCommaSeparated(inputPathsCommaSeparated)));
}
public static Path[] getAllSamplePaths(Configuration conf, String[] inputPaths) throws IOException {
return FileSystemHelper.getAllSamplePaths(conf, makePathFromString(conf, inputPaths));
}
public static Path[] getAllSamplePaths(Configuration conf, Collection<String> inputPaths) throws IOException {
return FileSystemHelper.getAllSamplePaths(conf, makePathFromString(conf, inputPaths));
}
public static Path[] getAllSamplePaths(Configuration conf, Path[] inputPaths) throws IOException {
List<Path> inputFiles = new ArrayList<Path>(); | SamplePathFilter filter = new SamplePathFilter(); |
iychoi/libra | src/libra/preprocess/common/kmerstatistics/KmerStatisticsPartTable.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
| import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerstatistics;
/**
*
* @author iychoi
*/
public class KmerStatisticsPartTable {
private static final Log LOG = LogFactory.getLog(KmerStatisticsPartTable.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerstatistics.kmerstatisticsparttable";
private String name;
private List<KmerStatisticsPart> statisticsPart = new ArrayList<KmerStatisticsPart>();
public static KmerStatisticsPartTable createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
// Path: src/libra/preprocess/common/kmerstatistics/KmerStatisticsPartTable.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerstatistics;
/**
*
* @author iychoi
*/
public class KmerStatisticsPartTable {
private static final Log LOG = LogFactory.getLog(KmerStatisticsPartTable.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerstatistics.kmerstatisticsparttable";
private String name;
private List<KmerStatisticsPart> statisticsPart = new ArrayList<KmerStatisticsPart>();
public static KmerStatisticsPartTable createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/preprocess/common/kmerstatistics/KmerStatisticsPart.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
| import java.io.File;
import java.io.IOException;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerstatistics;
/**
*
* @author iychoi
*/
public class KmerStatisticsPart {
private static final Log LOG = LogFactory.getLog(KmerStatisticsPart.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerstatistics.kmerstatisticspart";
private String name;
private double logTFWeightSquare;
private double naturalTFWeightSquare;
private double logTFWeight;
private double naturalTFWeight;
private double booleanTFWeight;
public static KmerStatisticsPart createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
// Path: src/libra/preprocess/common/kmerstatistics/KmerStatisticsPart.java
import java.io.File;
import java.io.IOException;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerstatistics;
/**
*
* @author iychoi
*/
public class KmerStatisticsPart {
private static final Log LOG = LogFactory.getLog(KmerStatisticsPart.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerstatistics.kmerstatisticspart";
private String name;
private double logTFWeightSquare;
private double naturalTFWeightSquare;
private double logTFWeight;
private double naturalTFWeight;
private double booleanTFWeight;
public static KmerStatisticsPart createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/distancematrix/common/helpers/KmerSimilarityHelper.java | // Path: src/libra/distancematrix/common/DistanceMatrixConstants.java
// public class DistanceMatrixConstants {
// public final static String KMER_SIMILARITY_FILE_MAPPING_TABLE_FILENAME = "file_mapping_table.json";
// public final static String KMER_SIMILARITY_RESULT_FILENAME_PREFIX = "result";
// public final static String KMER_SIMILARITY_RESULT_FILENAME_EXTENSION = "score";
// }
//
// Path: src/libra/distancematrix/common/kmersimilarity/KmerSimilarityResultPartPathFilter.java
// public class KmerSimilarityResultPartPathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerSimilarityHelper.isKmerSimilarityResultPartFile(path);
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.distancematrix.common.DistanceMatrixConstants;
import libra.distancematrix.common.kmersimilarity.KmerSimilarityResultPartPathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; | }
return false;
}
public static boolean isKmerSimilarityResultPartFile(Path path) {
return KmerSimilarityHelper.isKmerSimilarityResultPartFile(path.getName());
}
public static boolean isKmerSimilarityResultPartFile(String path) {
Matcher matcher = KMER_SIMILARITY_RESULT_PART_PATH_PATTERN.matcher(path.toLowerCase());
if(matcher.matches()) {
return true;
}
return false;
}
public static String makeKmerSimilarityFileMappingTableFileName() {
return DistanceMatrixConstants.KMER_SIMILARITY_FILE_MAPPING_TABLE_FILENAME;
}
public static String makeKmerSimilarityResultPartFileName(int mapreduceID) {
return DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_PREFIX + "." + DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_EXTENSION + "." + mapreduceID;
}
public static String makeKmerSimilarityResultFileName() {
return DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_PREFIX + "." + DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_EXTENSION;
}
public static Path[] getKmerSimilarityResultPartFilePath(Configuration conf, Path inputPath) throws IOException {
List<Path> inputFiles = new ArrayList<Path>(); | // Path: src/libra/distancematrix/common/DistanceMatrixConstants.java
// public class DistanceMatrixConstants {
// public final static String KMER_SIMILARITY_FILE_MAPPING_TABLE_FILENAME = "file_mapping_table.json";
// public final static String KMER_SIMILARITY_RESULT_FILENAME_PREFIX = "result";
// public final static String KMER_SIMILARITY_RESULT_FILENAME_EXTENSION = "score";
// }
//
// Path: src/libra/distancematrix/common/kmersimilarity/KmerSimilarityResultPartPathFilter.java
// public class KmerSimilarityResultPartPathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerSimilarityHelper.isKmerSimilarityResultPartFile(path);
// }
// }
// Path: src/libra/distancematrix/common/helpers/KmerSimilarityHelper.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.distancematrix.common.DistanceMatrixConstants;
import libra.distancematrix.common.kmersimilarity.KmerSimilarityResultPartPathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
}
return false;
}
public static boolean isKmerSimilarityResultPartFile(Path path) {
return KmerSimilarityHelper.isKmerSimilarityResultPartFile(path.getName());
}
public static boolean isKmerSimilarityResultPartFile(String path) {
Matcher matcher = KMER_SIMILARITY_RESULT_PART_PATH_PATTERN.matcher(path.toLowerCase());
if(matcher.matches()) {
return true;
}
return false;
}
public static String makeKmerSimilarityFileMappingTableFileName() {
return DistanceMatrixConstants.KMER_SIMILARITY_FILE_MAPPING_TABLE_FILENAME;
}
public static String makeKmerSimilarityResultPartFileName(int mapreduceID) {
return DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_PREFIX + "." + DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_EXTENSION + "." + mapreduceID;
}
public static String makeKmerSimilarityResultFileName() {
return DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_PREFIX + "." + DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_EXTENSION;
}
public static Path[] getKmerSimilarityResultPartFilePath(Configuration conf, Path inputPath) throws IOException {
List<Path> inputFiles = new ArrayList<Path>(); | KmerSimilarityResultPartPathFilter filter = new KmerSimilarityResultPartPathFilter(); |
iychoi/libra | src/libra/distancematrix/common/kmersimilarity/ScoreFactory.java | // Path: src/libra/distancematrix/common/ScoreAlgorithm.java
// public enum ScoreAlgorithm {
// COSINESIMILARITY,
// BRAYCURTIS,
// JENSENSHANNON;
//
// public static ScoreAlgorithm fromString(String alg) {
// try {
// ScoreAlgorithm wa = ScoreAlgorithm.valueOf(alg.trim().toUpperCase());
// return wa;
// } catch (Exception ex) {
// // fall
// }
//
// if("cosine".equalsIgnoreCase(alg.trim())) {
// return COSINESIMILARITY;
// } else if("cossim".equalsIgnoreCase(alg.trim())) {
// return COSINESIMILARITY;
// } else if("cos".equalsIgnoreCase(alg.trim())) {
// return COSINESIMILARITY;
// } else if("cs".equalsIgnoreCase(alg.trim())) {
// return COSINESIMILARITY;
// } else if ("bc".equalsIgnoreCase(alg.trim())) {
// return BRAYCURTIS;
// } else if ("bray".equalsIgnoreCase(alg.trim())) {
// return BRAYCURTIS;
// } else if ("jensen".equalsIgnoreCase(alg.trim())) {
// return JENSENSHANNON;
// } else if ("jensha".equalsIgnoreCase(alg.trim())) {
// return JENSENSHANNON;
// } else if ("js".equalsIgnoreCase(alg.trim())) {
// return JENSENSHANNON;
// }
//
// return COSINESIMILARITY;
// }
// }
| import java.io.IOException;
import libra.distancematrix.common.ScoreAlgorithm;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; | /*
* Copyright 2018 iychoi.
*
* 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 libra.distancematrix.common.kmersimilarity;
/**
*
* @author iychoi
*/
public class ScoreFactory {
private static final Log LOG = LogFactory.getLog(ScoreFactory.class);
| // Path: src/libra/distancematrix/common/ScoreAlgorithm.java
// public enum ScoreAlgorithm {
// COSINESIMILARITY,
// BRAYCURTIS,
// JENSENSHANNON;
//
// public static ScoreAlgorithm fromString(String alg) {
// try {
// ScoreAlgorithm wa = ScoreAlgorithm.valueOf(alg.trim().toUpperCase());
// return wa;
// } catch (Exception ex) {
// // fall
// }
//
// if("cosine".equalsIgnoreCase(alg.trim())) {
// return COSINESIMILARITY;
// } else if("cossim".equalsIgnoreCase(alg.trim())) {
// return COSINESIMILARITY;
// } else if("cos".equalsIgnoreCase(alg.trim())) {
// return COSINESIMILARITY;
// } else if("cs".equalsIgnoreCase(alg.trim())) {
// return COSINESIMILARITY;
// } else if ("bc".equalsIgnoreCase(alg.trim())) {
// return BRAYCURTIS;
// } else if ("bray".equalsIgnoreCase(alg.trim())) {
// return BRAYCURTIS;
// } else if ("jensen".equalsIgnoreCase(alg.trim())) {
// return JENSENSHANNON;
// } else if ("jensha".equalsIgnoreCase(alg.trim())) {
// return JENSENSHANNON;
// } else if ("js".equalsIgnoreCase(alg.trim())) {
// return JENSENSHANNON;
// }
//
// return COSINESIMILARITY;
// }
// }
// Path: src/libra/distancematrix/common/kmersimilarity/ScoreFactory.java
import java.io.IOException;
import libra.distancematrix.common.ScoreAlgorithm;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/*
* Copyright 2018 iychoi.
*
* 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 libra.distancematrix.common.kmersimilarity;
/**
*
* @author iychoi
*/
public class ScoreFactory {
private static final Log LOG = LogFactory.getLog(ScoreFactory.class);
| public static AbstractScore getScore(ScoreAlgorithm algorithm) throws IOException { |
iychoi/libra | src/libra/preprocess/common/kmerfilter/KmerFilterTable.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
| import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerfilter;
/**
*
* @author iychoi
*/
public class KmerFilterTable {
private static final Log LOG = LogFactory.getLog(KmerFilterTable.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerfilter.kmerfiltertable";
private String name;
private List<KmerFilter> filter = new ArrayList<KmerFilter>();
public static KmerFilterTable createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
// Path: src/libra/preprocess/common/kmerfilter/KmerFilterTable.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerfilter;
/**
*
* @author iychoi
*/
public class KmerFilterTable {
private static final Log LOG = LogFactory.getLog(KmerFilterTable.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerfilter.kmerfiltertable";
private String name;
private List<KmerFilter> filter = new ArrayList<KmerFilter>();
public static KmerFilterTable createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/distancematrix/common/kmersimilarity/KmerSimilarityResultPartPathFilter.java | // Path: src/libra/distancematrix/common/helpers/KmerSimilarityHelper.java
// public class KmerSimilarityHelper {
// private final static String KMER_SIMILARITY_RESULT_PART_PATH_EXP = ".+\\." + DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_EXTENSION + "\\.\\d+$";
// private final static Pattern KMER_SIMILARITY_RESULT_PART_PATH_PATTERN = Pattern.compile(KMER_SIMILARITY_RESULT_PART_PATH_EXP);
//
// public static boolean isKmerSimilarityFileMappingTableFile(Path path) {
// return isKmerSimilarityFileMappingTableFile(path.getName());
// }
//
// public static boolean isKmerSimilarityFileMappingTableFile(String path) {
// if(path.compareToIgnoreCase(DistanceMatrixConstants.KMER_SIMILARITY_FILE_MAPPING_TABLE_FILENAME) == 0) {
// return true;
// }
// return false;
// }
//
// public static boolean isKmerSimilarityResultPartFile(Path path) {
// return KmerSimilarityHelper.isKmerSimilarityResultPartFile(path.getName());
// }
//
// public static boolean isKmerSimilarityResultPartFile(String path) {
// Matcher matcher = KMER_SIMILARITY_RESULT_PART_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static String makeKmerSimilarityFileMappingTableFileName() {
// return DistanceMatrixConstants.KMER_SIMILARITY_FILE_MAPPING_TABLE_FILENAME;
// }
//
// public static String makeKmerSimilarityResultPartFileName(int mapreduceID) {
// return DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_PREFIX + "." + DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_EXTENSION + "." + mapreduceID;
// }
//
// public static String makeKmerSimilarityResultFileName() {
// return DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_PREFIX + "." + DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_EXTENSION;
// }
//
// public static Path[] getKmerSimilarityResultPartFilePath(Configuration conf, Path inputPath) throws IOException {
// List<Path> inputFiles = new ArrayList<Path>();
// KmerSimilarityResultPartPathFilter filter = new KmerSimilarityResultPartPathFilter();
//
// FileSystem fs = inputPath.getFileSystem(conf);
// if(fs.exists(inputPath)) {
// FileStatus status = fs.getFileStatus(inputPath);
// if(status.isDirectory()) {
// // check child
// FileStatus[] entries = fs.listStatus(inputPath);
// for (FileStatus entry : entries) {
// if(entry.isFile()) {
// if (filter.accept(entry.getPath())) {
// inputFiles.add(entry.getPath());
// }
// }
// }
// } else {
// if (filter.accept(status.getPath())) {
// inputFiles.add(status.getPath());
// }
// }
// }
//
// Path[] files = inputFiles.toArray(new Path[0]);
// return files;
// }
// }
| import libra.distancematrix.common.helpers.KmerSimilarityHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter; | /*
* Copyright 2016 iychoi.
*
* 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 libra.distancematrix.common.kmersimilarity;
/**
*
* @author iychoi
*/
public class KmerSimilarityResultPartPathFilter implements PathFilter {
@Override
public boolean accept(Path path) { | // Path: src/libra/distancematrix/common/helpers/KmerSimilarityHelper.java
// public class KmerSimilarityHelper {
// private final static String KMER_SIMILARITY_RESULT_PART_PATH_EXP = ".+\\." + DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_EXTENSION + "\\.\\d+$";
// private final static Pattern KMER_SIMILARITY_RESULT_PART_PATH_PATTERN = Pattern.compile(KMER_SIMILARITY_RESULT_PART_PATH_EXP);
//
// public static boolean isKmerSimilarityFileMappingTableFile(Path path) {
// return isKmerSimilarityFileMappingTableFile(path.getName());
// }
//
// public static boolean isKmerSimilarityFileMappingTableFile(String path) {
// if(path.compareToIgnoreCase(DistanceMatrixConstants.KMER_SIMILARITY_FILE_MAPPING_TABLE_FILENAME) == 0) {
// return true;
// }
// return false;
// }
//
// public static boolean isKmerSimilarityResultPartFile(Path path) {
// return KmerSimilarityHelper.isKmerSimilarityResultPartFile(path.getName());
// }
//
// public static boolean isKmerSimilarityResultPartFile(String path) {
// Matcher matcher = KMER_SIMILARITY_RESULT_PART_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static String makeKmerSimilarityFileMappingTableFileName() {
// return DistanceMatrixConstants.KMER_SIMILARITY_FILE_MAPPING_TABLE_FILENAME;
// }
//
// public static String makeKmerSimilarityResultPartFileName(int mapreduceID) {
// return DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_PREFIX + "." + DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_EXTENSION + "." + mapreduceID;
// }
//
// public static String makeKmerSimilarityResultFileName() {
// return DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_PREFIX + "." + DistanceMatrixConstants.KMER_SIMILARITY_RESULT_FILENAME_EXTENSION;
// }
//
// public static Path[] getKmerSimilarityResultPartFilePath(Configuration conf, Path inputPath) throws IOException {
// List<Path> inputFiles = new ArrayList<Path>();
// KmerSimilarityResultPartPathFilter filter = new KmerSimilarityResultPartPathFilter();
//
// FileSystem fs = inputPath.getFileSystem(conf);
// if(fs.exists(inputPath)) {
// FileStatus status = fs.getFileStatus(inputPath);
// if(status.isDirectory()) {
// // check child
// FileStatus[] entries = fs.listStatus(inputPath);
// for (FileStatus entry : entries) {
// if(entry.isFile()) {
// if (filter.accept(entry.getPath())) {
// inputFiles.add(entry.getPath());
// }
// }
// }
// } else {
// if (filter.accept(status.getPath())) {
// inputFiles.add(status.getPath());
// }
// }
// }
//
// Path[] files = inputFiles.toArray(new Path[0]);
// return files;
// }
// }
// Path: src/libra/distancematrix/common/kmersimilarity/KmerSimilarityResultPartPathFilter.java
import libra.distancematrix.common.helpers.KmerSimilarityHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
/*
* Copyright 2016 iychoi.
*
* 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 libra.distancematrix.common.kmersimilarity;
/**
*
* @author iychoi
*/
public class KmerSimilarityResultPartPathFilter implements PathFilter {
@Override
public boolean accept(Path path) { | return KmerSimilarityHelper.isKmerSimilarityResultPartFile(path); |
iychoi/libra | src/libra/preprocess/common/helpers/KmerStatisticsHelper.java | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/kmerstatistics/KmerStatisticsPartTablePathFilter.java
// public class KmerStatisticsPartTablePathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerStatisticsHelper.isKmerStatisticsPartTableFile(path);
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.kmerstatistics.KmerStatisticsPartTablePathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.helpers;
/**
*
* @author iychoi
*/
public class KmerStatisticsHelper {
private final static String KMER_STATISTICS_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "$";
private final static Pattern KMER_STATISTICS_TABLE_PATH_PATTERN = Pattern.compile(KMER_STATISTICS_TABLE_PATH_EXP);
private final static String KMER_STATISTICS_PART_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "\\.\\d+$";
private final static Pattern KMER_STATISTICS_PART_TABLE_PATH_PATTERN = Pattern.compile(KMER_STATISTICS_PART_TABLE_PATH_EXP);
public static String makeKmerStatisticsTableFileName(String filename) {
return filename + "." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION;
}
public static String makeKmerStatisticsPartTableFileName(String filename, int taskID) {
return filename + "." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "." + taskID;
}
public static String makeKmerStatisticsDirPath(String rootPath) { | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/kmerstatistics/KmerStatisticsPartTablePathFilter.java
// public class KmerStatisticsPartTablePathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerStatisticsHelper.isKmerStatisticsPartTableFile(path);
// }
// }
// Path: src/libra/preprocess/common/helpers/KmerStatisticsHelper.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.kmerstatistics.KmerStatisticsPartTablePathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.helpers;
/**
*
* @author iychoi
*/
public class KmerStatisticsHelper {
private final static String KMER_STATISTICS_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "$";
private final static Pattern KMER_STATISTICS_TABLE_PATH_PATTERN = Pattern.compile(KMER_STATISTICS_TABLE_PATH_EXP);
private final static String KMER_STATISTICS_PART_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "\\.\\d+$";
private final static Pattern KMER_STATISTICS_PART_TABLE_PATH_PATTERN = Pattern.compile(KMER_STATISTICS_PART_TABLE_PATH_EXP);
public static String makeKmerStatisticsTableFileName(String filename) {
return filename + "." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION;
}
public static String makeKmerStatisticsPartTableFileName(String filename, int taskID) {
return filename + "." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "." + taskID;
}
public static String makeKmerStatisticsDirPath(String rootPath) { | return PathHelper.concatPath(rootPath, PreprocessorConstants.KMER_STATISITCS_DIRNAME); |
iychoi/libra | src/libra/preprocess/common/helpers/KmerStatisticsHelper.java | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/kmerstatistics/KmerStatisticsPartTablePathFilter.java
// public class KmerStatisticsPartTablePathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerStatisticsHelper.isKmerStatisticsPartTableFile(path);
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.kmerstatistics.KmerStatisticsPartTablePathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; | public static String makeKmerStatisticsDirPath(String rootPath) {
return PathHelper.concatPath(rootPath, PreprocessorConstants.KMER_STATISITCS_DIRNAME);
}
public static boolean isKmerStatisticsTableFile(Path path) {
return isKmerStatisticsTableFile(path.getName());
}
public static boolean isKmerStatisticsTableFile(String path) {
Matcher matcher = KMER_STATISTICS_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
if(matcher.matches()) {
return true;
}
return false;
}
public static boolean isKmerStatisticsPartTableFile(Path path) {
return isKmerStatisticsPartTableFile(path.getName());
}
public static boolean isKmerStatisticsPartTableFile(String path) {
Matcher matcher = KMER_STATISTICS_PART_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
if(matcher.matches()) {
return true;
}
return false;
}
public static Path[] getKmerStatisticsPartTableFilePaths(Configuration conf, Path inputPath) throws IOException {
List<Path> inputFiles = new ArrayList<Path>(); | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/kmerstatistics/KmerStatisticsPartTablePathFilter.java
// public class KmerStatisticsPartTablePathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerStatisticsHelper.isKmerStatisticsPartTableFile(path);
// }
// }
// Path: src/libra/preprocess/common/helpers/KmerStatisticsHelper.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.kmerstatistics.KmerStatisticsPartTablePathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
public static String makeKmerStatisticsDirPath(String rootPath) {
return PathHelper.concatPath(rootPath, PreprocessorConstants.KMER_STATISITCS_DIRNAME);
}
public static boolean isKmerStatisticsTableFile(Path path) {
return isKmerStatisticsTableFile(path.getName());
}
public static boolean isKmerStatisticsTableFile(String path) {
Matcher matcher = KMER_STATISTICS_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
if(matcher.matches()) {
return true;
}
return false;
}
public static boolean isKmerStatisticsPartTableFile(Path path) {
return isKmerStatisticsPartTableFile(path.getName());
}
public static boolean isKmerStatisticsPartTableFile(String path) {
Matcher matcher = KMER_STATISTICS_PART_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
if(matcher.matches()) {
return true;
}
return false;
}
public static Path[] getKmerStatisticsPartTableFilePaths(Configuration conf, Path inputPath) throws IOException {
List<Path> inputFiles = new ArrayList<Path>(); | KmerStatisticsPartTablePathFilter filter = new KmerStatisticsPartTablePathFilter(); |
iychoi/libra | src/libra/preprocess/common/filetable/FileTablePathFilter.java | // Path: src/libra/preprocess/common/helpers/FileTableHelper.java
// public class FileTableHelper {
// private final static String FILE_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.FILE_TABLE_FILENAME_EXTENSION + "$";
// private final static Pattern FILE_TABLE_PATH_PATTERN = Pattern.compile(FILE_TABLE_PATH_EXP);
//
// public static String makeFileTableFileName(String sampleFileName) {
// return sampleFileName + "." + PreprocessorConstants.FILE_TABLE_FILENAME_EXTENSION;
// }
//
// public static String makeFileTableDirPath(String rootPath) {
// return PathHelper.concatPath(rootPath, PreprocessorConstants.FILE_TABLE_DIRNAME);
// }
//
// public static boolean isFileTableFile(Path path) {
// return isFileTableFile(path.getName());
// }
//
// public static boolean isFileTableFile(String path) {
// Matcher matcher = FILE_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static Path[] getFileTableFilePaths(Configuration conf, Path inputPath) throws IOException {
// List<Path> inputFiles = new ArrayList<Path>();
// FileTablePathFilter filter = new FileTablePathFilter();
//
// FileSystem fs = inputPath.getFileSystem(conf);
// if(fs.exists(inputPath)) {
// FileStatus status = fs.getFileStatus(inputPath);
// if(status.isDirectory()) {
// // check child
// FileStatus[] entries = fs.listStatus(inputPath);
// for (FileStatus entry : entries) {
// if(entry.isFile()) {
// if (filter.accept(entry.getPath())) {
// inputFiles.add(entry.getPath());
// }
// }
// }
// } else {
// if (filter.accept(inputPath)) {
// inputFiles.add(inputPath);
// }
// }
// }
//
// Path[] files = inputFiles.toArray(new Path[0]);
// return files;
// }
// }
| import libra.preprocess.common.helpers.FileTableHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.filetable;
/**
*
* @author iychoi
*/
public class FileTablePathFilter implements PathFilter {
@Override
public boolean accept(Path path) { | // Path: src/libra/preprocess/common/helpers/FileTableHelper.java
// public class FileTableHelper {
// private final static String FILE_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.FILE_TABLE_FILENAME_EXTENSION + "$";
// private final static Pattern FILE_TABLE_PATH_PATTERN = Pattern.compile(FILE_TABLE_PATH_EXP);
//
// public static String makeFileTableFileName(String sampleFileName) {
// return sampleFileName + "." + PreprocessorConstants.FILE_TABLE_FILENAME_EXTENSION;
// }
//
// public static String makeFileTableDirPath(String rootPath) {
// return PathHelper.concatPath(rootPath, PreprocessorConstants.FILE_TABLE_DIRNAME);
// }
//
// public static boolean isFileTableFile(Path path) {
// return isFileTableFile(path.getName());
// }
//
// public static boolean isFileTableFile(String path) {
// Matcher matcher = FILE_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static Path[] getFileTableFilePaths(Configuration conf, Path inputPath) throws IOException {
// List<Path> inputFiles = new ArrayList<Path>();
// FileTablePathFilter filter = new FileTablePathFilter();
//
// FileSystem fs = inputPath.getFileSystem(conf);
// if(fs.exists(inputPath)) {
// FileStatus status = fs.getFileStatus(inputPath);
// if(status.isDirectory()) {
// // check child
// FileStatus[] entries = fs.listStatus(inputPath);
// for (FileStatus entry : entries) {
// if(entry.isFile()) {
// if (filter.accept(entry.getPath())) {
// inputFiles.add(entry.getPath());
// }
// }
// }
// } else {
// if (filter.accept(inputPath)) {
// inputFiles.add(inputPath);
// }
// }
// }
//
// Path[] files = inputFiles.toArray(new Path[0]);
// return files;
// }
// }
// Path: src/libra/preprocess/common/filetable/FileTablePathFilter.java
import libra.preprocess.common.helpers.FileTableHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.filetable;
/**
*
* @author iychoi
*/
public class FileTablePathFilter implements PathFilter {
@Override
public boolean accept(Path path) { | return FileTableHelper.isFileTableFile(path); |
iychoi/libra | src/libra/preprocess/common/kmerstatistics/KmerStatistics.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
| import java.io.File;
import java.io.IOException;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerstatistics;
/**
*
* @author iychoi
*/
public class KmerStatistics {
private static final Log LOG = LogFactory.getLog(KmerStatistics.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerstatistics.kmerstatistics";
private String name;
private double logTFCosnormBase;
private double naturalTFCosnormBase;
private double booleanTFCosnormBase;
private double logTFSum;
private double naturalTFSum;
private double booleanTFSum;
public static KmerStatistics createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
// Path: src/libra/preprocess/common/kmerstatistics/KmerStatistics.java
import java.io.File;
import java.io.IOException;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerstatistics;
/**
*
* @author iychoi
*/
public class KmerStatistics {
private static final Log LOG = LogFactory.getLog(KmerStatistics.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerstatistics.kmerstatistics";
private String name;
private double logTFCosnormBase;
private double naturalTFCosnormBase;
private double booleanTFCosnormBase;
private double logTFSum;
private double naturalTFSum;
private double booleanTFSum;
public static KmerStatistics createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/common/hadoop/io/reader/sequence/SplitReadReader.java | // Path: src/libra/common/sequence/Read.java
// public class Read {
//
// private static final Log LOG = LogFactory.getLog(Read.class);
//
// public static final char FASTA_READ_DESCRIPTION_IDENTIFIER = '>';
// public static final char FASTQ_READ_DESCRIPTION_IDENTIFIER = '@';
// public static final char FASTQ_READ_DESCRIPTION2_IDENTIFIER = '+';
//
// private String description;
// private String quality;
// private String description2;
// private List<String> sequences = new ArrayList<String>();
//
// public Read() {
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return this.description;
// }
//
// public void setQuality(String quality) {
// this.quality = quality;
// }
//
// public String getQuality() {
// return this.quality;
// }
//
// public void setDescription2(String description2) {
// this.description2 = description2;
// }
//
// public String getDescription2() {
// return this.description2;
// }
//
// public void addSequence(String sequence) {
// this.sequences.add(sequence);
// }
//
// public List<String> getSequences() {
// return Collections.unmodifiableList(sequences);
// }
//
// public String getFullSequence() {
// StringBuilder sb = new StringBuilder();
// for(String sequence : this.sequences) {
// sb.append(sequence.trim());
// }
// return sb.toString();
// }
//
// public void parseFasta(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() < 2) {
// throw new IOException("invalid fasta read format");
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTA read");
// for(String line : lines) {
// //LOG.info(line);
// if(line.length() > 0) {
// if(lineNo == 0) {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fasta read description format - " + line);
// }
// } else {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// throw new IOException("invalid fasta read sequence format - " + line);
// } else {
// addSequence(line.trim());
// }
// }
// }
//
// lineNo++;
// }
// }
//
// public void parseFastq(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() == 0) {
// return;
// }
//
// if(lines.size() != 4) {
// String header = lines.get(0);
// throw new IOException(String.format("invalid fastq read format - a read (%s) has %d lines", header, lines.size()));
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTQ read");
// for(String line : lines) {
// //LOG.info(line);
// switch(lineNo) {
// case 0:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fastq read description format - " + line);
// }
// }
// break;
// case 1:
// {
// addSequence(line.trim());
// }
// break;
// case 2:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION2_IDENTIFIER) {
// setDescription2(line.trim());
// } else {
// throw new IOException("invalid fastq read description2 format - " + line);
// }
// }
// break;
// case 3:
// {
// setQuality(line.trim());
// }
// break;
// }
//
// lineNo++;
// }
// }
//
// public void parse(List<String> lines) throws IOException {
// // check first line
// String first = lines.get(0);
// if(first.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// parseFastq(lines);
// return;
// } else if(first.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// parseFasta(lines);
// return;
// }
//
// throw new IOException("invalid read format");
// }
//
// public void clear() {
// this.description = null;
// this.quality = null;
// this.description2 = null;
// this.sequences.clear();
// }
//
// public boolean isEmpty() {
// return this.description == null;
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import libra.common.sequence.Read;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; | /*
* Copyright 2018 iychoi.
*
* 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 libra.common.hadoop.io.reader.sequence;
/**
*
* @author iychoi
*/
public class SplitReadReader extends RawReadReader {
private static final Log LOG = LogFactory.getLog(SplitReadReader.class);
protected boolean finished = false;
public SplitReadReader(SampleFormat format, InputStream in, Configuration conf) throws IOException {
super(format, in, conf);
this.finished = false;
}
@Override | // Path: src/libra/common/sequence/Read.java
// public class Read {
//
// private static final Log LOG = LogFactory.getLog(Read.class);
//
// public static final char FASTA_READ_DESCRIPTION_IDENTIFIER = '>';
// public static final char FASTQ_READ_DESCRIPTION_IDENTIFIER = '@';
// public static final char FASTQ_READ_DESCRIPTION2_IDENTIFIER = '+';
//
// private String description;
// private String quality;
// private String description2;
// private List<String> sequences = new ArrayList<String>();
//
// public Read() {
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return this.description;
// }
//
// public void setQuality(String quality) {
// this.quality = quality;
// }
//
// public String getQuality() {
// return this.quality;
// }
//
// public void setDescription2(String description2) {
// this.description2 = description2;
// }
//
// public String getDescription2() {
// return this.description2;
// }
//
// public void addSequence(String sequence) {
// this.sequences.add(sequence);
// }
//
// public List<String> getSequences() {
// return Collections.unmodifiableList(sequences);
// }
//
// public String getFullSequence() {
// StringBuilder sb = new StringBuilder();
// for(String sequence : this.sequences) {
// sb.append(sequence.trim());
// }
// return sb.toString();
// }
//
// public void parseFasta(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() < 2) {
// throw new IOException("invalid fasta read format");
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTA read");
// for(String line : lines) {
// //LOG.info(line);
// if(line.length() > 0) {
// if(lineNo == 0) {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fasta read description format - " + line);
// }
// } else {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// throw new IOException("invalid fasta read sequence format - " + line);
// } else {
// addSequence(line.trim());
// }
// }
// }
//
// lineNo++;
// }
// }
//
// public void parseFastq(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() == 0) {
// return;
// }
//
// if(lines.size() != 4) {
// String header = lines.get(0);
// throw new IOException(String.format("invalid fastq read format - a read (%s) has %d lines", header, lines.size()));
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTQ read");
// for(String line : lines) {
// //LOG.info(line);
// switch(lineNo) {
// case 0:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fastq read description format - " + line);
// }
// }
// break;
// case 1:
// {
// addSequence(line.trim());
// }
// break;
// case 2:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION2_IDENTIFIER) {
// setDescription2(line.trim());
// } else {
// throw new IOException("invalid fastq read description2 format - " + line);
// }
// }
// break;
// case 3:
// {
// setQuality(line.trim());
// }
// break;
// }
//
// lineNo++;
// }
// }
//
// public void parse(List<String> lines) throws IOException {
// // check first line
// String first = lines.get(0);
// if(first.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// parseFastq(lines);
// return;
// } else if(first.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// parseFasta(lines);
// return;
// }
//
// throw new IOException("invalid read format");
// }
//
// public void clear() {
// this.description = null;
// this.quality = null;
// this.description2 = null;
// this.sequences.clear();
// }
//
// public boolean isEmpty() {
// return this.description == null;
// }
// }
// Path: src/libra/common/hadoop/io/reader/sequence/SplitReadReader.java
import java.io.IOException;
import java.io.InputStream;
import libra.common.sequence.Read;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
/*
* Copyright 2018 iychoi.
*
* 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 libra.common.hadoop.io.reader.sequence;
/**
*
* @author iychoi
*/
public class SplitReadReader extends RawReadReader {
private static final Log LOG = LogFactory.getLog(SplitReadReader.class);
protected boolean finished = false;
public SplitReadReader(SampleFormat format, InputStream in, Configuration conf) throws IOException {
super(format, in, conf);
this.finished = false;
}
@Override | public long readRead(Read read) throws IOException { |
iychoi/libra | src/libra/common/namedoutput/NamedOutputs.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
//
// Path: src/libra/common/helpers/MapReduceHelper.java
// public class MapReduceHelper {
// public static String getOutputNameFromMapReduceOutput(Path mapreduceOutputPath) {
// return getOutputNameFromMapReduceOutput(mapreduceOutputPath.getName());
// }
//
// public static String getOutputNameFromMapReduceOutput(String mapreduceOutputName) {
// int midx = mapreduceOutputName.indexOf("-m-");
// if(midx > 0) {
// return mapreduceOutputName.substring(0, midx);
// }
//
// int ridx = mapreduceOutputName.indexOf("-r-");
// if(ridx > 0) {
// return mapreduceOutputName.substring(0, ridx);
// }
//
// return mapreduceOutputName;
// }
//
// public static int getMapReduceID(Path mapreduceOutputName) {
// return getMapReduceID(mapreduceOutputName.getName());
// }
//
// public static int getMapReduceID(String mapreduceOutputName) {
// int midx = mapreduceOutputName.indexOf("-m-");
// if(midx > 0) {
// return Integer.parseInt(mapreduceOutputName.substring(midx + 3));
// }
//
// int ridx = mapreduceOutputName.indexOf("-r-");
// if(ridx > 0) {
// return Integer.parseInt(mapreduceOutputName.substring(ridx + 3));
// }
//
// return 0;
// }
//
// public static boolean isLogFiles(Path path) {
// if(path.getName().equals("_SUCCESS")) {
// return true;
// } else if(path.getName().equals("_logs")) {
// return true;
// }
// return false;
// }
//
// public static boolean isPartialOutputFiles(Path path) {
// if(path.getName().startsWith("part-r-")) {
// return true;
// } else if(path.getName().startsWith("part-m-")) {
// return true;
// }
// return false;
// }
// }
| import org.codehaus.jackson.annotate.JsonProperty;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import libra.common.json.JsonSerializer;
import libra.common.helpers.MapReduceHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore; | /*
* Copyright 2016 iychoi.
*
* 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 libra.common.namedoutput;
/**
*
* @author iychoi
*/
public class NamedOutputs {
private static final Log LOG = LogFactory.getLog(NamedOutputs.class);
private static final String HADOOP_CONFIG_KEY = "libra.common.namedoutput.namedoutputs";
private Hashtable<String, Integer> identifierCache = new Hashtable<String, Integer>();
private Hashtable<String, Integer> filenameCache = new Hashtable<String, Integer>();
private List<NamedOutputRecord> recordList = new ArrayList<NamedOutputRecord>();
public static NamedOutputs createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
//
// Path: src/libra/common/helpers/MapReduceHelper.java
// public class MapReduceHelper {
// public static String getOutputNameFromMapReduceOutput(Path mapreduceOutputPath) {
// return getOutputNameFromMapReduceOutput(mapreduceOutputPath.getName());
// }
//
// public static String getOutputNameFromMapReduceOutput(String mapreduceOutputName) {
// int midx = mapreduceOutputName.indexOf("-m-");
// if(midx > 0) {
// return mapreduceOutputName.substring(0, midx);
// }
//
// int ridx = mapreduceOutputName.indexOf("-r-");
// if(ridx > 0) {
// return mapreduceOutputName.substring(0, ridx);
// }
//
// return mapreduceOutputName;
// }
//
// public static int getMapReduceID(Path mapreduceOutputName) {
// return getMapReduceID(mapreduceOutputName.getName());
// }
//
// public static int getMapReduceID(String mapreduceOutputName) {
// int midx = mapreduceOutputName.indexOf("-m-");
// if(midx > 0) {
// return Integer.parseInt(mapreduceOutputName.substring(midx + 3));
// }
//
// int ridx = mapreduceOutputName.indexOf("-r-");
// if(ridx > 0) {
// return Integer.parseInt(mapreduceOutputName.substring(ridx + 3));
// }
//
// return 0;
// }
//
// public static boolean isLogFiles(Path path) {
// if(path.getName().equals("_SUCCESS")) {
// return true;
// } else if(path.getName().equals("_logs")) {
// return true;
// }
// return false;
// }
//
// public static boolean isPartialOutputFiles(Path path) {
// if(path.getName().startsWith("part-r-")) {
// return true;
// } else if(path.getName().startsWith("part-m-")) {
// return true;
// }
// return false;
// }
// }
// Path: src/libra/common/namedoutput/NamedOutputs.java
import org.codehaus.jackson.annotate.JsonProperty;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import libra.common.json.JsonSerializer;
import libra.common.helpers.MapReduceHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
/*
* Copyright 2016 iychoi.
*
* 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 libra.common.namedoutput;
/**
*
* @author iychoi
*/
public class NamedOutputs {
private static final Log LOG = LogFactory.getLog(NamedOutputs.class);
private static final String HADOOP_CONFIG_KEY = "libra.common.namedoutput.namedoutputs";
private Hashtable<String, Integer> identifierCache = new Hashtable<String, Integer>();
private Hashtable<String, Integer> filenameCache = new Hashtable<String, Integer>();
private List<NamedOutputRecord> recordList = new ArrayList<NamedOutputRecord>();
public static NamedOutputs createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/common/namedoutput/NamedOutputs.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
//
// Path: src/libra/common/helpers/MapReduceHelper.java
// public class MapReduceHelper {
// public static String getOutputNameFromMapReduceOutput(Path mapreduceOutputPath) {
// return getOutputNameFromMapReduceOutput(mapreduceOutputPath.getName());
// }
//
// public static String getOutputNameFromMapReduceOutput(String mapreduceOutputName) {
// int midx = mapreduceOutputName.indexOf("-m-");
// if(midx > 0) {
// return mapreduceOutputName.substring(0, midx);
// }
//
// int ridx = mapreduceOutputName.indexOf("-r-");
// if(ridx > 0) {
// return mapreduceOutputName.substring(0, ridx);
// }
//
// return mapreduceOutputName;
// }
//
// public static int getMapReduceID(Path mapreduceOutputName) {
// return getMapReduceID(mapreduceOutputName.getName());
// }
//
// public static int getMapReduceID(String mapreduceOutputName) {
// int midx = mapreduceOutputName.indexOf("-m-");
// if(midx > 0) {
// return Integer.parseInt(mapreduceOutputName.substring(midx + 3));
// }
//
// int ridx = mapreduceOutputName.indexOf("-r-");
// if(ridx > 0) {
// return Integer.parseInt(mapreduceOutputName.substring(ridx + 3));
// }
//
// return 0;
// }
//
// public static boolean isLogFiles(Path path) {
// if(path.getName().equals("_SUCCESS")) {
// return true;
// } else if(path.getName().equals("_logs")) {
// return true;
// }
// return false;
// }
//
// public static boolean isPartialOutputFiles(Path path) {
// if(path.getName().startsWith("part-r-")) {
// return true;
// } else if(path.getName().startsWith("part-m-")) {
// return true;
// }
// return false;
// }
// }
| import org.codehaus.jackson.annotate.JsonProperty;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import libra.common.json.JsonSerializer;
import libra.common.helpers.MapReduceHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore; | addRecord(record);
}
}
@JsonIgnore
public int getIDFromFilename(String filename) throws IOException {
Integer ret = this.filenameCache.get(filename);
if(ret == null) {
throw new IOException("could not find id from " + filename);
} else {
return ret.intValue();
}
}
@JsonIgnore
public NamedOutputRecord getRecordFromID(int id) throws IOException {
if(this.recordList.size() <= id) {
throw new IOException("could not find record " + id);
} else {
return this.recordList.get(id);
}
}
@JsonIgnore
public NamedOutputRecord getRecordFromMROutput(Path outputFile) throws IOException {
return getRecordFromMROutput(outputFile.getName());
}
@JsonIgnore
public NamedOutputRecord getRecordFromMROutput(String outputFilename) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
//
// Path: src/libra/common/helpers/MapReduceHelper.java
// public class MapReduceHelper {
// public static String getOutputNameFromMapReduceOutput(Path mapreduceOutputPath) {
// return getOutputNameFromMapReduceOutput(mapreduceOutputPath.getName());
// }
//
// public static String getOutputNameFromMapReduceOutput(String mapreduceOutputName) {
// int midx = mapreduceOutputName.indexOf("-m-");
// if(midx > 0) {
// return mapreduceOutputName.substring(0, midx);
// }
//
// int ridx = mapreduceOutputName.indexOf("-r-");
// if(ridx > 0) {
// return mapreduceOutputName.substring(0, ridx);
// }
//
// return mapreduceOutputName;
// }
//
// public static int getMapReduceID(Path mapreduceOutputName) {
// return getMapReduceID(mapreduceOutputName.getName());
// }
//
// public static int getMapReduceID(String mapreduceOutputName) {
// int midx = mapreduceOutputName.indexOf("-m-");
// if(midx > 0) {
// return Integer.parseInt(mapreduceOutputName.substring(midx + 3));
// }
//
// int ridx = mapreduceOutputName.indexOf("-r-");
// if(ridx > 0) {
// return Integer.parseInt(mapreduceOutputName.substring(ridx + 3));
// }
//
// return 0;
// }
//
// public static boolean isLogFiles(Path path) {
// if(path.getName().equals("_SUCCESS")) {
// return true;
// } else if(path.getName().equals("_logs")) {
// return true;
// }
// return false;
// }
//
// public static boolean isPartialOutputFiles(Path path) {
// if(path.getName().startsWith("part-r-")) {
// return true;
// } else if(path.getName().startsWith("part-m-")) {
// return true;
// }
// return false;
// }
// }
// Path: src/libra/common/namedoutput/NamedOutputs.java
import org.codehaus.jackson.annotate.JsonProperty;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import libra.common.json.JsonSerializer;
import libra.common.helpers.MapReduceHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
addRecord(record);
}
}
@JsonIgnore
public int getIDFromFilename(String filename) throws IOException {
Integer ret = this.filenameCache.get(filename);
if(ret == null) {
throw new IOException("could not find id from " + filename);
} else {
return ret.intValue();
}
}
@JsonIgnore
public NamedOutputRecord getRecordFromID(int id) throws IOException {
if(this.recordList.size() <= id) {
throw new IOException("could not find record " + id);
} else {
return this.recordList.get(id);
}
}
@JsonIgnore
public NamedOutputRecord getRecordFromMROutput(Path outputFile) throws IOException {
return getRecordFromMROutput(outputFile.getName());
}
@JsonIgnore
public NamedOutputRecord getRecordFromMROutput(String outputFilename) throws IOException { | String identifier = MapReduceHelper.getOutputNameFromMapReduceOutput(outputFilename); |
iychoi/libra | src/libra/preprocess/common/kmerfilter/KmerFilterPartTablePathFilter.java | // Path: src/libra/preprocess/common/helpers/KmerFilterHelper.java
// public class KmerFilterHelper {
//
// private final static String KMER_FILTER_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "$";
// private final static Pattern KMER_FILTER_TABLE_PATH_PATTERN = Pattern.compile(KMER_FILTER_TABLE_PATH_EXP);
//
// private final static String KMER_FILTER_PART_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "\\.\\d+$";
// private final static Pattern KMER_FILTER_PART_TABLE_PATH_PATTERN = Pattern.compile(KMER_FILTER_PART_TABLE_PATH_EXP);
//
// public static String makeKmerFilterTableFileName(String filename) {
// return filename + "." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION;
// }
//
// public static String makeKmerFilterPartTableFileName(String filename, int taskID) {
// return filename + "." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "." + taskID;
// }
//
// public static String makeKmerFilterDirPath(String rootPath) {
// return PathHelper.concatPath(rootPath, PreprocessorConstants.KMER_FILTER_DIRNAME);
// }
//
// public static boolean isKmerFilterTableFile(Path path) {
// return isKmerFilterTableFile(path.getName());
// }
//
// public static boolean isKmerFilterTableFile(String path) {
// Matcher matcher = KMER_FILTER_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static boolean isKmerFilterPartTableFile(Path path) {
// return isKmerFilterPartTableFile(path.getName());
// }
//
// public static boolean isKmerFilterPartTableFile(String path) {
// Matcher matcher = KMER_FILTER_PART_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static Path[] getKmerFilterPartTableFilePaths(Configuration conf, Path inputPath) throws IOException {
// List<Path> inputFiles = new ArrayList<Path>();
// KmerFilterPartTablePathFilter filter = new KmerFilterPartTablePathFilter();
//
// FileSystem fs = inputPath.getFileSystem(conf);
// if(fs.exists(inputPath)) {
// FileStatus status = fs.getFileStatus(inputPath);
// if(status.isDirectory()) {
// // check child
// FileStatus[] entries = fs.listStatus(inputPath);
// for (FileStatus entry : entries) {
// if(entry.isFile()) {
// if (filter.accept(entry.getPath())) {
// inputFiles.add(entry.getPath());
// }
// }
// }
// } else {
// if (filter.accept(inputPath)) {
// inputFiles.add(inputPath);
// }
// }
// }
//
// Path[] files = inputFiles.toArray(new Path[0]);
// return files;
// }
// }
| import libra.preprocess.common.helpers.KmerFilterHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerfilter;
/**
*
* @author iychoi
*/
public class KmerFilterPartTablePathFilter implements PathFilter {
@Override
public boolean accept(Path path) { | // Path: src/libra/preprocess/common/helpers/KmerFilterHelper.java
// public class KmerFilterHelper {
//
// private final static String KMER_FILTER_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "$";
// private final static Pattern KMER_FILTER_TABLE_PATH_PATTERN = Pattern.compile(KMER_FILTER_TABLE_PATH_EXP);
//
// private final static String KMER_FILTER_PART_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "\\.\\d+$";
// private final static Pattern KMER_FILTER_PART_TABLE_PATH_PATTERN = Pattern.compile(KMER_FILTER_PART_TABLE_PATH_EXP);
//
// public static String makeKmerFilterTableFileName(String filename) {
// return filename + "." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION;
// }
//
// public static String makeKmerFilterPartTableFileName(String filename, int taskID) {
// return filename + "." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "." + taskID;
// }
//
// public static String makeKmerFilterDirPath(String rootPath) {
// return PathHelper.concatPath(rootPath, PreprocessorConstants.KMER_FILTER_DIRNAME);
// }
//
// public static boolean isKmerFilterTableFile(Path path) {
// return isKmerFilterTableFile(path.getName());
// }
//
// public static boolean isKmerFilterTableFile(String path) {
// Matcher matcher = KMER_FILTER_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static boolean isKmerFilterPartTableFile(Path path) {
// return isKmerFilterPartTableFile(path.getName());
// }
//
// public static boolean isKmerFilterPartTableFile(String path) {
// Matcher matcher = KMER_FILTER_PART_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static Path[] getKmerFilterPartTableFilePaths(Configuration conf, Path inputPath) throws IOException {
// List<Path> inputFiles = new ArrayList<Path>();
// KmerFilterPartTablePathFilter filter = new KmerFilterPartTablePathFilter();
//
// FileSystem fs = inputPath.getFileSystem(conf);
// if(fs.exists(inputPath)) {
// FileStatus status = fs.getFileStatus(inputPath);
// if(status.isDirectory()) {
// // check child
// FileStatus[] entries = fs.listStatus(inputPath);
// for (FileStatus entry : entries) {
// if(entry.isFile()) {
// if (filter.accept(entry.getPath())) {
// inputFiles.add(entry.getPath());
// }
// }
// }
// } else {
// if (filter.accept(inputPath)) {
// inputFiles.add(inputPath);
// }
// }
// }
//
// Path[] files = inputFiles.toArray(new Path[0]);
// return files;
// }
// }
// Path: src/libra/preprocess/common/kmerfilter/KmerFilterPartTablePathFilter.java
import libra.preprocess.common.helpers.KmerFilterHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerfilter;
/**
*
* @author iychoi
*/
public class KmerFilterPartTablePathFilter implements PathFilter {
@Override
public boolean accept(Path path) { | return KmerFilterHelper.isKmerFilterPartTableFile(path); |
iychoi/libra | src/libra/preprocess/common/kmerfilter/KmerFilterPartTable.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
| import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerfilter;
/**
*
* @author iychoi
*/
public class KmerFilterPartTable {
private static final Log LOG = LogFactory.getLog(KmerFilterPartTable.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerfilter.kmerfilterparttable";
private String name;
private List<KmerFilterPart> filterPart = new ArrayList<KmerFilterPart>();
public static KmerFilterPartTable createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
// Path: src/libra/preprocess/common/kmerfilter/KmerFilterPartTable.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerfilter;
/**
*
* @author iychoi
*/
public class KmerFilterPartTable {
private static final Log LOG = LogFactory.getLog(KmerFilterPartTable.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerfilter.kmerfilterparttable";
private String name;
private List<KmerFilterPart> filterPart = new ArrayList<KmerFilterPart>();
public static KmerFilterPartTable createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/common/hadoop/io/reader/sequence/RawReadReader.java | // Path: src/libra/common/sequence/Read.java
// public class Read {
//
// private static final Log LOG = LogFactory.getLog(Read.class);
//
// public static final char FASTA_READ_DESCRIPTION_IDENTIFIER = '>';
// public static final char FASTQ_READ_DESCRIPTION_IDENTIFIER = '@';
// public static final char FASTQ_READ_DESCRIPTION2_IDENTIFIER = '+';
//
// private String description;
// private String quality;
// private String description2;
// private List<String> sequences = new ArrayList<String>();
//
// public Read() {
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return this.description;
// }
//
// public void setQuality(String quality) {
// this.quality = quality;
// }
//
// public String getQuality() {
// return this.quality;
// }
//
// public void setDescription2(String description2) {
// this.description2 = description2;
// }
//
// public String getDescription2() {
// return this.description2;
// }
//
// public void addSequence(String sequence) {
// this.sequences.add(sequence);
// }
//
// public List<String> getSequences() {
// return Collections.unmodifiableList(sequences);
// }
//
// public String getFullSequence() {
// StringBuilder sb = new StringBuilder();
// for(String sequence : this.sequences) {
// sb.append(sequence.trim());
// }
// return sb.toString();
// }
//
// public void parseFasta(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() < 2) {
// throw new IOException("invalid fasta read format");
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTA read");
// for(String line : lines) {
// //LOG.info(line);
// if(line.length() > 0) {
// if(lineNo == 0) {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fasta read description format - " + line);
// }
// } else {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// throw new IOException("invalid fasta read sequence format - " + line);
// } else {
// addSequence(line.trim());
// }
// }
// }
//
// lineNo++;
// }
// }
//
// public void parseFastq(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() == 0) {
// return;
// }
//
// if(lines.size() != 4) {
// String header = lines.get(0);
// throw new IOException(String.format("invalid fastq read format - a read (%s) has %d lines", header, lines.size()));
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTQ read");
// for(String line : lines) {
// //LOG.info(line);
// switch(lineNo) {
// case 0:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fastq read description format - " + line);
// }
// }
// break;
// case 1:
// {
// addSequence(line.trim());
// }
// break;
// case 2:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION2_IDENTIFIER) {
// setDescription2(line.trim());
// } else {
// throw new IOException("invalid fastq read description2 format - " + line);
// }
// }
// break;
// case 3:
// {
// setQuality(line.trim());
// }
// break;
// }
//
// lineNo++;
// }
// }
//
// public void parse(List<String> lines) throws IOException {
// // check first line
// String first = lines.get(0);
// if(first.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// parseFastq(lines);
// return;
// } else if(first.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// parseFasta(lines);
// return;
// }
//
// throw new IOException("invalid read format");
// }
//
// public void clear() {
// this.description = null;
// this.quality = null;
// this.description2 = null;
// this.sequences.clear();
// }
//
// public boolean isEmpty() {
// return this.description == null;
// }
// }
| import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import libra.common.sequence.Read;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.util.LineReader; | } else {
filled++;
}
}
if(LINE_BUFFERS - emptyBuffers + filled > 0) {
return true;
} else {
return false;
}
} else {
return true;
}
}
private long _skipIncompleteFASTARead() throws IOException {
if(this.finished) {
return 0;
}
boolean hasBufferData = _fillBuffer();
if(!hasBufferData) {
//EOF
this.finished = true;
return 0;
}
long bytesConsumed = 0;
boolean headerFound = false;
while(hasBufferData) { | // Path: src/libra/common/sequence/Read.java
// public class Read {
//
// private static final Log LOG = LogFactory.getLog(Read.class);
//
// public static final char FASTA_READ_DESCRIPTION_IDENTIFIER = '>';
// public static final char FASTQ_READ_DESCRIPTION_IDENTIFIER = '@';
// public static final char FASTQ_READ_DESCRIPTION2_IDENTIFIER = '+';
//
// private String description;
// private String quality;
// private String description2;
// private List<String> sequences = new ArrayList<String>();
//
// public Read() {
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return this.description;
// }
//
// public void setQuality(String quality) {
// this.quality = quality;
// }
//
// public String getQuality() {
// return this.quality;
// }
//
// public void setDescription2(String description2) {
// this.description2 = description2;
// }
//
// public String getDescription2() {
// return this.description2;
// }
//
// public void addSequence(String sequence) {
// this.sequences.add(sequence);
// }
//
// public List<String> getSequences() {
// return Collections.unmodifiableList(sequences);
// }
//
// public String getFullSequence() {
// StringBuilder sb = new StringBuilder();
// for(String sequence : this.sequences) {
// sb.append(sequence.trim());
// }
// return sb.toString();
// }
//
// public void parseFasta(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() < 2) {
// throw new IOException("invalid fasta read format");
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTA read");
// for(String line : lines) {
// //LOG.info(line);
// if(line.length() > 0) {
// if(lineNo == 0) {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fasta read description format - " + line);
// }
// } else {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// throw new IOException("invalid fasta read sequence format - " + line);
// } else {
// addSequence(line.trim());
// }
// }
// }
//
// lineNo++;
// }
// }
//
// public void parseFastq(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() == 0) {
// return;
// }
//
// if(lines.size() != 4) {
// String header = lines.get(0);
// throw new IOException(String.format("invalid fastq read format - a read (%s) has %d lines", header, lines.size()));
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTQ read");
// for(String line : lines) {
// //LOG.info(line);
// switch(lineNo) {
// case 0:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fastq read description format - " + line);
// }
// }
// break;
// case 1:
// {
// addSequence(line.trim());
// }
// break;
// case 2:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION2_IDENTIFIER) {
// setDescription2(line.trim());
// } else {
// throw new IOException("invalid fastq read description2 format - " + line);
// }
// }
// break;
// case 3:
// {
// setQuality(line.trim());
// }
// break;
// }
//
// lineNo++;
// }
// }
//
// public void parse(List<String> lines) throws IOException {
// // check first line
// String first = lines.get(0);
// if(first.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// parseFastq(lines);
// return;
// } else if(first.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// parseFasta(lines);
// return;
// }
//
// throw new IOException("invalid read format");
// }
//
// public void clear() {
// this.description = null;
// this.quality = null;
// this.description2 = null;
// this.sequences.clear();
// }
//
// public boolean isEmpty() {
// return this.description == null;
// }
// }
// Path: src/libra/common/hadoop/io/reader/sequence/RawReadReader.java
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import libra.common.sequence.Read;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.util.LineReader;
} else {
filled++;
}
}
if(LINE_BUFFERS - emptyBuffers + filled > 0) {
return true;
} else {
return false;
}
} else {
return true;
}
}
private long _skipIncompleteFASTARead() throws IOException {
if(this.finished) {
return 0;
}
boolean hasBufferData = _fillBuffer();
if(!hasBufferData) {
//EOF
this.finished = true;
return 0;
}
long bytesConsumed = 0;
boolean headerFound = false;
while(hasBufferData) { | if(this.buffers[0].getLength() > 0 && this.buffers[0].charAt(0) == Read.FASTA_READ_DESCRIPTION_IDENTIFIER) { |
iychoi/libra | src/libra/preprocess/common/helpers/KmerIndexHelper.java | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/kmerindex/KmerIndexDataPathFilter.java
// public class KmerIndexDataPathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerIndexHelper.isKmerIndexDataFile(path);
// }
// }
| import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.kmerindex.KmerIndexDataPathFilter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.helpers;
/**
*
* @author iychoi
*/
public class KmerIndexHelper {
private static final Log LOG = LogFactory.getLog(KmerIndexHelper.class);
| // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/kmerindex/KmerIndexDataPathFilter.java
// public class KmerIndexDataPathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerIndexHelper.isKmerIndexDataFile(path);
// }
// }
// Path: src/libra/preprocess/common/helpers/KmerIndexHelper.java
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.kmerindex.KmerIndexDataPathFilter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.helpers;
/**
*
* @author iychoi
*/
public class KmerIndexHelper {
private static final Log LOG = LogFactory.getLog(KmerIndexHelper.class);
| private final static String KMER_INDEX_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_INDEX_TABLE_FILENAME_EXTENSION + "$"; |
iychoi/libra | src/libra/preprocess/common/helpers/KmerIndexHelper.java | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/kmerindex/KmerIndexDataPathFilter.java
// public class KmerIndexDataPathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerIndexHelper.isKmerIndexDataFile(path);
// }
// }
| import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.kmerindex.KmerIndexDataPathFilter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.helpers;
/**
*
* @author iychoi
*/
public class KmerIndexHelper {
private static final Log LOG = LogFactory.getLog(KmerIndexHelper.class);
private final static String KMER_INDEX_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_INDEX_TABLE_FILENAME_EXTENSION + "$";
private final static Pattern KMER_INDEX_TABLE_PATH_PATTERN = Pattern.compile(KMER_INDEX_TABLE_PATH_EXP);
private final static String KMER_INDEX_DATA_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_INDEX_DATA_FILENAME_EXTENSION + "\\.\\d+$";
private final static Pattern KMER_INDEX_DATA_PATH_PATTERN = Pattern.compile(KMER_INDEX_DATA_PATH_EXP);
public static String makeKmerIndexTableFileName(String filename) {
return filename + "." + PreprocessorConstants.KMER_INDEX_TABLE_FILENAME_EXTENSION;
}
public static String makeKmerIndexDataFileName(Path filePath, int mapreduceID) {
return makeKmerIndexDataFileName(filePath.getName(), mapreduceID);
}
public static String makeKmerIndexDataFileName(String filename, int mapreduceID) {
return filename + "." + PreprocessorConstants.KMER_INDEX_DATA_FILENAME_EXTENSION + "." + mapreduceID;
}
public static String makeKmerIndexDirPath(String rootPath) { | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/kmerindex/KmerIndexDataPathFilter.java
// public class KmerIndexDataPathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerIndexHelper.isKmerIndexDataFile(path);
// }
// }
// Path: src/libra/preprocess/common/helpers/KmerIndexHelper.java
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.kmerindex.KmerIndexDataPathFilter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.helpers;
/**
*
* @author iychoi
*/
public class KmerIndexHelper {
private static final Log LOG = LogFactory.getLog(KmerIndexHelper.class);
private final static String KMER_INDEX_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_INDEX_TABLE_FILENAME_EXTENSION + "$";
private final static Pattern KMER_INDEX_TABLE_PATH_PATTERN = Pattern.compile(KMER_INDEX_TABLE_PATH_EXP);
private final static String KMER_INDEX_DATA_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_INDEX_DATA_FILENAME_EXTENSION + "\\.\\d+$";
private final static Pattern KMER_INDEX_DATA_PATH_PATTERN = Pattern.compile(KMER_INDEX_DATA_PATH_EXP);
public static String makeKmerIndexTableFileName(String filename) {
return filename + "." + PreprocessorConstants.KMER_INDEX_TABLE_FILENAME_EXTENSION;
}
public static String makeKmerIndexDataFileName(Path filePath, int mapreduceID) {
return makeKmerIndexDataFileName(filePath.getName(), mapreduceID);
}
public static String makeKmerIndexDataFileName(String filename, int mapreduceID) {
return filename + "." + PreprocessorConstants.KMER_INDEX_DATA_FILENAME_EXTENSION + "." + mapreduceID;
}
public static String makeKmerIndexDirPath(String rootPath) { | return PathHelper.concatPath(rootPath, PreprocessorConstants.KMER_INDEX_DIRNAME); |
iychoi/libra | src/libra/preprocess/common/helpers/KmerIndexHelper.java | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/kmerindex/KmerIndexDataPathFilter.java
// public class KmerIndexDataPathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerIndexHelper.isKmerIndexDataFile(path);
// }
// }
| import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.kmerindex.KmerIndexDataPathFilter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus; | public static boolean isSameKmerIndex(Path index1, Path index2) {
return isSameKmerIndex(index1.getName(), index2.getName());
}
public static boolean isSameKmerIndex(String index1, String index2) {
String fileTableName1 = getFileTableName(index1);
String fileTableName2 = getFileTableName(index2);
if(fileTableName1 == null || fileTableName2 == null) {
return false;
}
return fileTableName1.equals(fileTableName2);
}
public static int getIndexDataID(Path indexFilePath) {
return getIndexDataID(indexFilePath.getName());
}
public static int getIndexDataID(String indexFileName) {
int idx = indexFileName.lastIndexOf(".");
if(idx >= 0) {
String partID = indexFileName.substring(idx + 1);
return Integer.parseInt(partID);
}
return -1;
}
public static Path[] getKmerIndexDataFilePaths(Configuration conf, Path inputPath) throws IOException {
List<Path> inputFiles = new ArrayList<Path>(); | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/kmerindex/KmerIndexDataPathFilter.java
// public class KmerIndexDataPathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerIndexHelper.isKmerIndexDataFile(path);
// }
// }
// Path: src/libra/preprocess/common/helpers/KmerIndexHelper.java
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.kmerindex.KmerIndexDataPathFilter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
public static boolean isSameKmerIndex(Path index1, Path index2) {
return isSameKmerIndex(index1.getName(), index2.getName());
}
public static boolean isSameKmerIndex(String index1, String index2) {
String fileTableName1 = getFileTableName(index1);
String fileTableName2 = getFileTableName(index2);
if(fileTableName1 == null || fileTableName2 == null) {
return false;
}
return fileTableName1.equals(fileTableName2);
}
public static int getIndexDataID(Path indexFilePath) {
return getIndexDataID(indexFilePath.getName());
}
public static int getIndexDataID(String indexFileName) {
int idx = indexFileName.lastIndexOf(".");
if(idx >= 0) {
String partID = indexFileName.substring(idx + 1);
return Integer.parseInt(partID);
}
return -1;
}
public static Path[] getKmerIndexDataFilePaths(Configuration conf, Path inputPath) throws IOException {
List<Path> inputFiles = new ArrayList<Path>(); | KmerIndexDataPathFilter filter = new KmerIndexDataPathFilter(); |
iychoi/libra | src/libra/common/hadoop/io/reader/sequence/SampleFormat.java | // Path: src/libra/common/sequence/FastaPathFilter.java
// public class FastaPathFilter implements PathFilter {
//
// private static final String[] FASTA_EXT = {"fa", "ffn", "fna", "faa", "fasta", "fas", "fsa", "seq"};
//
// @Override
// public boolean accept(Path path) {
// String ext = PathHelper.getExtensionOfDecompressedFile(path.getName());
// if(ext != null) {
// ext = ext.toLowerCase();
// }
//
// for(String fext : FASTA_EXT) {
// if(fext.equals(ext)) {
// return true;
// }
// }
//
// return false;
// }
// }
//
// Path: src/libra/common/sequence/FastqPathFilter.java
// public class FastqPathFilter implements PathFilter {
//
// private static final String[] FASTAQ_EXT = {"fastq", "fq"};
//
// @Override
// public boolean accept(Path path) {
// String ext = PathHelper.getExtensionOfDecompressedFile(path.getName());
// if(ext != null) {
// ext = ext.toLowerCase();
// }
//
// for(String fext : FASTAQ_EXT) {
// if(fext.equals(ext)) {
// return true;
// }
// }
//
// return false;
// }
// }
| import libra.common.sequence.FastaPathFilter;
import libra.common.sequence.FastqPathFilter;
import org.apache.hadoop.fs.Path; | /*
* Copyright 2018 iychoi.
*
* 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 libra.common.hadoop.io.reader.sequence;
/**
*
* @author iychoi
*/
public enum SampleFormat {
FASTA,
FASTQ;
| // Path: src/libra/common/sequence/FastaPathFilter.java
// public class FastaPathFilter implements PathFilter {
//
// private static final String[] FASTA_EXT = {"fa", "ffn", "fna", "faa", "fasta", "fas", "fsa", "seq"};
//
// @Override
// public boolean accept(Path path) {
// String ext = PathHelper.getExtensionOfDecompressedFile(path.getName());
// if(ext != null) {
// ext = ext.toLowerCase();
// }
//
// for(String fext : FASTA_EXT) {
// if(fext.equals(ext)) {
// return true;
// }
// }
//
// return false;
// }
// }
//
// Path: src/libra/common/sequence/FastqPathFilter.java
// public class FastqPathFilter implements PathFilter {
//
// private static final String[] FASTAQ_EXT = {"fastq", "fq"};
//
// @Override
// public boolean accept(Path path) {
// String ext = PathHelper.getExtensionOfDecompressedFile(path.getName());
// if(ext != null) {
// ext = ext.toLowerCase();
// }
//
// for(String fext : FASTAQ_EXT) {
// if(fext.equals(ext)) {
// return true;
// }
// }
//
// return false;
// }
// }
// Path: src/libra/common/hadoop/io/reader/sequence/SampleFormat.java
import libra.common.sequence.FastaPathFilter;
import libra.common.sequence.FastqPathFilter;
import org.apache.hadoop.fs.Path;
/*
* Copyright 2018 iychoi.
*
* 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 libra.common.hadoop.io.reader.sequence;
/**
*
* @author iychoi
*/
public enum SampleFormat {
FASTA,
FASTQ;
| private static FastaPathFilter fastaFilter = new FastaPathFilter(); |
iychoi/libra | src/libra/common/hadoop/io/reader/sequence/SampleFormat.java | // Path: src/libra/common/sequence/FastaPathFilter.java
// public class FastaPathFilter implements PathFilter {
//
// private static final String[] FASTA_EXT = {"fa", "ffn", "fna", "faa", "fasta", "fas", "fsa", "seq"};
//
// @Override
// public boolean accept(Path path) {
// String ext = PathHelper.getExtensionOfDecompressedFile(path.getName());
// if(ext != null) {
// ext = ext.toLowerCase();
// }
//
// for(String fext : FASTA_EXT) {
// if(fext.equals(ext)) {
// return true;
// }
// }
//
// return false;
// }
// }
//
// Path: src/libra/common/sequence/FastqPathFilter.java
// public class FastqPathFilter implements PathFilter {
//
// private static final String[] FASTAQ_EXT = {"fastq", "fq"};
//
// @Override
// public boolean accept(Path path) {
// String ext = PathHelper.getExtensionOfDecompressedFile(path.getName());
// if(ext != null) {
// ext = ext.toLowerCase();
// }
//
// for(String fext : FASTAQ_EXT) {
// if(fext.equals(ext)) {
// return true;
// }
// }
//
// return false;
// }
// }
| import libra.common.sequence.FastaPathFilter;
import libra.common.sequence.FastqPathFilter;
import org.apache.hadoop.fs.Path; | /*
* Copyright 2018 iychoi.
*
* 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 libra.common.hadoop.io.reader.sequence;
/**
*
* @author iychoi
*/
public enum SampleFormat {
FASTA,
FASTQ;
private static FastaPathFilter fastaFilter = new FastaPathFilter(); | // Path: src/libra/common/sequence/FastaPathFilter.java
// public class FastaPathFilter implements PathFilter {
//
// private static final String[] FASTA_EXT = {"fa", "ffn", "fna", "faa", "fasta", "fas", "fsa", "seq"};
//
// @Override
// public boolean accept(Path path) {
// String ext = PathHelper.getExtensionOfDecompressedFile(path.getName());
// if(ext != null) {
// ext = ext.toLowerCase();
// }
//
// for(String fext : FASTA_EXT) {
// if(fext.equals(ext)) {
// return true;
// }
// }
//
// return false;
// }
// }
//
// Path: src/libra/common/sequence/FastqPathFilter.java
// public class FastqPathFilter implements PathFilter {
//
// private static final String[] FASTAQ_EXT = {"fastq", "fq"};
//
// @Override
// public boolean accept(Path path) {
// String ext = PathHelper.getExtensionOfDecompressedFile(path.getName());
// if(ext != null) {
// ext = ext.toLowerCase();
// }
//
// for(String fext : FASTAQ_EXT) {
// if(fext.equals(ext)) {
// return true;
// }
// }
//
// return false;
// }
// }
// Path: src/libra/common/hadoop/io/reader/sequence/SampleFormat.java
import libra.common.sequence.FastaPathFilter;
import libra.common.sequence.FastqPathFilter;
import org.apache.hadoop.fs.Path;
/*
* Copyright 2018 iychoi.
*
* 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 libra.common.hadoop.io.reader.sequence;
/**
*
* @author iychoi
*/
public enum SampleFormat {
FASTA,
FASTQ;
private static FastaPathFilter fastaFilter = new FastaPathFilter(); | private static FastqPathFilter fastqFilter = new FastqPathFilter(); |
iychoi/libra | src/libra/common/sequence/FastqPathFilter.java | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
| import libra.common.helpers.PathHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter; | /*
* Copyright 2016 iychoi.
*
* 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 libra.common.sequence;
/**
*
* @author iychoi
*/
public class FastqPathFilter implements PathFilter {
private static final String[] FASTAQ_EXT = {"fastq", "fq"};
@Override
public boolean accept(Path path) { | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
// Path: src/libra/common/sequence/FastqPathFilter.java
import libra.common.helpers.PathHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
/*
* Copyright 2016 iychoi.
*
* 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 libra.common.sequence;
/**
*
* @author iychoi
*/
public class FastqPathFilter implements PathFilter {
private static final String[] FASTAQ_EXT = {"fastq", "fq"};
@Override
public boolean accept(Path path) { | String ext = PathHelper.getExtensionOfDecompressedFile(path.getName()); |
iychoi/libra | src/libra/common/hadoop/io/reader/sequence/UncompressedSplitReadReader.java | // Path: src/libra/common/sequence/Read.java
// public class Read {
//
// private static final Log LOG = LogFactory.getLog(Read.class);
//
// public static final char FASTA_READ_DESCRIPTION_IDENTIFIER = '>';
// public static final char FASTQ_READ_DESCRIPTION_IDENTIFIER = '@';
// public static final char FASTQ_READ_DESCRIPTION2_IDENTIFIER = '+';
//
// private String description;
// private String quality;
// private String description2;
// private List<String> sequences = new ArrayList<String>();
//
// public Read() {
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return this.description;
// }
//
// public void setQuality(String quality) {
// this.quality = quality;
// }
//
// public String getQuality() {
// return this.quality;
// }
//
// public void setDescription2(String description2) {
// this.description2 = description2;
// }
//
// public String getDescription2() {
// return this.description2;
// }
//
// public void addSequence(String sequence) {
// this.sequences.add(sequence);
// }
//
// public List<String> getSequences() {
// return Collections.unmodifiableList(sequences);
// }
//
// public String getFullSequence() {
// StringBuilder sb = new StringBuilder();
// for(String sequence : this.sequences) {
// sb.append(sequence.trim());
// }
// return sb.toString();
// }
//
// public void parseFasta(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() < 2) {
// throw new IOException("invalid fasta read format");
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTA read");
// for(String line : lines) {
// //LOG.info(line);
// if(line.length() > 0) {
// if(lineNo == 0) {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fasta read description format - " + line);
// }
// } else {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// throw new IOException("invalid fasta read sequence format - " + line);
// } else {
// addSequence(line.trim());
// }
// }
// }
//
// lineNo++;
// }
// }
//
// public void parseFastq(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() == 0) {
// return;
// }
//
// if(lines.size() != 4) {
// String header = lines.get(0);
// throw new IOException(String.format("invalid fastq read format - a read (%s) has %d lines", header, lines.size()));
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTQ read");
// for(String line : lines) {
// //LOG.info(line);
// switch(lineNo) {
// case 0:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fastq read description format - " + line);
// }
// }
// break;
// case 1:
// {
// addSequence(line.trim());
// }
// break;
// case 2:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION2_IDENTIFIER) {
// setDescription2(line.trim());
// } else {
// throw new IOException("invalid fastq read description2 format - " + line);
// }
// }
// break;
// case 3:
// {
// setQuality(line.trim());
// }
// break;
// }
//
// lineNo++;
// }
// }
//
// public void parse(List<String> lines) throws IOException {
// // check first line
// String first = lines.get(0);
// if(first.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// parseFastq(lines);
// return;
// } else if(first.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// parseFasta(lines);
// return;
// }
//
// throw new IOException("invalid read format");
// }
//
// public void clear() {
// this.description = null;
// this.quality = null;
// this.description2 = null;
// this.sequences.clear();
// }
//
// public boolean isEmpty() {
// return this.description == null;
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import libra.common.sequence.Read;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; | /*
* Copyright 2018 iychoi.
*
* 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 libra.common.hadoop.io.reader.sequence;
/**
*
* @author iychoi
*/
public class UncompressedSplitReadReader extends SplitReadReader {
private static final Log LOG = LogFactory.getLog(UncompressedSplitReadReader.class);
protected long splitLength = 0;
protected long totalBytesRead = 0;
protected boolean finished = false;
public UncompressedSplitReadReader(SampleFormat format, InputStream in, Configuration conf, long splitLength) throws IOException {
super(format, in, conf);
this.splitLength = splitLength;
this.totalBytesRead = 0;
this.finished = false;
}
@Override | // Path: src/libra/common/sequence/Read.java
// public class Read {
//
// private static final Log LOG = LogFactory.getLog(Read.class);
//
// public static final char FASTA_READ_DESCRIPTION_IDENTIFIER = '>';
// public static final char FASTQ_READ_DESCRIPTION_IDENTIFIER = '@';
// public static final char FASTQ_READ_DESCRIPTION2_IDENTIFIER = '+';
//
// private String description;
// private String quality;
// private String description2;
// private List<String> sequences = new ArrayList<String>();
//
// public Read() {
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return this.description;
// }
//
// public void setQuality(String quality) {
// this.quality = quality;
// }
//
// public String getQuality() {
// return this.quality;
// }
//
// public void setDescription2(String description2) {
// this.description2 = description2;
// }
//
// public String getDescription2() {
// return this.description2;
// }
//
// public void addSequence(String sequence) {
// this.sequences.add(sequence);
// }
//
// public List<String> getSequences() {
// return Collections.unmodifiableList(sequences);
// }
//
// public String getFullSequence() {
// StringBuilder sb = new StringBuilder();
// for(String sequence : this.sequences) {
// sb.append(sequence.trim());
// }
// return sb.toString();
// }
//
// public void parseFasta(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() < 2) {
// throw new IOException("invalid fasta read format");
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTA read");
// for(String line : lines) {
// //LOG.info(line);
// if(line.length() > 0) {
// if(lineNo == 0) {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fasta read description format - " + line);
// }
// } else {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// throw new IOException("invalid fasta read sequence format - " + line);
// } else {
// addSequence(line.trim());
// }
// }
// }
//
// lineNo++;
// }
// }
//
// public void parseFastq(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() == 0) {
// return;
// }
//
// if(lines.size() != 4) {
// String header = lines.get(0);
// throw new IOException(String.format("invalid fastq read format - a read (%s) has %d lines", header, lines.size()));
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTQ read");
// for(String line : lines) {
// //LOG.info(line);
// switch(lineNo) {
// case 0:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fastq read description format - " + line);
// }
// }
// break;
// case 1:
// {
// addSequence(line.trim());
// }
// break;
// case 2:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION2_IDENTIFIER) {
// setDescription2(line.trim());
// } else {
// throw new IOException("invalid fastq read description2 format - " + line);
// }
// }
// break;
// case 3:
// {
// setQuality(line.trim());
// }
// break;
// }
//
// lineNo++;
// }
// }
//
// public void parse(List<String> lines) throws IOException {
// // check first line
// String first = lines.get(0);
// if(first.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// parseFastq(lines);
// return;
// } else if(first.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// parseFasta(lines);
// return;
// }
//
// throw new IOException("invalid read format");
// }
//
// public void clear() {
// this.description = null;
// this.quality = null;
// this.description2 = null;
// this.sequences.clear();
// }
//
// public boolean isEmpty() {
// return this.description == null;
// }
// }
// Path: src/libra/common/hadoop/io/reader/sequence/UncompressedSplitReadReader.java
import java.io.IOException;
import java.io.InputStream;
import libra.common.sequence.Read;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
/*
* Copyright 2018 iychoi.
*
* 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 libra.common.hadoop.io.reader.sequence;
/**
*
* @author iychoi
*/
public class UncompressedSplitReadReader extends SplitReadReader {
private static final Log LOG = LogFactory.getLog(UncompressedSplitReadReader.class);
protected long splitLength = 0;
protected long totalBytesRead = 0;
protected boolean finished = false;
public UncompressedSplitReadReader(SampleFormat format, InputStream in, Configuration conf, long splitLength) throws IOException {
super(format, in, conf);
this.splitLength = splitLength;
this.totalBytesRead = 0;
this.finished = false;
}
@Override | public long readRead(Read read) throws IOException { |
iychoi/libra | src/libra/preprocess/common/kmerstatistics/KmerStatisticsPartTablePathFilter.java | // Path: src/libra/preprocess/common/helpers/KmerStatisticsHelper.java
// public class KmerStatisticsHelper {
//
// private final static String KMER_STATISTICS_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "$";
// private final static Pattern KMER_STATISTICS_TABLE_PATH_PATTERN = Pattern.compile(KMER_STATISTICS_TABLE_PATH_EXP);
//
// private final static String KMER_STATISTICS_PART_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "\\.\\d+$";
// private final static Pattern KMER_STATISTICS_PART_TABLE_PATH_PATTERN = Pattern.compile(KMER_STATISTICS_PART_TABLE_PATH_EXP);
//
// public static String makeKmerStatisticsTableFileName(String filename) {
// return filename + "." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION;
// }
//
// public static String makeKmerStatisticsPartTableFileName(String filename, int taskID) {
// return filename + "." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "." + taskID;
// }
//
// public static String makeKmerStatisticsDirPath(String rootPath) {
// return PathHelper.concatPath(rootPath, PreprocessorConstants.KMER_STATISITCS_DIRNAME);
// }
//
// public static boolean isKmerStatisticsTableFile(Path path) {
// return isKmerStatisticsTableFile(path.getName());
// }
//
// public static boolean isKmerStatisticsTableFile(String path) {
// Matcher matcher = KMER_STATISTICS_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static boolean isKmerStatisticsPartTableFile(Path path) {
// return isKmerStatisticsPartTableFile(path.getName());
// }
//
// public static boolean isKmerStatisticsPartTableFile(String path) {
// Matcher matcher = KMER_STATISTICS_PART_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static Path[] getKmerStatisticsPartTableFilePaths(Configuration conf, Path inputPath) throws IOException {
// List<Path> inputFiles = new ArrayList<Path>();
// KmerStatisticsPartTablePathFilter filter = new KmerStatisticsPartTablePathFilter();
//
// FileSystem fs = inputPath.getFileSystem(conf);
// if(fs.exists(inputPath)) {
// FileStatus status = fs.getFileStatus(inputPath);
// if(status.isDirectory()) {
// // check child
// FileStatus[] entries = fs.listStatus(inputPath);
// for (FileStatus entry : entries) {
// if(entry.isFile()) {
// if (filter.accept(entry.getPath())) {
// inputFiles.add(entry.getPath());
// }
// }
// }
// } else {
// if (filter.accept(inputPath)) {
// inputFiles.add(inputPath);
// }
// }
// }
//
// Path[] files = inputFiles.toArray(new Path[0]);
// return files;
// }
// }
| import libra.preprocess.common.helpers.KmerStatisticsHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerstatistics;
/**
*
* @author iychoi
*/
public class KmerStatisticsPartTablePathFilter implements PathFilter {
@Override
public boolean accept(Path path) { | // Path: src/libra/preprocess/common/helpers/KmerStatisticsHelper.java
// public class KmerStatisticsHelper {
//
// private final static String KMER_STATISTICS_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "$";
// private final static Pattern KMER_STATISTICS_TABLE_PATH_PATTERN = Pattern.compile(KMER_STATISTICS_TABLE_PATH_EXP);
//
// private final static String KMER_STATISTICS_PART_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "\\.\\d+$";
// private final static Pattern KMER_STATISTICS_PART_TABLE_PATH_PATTERN = Pattern.compile(KMER_STATISTICS_PART_TABLE_PATH_EXP);
//
// public static String makeKmerStatisticsTableFileName(String filename) {
// return filename + "." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION;
// }
//
// public static String makeKmerStatisticsPartTableFileName(String filename, int taskID) {
// return filename + "." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "." + taskID;
// }
//
// public static String makeKmerStatisticsDirPath(String rootPath) {
// return PathHelper.concatPath(rootPath, PreprocessorConstants.KMER_STATISITCS_DIRNAME);
// }
//
// public static boolean isKmerStatisticsTableFile(Path path) {
// return isKmerStatisticsTableFile(path.getName());
// }
//
// public static boolean isKmerStatisticsTableFile(String path) {
// Matcher matcher = KMER_STATISTICS_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static boolean isKmerStatisticsPartTableFile(Path path) {
// return isKmerStatisticsPartTableFile(path.getName());
// }
//
// public static boolean isKmerStatisticsPartTableFile(String path) {
// Matcher matcher = KMER_STATISTICS_PART_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static Path[] getKmerStatisticsPartTableFilePaths(Configuration conf, Path inputPath) throws IOException {
// List<Path> inputFiles = new ArrayList<Path>();
// KmerStatisticsPartTablePathFilter filter = new KmerStatisticsPartTablePathFilter();
//
// FileSystem fs = inputPath.getFileSystem(conf);
// if(fs.exists(inputPath)) {
// FileStatus status = fs.getFileStatus(inputPath);
// if(status.isDirectory()) {
// // check child
// FileStatus[] entries = fs.listStatus(inputPath);
// for (FileStatus entry : entries) {
// if(entry.isFile()) {
// if (filter.accept(entry.getPath())) {
// inputFiles.add(entry.getPath());
// }
// }
// }
// } else {
// if (filter.accept(inputPath)) {
// inputFiles.add(inputPath);
// }
// }
// }
//
// Path[] files = inputFiles.toArray(new Path[0]);
// return files;
// }
// }
// Path: src/libra/preprocess/common/kmerstatistics/KmerStatisticsPartTablePathFilter.java
import libra.preprocess.common.helpers.KmerStatisticsHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerstatistics;
/**
*
* @author iychoi
*/
public class KmerStatisticsPartTablePathFilter implements PathFilter {
@Override
public boolean accept(Path path) { | return KmerStatisticsHelper.isKmerStatisticsPartTableFile(path); |
iychoi/libra | src/libra/preprocess/common/helpers/FileTableHelper.java | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/filetable/FileTablePathFilter.java
// public class FileTablePathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return FileTableHelper.isFileTableFile(path);
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.filetable.FileTablePathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.helpers;
/**
*
* @author iychoi
*/
public class FileTableHelper {
private final static String FILE_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.FILE_TABLE_FILENAME_EXTENSION + "$";
private final static Pattern FILE_TABLE_PATH_PATTERN = Pattern.compile(FILE_TABLE_PATH_EXP);
public static String makeFileTableFileName(String sampleFileName) {
return sampleFileName + "." + PreprocessorConstants.FILE_TABLE_FILENAME_EXTENSION;
}
public static String makeFileTableDirPath(String rootPath) { | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/filetable/FileTablePathFilter.java
// public class FileTablePathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return FileTableHelper.isFileTableFile(path);
// }
// }
// Path: src/libra/preprocess/common/helpers/FileTableHelper.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.filetable.FileTablePathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.helpers;
/**
*
* @author iychoi
*/
public class FileTableHelper {
private final static String FILE_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.FILE_TABLE_FILENAME_EXTENSION + "$";
private final static Pattern FILE_TABLE_PATH_PATTERN = Pattern.compile(FILE_TABLE_PATH_EXP);
public static String makeFileTableFileName(String sampleFileName) {
return sampleFileName + "." + PreprocessorConstants.FILE_TABLE_FILENAME_EXTENSION;
}
public static String makeFileTableDirPath(String rootPath) { | return PathHelper.concatPath(rootPath, PreprocessorConstants.FILE_TABLE_DIRNAME); |
iychoi/libra | src/libra/preprocess/common/helpers/FileTableHelper.java | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/filetable/FileTablePathFilter.java
// public class FileTablePathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return FileTableHelper.isFileTableFile(path);
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.filetable.FileTablePathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.helpers;
/**
*
* @author iychoi
*/
public class FileTableHelper {
private final static String FILE_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.FILE_TABLE_FILENAME_EXTENSION + "$";
private final static Pattern FILE_TABLE_PATH_PATTERN = Pattern.compile(FILE_TABLE_PATH_EXP);
public static String makeFileTableFileName(String sampleFileName) {
return sampleFileName + "." + PreprocessorConstants.FILE_TABLE_FILENAME_EXTENSION;
}
public static String makeFileTableDirPath(String rootPath) {
return PathHelper.concatPath(rootPath, PreprocessorConstants.FILE_TABLE_DIRNAME);
}
public static boolean isFileTableFile(Path path) {
return isFileTableFile(path.getName());
}
public static boolean isFileTableFile(String path) {
Matcher matcher = FILE_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
if(matcher.matches()) {
return true;
}
return false;
}
public static Path[] getFileTableFilePaths(Configuration conf, Path inputPath) throws IOException {
List<Path> inputFiles = new ArrayList<Path>(); | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/filetable/FileTablePathFilter.java
// public class FileTablePathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return FileTableHelper.isFileTableFile(path);
// }
// }
// Path: src/libra/preprocess/common/helpers/FileTableHelper.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.filetable.FileTablePathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.helpers;
/**
*
* @author iychoi
*/
public class FileTableHelper {
private final static String FILE_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.FILE_TABLE_FILENAME_EXTENSION + "$";
private final static Pattern FILE_TABLE_PATH_PATTERN = Pattern.compile(FILE_TABLE_PATH_EXP);
public static String makeFileTableFileName(String sampleFileName) {
return sampleFileName + "." + PreprocessorConstants.FILE_TABLE_FILENAME_EXTENSION;
}
public static String makeFileTableDirPath(String rootPath) {
return PathHelper.concatPath(rootPath, PreprocessorConstants.FILE_TABLE_DIRNAME);
}
public static boolean isFileTableFile(Path path) {
return isFileTableFile(path.getName());
}
public static boolean isFileTableFile(String path) {
Matcher matcher = FILE_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
if(matcher.matches()) {
return true;
}
return false;
}
public static Path[] getFileTableFilePaths(Configuration conf, Path inputPath) throws IOException {
List<Path> inputFiles = new ArrayList<Path>(); | FileTablePathFilter filter = new FileTablePathFilter(); |
iychoi/libra | src/libra/distancematrix/common/kmersimilarity/KmerSimilarityResultPartRecordGroup.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
| import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty; | /*
* Copyright 2016 iychoi.
*
* 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 libra.distancematrix.common.kmersimilarity;
/**
*
* @author iychoi
*/
public class KmerSimilarityResultPartRecordGroup {
private static final Log LOG = LogFactory.getLog(KmerSimilarityResultPartRecordGroup.class);
private static final String HADOOP_CONFIG_KEY = "libra.core.common.kmersimilarity.kmersimilarityresultpartrecordgroup";
private List<KmerSimilarityResultPartRecord> scores = new ArrayList<KmerSimilarityResultPartRecord>();
public static KmerSimilarityResultPartRecordGroup createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
// Path: src/libra/distancematrix/common/kmersimilarity/KmerSimilarityResultPartRecordGroup.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/*
* Copyright 2016 iychoi.
*
* 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 libra.distancematrix.common.kmersimilarity;
/**
*
* @author iychoi
*/
public class KmerSimilarityResultPartRecordGroup {
private static final Log LOG = LogFactory.getLog(KmerSimilarityResultPartRecordGroup.class);
private static final String HADOOP_CONFIG_KEY = "libra.core.common.kmersimilarity.kmersimilarityresultpartrecordgroup";
private List<KmerSimilarityResultPartRecord> scores = new ArrayList<KmerSimilarityResultPartRecord>();
public static KmerSimilarityResultPartRecordGroup createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/common/hadoop/io/reader/sequence/CompressedSplitReadReader.java | // Path: src/libra/common/sequence/Read.java
// public class Read {
//
// private static final Log LOG = LogFactory.getLog(Read.class);
//
// public static final char FASTA_READ_DESCRIPTION_IDENTIFIER = '>';
// public static final char FASTQ_READ_DESCRIPTION_IDENTIFIER = '@';
// public static final char FASTQ_READ_DESCRIPTION2_IDENTIFIER = '+';
//
// private String description;
// private String quality;
// private String description2;
// private List<String> sequences = new ArrayList<String>();
//
// public Read() {
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return this.description;
// }
//
// public void setQuality(String quality) {
// this.quality = quality;
// }
//
// public String getQuality() {
// return this.quality;
// }
//
// public void setDescription2(String description2) {
// this.description2 = description2;
// }
//
// public String getDescription2() {
// return this.description2;
// }
//
// public void addSequence(String sequence) {
// this.sequences.add(sequence);
// }
//
// public List<String> getSequences() {
// return Collections.unmodifiableList(sequences);
// }
//
// public String getFullSequence() {
// StringBuilder sb = new StringBuilder();
// for(String sequence : this.sequences) {
// sb.append(sequence.trim());
// }
// return sb.toString();
// }
//
// public void parseFasta(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() < 2) {
// throw new IOException("invalid fasta read format");
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTA read");
// for(String line : lines) {
// //LOG.info(line);
// if(line.length() > 0) {
// if(lineNo == 0) {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fasta read description format - " + line);
// }
// } else {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// throw new IOException("invalid fasta read sequence format - " + line);
// } else {
// addSequence(line.trim());
// }
// }
// }
//
// lineNo++;
// }
// }
//
// public void parseFastq(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() == 0) {
// return;
// }
//
// if(lines.size() != 4) {
// String header = lines.get(0);
// throw new IOException(String.format("invalid fastq read format - a read (%s) has %d lines", header, lines.size()));
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTQ read");
// for(String line : lines) {
// //LOG.info(line);
// switch(lineNo) {
// case 0:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fastq read description format - " + line);
// }
// }
// break;
// case 1:
// {
// addSequence(line.trim());
// }
// break;
// case 2:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION2_IDENTIFIER) {
// setDescription2(line.trim());
// } else {
// throw new IOException("invalid fastq read description2 format - " + line);
// }
// }
// break;
// case 3:
// {
// setQuality(line.trim());
// }
// break;
// }
//
// lineNo++;
// }
// }
//
// public void parse(List<String> lines) throws IOException {
// // check first line
// String first = lines.get(0);
// if(first.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// parseFastq(lines);
// return;
// } else if(first.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// parseFasta(lines);
// return;
// }
//
// throw new IOException("invalid read format");
// }
//
// public void clear() {
// this.description = null;
// this.quality = null;
// this.description2 = null;
// this.sequences.clear();
// }
//
// public boolean isEmpty() {
// return this.description == null;
// }
// }
| import java.io.IOException;
import libra.common.sequence.Read;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.compress.SplitCompressionInputStream; | /*
* Copyright 2018 iychoi.
*
* 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 libra.common.hadoop.io.reader.sequence;
/**
*
* @author iychoi
*/
public class CompressedSplitReadReader extends SplitReadReader {
private static final Log LOG = LogFactory.getLog(CompressedSplitReadReader.class);
private SplitCompressionInputStream scin;
protected boolean finished = false;
public CompressedSplitReadReader(SampleFormat format, SplitCompressionInputStream in, Configuration conf) throws IOException {
super(format, in, conf);
this.scin = in;
this.finished = false;
}
@Override | // Path: src/libra/common/sequence/Read.java
// public class Read {
//
// private static final Log LOG = LogFactory.getLog(Read.class);
//
// public static final char FASTA_READ_DESCRIPTION_IDENTIFIER = '>';
// public static final char FASTQ_READ_DESCRIPTION_IDENTIFIER = '@';
// public static final char FASTQ_READ_DESCRIPTION2_IDENTIFIER = '+';
//
// private String description;
// private String quality;
// private String description2;
// private List<String> sequences = new ArrayList<String>();
//
// public Read() {
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return this.description;
// }
//
// public void setQuality(String quality) {
// this.quality = quality;
// }
//
// public String getQuality() {
// return this.quality;
// }
//
// public void setDescription2(String description2) {
// this.description2 = description2;
// }
//
// public String getDescription2() {
// return this.description2;
// }
//
// public void addSequence(String sequence) {
// this.sequences.add(sequence);
// }
//
// public List<String> getSequences() {
// return Collections.unmodifiableList(sequences);
// }
//
// public String getFullSequence() {
// StringBuilder sb = new StringBuilder();
// for(String sequence : this.sequences) {
// sb.append(sequence.trim());
// }
// return sb.toString();
// }
//
// public void parseFasta(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() < 2) {
// throw new IOException("invalid fasta read format");
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTA read");
// for(String line : lines) {
// //LOG.info(line);
// if(line.length() > 0) {
// if(lineNo == 0) {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fasta read description format - " + line);
// }
// } else {
// if(line.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// throw new IOException("invalid fasta read sequence format - " + line);
// } else {
// addSequence(line.trim());
// }
// }
// }
//
// lineNo++;
// }
// }
//
// public void parseFastq(List<String> lines) throws IOException {
// clear();
//
// if(lines.size() == 0) {
// return;
// }
//
// if(lines.size() != 4) {
// String header = lines.get(0);
// throw new IOException(String.format("invalid fastq read format - a read (%s) has %d lines", header, lines.size()));
// }
//
// int lineNo = 0;
// //LOG.info("Parsing a FASTQ read");
// for(String line : lines) {
// //LOG.info(line);
// switch(lineNo) {
// case 0:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// setDescription(line.trim());
// } else {
// throw new IOException("invalid fastq read description format - " + line);
// }
// }
// break;
// case 1:
// {
// addSequence(line.trim());
// }
// break;
// case 2:
// {
// if(line.charAt(0) == FASTQ_READ_DESCRIPTION2_IDENTIFIER) {
// setDescription2(line.trim());
// } else {
// throw new IOException("invalid fastq read description2 format - " + line);
// }
// }
// break;
// case 3:
// {
// setQuality(line.trim());
// }
// break;
// }
//
// lineNo++;
// }
// }
//
// public void parse(List<String> lines) throws IOException {
// // check first line
// String first = lines.get(0);
// if(first.charAt(0) == FASTQ_READ_DESCRIPTION_IDENTIFIER) {
// parseFastq(lines);
// return;
// } else if(first.charAt(0) == FASTA_READ_DESCRIPTION_IDENTIFIER) {
// parseFasta(lines);
// return;
// }
//
// throw new IOException("invalid read format");
// }
//
// public void clear() {
// this.description = null;
// this.quality = null;
// this.description2 = null;
// this.sequences.clear();
// }
//
// public boolean isEmpty() {
// return this.description == null;
// }
// }
// Path: src/libra/common/hadoop/io/reader/sequence/CompressedSplitReadReader.java
import java.io.IOException;
import libra.common.sequence.Read;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.compress.SplitCompressionInputStream;
/*
* Copyright 2018 iychoi.
*
* 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 libra.common.hadoop.io.reader.sequence;
/**
*
* @author iychoi
*/
public class CompressedSplitReadReader extends SplitReadReader {
private static final Log LOG = LogFactory.getLog(CompressedSplitReadReader.class);
private SplitCompressionInputStream scin;
protected boolean finished = false;
public CompressedSplitReadReader(SampleFormat format, SplitCompressionInputStream in, Configuration conf) throws IOException {
super(format, in, conf);
this.scin = in;
this.finished = false;
}
@Override | public long readRead(Read read) throws IOException { |
iychoi/libra | src/libra/preprocess/common/samplegroup/SampleGroup.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
| import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.samplegroup;
/**
*
* @author iychoi
*/
public class SampleGroup {
private static final Log LOG = LogFactory.getLog(SampleGroup.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.samplegroup.samplegroup";
private String name;
private long totalSampleSize = 0;
private List<SampleInfo> samples = new ArrayList<SampleInfo>();
public static SampleGroup createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
// Path: src/libra/preprocess/common/samplegroup/SampleGroup.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.samplegroup;
/**
*
* @author iychoi
*/
public class SampleGroup {
private static final Log LOG = LogFactory.getLog(SampleGroup.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.samplegroup.samplegroup";
private String name;
private long totalSampleSize = 0;
private List<SampleInfo> samples = new ArrayList<SampleInfo>();
public static SampleGroup createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/distancematrix/common/kmersimilarity/KmerSimilarityResultPartRecord.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
| import java.io.File;
import java.io.IOException;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty; | /*
* Copyright 2016 iychoi.
*
* 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 libra.distancematrix.common.kmersimilarity;
/**
*
* @author iychoi
*/
public class KmerSimilarityResultPartRecord {
private static final Log LOG = LogFactory.getLog(KmerSimilarityResultPartRecord.class);
private static final String HADOOP_CONFIG_KEY = "libra.core.common.kmersimilarity.kmersimilarityresultpartrecord";
private int file1ID;
private int file2ID;
private double score;
public static KmerSimilarityResultPartRecord createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
// Path: src/libra/distancematrix/common/kmersimilarity/KmerSimilarityResultPartRecord.java
import java.io.File;
import java.io.IOException;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/*
* Copyright 2016 iychoi.
*
* 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 libra.distancematrix.common.kmersimilarity;
/**
*
* @author iychoi
*/
public class KmerSimilarityResultPartRecord {
private static final Log LOG = LogFactory.getLog(KmerSimilarityResultPartRecord.class);
private static final String HADOOP_CONFIG_KEY = "libra.core.common.kmersimilarity.kmersimilarityresultpartrecord";
private int file1ID;
private int file2ID;
private double score;
public static KmerSimilarityResultPartRecord createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/preprocess/common/kmerfilter/KmerFilterPart.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
| import java.io.File;
import java.io.IOException;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerfilter;
/**
*
* @author iychoi
*/
public class KmerFilterPart {
private static final Log LOG = LogFactory.getLog(KmerFilterPart.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerfilter.kmerfilterpart";
private String name;
private long totalKmers;
private long uniqueKmers;
private long sumOfSquare;
public static KmerFilterPart createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
// Path: src/libra/preprocess/common/kmerfilter/KmerFilterPart.java
import java.io.File;
import java.io.IOException;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerfilter;
/**
*
* @author iychoi
*/
public class KmerFilterPart {
private static final Log LOG = LogFactory.getLog(KmerFilterPart.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerfilter.kmerfilterpart";
private String name;
private long totalKmers;
private long uniqueKmers;
private long sumOfSquare;
public static KmerFilterPart createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/preprocess/common/kmerfilter/KmerFilter.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
| import java.io.File;
import java.io.IOException;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerfilter;
/**
*
* @author iychoi
*/
public class KmerFilter {
private static final Log LOG = LogFactory.getLog(KmerFilter.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerfilter.kmerfilter";
private String name;
private long totalKmers;
private long uniqueKmers;
private long sumOfSquare;
public static KmerFilter createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
// Path: src/libra/preprocess/common/kmerfilter/KmerFilter.java
import java.io.File;
import java.io.IOException;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerfilter;
/**
*
* @author iychoi
*/
public class KmerFilter {
private static final Log LOG = LogFactory.getLog(KmerFilter.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerfilter.kmerfilter";
private String name;
private long totalKmers;
private long uniqueKmers;
private long sumOfSquare;
public static KmerFilter createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/common/kmermatch/KmerMatchInputFormatConfig.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
| import java.io.File;
import java.io.IOException;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty; | /*
* Copyright 2016 iychoi.
*
* 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 libra.common.kmermatch;
/**
*
* @author iychoi
*/
public class KmerMatchInputFormatConfig {
private static final Log LOG = LogFactory.getLog(KmerMatchInputFormatConfig.class);
private static final String HADOOP_CONFIG_KEY = "libra.common.kmermatch.kmermatchinputformatconfig";
private int kmerSize;
private String fileTablePath;
private String kmerIndexPath;
public static KmerMatchInputFormatConfig createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
// Path: src/libra/common/kmermatch/KmerMatchInputFormatConfig.java
import java.io.File;
import java.io.IOException;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/*
* Copyright 2016 iychoi.
*
* 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 libra.common.kmermatch;
/**
*
* @author iychoi
*/
public class KmerMatchInputFormatConfig {
private static final Log LOG = LogFactory.getLog(KmerMatchInputFormatConfig.class);
private static final String HADOOP_CONFIG_KEY = "libra.common.kmermatch.kmermatchinputformatconfig";
private int kmerSize;
private String fileTablePath;
private String kmerIndexPath;
public static KmerMatchInputFormatConfig createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/preprocess/common/kmerfilter/KmerFilterTablePathFilter.java | // Path: src/libra/preprocess/common/helpers/KmerFilterHelper.java
// public class KmerFilterHelper {
//
// private final static String KMER_FILTER_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "$";
// private final static Pattern KMER_FILTER_TABLE_PATH_PATTERN = Pattern.compile(KMER_FILTER_TABLE_PATH_EXP);
//
// private final static String KMER_FILTER_PART_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "\\.\\d+$";
// private final static Pattern KMER_FILTER_PART_TABLE_PATH_PATTERN = Pattern.compile(KMER_FILTER_PART_TABLE_PATH_EXP);
//
// public static String makeKmerFilterTableFileName(String filename) {
// return filename + "." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION;
// }
//
// public static String makeKmerFilterPartTableFileName(String filename, int taskID) {
// return filename + "." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "." + taskID;
// }
//
// public static String makeKmerFilterDirPath(String rootPath) {
// return PathHelper.concatPath(rootPath, PreprocessorConstants.KMER_FILTER_DIRNAME);
// }
//
// public static boolean isKmerFilterTableFile(Path path) {
// return isKmerFilterTableFile(path.getName());
// }
//
// public static boolean isKmerFilterTableFile(String path) {
// Matcher matcher = KMER_FILTER_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static boolean isKmerFilterPartTableFile(Path path) {
// return isKmerFilterPartTableFile(path.getName());
// }
//
// public static boolean isKmerFilterPartTableFile(String path) {
// Matcher matcher = KMER_FILTER_PART_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static Path[] getKmerFilterPartTableFilePaths(Configuration conf, Path inputPath) throws IOException {
// List<Path> inputFiles = new ArrayList<Path>();
// KmerFilterPartTablePathFilter filter = new KmerFilterPartTablePathFilter();
//
// FileSystem fs = inputPath.getFileSystem(conf);
// if(fs.exists(inputPath)) {
// FileStatus status = fs.getFileStatus(inputPath);
// if(status.isDirectory()) {
// // check child
// FileStatus[] entries = fs.listStatus(inputPath);
// for (FileStatus entry : entries) {
// if(entry.isFile()) {
// if (filter.accept(entry.getPath())) {
// inputFiles.add(entry.getPath());
// }
// }
// }
// } else {
// if (filter.accept(inputPath)) {
// inputFiles.add(inputPath);
// }
// }
// }
//
// Path[] files = inputFiles.toArray(new Path[0]);
// return files;
// }
// }
| import libra.preprocess.common.helpers.KmerFilterHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerfilter;
/**
*
* @author iychoi
*/
public class KmerFilterTablePathFilter implements PathFilter {
@Override
public boolean accept(Path path) { | // Path: src/libra/preprocess/common/helpers/KmerFilterHelper.java
// public class KmerFilterHelper {
//
// private final static String KMER_FILTER_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "$";
// private final static Pattern KMER_FILTER_TABLE_PATH_PATTERN = Pattern.compile(KMER_FILTER_TABLE_PATH_EXP);
//
// private final static String KMER_FILTER_PART_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "\\.\\d+$";
// private final static Pattern KMER_FILTER_PART_TABLE_PATH_PATTERN = Pattern.compile(KMER_FILTER_PART_TABLE_PATH_EXP);
//
// public static String makeKmerFilterTableFileName(String filename) {
// return filename + "." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION;
// }
//
// public static String makeKmerFilterPartTableFileName(String filename, int taskID) {
// return filename + "." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "." + taskID;
// }
//
// public static String makeKmerFilterDirPath(String rootPath) {
// return PathHelper.concatPath(rootPath, PreprocessorConstants.KMER_FILTER_DIRNAME);
// }
//
// public static boolean isKmerFilterTableFile(Path path) {
// return isKmerFilterTableFile(path.getName());
// }
//
// public static boolean isKmerFilterTableFile(String path) {
// Matcher matcher = KMER_FILTER_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static boolean isKmerFilterPartTableFile(Path path) {
// return isKmerFilterPartTableFile(path.getName());
// }
//
// public static boolean isKmerFilterPartTableFile(String path) {
// Matcher matcher = KMER_FILTER_PART_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static Path[] getKmerFilterPartTableFilePaths(Configuration conf, Path inputPath) throws IOException {
// List<Path> inputFiles = new ArrayList<Path>();
// KmerFilterPartTablePathFilter filter = new KmerFilterPartTablePathFilter();
//
// FileSystem fs = inputPath.getFileSystem(conf);
// if(fs.exists(inputPath)) {
// FileStatus status = fs.getFileStatus(inputPath);
// if(status.isDirectory()) {
// // check child
// FileStatus[] entries = fs.listStatus(inputPath);
// for (FileStatus entry : entries) {
// if(entry.isFile()) {
// if (filter.accept(entry.getPath())) {
// inputFiles.add(entry.getPath());
// }
// }
// }
// } else {
// if (filter.accept(inputPath)) {
// inputFiles.add(inputPath);
// }
// }
// }
//
// Path[] files = inputFiles.toArray(new Path[0]);
// return files;
// }
// }
// Path: src/libra/preprocess/common/kmerfilter/KmerFilterTablePathFilter.java
import libra.preprocess.common.helpers.KmerFilterHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerfilter;
/**
*
* @author iychoi
*/
public class KmerFilterTablePathFilter implements PathFilter {
@Override
public boolean accept(Path path) { | return KmerFilterHelper.isKmerFilterTableFile(path); |
iychoi/libra | src/libra/common/sequence/FastaPathFilter.java | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
| import libra.common.helpers.PathHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter; | /*
* Copyright 2016 iychoi.
*
* 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 libra.common.sequence;
/**
*
* @author iychoi
*/
public class FastaPathFilter implements PathFilter {
private static final String[] FASTA_EXT = {"fa", "ffn", "fna", "faa", "fasta", "fas", "fsa", "seq"};
@Override
public boolean accept(Path path) { | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
// Path: src/libra/common/sequence/FastaPathFilter.java
import libra.common.helpers.PathHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
/*
* Copyright 2016 iychoi.
*
* 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 libra.common.sequence;
/**
*
* @author iychoi
*/
public class FastaPathFilter implements PathFilter {
private static final String[] FASTA_EXT = {"fa", "ffn", "fna", "faa", "fasta", "fas", "fsa", "seq"};
@Override
public boolean accept(Path path) { | String ext = PathHelper.getExtensionOfDecompressedFile(path.getName()); |
iychoi/libra | src/libra/preprocess/common/kmerstatistics/KmerStatisticsTablePathFilter.java | // Path: src/libra/preprocess/common/helpers/KmerStatisticsHelper.java
// public class KmerStatisticsHelper {
//
// private final static String KMER_STATISTICS_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "$";
// private final static Pattern KMER_STATISTICS_TABLE_PATH_PATTERN = Pattern.compile(KMER_STATISTICS_TABLE_PATH_EXP);
//
// private final static String KMER_STATISTICS_PART_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "\\.\\d+$";
// private final static Pattern KMER_STATISTICS_PART_TABLE_PATH_PATTERN = Pattern.compile(KMER_STATISTICS_PART_TABLE_PATH_EXP);
//
// public static String makeKmerStatisticsTableFileName(String filename) {
// return filename + "." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION;
// }
//
// public static String makeKmerStatisticsPartTableFileName(String filename, int taskID) {
// return filename + "." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "." + taskID;
// }
//
// public static String makeKmerStatisticsDirPath(String rootPath) {
// return PathHelper.concatPath(rootPath, PreprocessorConstants.KMER_STATISITCS_DIRNAME);
// }
//
// public static boolean isKmerStatisticsTableFile(Path path) {
// return isKmerStatisticsTableFile(path.getName());
// }
//
// public static boolean isKmerStatisticsTableFile(String path) {
// Matcher matcher = KMER_STATISTICS_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static boolean isKmerStatisticsPartTableFile(Path path) {
// return isKmerStatisticsPartTableFile(path.getName());
// }
//
// public static boolean isKmerStatisticsPartTableFile(String path) {
// Matcher matcher = KMER_STATISTICS_PART_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static Path[] getKmerStatisticsPartTableFilePaths(Configuration conf, Path inputPath) throws IOException {
// List<Path> inputFiles = new ArrayList<Path>();
// KmerStatisticsPartTablePathFilter filter = new KmerStatisticsPartTablePathFilter();
//
// FileSystem fs = inputPath.getFileSystem(conf);
// if(fs.exists(inputPath)) {
// FileStatus status = fs.getFileStatus(inputPath);
// if(status.isDirectory()) {
// // check child
// FileStatus[] entries = fs.listStatus(inputPath);
// for (FileStatus entry : entries) {
// if(entry.isFile()) {
// if (filter.accept(entry.getPath())) {
// inputFiles.add(entry.getPath());
// }
// }
// }
// } else {
// if (filter.accept(inputPath)) {
// inputFiles.add(inputPath);
// }
// }
// }
//
// Path[] files = inputFiles.toArray(new Path[0]);
// return files;
// }
// }
| import libra.preprocess.common.helpers.KmerStatisticsHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerstatistics;
/**
*
* @author iychoi
*/
public class KmerStatisticsTablePathFilter implements PathFilter {
@Override
public boolean accept(Path path) { | // Path: src/libra/preprocess/common/helpers/KmerStatisticsHelper.java
// public class KmerStatisticsHelper {
//
// private final static String KMER_STATISTICS_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "$";
// private final static Pattern KMER_STATISTICS_TABLE_PATH_PATTERN = Pattern.compile(KMER_STATISTICS_TABLE_PATH_EXP);
//
// private final static String KMER_STATISTICS_PART_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "\\.\\d+$";
// private final static Pattern KMER_STATISTICS_PART_TABLE_PATH_PATTERN = Pattern.compile(KMER_STATISTICS_PART_TABLE_PATH_EXP);
//
// public static String makeKmerStatisticsTableFileName(String filename) {
// return filename + "." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION;
// }
//
// public static String makeKmerStatisticsPartTableFileName(String filename, int taskID) {
// return filename + "." + PreprocessorConstants.KMER_STATISTICS_TABLE_FILENAME_EXTENSION + "." + taskID;
// }
//
// public static String makeKmerStatisticsDirPath(String rootPath) {
// return PathHelper.concatPath(rootPath, PreprocessorConstants.KMER_STATISITCS_DIRNAME);
// }
//
// public static boolean isKmerStatisticsTableFile(Path path) {
// return isKmerStatisticsTableFile(path.getName());
// }
//
// public static boolean isKmerStatisticsTableFile(String path) {
// Matcher matcher = KMER_STATISTICS_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static boolean isKmerStatisticsPartTableFile(Path path) {
// return isKmerStatisticsPartTableFile(path.getName());
// }
//
// public static boolean isKmerStatisticsPartTableFile(String path) {
// Matcher matcher = KMER_STATISTICS_PART_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
// if(matcher.matches()) {
// return true;
// }
// return false;
// }
//
// public static Path[] getKmerStatisticsPartTableFilePaths(Configuration conf, Path inputPath) throws IOException {
// List<Path> inputFiles = new ArrayList<Path>();
// KmerStatisticsPartTablePathFilter filter = new KmerStatisticsPartTablePathFilter();
//
// FileSystem fs = inputPath.getFileSystem(conf);
// if(fs.exists(inputPath)) {
// FileStatus status = fs.getFileStatus(inputPath);
// if(status.isDirectory()) {
// // check child
// FileStatus[] entries = fs.listStatus(inputPath);
// for (FileStatus entry : entries) {
// if(entry.isFile()) {
// if (filter.accept(entry.getPath())) {
// inputFiles.add(entry.getPath());
// }
// }
// }
// } else {
// if (filter.accept(inputPath)) {
// inputFiles.add(inputPath);
// }
// }
// }
//
// Path[] files = inputFiles.toArray(new Path[0]);
// return files;
// }
// }
// Path: src/libra/preprocess/common/kmerstatistics/KmerStatisticsTablePathFilter.java
import libra.preprocess.common.helpers.KmerStatisticsHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerstatistics;
/**
*
* @author iychoi
*/
public class KmerStatisticsTablePathFilter implements PathFilter {
@Override
public boolean accept(Path path) { | return KmerStatisticsHelper.isKmerStatisticsTableFile(path); |
iychoi/libra | src/libra/preprocess/common/kmerstatistics/KmerStatisticsTable.java | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
| import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerstatistics;
/**
*
* @author iychoi
*/
public class KmerStatisticsTable {
private static final Log LOG = LogFactory.getLog(KmerStatisticsTable.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerstatistics.kmerstatisticstable";
private String name;
private List<KmerStatistics> statistics = new ArrayList<KmerStatistics>();
public static KmerStatisticsTable createInstance(File file) throws IOException { | // Path: src/libra/common/json/JsonSerializer.java
// public class JsonSerializer {
//
// private ObjectMapper mapper;
//
// public JsonSerializer() {
// this.mapper = new ObjectMapper();
// }
//
// public JsonSerializer(boolean prettyformat) {
// this.mapper = new ObjectMapper();
// this.mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, prettyformat);
// }
//
// public String toJson(Object obj) throws IOException {
// StringWriter writer = new StringWriter();
// this.mapper.writeValue(writer, obj);
// return writer.getBuffer().toString();
// }
//
// public void toJsonConfiguration(Configuration conf, String key, Object obj) throws IOException {
// String jsonString = toJson(obj);
//
// conf.set(key, jsonString);
// }
//
// public void toJsonFile(File f, Object obj) throws IOException {
// this.mapper.writeValue(f, obj);
// }
//
// public void toJsonFile(FileSystem fs, Path file, Object obj) throws IOException {
// if(!fs.exists(file.getParent())) {
// fs.mkdirs(file.getParent());
// }
//
// DataOutputStream ostream = fs.create(file, true, 64 * 1024, (short)3, 1024 * 1024);
// this.mapper.writeValue(ostream, obj);
// ostream.close();
// }
//
// public Object fromJson(String json, Class<?> cls) throws IOException {
// if(json == null) {
// return null;
// }
// StringReader reader = new StringReader(json);
// return this.mapper.readValue(reader, cls);
// }
//
// public Object fromJsonConfiguration(Configuration conf, String key, Class<?> cls) throws IOException {
// String jsonString = conf.get(key);
//
// if(jsonString == null) {
// return null;
// }
//
// return fromJson(jsonString, cls);
// }
//
// public Object fromJsonFile(File f, Class<?> cls) throws IOException {
// return this.mapper.readValue(f, cls);
// }
//
// public Object fromJsonFile(FileSystem fs, Path file, Class<?> cls) throws IOException {
// DataInputStream istream = fs.open(file);
// Object obj = this.mapper.readValue(istream, cls);
//
// istream.close();
// return obj;
// }
// }
// Path: src/libra/preprocess/common/kmerstatistics/KmerStatisticsTable.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import libra.common.json.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.kmerstatistics;
/**
*
* @author iychoi
*/
public class KmerStatisticsTable {
private static final Log LOG = LogFactory.getLog(KmerStatisticsTable.class);
private static final String HADOOP_CONFIG_KEY = "libra.preprocess.common.kmerstatistics.kmerstatisticstable";
private String name;
private List<KmerStatistics> statistics = new ArrayList<KmerStatistics>();
public static KmerStatisticsTable createInstance(File file) throws IOException { | JsonSerializer serializer = new JsonSerializer(); |
iychoi/libra | src/libra/preprocess/common/helpers/KmerFilterHelper.java | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/kmerfilter/KmerFilterPartTablePathFilter.java
// public class KmerFilterPartTablePathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerFilterHelper.isKmerFilterPartTableFile(path);
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.kmerfilter.KmerFilterPartTablePathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; | /*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.helpers;
/**
*
* @author iychoi
*/
public class KmerFilterHelper {
private final static String KMER_FILTER_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "$";
private final static Pattern KMER_FILTER_TABLE_PATH_PATTERN = Pattern.compile(KMER_FILTER_TABLE_PATH_EXP);
private final static String KMER_FILTER_PART_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "\\.\\d+$";
private final static Pattern KMER_FILTER_PART_TABLE_PATH_PATTERN = Pattern.compile(KMER_FILTER_PART_TABLE_PATH_EXP);
public static String makeKmerFilterTableFileName(String filename) {
return filename + "." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION;
}
public static String makeKmerFilterPartTableFileName(String filename, int taskID) {
return filename + "." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "." + taskID;
}
public static String makeKmerFilterDirPath(String rootPath) { | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/kmerfilter/KmerFilterPartTablePathFilter.java
// public class KmerFilterPartTablePathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerFilterHelper.isKmerFilterPartTableFile(path);
// }
// }
// Path: src/libra/preprocess/common/helpers/KmerFilterHelper.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.kmerfilter.KmerFilterPartTablePathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
/*
* Copyright 2016 iychoi.
*
* 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 libra.preprocess.common.helpers;
/**
*
* @author iychoi
*/
public class KmerFilterHelper {
private final static String KMER_FILTER_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "$";
private final static Pattern KMER_FILTER_TABLE_PATH_PATTERN = Pattern.compile(KMER_FILTER_TABLE_PATH_EXP);
private final static String KMER_FILTER_PART_TABLE_PATH_EXP = ".+\\." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "\\.\\d+$";
private final static Pattern KMER_FILTER_PART_TABLE_PATH_PATTERN = Pattern.compile(KMER_FILTER_PART_TABLE_PATH_EXP);
public static String makeKmerFilterTableFileName(String filename) {
return filename + "." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION;
}
public static String makeKmerFilterPartTableFileName(String filename, int taskID) {
return filename + "." + PreprocessorConstants.KMER_FILTER_TABLE_FILENAME_EXTENSION + "." + taskID;
}
public static String makeKmerFilterDirPath(String rootPath) { | return PathHelper.concatPath(rootPath, PreprocessorConstants.KMER_FILTER_DIRNAME); |
iychoi/libra | src/libra/preprocess/common/helpers/KmerFilterHelper.java | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/kmerfilter/KmerFilterPartTablePathFilter.java
// public class KmerFilterPartTablePathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerFilterHelper.isKmerFilterPartTableFile(path);
// }
// }
| import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.kmerfilter.KmerFilterPartTablePathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; | public static String makeKmerFilterDirPath(String rootPath) {
return PathHelper.concatPath(rootPath, PreprocessorConstants.KMER_FILTER_DIRNAME);
}
public static boolean isKmerFilterTableFile(Path path) {
return isKmerFilterTableFile(path.getName());
}
public static boolean isKmerFilterTableFile(String path) {
Matcher matcher = KMER_FILTER_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
if(matcher.matches()) {
return true;
}
return false;
}
public static boolean isKmerFilterPartTableFile(Path path) {
return isKmerFilterPartTableFile(path.getName());
}
public static boolean isKmerFilterPartTableFile(String path) {
Matcher matcher = KMER_FILTER_PART_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
if(matcher.matches()) {
return true;
}
return false;
}
public static Path[] getKmerFilterPartTableFilePaths(Configuration conf, Path inputPath) throws IOException {
List<Path> inputFiles = new ArrayList<Path>(); | // Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//
// private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//
// public static String getParent(String path) {
// // check root
// if(path.equals("/")) {
// return null;
// }
//
// int lastIdx = path.lastIndexOf("/");
// if(lastIdx > 0) {
// return path.substring(0, lastIdx);
// } else {
// return "/";
// }
// }
//
// public static String concatPath(String path1, String path2) {
// StringBuffer sb = new StringBuffer();
//
// if(path1 != null && !path1.isEmpty()) {
// sb.append(path1);
// }
//
// if(!path1.endsWith("/")) {
// sb.append("/");
// }
//
// if(path2 != null && !path2.isEmpty()) {
// if(path2.startsWith("/")) {
// sb.append(path2.substring(1, path2.length()));
// } else {
// sb.append(path2);
// }
// }
//
// return sb.toString();
// }
//
// public static String getExtensionOfDecompressedFile(String name) {
// String myname = name;
// int idx = myname.lastIndexOf(".");
// if(idx > 0) {
// String ext = myname.substring(idx + 1);
// for(String cext : COMPRESSED_EXT) {
// if(cext.equalsIgnoreCase(ext)) {
// // compressed
// myname = myname.substring(0, idx);
// break;
// }
// }
// } else {
// return null;
// }
//
// idx = myname.lastIndexOf(".");
// if(idx > 0) {
// return myname.substring(idx + 1);
// }
// return null;
// }
// }
//
// Path: src/libra/preprocess/common/PreprocessorConstants.java
// public class PreprocessorConstants {
// public static final String FILE_TABLE_FILENAME_EXTENSION = "ftbl";
// public static final String KMER_FILTER_TABLE_FILENAME_EXTENSION = "kflt";
// public static final String KMER_INDEX_TABLE_FILENAME_EXTENSION = "kidx";
// public static final String KMER_INDEX_DATA_FILENAME_EXTENSION = "kidxc";
// public static final String KMER_STATISTICS_TABLE_FILENAME_EXTENSION = "kstat";
//
// public static final String FILE_TABLE_DIRNAME = "filetable";
// public static final String KMER_FILTER_DIRNAME = "filter";
// public static final String KMER_INDEX_DIRNAME = "kmerindex";
// public static final String KMER_STATISITCS_DIRNAME = "statistics";
// }
//
// Path: src/libra/preprocess/common/kmerfilter/KmerFilterPartTablePathFilter.java
// public class KmerFilterPartTablePathFilter implements PathFilter {
//
// @Override
// public boolean accept(Path path) {
// return KmerFilterHelper.isKmerFilterPartTableFile(path);
// }
// }
// Path: src/libra/preprocess/common/helpers/KmerFilterHelper.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import libra.common.helpers.PathHelper;
import libra.preprocess.common.PreprocessorConstants;
import libra.preprocess.common.kmerfilter.KmerFilterPartTablePathFilter;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
public static String makeKmerFilterDirPath(String rootPath) {
return PathHelper.concatPath(rootPath, PreprocessorConstants.KMER_FILTER_DIRNAME);
}
public static boolean isKmerFilterTableFile(Path path) {
return isKmerFilterTableFile(path.getName());
}
public static boolean isKmerFilterTableFile(String path) {
Matcher matcher = KMER_FILTER_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
if(matcher.matches()) {
return true;
}
return false;
}
public static boolean isKmerFilterPartTableFile(Path path) {
return isKmerFilterPartTableFile(path.getName());
}
public static boolean isKmerFilterPartTableFile(String path) {
Matcher matcher = KMER_FILTER_PART_TABLE_PATH_PATTERN.matcher(path.toLowerCase());
if(matcher.matches()) {
return true;
}
return false;
}
public static Path[] getKmerFilterPartTableFilePaths(Configuration conf, Path inputPath) throws IOException {
List<Path> inputFiles = new ArrayList<Path>(); | KmerFilterPartTablePathFilter filter = new KmerFilterPartTablePathFilter(); |
esbtools/esb-message-admin | common/src/main/java/org/esbtools/message/admin/common/config/EMAConfiguration.java | // Path: api/src/main/java/org/esbtools/message/admin/model/MessageSearchConfiguration.java
// public class MessageSearchConfiguration {
// /**
// * The display value for the configuration
// */
// private String label;
//
// /**
// * The value that will be passed to the controller from the frontend
// */
// private String value;
//
// /**
// * A list of systems that this configuration is applicable for. This will be null if
// * none exist
// */
// private String[] availableSystems;
//
// public MessageSearchConfiguration() {
// this.label = "";
// this.value = "";
// }
//
// public MessageSearchConfiguration(String label, String value) {
// this.label = label;
// this.value = value;
// }
//
// public String getLabel() {
// return label;
// }
//
// public void setLabel(String label) {
// this.label = label;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String[] getAvailableSystems() {
// return availableSystems;
// }
//
// public void setAvailableSystems(String[] availableSystems) {
// this.availableSystems = availableSystems;
// }
//
// }
//
// Path: api/src/main/java/org/esbtools/message/admin/model/MessageSearchConfigurations.java
// public class MessageSearchConfigurations {
// private List<MessageSearchConfiguration> searchSystems;
// private List<MessageSearchConfiguration> searchEntities;
// private List<MessageSearchConfiguration> searchFilters;
// private String searchSystemKey;
// private String searchEntityKey;
//
// public List<MessageSearchConfiguration> getSearchSystems() {
// return searchSystems;
// }
//
// public void setSearchSystems(List<MessageSearchConfiguration> searchSystems) {
// this.searchSystems = searchSystems;
// }
//
// public List<MessageSearchConfiguration> getSearchEntities() {
// return searchEntities;
// }
//
// public void setSearchEntities(List<MessageSearchConfiguration> searchEntities) {
// this.searchEntities = searchEntities;
// }
//
// public List<MessageSearchConfiguration> getSearchFilters() {
// return searchFilters;
// }
//
// public void setSearchFilters(List<MessageSearchConfiguration> searchFilters) {
// this.searchFilters = searchFilters;
// }
//
// public String getSearchSystemKey() {
// return searchSystemKey;
// }
//
// public void setSearchSystemKey(String searchSystemKey) {
// this.searchSystemKey = searchSystemKey;
// }
//
// public String getSearchEntityKey() {
// return searchEntityKey;
// }
//
// public void setSearchEntityKey(String searchEntityKey) {
// this.searchEntityKey = searchEntityKey;
// }
// }
| import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.esbtools.message.admin.model.MessageSearchConfiguration;
import org.esbtools.message.admin.model.MessageSearchConfigurations;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser; | package org.esbtools.message.admin.common.config;
public final class EMAConfiguration {
private static final String DEFAULT_ENCODING = "UTF-8";
private static JSONObject jsonConfig;
private static String encryptionKey;
private static Set<String> sortingFields;
private static Set<String> suggestedFields;
private static List<String> resyncRestEndpoints;
private static List<VisibilityConfiguration> nonViewableMessages;
private static List<VisibilityConfiguration> partiallyViewableMessages;
private static List<String> resubmitBlackList;
private static List<String> resubmitRestEndpoints;
private static String resubmitControlHeader;
private static String resubmitHeaderNamespace;
private static String caCertificate; | // Path: api/src/main/java/org/esbtools/message/admin/model/MessageSearchConfiguration.java
// public class MessageSearchConfiguration {
// /**
// * The display value for the configuration
// */
// private String label;
//
// /**
// * The value that will be passed to the controller from the frontend
// */
// private String value;
//
// /**
// * A list of systems that this configuration is applicable for. This will be null if
// * none exist
// */
// private String[] availableSystems;
//
// public MessageSearchConfiguration() {
// this.label = "";
// this.value = "";
// }
//
// public MessageSearchConfiguration(String label, String value) {
// this.label = label;
// this.value = value;
// }
//
// public String getLabel() {
// return label;
// }
//
// public void setLabel(String label) {
// this.label = label;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String[] getAvailableSystems() {
// return availableSystems;
// }
//
// public void setAvailableSystems(String[] availableSystems) {
// this.availableSystems = availableSystems;
// }
//
// }
//
// Path: api/src/main/java/org/esbtools/message/admin/model/MessageSearchConfigurations.java
// public class MessageSearchConfigurations {
// private List<MessageSearchConfiguration> searchSystems;
// private List<MessageSearchConfiguration> searchEntities;
// private List<MessageSearchConfiguration> searchFilters;
// private String searchSystemKey;
// private String searchEntityKey;
//
// public List<MessageSearchConfiguration> getSearchSystems() {
// return searchSystems;
// }
//
// public void setSearchSystems(List<MessageSearchConfiguration> searchSystems) {
// this.searchSystems = searchSystems;
// }
//
// public List<MessageSearchConfiguration> getSearchEntities() {
// return searchEntities;
// }
//
// public void setSearchEntities(List<MessageSearchConfiguration> searchEntities) {
// this.searchEntities = searchEntities;
// }
//
// public List<MessageSearchConfiguration> getSearchFilters() {
// return searchFilters;
// }
//
// public void setSearchFilters(List<MessageSearchConfiguration> searchFilters) {
// this.searchFilters = searchFilters;
// }
//
// public String getSearchSystemKey() {
// return searchSystemKey;
// }
//
// public void setSearchSystemKey(String searchSystemKey) {
// this.searchSystemKey = searchSystemKey;
// }
//
// public String getSearchEntityKey() {
// return searchEntityKey;
// }
//
// public void setSearchEntityKey(String searchEntityKey) {
// this.searchEntityKey = searchEntityKey;
// }
// }
// Path: common/src/main/java/org/esbtools/message/admin/common/config/EMAConfiguration.java
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.esbtools.message.admin.model.MessageSearchConfiguration;
import org.esbtools.message.admin.model.MessageSearchConfigurations;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
package org.esbtools.message.admin.common.config;
public final class EMAConfiguration {
private static final String DEFAULT_ENCODING = "UTF-8";
private static JSONObject jsonConfig;
private static String encryptionKey;
private static Set<String> sortingFields;
private static Set<String> suggestedFields;
private static List<String> resyncRestEndpoints;
private static List<VisibilityConfiguration> nonViewableMessages;
private static List<VisibilityConfiguration> partiallyViewableMessages;
private static List<String> resubmitBlackList;
private static List<String> resubmitRestEndpoints;
private static String resubmitControlHeader;
private static String resubmitHeaderNamespace;
private static String caCertificate; | private static MessageSearchConfigurations messageSearchConfigurations; |
esbtools/esb-message-admin | common/src/main/java/org/esbtools/message/admin/common/config/EMAConfiguration.java | // Path: api/src/main/java/org/esbtools/message/admin/model/MessageSearchConfiguration.java
// public class MessageSearchConfiguration {
// /**
// * The display value for the configuration
// */
// private String label;
//
// /**
// * The value that will be passed to the controller from the frontend
// */
// private String value;
//
// /**
// * A list of systems that this configuration is applicable for. This will be null if
// * none exist
// */
// private String[] availableSystems;
//
// public MessageSearchConfiguration() {
// this.label = "";
// this.value = "";
// }
//
// public MessageSearchConfiguration(String label, String value) {
// this.label = label;
// this.value = value;
// }
//
// public String getLabel() {
// return label;
// }
//
// public void setLabel(String label) {
// this.label = label;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String[] getAvailableSystems() {
// return availableSystems;
// }
//
// public void setAvailableSystems(String[] availableSystems) {
// this.availableSystems = availableSystems;
// }
//
// }
//
// Path: api/src/main/java/org/esbtools/message/admin/model/MessageSearchConfigurations.java
// public class MessageSearchConfigurations {
// private List<MessageSearchConfiguration> searchSystems;
// private List<MessageSearchConfiguration> searchEntities;
// private List<MessageSearchConfiguration> searchFilters;
// private String searchSystemKey;
// private String searchEntityKey;
//
// public List<MessageSearchConfiguration> getSearchSystems() {
// return searchSystems;
// }
//
// public void setSearchSystems(List<MessageSearchConfiguration> searchSystems) {
// this.searchSystems = searchSystems;
// }
//
// public List<MessageSearchConfiguration> getSearchEntities() {
// return searchEntities;
// }
//
// public void setSearchEntities(List<MessageSearchConfiguration> searchEntities) {
// this.searchEntities = searchEntities;
// }
//
// public List<MessageSearchConfiguration> getSearchFilters() {
// return searchFilters;
// }
//
// public void setSearchFilters(List<MessageSearchConfiguration> searchFilters) {
// this.searchFilters = searchFilters;
// }
//
// public String getSearchSystemKey() {
// return searchSystemKey;
// }
//
// public void setSearchSystemKey(String searchSystemKey) {
// this.searchSystemKey = searchSystemKey;
// }
//
// public String getSearchEntityKey() {
// return searchEntityKey;
// }
//
// public void setSearchEntityKey(String searchEntityKey) {
// this.searchEntityKey = searchEntityKey;
// }
// }
| import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.esbtools.message.admin.model.MessageSearchConfiguration;
import org.esbtools.message.admin.model.MessageSearchConfigurations;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser; | return resubmitBlackList;
}
private static List<String> loadResubmitRestEndpoints() {
List<String> resubmitRestEndpoints = new ArrayList<>();
JSONArray endpoints = (JSONArray) getJsonConfig().get("resubmitRestEndpoints");
if(endpoints!=null) {
for(Object endpoint: endpoints) {
resubmitRestEndpoints.add( endpoint.toString() ); // this will make comparison more sane
}
}
return resubmitRestEndpoints;
}
private static String loadResubmitControlHeader() {
return (String) getJsonConfig().get("resubmitControlHeader");
}
private static String loadResubmitHeaderNamespace() {
return (String) getJsonConfig().get("resubmitHeaderNamespace");
}
private static String loadCaCertificate() {
return (String) getJsonConfig().get("caCertificate");
}
private static String loadSearchSystemKey() {
return (String) getJsonConfig().get("messageSearchSystemKey");
}
| // Path: api/src/main/java/org/esbtools/message/admin/model/MessageSearchConfiguration.java
// public class MessageSearchConfiguration {
// /**
// * The display value for the configuration
// */
// private String label;
//
// /**
// * The value that will be passed to the controller from the frontend
// */
// private String value;
//
// /**
// * A list of systems that this configuration is applicable for. This will be null if
// * none exist
// */
// private String[] availableSystems;
//
// public MessageSearchConfiguration() {
// this.label = "";
// this.value = "";
// }
//
// public MessageSearchConfiguration(String label, String value) {
// this.label = label;
// this.value = value;
// }
//
// public String getLabel() {
// return label;
// }
//
// public void setLabel(String label) {
// this.label = label;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String[] getAvailableSystems() {
// return availableSystems;
// }
//
// public void setAvailableSystems(String[] availableSystems) {
// this.availableSystems = availableSystems;
// }
//
// }
//
// Path: api/src/main/java/org/esbtools/message/admin/model/MessageSearchConfigurations.java
// public class MessageSearchConfigurations {
// private List<MessageSearchConfiguration> searchSystems;
// private List<MessageSearchConfiguration> searchEntities;
// private List<MessageSearchConfiguration> searchFilters;
// private String searchSystemKey;
// private String searchEntityKey;
//
// public List<MessageSearchConfiguration> getSearchSystems() {
// return searchSystems;
// }
//
// public void setSearchSystems(List<MessageSearchConfiguration> searchSystems) {
// this.searchSystems = searchSystems;
// }
//
// public List<MessageSearchConfiguration> getSearchEntities() {
// return searchEntities;
// }
//
// public void setSearchEntities(List<MessageSearchConfiguration> searchEntities) {
// this.searchEntities = searchEntities;
// }
//
// public List<MessageSearchConfiguration> getSearchFilters() {
// return searchFilters;
// }
//
// public void setSearchFilters(List<MessageSearchConfiguration> searchFilters) {
// this.searchFilters = searchFilters;
// }
//
// public String getSearchSystemKey() {
// return searchSystemKey;
// }
//
// public void setSearchSystemKey(String searchSystemKey) {
// this.searchSystemKey = searchSystemKey;
// }
//
// public String getSearchEntityKey() {
// return searchEntityKey;
// }
//
// public void setSearchEntityKey(String searchEntityKey) {
// this.searchEntityKey = searchEntityKey;
// }
// }
// Path: common/src/main/java/org/esbtools/message/admin/common/config/EMAConfiguration.java
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.esbtools.message.admin.model.MessageSearchConfiguration;
import org.esbtools.message.admin.model.MessageSearchConfigurations;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
return resubmitBlackList;
}
private static List<String> loadResubmitRestEndpoints() {
List<String> resubmitRestEndpoints = new ArrayList<>();
JSONArray endpoints = (JSONArray) getJsonConfig().get("resubmitRestEndpoints");
if(endpoints!=null) {
for(Object endpoint: endpoints) {
resubmitRestEndpoints.add( endpoint.toString() ); // this will make comparison more sane
}
}
return resubmitRestEndpoints;
}
private static String loadResubmitControlHeader() {
return (String) getJsonConfig().get("resubmitControlHeader");
}
private static String loadResubmitHeaderNamespace() {
return (String) getJsonConfig().get("resubmitHeaderNamespace");
}
private static String loadCaCertificate() {
return (String) getJsonConfig().get("caCertificate");
}
private static String loadSearchSystemKey() {
return (String) getJsonConfig().get("messageSearchSystemKey");
}
| private static List<MessageSearchConfiguration> loadSearchSystems() { |
esbtools/esb-message-admin | common/src/test/java/org/esbtools/message/admin/common/EncryptionUtilityTest.java | // Path: common/src/main/java/org/esbtools/message/admin/common/utility/EncryptionUtility.java
// public class EncryptionUtility {
//
// private static final Logger LOGGER=LoggerFactory.getLogger(EncryptionUtility.class);
// private static final String ALGORITHM = "AES/ECB/PKCS5Padding";
// private static final String FILE_ENCODING = "UTF-8";
// public static final String SECURITY_PROVIDER = "SunJCE";
// private final String encryptionKey;
//
// public EncryptionUtility(String key) {
// this.encryptionKey = key;
// }
//
// public String encrypt(String sensitiveInfo) {
// try {
// Cipher cipher = Cipher.getInstance(ALGORITHM, SECURITY_PROVIDER);
// SecretKeySpec key = new SecretKeySpec(encryptionKey.getBytes(FILE_ENCODING), "AES");
// cipher.init(Cipher.ENCRYPT_MODE, key);
// return Base64.encodeBase64String(cipher.doFinal(sensitiveInfo.getBytes(FILE_ENCODING)));
// } catch(NoSuchAlgorithmException | NoSuchProviderException | NoSuchPaddingException
// | UnsupportedEncodingException | InvalidKeyException | IllegalBlockSizeException
// | BadPaddingException e) {
// LOGGER.error("EMA Encryption error!", e);
// return null;
// }
// }
//
// public String decrypt(String encryptedInfo) {
// try {
// Cipher cipher = Cipher.getInstance(ALGORITHM, SECURITY_PROVIDER);
// SecretKeySpec key = new SecretKeySpec(encryptionKey.getBytes(FILE_ENCODING), "AES");
// cipher.init(Cipher.DECRYPT_MODE, key);
// return new String(cipher.doFinal(Base64.decodeBase64(encryptedInfo.getBytes(FILE_ENCODING))), FILE_ENCODING).trim();
// } catch(NoSuchAlgorithmException | NoSuchProviderException | NoSuchPaddingException
// | UnsupportedEncodingException | InvalidKeyException | IllegalBlockSizeException
// | BadPaddingException e) {
// LOGGER.error("EMA Decryption error!", e);
// return null;
// }
// }
//
// }
| import org.esbtools.message.admin.common.utility.EncryptionUtility;
import org.junit.Assert;
import org.junit.Test; | /*
Copyright 2015 esbtools Contributors and/or its affiliates.
This file is part of esbtools.
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 org.esbtools.message.admin.common;
/**
* Unit test to demonstrate using the KeyExtractor Util
*
* @author ykoer
*/
public class EncryptionUtilityTest {
@Test
public void testEncrypter() { | // Path: common/src/main/java/org/esbtools/message/admin/common/utility/EncryptionUtility.java
// public class EncryptionUtility {
//
// private static final Logger LOGGER=LoggerFactory.getLogger(EncryptionUtility.class);
// private static final String ALGORITHM = "AES/ECB/PKCS5Padding";
// private static final String FILE_ENCODING = "UTF-8";
// public static final String SECURITY_PROVIDER = "SunJCE";
// private final String encryptionKey;
//
// public EncryptionUtility(String key) {
// this.encryptionKey = key;
// }
//
// public String encrypt(String sensitiveInfo) {
// try {
// Cipher cipher = Cipher.getInstance(ALGORITHM, SECURITY_PROVIDER);
// SecretKeySpec key = new SecretKeySpec(encryptionKey.getBytes(FILE_ENCODING), "AES");
// cipher.init(Cipher.ENCRYPT_MODE, key);
// return Base64.encodeBase64String(cipher.doFinal(sensitiveInfo.getBytes(FILE_ENCODING)));
// } catch(NoSuchAlgorithmException | NoSuchProviderException | NoSuchPaddingException
// | UnsupportedEncodingException | InvalidKeyException | IllegalBlockSizeException
// | BadPaddingException e) {
// LOGGER.error("EMA Encryption error!", e);
// return null;
// }
// }
//
// public String decrypt(String encryptedInfo) {
// try {
// Cipher cipher = Cipher.getInstance(ALGORITHM, SECURITY_PROVIDER);
// SecretKeySpec key = new SecretKeySpec(encryptionKey.getBytes(FILE_ENCODING), "AES");
// cipher.init(Cipher.DECRYPT_MODE, key);
// return new String(cipher.doFinal(Base64.decodeBase64(encryptedInfo.getBytes(FILE_ENCODING))), FILE_ENCODING).trim();
// } catch(NoSuchAlgorithmException | NoSuchProviderException | NoSuchPaddingException
// | UnsupportedEncodingException | InvalidKeyException | IllegalBlockSizeException
// | BadPaddingException e) {
// LOGGER.error("EMA Decryption error!", e);
// return null;
// }
// }
//
// }
// Path: common/src/test/java/org/esbtools/message/admin/common/EncryptionUtilityTest.java
import org.esbtools.message.admin.common.utility.EncryptionUtility;
import org.junit.Assert;
import org.junit.Test;
/*
Copyright 2015 esbtools Contributors and/or its affiliates.
This file is part of esbtools.
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 org.esbtools.message.admin.common;
/**
* Unit test to demonstrate using the KeyExtractor Util
*
* @author ykoer
*/
public class EncryptionUtilityTest {
@Test
public void testEncrypter() { | EncryptionUtility util = new EncryptionUtility("myPassisBIG12345"); |
esbtools/esb-message-admin | common/src/main/java/org/esbtools/message/admin/common/orm/MetadataEntity.java | // Path: api/src/main/java/org/esbtools/message/admin/model/MetadataType.java
// public enum MetadataType {
// Entities, Entity, System, SyncKey, SearchKeys, SearchKey, XPATH, Suggestion;
//
// public boolean isSearchKeyType() {
// return this==SearchKeys || this==SearchKey || this==XPATH || this==Suggestion;
// }
//
// public boolean isSyncKeyType() {
// return !isSearchKeyType();
// }
// }
| import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.esbtools.message.admin.model.MetadataType; | /*
Copyright 2015 esbtools Contributors and/or its affiliates.
This file is part of esbtools.
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 org.esbtools.message.admin.common.orm;
@Entity
@Table(name = "METADATA")
public class MetadataEntity implements Serializable {
private static final long serialVersionUID = 357984147079041238L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@Column(name="type")
@Enumerated(EnumType.STRING) | // Path: api/src/main/java/org/esbtools/message/admin/model/MetadataType.java
// public enum MetadataType {
// Entities, Entity, System, SyncKey, SearchKeys, SearchKey, XPATH, Suggestion;
//
// public boolean isSearchKeyType() {
// return this==SearchKeys || this==SearchKey || this==XPATH || this==Suggestion;
// }
//
// public boolean isSyncKeyType() {
// return !isSearchKeyType();
// }
// }
// Path: common/src/main/java/org/esbtools/message/admin/common/orm/MetadataEntity.java
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.esbtools.message.admin.model.MetadataType;
/*
Copyright 2015 esbtools Contributors and/or its affiliates.
This file is part of esbtools.
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 org.esbtools.message.admin.common.orm;
@Entity
@Table(name = "METADATA")
public class MetadataEntity implements Serializable {
private static final long serialVersionUID = 357984147079041238L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@Column(name="type")
@Enumerated(EnumType.STRING) | private MetadataType type; |
esbtools/esb-message-admin | common/src/main/java/org/esbtools/message/admin/common/orm/EsbMessageEntity.java | // Path: api/src/main/java/org/esbtools/message/admin/model/EsbMessage.java
// public enum ErrorType {
// DATA_ERROR, SYSTEM_ERROR
// }
| import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.esbtools.message.admin.model.EsbMessage.ErrorType;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; |
@Column(name = "message_type")
private String messageType;
@Column(name="source_queue")
private String sourceQueue;
@Column(name="source_location")
private String sourceLocation;
@Column(name="source_system")
private String sourceSystem;
@Column(name="service_name")
private String serviceName;
@Column(name="error_component")
private String errorComponent;
@Column(name="error_message")
private String errorMessage;
@Column(name="error_details")
private String errorDetails;
@Column(name = "error_system")
private String errorSystem;
@Enumerated(EnumType.STRING)
@Column(name = "error_type") | // Path: api/src/main/java/org/esbtools/message/admin/model/EsbMessage.java
// public enum ErrorType {
// DATA_ERROR, SYSTEM_ERROR
// }
// Path: common/src/main/java/org/esbtools/message/admin/common/orm/EsbMessageEntity.java
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.esbtools.message.admin.model.EsbMessage.ErrorType;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
@Column(name = "message_type")
private String messageType;
@Column(name="source_queue")
private String sourceQueue;
@Column(name="source_location")
private String sourceLocation;
@Column(name="source_system")
private String sourceSystem;
@Column(name="service_name")
private String serviceName;
@Column(name="error_component")
private String errorComponent;
@Column(name="error_message")
private String errorMessage;
@Column(name="error_details")
private String errorDetails;
@Column(name = "error_system")
private String errorSystem;
@Enumerated(EnumType.STRING)
@Column(name = "error_type") | private ErrorType errorType; |
esbtools/esb-message-admin | app/src/main/java/org/esbtools/message/admin/rest/ConfigResourceBean.java | // Path: api/src/main/java/org/esbtools/message/admin/EsbMessageAdminService.java
// public interface EsbMessageAdminService {
//
// /**
// * Persists a single ESB Message
// *
// * @param esbMessage an ESB Message
// * @throws IOException
// */
// void persist(EsbMessage esbMessage) throws IOException;
//
// /**
// * Persists multiple ESB MessagesA
// *
// * @param esbMessages array of ESB Messages
// * @throws IOException
// */
// void persist(EsbMessage[] esbMessages) throws IOException;
//
// /**
// * Updates a given ESB Message ( Payload only )
// *
// * @param messageId - a message Id
// * @param messageBody - the message body
// * @throws IOException
// */
// MetadataResponse resubmit(Long messageId, String messageBody);
//
// /**
// * @param criteria search
// * @param fromDate the start timestamp of the range
// * @param toDate the end timestamp of the range
// * @param start sets the position of the first result to retrieve
// * @param maxResults sets the maximum number of results to retrieve
// * @return SearchResult results matching the search criteria
// */
// SearchResult searchMessagesByCriteria(SearchCriteria criteria, Date fromDate, Date toDate, String sortField, boolean sortAsc, int start, int maxResults);
//
// /**
// * Returns details for a specific message
// *
// * @param id the id of the message to retrieve
// * @return SearchResult the resulting message
// */
// SearchResult getMessageById(Long id);
//
// /**
// * Suggests search key and value suggestions
// *
// * @return all key and value suggestions
// */
// Map<String, List<String>> getSearchKeyValueSuggestions();
//
// /**
// * @param type specific tree type to return, possible values:
// * [Entities,KeyGroups]
// * @return MetadataResponse the entire keys tree
// */
// MetadataResponse getMetadataTree(MetadataType type);
//
// /**
// * @param parentId the id of the MetadataField to add a child to
// * @param name the name of the child
// * @param type the type of the child
// * @param value the value of the child
// * @return MetadataResponse the entire MetadataField tree and the parent field
// */
// MetadataResponse addChildMetadataField(Long parentId, String name, MetadataType type, String value);
//
// /**
// * @param id the id of the MetadataField to update
// * @param name the name of the field
// * @param type the type of the field
// * @param value the value of the field
// * @return MetadataResponse the entire MetadataField tree and the parent field
// */
// MetadataResponse updateMetadataField(Long id, String name, MetadataType type, String value);
//
// /**
// * @param id the id of the MetadataField to delete
// * @return MetadataResponse the entire MetadataField tree and the parent field
// */
// MetadataResponse deleteMetadataField(Long id);
//
// /**
// * @param entity the entity to sync
// * @param system the system to sync from
// * @param key the key name using which to sync
// * @param values the values of the key
// */
// MetadataResponse sync(String entity, String system, String key, String... values);
//
// /**
// * Fetches configurations used for searching messages from the configuration store
// *
// * @return MessageSearchConfigurations an object containing all pertinent configurations
// */
// MessageSearchConfigurations getSearchConfigurations();
// }
//
// Path: api/src/main/java/org/esbtools/message/admin/model/MessageSearchConfigurations.java
// public class MessageSearchConfigurations {
// private List<MessageSearchConfiguration> searchSystems;
// private List<MessageSearchConfiguration> searchEntities;
// private List<MessageSearchConfiguration> searchFilters;
// private String searchSystemKey;
// private String searchEntityKey;
//
// public List<MessageSearchConfiguration> getSearchSystems() {
// return searchSystems;
// }
//
// public void setSearchSystems(List<MessageSearchConfiguration> searchSystems) {
// this.searchSystems = searchSystems;
// }
//
// public List<MessageSearchConfiguration> getSearchEntities() {
// return searchEntities;
// }
//
// public void setSearchEntities(List<MessageSearchConfiguration> searchEntities) {
// this.searchEntities = searchEntities;
// }
//
// public List<MessageSearchConfiguration> getSearchFilters() {
// return searchFilters;
// }
//
// public void setSearchFilters(List<MessageSearchConfiguration> searchFilters) {
// this.searchFilters = searchFilters;
// }
//
// public String getSearchSystemKey() {
// return searchSystemKey;
// }
//
// public void setSearchSystemKey(String searchSystemKey) {
// this.searchSystemKey = searchSystemKey;
// }
//
// public String getSearchEntityKey() {
// return searchEntityKey;
// }
//
// public void setSearchEntityKey(String searchEntityKey) {
// this.searchEntityKey = searchEntityKey;
// }
// }
| import org.esbtools.message.admin.EsbMessageAdminService;
import org.esbtools.message.admin.model.MessageSearchConfigurations;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ejb.Stateless;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; | package org.esbtools.message.admin.rest;
@Path("/config")
@Stateless
public class ConfigResourceBean {
@Inject | // Path: api/src/main/java/org/esbtools/message/admin/EsbMessageAdminService.java
// public interface EsbMessageAdminService {
//
// /**
// * Persists a single ESB Message
// *
// * @param esbMessage an ESB Message
// * @throws IOException
// */
// void persist(EsbMessage esbMessage) throws IOException;
//
// /**
// * Persists multiple ESB MessagesA
// *
// * @param esbMessages array of ESB Messages
// * @throws IOException
// */
// void persist(EsbMessage[] esbMessages) throws IOException;
//
// /**
// * Updates a given ESB Message ( Payload only )
// *
// * @param messageId - a message Id
// * @param messageBody - the message body
// * @throws IOException
// */
// MetadataResponse resubmit(Long messageId, String messageBody);
//
// /**
// * @param criteria search
// * @param fromDate the start timestamp of the range
// * @param toDate the end timestamp of the range
// * @param start sets the position of the first result to retrieve
// * @param maxResults sets the maximum number of results to retrieve
// * @return SearchResult results matching the search criteria
// */
// SearchResult searchMessagesByCriteria(SearchCriteria criteria, Date fromDate, Date toDate, String sortField, boolean sortAsc, int start, int maxResults);
//
// /**
// * Returns details for a specific message
// *
// * @param id the id of the message to retrieve
// * @return SearchResult the resulting message
// */
// SearchResult getMessageById(Long id);
//
// /**
// * Suggests search key and value suggestions
// *
// * @return all key and value suggestions
// */
// Map<String, List<String>> getSearchKeyValueSuggestions();
//
// /**
// * @param type specific tree type to return, possible values:
// * [Entities,KeyGroups]
// * @return MetadataResponse the entire keys tree
// */
// MetadataResponse getMetadataTree(MetadataType type);
//
// /**
// * @param parentId the id of the MetadataField to add a child to
// * @param name the name of the child
// * @param type the type of the child
// * @param value the value of the child
// * @return MetadataResponse the entire MetadataField tree and the parent field
// */
// MetadataResponse addChildMetadataField(Long parentId, String name, MetadataType type, String value);
//
// /**
// * @param id the id of the MetadataField to update
// * @param name the name of the field
// * @param type the type of the field
// * @param value the value of the field
// * @return MetadataResponse the entire MetadataField tree and the parent field
// */
// MetadataResponse updateMetadataField(Long id, String name, MetadataType type, String value);
//
// /**
// * @param id the id of the MetadataField to delete
// * @return MetadataResponse the entire MetadataField tree and the parent field
// */
// MetadataResponse deleteMetadataField(Long id);
//
// /**
// * @param entity the entity to sync
// * @param system the system to sync from
// * @param key the key name using which to sync
// * @param values the values of the key
// */
// MetadataResponse sync(String entity, String system, String key, String... values);
//
// /**
// * Fetches configurations used for searching messages from the configuration store
// *
// * @return MessageSearchConfigurations an object containing all pertinent configurations
// */
// MessageSearchConfigurations getSearchConfigurations();
// }
//
// Path: api/src/main/java/org/esbtools/message/admin/model/MessageSearchConfigurations.java
// public class MessageSearchConfigurations {
// private List<MessageSearchConfiguration> searchSystems;
// private List<MessageSearchConfiguration> searchEntities;
// private List<MessageSearchConfiguration> searchFilters;
// private String searchSystemKey;
// private String searchEntityKey;
//
// public List<MessageSearchConfiguration> getSearchSystems() {
// return searchSystems;
// }
//
// public void setSearchSystems(List<MessageSearchConfiguration> searchSystems) {
// this.searchSystems = searchSystems;
// }
//
// public List<MessageSearchConfiguration> getSearchEntities() {
// return searchEntities;
// }
//
// public void setSearchEntities(List<MessageSearchConfiguration> searchEntities) {
// this.searchEntities = searchEntities;
// }
//
// public List<MessageSearchConfiguration> getSearchFilters() {
// return searchFilters;
// }
//
// public void setSearchFilters(List<MessageSearchConfiguration> searchFilters) {
// this.searchFilters = searchFilters;
// }
//
// public String getSearchSystemKey() {
// return searchSystemKey;
// }
//
// public void setSearchSystemKey(String searchSystemKey) {
// this.searchSystemKey = searchSystemKey;
// }
//
// public String getSearchEntityKey() {
// return searchEntityKey;
// }
//
// public void setSearchEntityKey(String searchEntityKey) {
// this.searchEntityKey = searchEntityKey;
// }
// }
// Path: app/src/main/java/org/esbtools/message/admin/rest/ConfigResourceBean.java
import org.esbtools.message.admin.EsbMessageAdminService;
import org.esbtools.message.admin.model.MessageSearchConfigurations;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ejb.Stateless;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
package org.esbtools.message.admin.rest;
@Path("/config")
@Stateless
public class ConfigResourceBean {
@Inject | private Instance<EsbMessageAdminService> client; |
esbtools/esb-message-admin | app/src/main/java/org/esbtools/message/admin/rest/ConfigResourceBean.java | // Path: api/src/main/java/org/esbtools/message/admin/EsbMessageAdminService.java
// public interface EsbMessageAdminService {
//
// /**
// * Persists a single ESB Message
// *
// * @param esbMessage an ESB Message
// * @throws IOException
// */
// void persist(EsbMessage esbMessage) throws IOException;
//
// /**
// * Persists multiple ESB MessagesA
// *
// * @param esbMessages array of ESB Messages
// * @throws IOException
// */
// void persist(EsbMessage[] esbMessages) throws IOException;
//
// /**
// * Updates a given ESB Message ( Payload only )
// *
// * @param messageId - a message Id
// * @param messageBody - the message body
// * @throws IOException
// */
// MetadataResponse resubmit(Long messageId, String messageBody);
//
// /**
// * @param criteria search
// * @param fromDate the start timestamp of the range
// * @param toDate the end timestamp of the range
// * @param start sets the position of the first result to retrieve
// * @param maxResults sets the maximum number of results to retrieve
// * @return SearchResult results matching the search criteria
// */
// SearchResult searchMessagesByCriteria(SearchCriteria criteria, Date fromDate, Date toDate, String sortField, boolean sortAsc, int start, int maxResults);
//
// /**
// * Returns details for a specific message
// *
// * @param id the id of the message to retrieve
// * @return SearchResult the resulting message
// */
// SearchResult getMessageById(Long id);
//
// /**
// * Suggests search key and value suggestions
// *
// * @return all key and value suggestions
// */
// Map<String, List<String>> getSearchKeyValueSuggestions();
//
// /**
// * @param type specific tree type to return, possible values:
// * [Entities,KeyGroups]
// * @return MetadataResponse the entire keys tree
// */
// MetadataResponse getMetadataTree(MetadataType type);
//
// /**
// * @param parentId the id of the MetadataField to add a child to
// * @param name the name of the child
// * @param type the type of the child
// * @param value the value of the child
// * @return MetadataResponse the entire MetadataField tree and the parent field
// */
// MetadataResponse addChildMetadataField(Long parentId, String name, MetadataType type, String value);
//
// /**
// * @param id the id of the MetadataField to update
// * @param name the name of the field
// * @param type the type of the field
// * @param value the value of the field
// * @return MetadataResponse the entire MetadataField tree and the parent field
// */
// MetadataResponse updateMetadataField(Long id, String name, MetadataType type, String value);
//
// /**
// * @param id the id of the MetadataField to delete
// * @return MetadataResponse the entire MetadataField tree and the parent field
// */
// MetadataResponse deleteMetadataField(Long id);
//
// /**
// * @param entity the entity to sync
// * @param system the system to sync from
// * @param key the key name using which to sync
// * @param values the values of the key
// */
// MetadataResponse sync(String entity, String system, String key, String... values);
//
// /**
// * Fetches configurations used for searching messages from the configuration store
// *
// * @return MessageSearchConfigurations an object containing all pertinent configurations
// */
// MessageSearchConfigurations getSearchConfigurations();
// }
//
// Path: api/src/main/java/org/esbtools/message/admin/model/MessageSearchConfigurations.java
// public class MessageSearchConfigurations {
// private List<MessageSearchConfiguration> searchSystems;
// private List<MessageSearchConfiguration> searchEntities;
// private List<MessageSearchConfiguration> searchFilters;
// private String searchSystemKey;
// private String searchEntityKey;
//
// public List<MessageSearchConfiguration> getSearchSystems() {
// return searchSystems;
// }
//
// public void setSearchSystems(List<MessageSearchConfiguration> searchSystems) {
// this.searchSystems = searchSystems;
// }
//
// public List<MessageSearchConfiguration> getSearchEntities() {
// return searchEntities;
// }
//
// public void setSearchEntities(List<MessageSearchConfiguration> searchEntities) {
// this.searchEntities = searchEntities;
// }
//
// public List<MessageSearchConfiguration> getSearchFilters() {
// return searchFilters;
// }
//
// public void setSearchFilters(List<MessageSearchConfiguration> searchFilters) {
// this.searchFilters = searchFilters;
// }
//
// public String getSearchSystemKey() {
// return searchSystemKey;
// }
//
// public void setSearchSystemKey(String searchSystemKey) {
// this.searchSystemKey = searchSystemKey;
// }
//
// public String getSearchEntityKey() {
// return searchEntityKey;
// }
//
// public void setSearchEntityKey(String searchEntityKey) {
// this.searchEntityKey = searchEntityKey;
// }
// }
| import org.esbtools.message.admin.EsbMessageAdminService;
import org.esbtools.message.admin.model.MessageSearchConfigurations;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ejb.Stateless;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; | package org.esbtools.message.admin.rest;
@Path("/config")
@Stateless
public class ConfigResourceBean {
@Inject
private Instance<EsbMessageAdminService> client;
/**
* Fetches configurations for searching messages
*
* @return MessageSearchConfigurations an object containing all
* configurations for searching messages
*/
@GET
@Path("/messageSearch")
@Produces({MediaType.APPLICATION_JSON}) | // Path: api/src/main/java/org/esbtools/message/admin/EsbMessageAdminService.java
// public interface EsbMessageAdminService {
//
// /**
// * Persists a single ESB Message
// *
// * @param esbMessage an ESB Message
// * @throws IOException
// */
// void persist(EsbMessage esbMessage) throws IOException;
//
// /**
// * Persists multiple ESB MessagesA
// *
// * @param esbMessages array of ESB Messages
// * @throws IOException
// */
// void persist(EsbMessage[] esbMessages) throws IOException;
//
// /**
// * Updates a given ESB Message ( Payload only )
// *
// * @param messageId - a message Id
// * @param messageBody - the message body
// * @throws IOException
// */
// MetadataResponse resubmit(Long messageId, String messageBody);
//
// /**
// * @param criteria search
// * @param fromDate the start timestamp of the range
// * @param toDate the end timestamp of the range
// * @param start sets the position of the first result to retrieve
// * @param maxResults sets the maximum number of results to retrieve
// * @return SearchResult results matching the search criteria
// */
// SearchResult searchMessagesByCriteria(SearchCriteria criteria, Date fromDate, Date toDate, String sortField, boolean sortAsc, int start, int maxResults);
//
// /**
// * Returns details for a specific message
// *
// * @param id the id of the message to retrieve
// * @return SearchResult the resulting message
// */
// SearchResult getMessageById(Long id);
//
// /**
// * Suggests search key and value suggestions
// *
// * @return all key and value suggestions
// */
// Map<String, List<String>> getSearchKeyValueSuggestions();
//
// /**
// * @param type specific tree type to return, possible values:
// * [Entities,KeyGroups]
// * @return MetadataResponse the entire keys tree
// */
// MetadataResponse getMetadataTree(MetadataType type);
//
// /**
// * @param parentId the id of the MetadataField to add a child to
// * @param name the name of the child
// * @param type the type of the child
// * @param value the value of the child
// * @return MetadataResponse the entire MetadataField tree and the parent field
// */
// MetadataResponse addChildMetadataField(Long parentId, String name, MetadataType type, String value);
//
// /**
// * @param id the id of the MetadataField to update
// * @param name the name of the field
// * @param type the type of the field
// * @param value the value of the field
// * @return MetadataResponse the entire MetadataField tree and the parent field
// */
// MetadataResponse updateMetadataField(Long id, String name, MetadataType type, String value);
//
// /**
// * @param id the id of the MetadataField to delete
// * @return MetadataResponse the entire MetadataField tree and the parent field
// */
// MetadataResponse deleteMetadataField(Long id);
//
// /**
// * @param entity the entity to sync
// * @param system the system to sync from
// * @param key the key name using which to sync
// * @param values the values of the key
// */
// MetadataResponse sync(String entity, String system, String key, String... values);
//
// /**
// * Fetches configurations used for searching messages from the configuration store
// *
// * @return MessageSearchConfigurations an object containing all pertinent configurations
// */
// MessageSearchConfigurations getSearchConfigurations();
// }
//
// Path: api/src/main/java/org/esbtools/message/admin/model/MessageSearchConfigurations.java
// public class MessageSearchConfigurations {
// private List<MessageSearchConfiguration> searchSystems;
// private List<MessageSearchConfiguration> searchEntities;
// private List<MessageSearchConfiguration> searchFilters;
// private String searchSystemKey;
// private String searchEntityKey;
//
// public List<MessageSearchConfiguration> getSearchSystems() {
// return searchSystems;
// }
//
// public void setSearchSystems(List<MessageSearchConfiguration> searchSystems) {
// this.searchSystems = searchSystems;
// }
//
// public List<MessageSearchConfiguration> getSearchEntities() {
// return searchEntities;
// }
//
// public void setSearchEntities(List<MessageSearchConfiguration> searchEntities) {
// this.searchEntities = searchEntities;
// }
//
// public List<MessageSearchConfiguration> getSearchFilters() {
// return searchFilters;
// }
//
// public void setSearchFilters(List<MessageSearchConfiguration> searchFilters) {
// this.searchFilters = searchFilters;
// }
//
// public String getSearchSystemKey() {
// return searchSystemKey;
// }
//
// public void setSearchSystemKey(String searchSystemKey) {
// this.searchSystemKey = searchSystemKey;
// }
//
// public String getSearchEntityKey() {
// return searchEntityKey;
// }
//
// public void setSearchEntityKey(String searchEntityKey) {
// this.searchEntityKey = searchEntityKey;
// }
// }
// Path: app/src/main/java/org/esbtools/message/admin/rest/ConfigResourceBean.java
import org.esbtools.message.admin.EsbMessageAdminService;
import org.esbtools.message.admin.model.MessageSearchConfigurations;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ejb.Stateless;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
package org.esbtools.message.admin.rest;
@Path("/config")
@Stateless
public class ConfigResourceBean {
@Inject
private Instance<EsbMessageAdminService> client;
/**
* Fetches configurations for searching messages
*
* @return MessageSearchConfigurations an object containing all
* configurations for searching messages
*/
@GET
@Path("/messageSearch")
@Produces({MediaType.APPLICATION_JSON}) | public MessageSearchConfigurations getMessageSearchConfigurations() { |
esbtools/esb-message-admin | common/src/main/java/org/esbtools/message/admin/common/extractor/KeyExtractorUtil.java | // Path: api/src/main/java/org/esbtools/message/admin/model/MetadataType.java
// public enum MetadataType {
// Entities, Entity, System, SyncKey, SearchKeys, SearchKey, XPATH, Suggestion;
//
// public boolean isSearchKeyType() {
// return this==SearchKeys || this==SearchKey || this==XPATH || this==Suggestion;
// }
//
// public boolean isSyncKeyType() {
// return !isSearchKeyType();
// }
// }
| import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.esbtools.message.admin.model.MetadataField;
import org.esbtools.message.admin.model.MetadataType;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException; | /*
Copyright 2015 esbtools Contributors and/or its affiliates.
This file is part of esbtools.
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 org.esbtools.message.admin.common.extractor;
/**
* The KeyExtractor is a xpath based ValueExtractor implementation.
* It evaluates a list of xpath operations against the given payload
* and puts the value along with the name into map.
* The purpose is to enrich the payload with additional metadata so users
* can search by them.
*
* @author vrjain
* @author ykoer
*
*/
public class KeyExtractorUtil {
private static final Logger LOGGER=LoggerFactory.getLogger(KeyExtractorUtil.class);
private String hash;
private Map<String, List<XPathExpression>> expressions;
public KeyExtractorUtil(List<MetadataField> searchKeys, String argHash) {
expressions = new HashMap<>();
hash = argHash;
XPath xpath = XPathFactory.newInstance().newXPath();
for (MetadataField searchKey : searchKeys) {
for (MetadataField path : searchKey.getChildren()) { | // Path: api/src/main/java/org/esbtools/message/admin/model/MetadataType.java
// public enum MetadataType {
// Entities, Entity, System, SyncKey, SearchKeys, SearchKey, XPATH, Suggestion;
//
// public boolean isSearchKeyType() {
// return this==SearchKeys || this==SearchKey || this==XPATH || this==Suggestion;
// }
//
// public boolean isSyncKeyType() {
// return !isSearchKeyType();
// }
// }
// Path: common/src/main/java/org/esbtools/message/admin/common/extractor/KeyExtractorUtil.java
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.esbtools.message.admin.model.MetadataField;
import org.esbtools.message.admin.model.MetadataType;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/*
Copyright 2015 esbtools Contributors and/or its affiliates.
This file is part of esbtools.
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 org.esbtools.message.admin.common.extractor;
/**
* The KeyExtractor is a xpath based ValueExtractor implementation.
* It evaluates a list of xpath operations against the given payload
* and puts the value along with the name into map.
* The purpose is to enrich the payload with additional metadata so users
* can search by them.
*
* @author vrjain
* @author ykoer
*
*/
public class KeyExtractorUtil {
private static final Logger LOGGER=LoggerFactory.getLogger(KeyExtractorUtil.class);
private String hash;
private Map<String, List<XPathExpression>> expressions;
public KeyExtractorUtil(List<MetadataField> searchKeys, String argHash) {
expressions = new HashMap<>();
hash = argHash;
XPath xpath = XPathFactory.newInstance().newXPath();
for (MetadataField searchKey : searchKeys) {
for (MetadataField path : searchKey.getChildren()) { | if (path.getType() == MetadataType.XPATH) { |
esbtools/esb-message-admin | common/src/main/java/org/esbtools/message/admin/common/orm/AuditEventEntity.java | // Path: api/src/main/java/org/esbtools/message/admin/model/AuditEvent.java
// public class AuditEvent {
//
// private Long eventId;
// private Date loggedTime;
// private String principal;
// private String action;
// private String messageType;
// private String keyType;
// private String messageKey;
// private String message;
//
// public AuditEvent() {
// this.loggedTime = new Date();
// }
//
// public AuditEvent(String principal, String action, String messageType,
// String keyType, String messageKey, String message) {
// this.loggedTime = new Date();
// this.principal = principal;
// this.action = action;
// this.messageType = messageType;
// this.keyType = keyType;
// this.messageKey = messageKey;
// this.message = message;
// }
//
// public Long getEventId() {
// return eventId;
// }
//
// public void setEventId(Long eventId) {
// this.eventId = eventId;
// }
//
// public Date getLoggedTime() {
// return loggedTime;
// }
//
// public void setLoggedTime(Date loggedTime) {
// this.loggedTime = loggedTime;
// }
//
// public String getPrincipal() {
// return principal;
// }
//
// public void setPrincipal(String principal) {
// this.principal = principal;
// }
//
// public String getAction() {
// return action;
// }
//
// public void setAction(String action) {
// this.action = action;
// }
//
// public String getMessageType() {
// return messageType;
// }
//
// public void setMessageType(String messageType) {
// this.messageType = messageType;
// }
//
// public String getKeyType() {
// return keyType;
// }
//
// public void setKeyType(String keyType) {
// this.keyType = keyType;
// }
//
// public String getMessageKey() {
// return messageKey;
// }
//
// public void setMessageKey(String messageKey) {
// this.messageKey = messageKey;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// }
| import org.esbtools.message.admin.model.AuditEvent;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table; | /*
Copyright 2015 esbtools Contributors and/or its affiliates.
This file is part of esbtools.
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 org.esbtools.message.admin.common.orm;
@Entity
@Table(name="AUDIT_EVENT")
public class AuditEventEntity {
// ~ Instance fields
// --------------------------------------------------------
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="event_id")
private Long eventId;
@Column(name = "timestamp", nullable = false)
private Date loggedTime;
@Column(name = "principal", nullable = false)
private String principal;
@Column(name = "action", nullable = false)
private String action;
@Column(name = "message_type", nullable = false)
private String messageType;
@Column(name = "key_type")
private String keyType;
@Column(name = "message_key", nullable = false)
private String messageKey;
@Column(name = "message")
private String message;
// ~ Constructors
// -----------------------------------------------------------
public AuditEventEntity() {
}
| // Path: api/src/main/java/org/esbtools/message/admin/model/AuditEvent.java
// public class AuditEvent {
//
// private Long eventId;
// private Date loggedTime;
// private String principal;
// private String action;
// private String messageType;
// private String keyType;
// private String messageKey;
// private String message;
//
// public AuditEvent() {
// this.loggedTime = new Date();
// }
//
// public AuditEvent(String principal, String action, String messageType,
// String keyType, String messageKey, String message) {
// this.loggedTime = new Date();
// this.principal = principal;
// this.action = action;
// this.messageType = messageType;
// this.keyType = keyType;
// this.messageKey = messageKey;
// this.message = message;
// }
//
// public Long getEventId() {
// return eventId;
// }
//
// public void setEventId(Long eventId) {
// this.eventId = eventId;
// }
//
// public Date getLoggedTime() {
// return loggedTime;
// }
//
// public void setLoggedTime(Date loggedTime) {
// this.loggedTime = loggedTime;
// }
//
// public String getPrincipal() {
// return principal;
// }
//
// public void setPrincipal(String principal) {
// this.principal = principal;
// }
//
// public String getAction() {
// return action;
// }
//
// public void setAction(String action) {
// this.action = action;
// }
//
// public String getMessageType() {
// return messageType;
// }
//
// public void setMessageType(String messageType) {
// this.messageType = messageType;
// }
//
// public String getKeyType() {
// return keyType;
// }
//
// public void setKeyType(String keyType) {
// this.keyType = keyType;
// }
//
// public String getMessageKey() {
// return messageKey;
// }
//
// public void setMessageKey(String messageKey) {
// this.messageKey = messageKey;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// }
// Path: common/src/main/java/org/esbtools/message/admin/common/orm/AuditEventEntity.java
import org.esbtools.message.admin.model.AuditEvent;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/*
Copyright 2015 esbtools Contributors and/or its affiliates.
This file is part of esbtools.
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 org.esbtools.message.admin.common.orm;
@Entity
@Table(name="AUDIT_EVENT")
public class AuditEventEntity {
// ~ Instance fields
// --------------------------------------------------------
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="event_id")
private Long eventId;
@Column(name = "timestamp", nullable = false)
private Date loggedTime;
@Column(name = "principal", nullable = false)
private String principal;
@Column(name = "action", nullable = false)
private String action;
@Column(name = "message_type", nullable = false)
private String messageType;
@Column(name = "key_type")
private String keyType;
@Column(name = "message_key", nullable = false)
private String messageKey;
@Column(name = "message")
private String message;
// ~ Constructors
// -----------------------------------------------------------
public AuditEventEntity() {
}
| public AuditEventEntity(AuditEvent auditEvent) { |
DevConMyanmar/devcon-android-2013 | src/org/devcon/android/adapter/SpeakerAdapter.java | // Path: src/org/devcon/android/objects/Speaker.java
// public class Speaker implements Serializable{
// public int _id;
// public String name;
// public String title;
// public String bio;
// public String photo;
// public int schedule_id;
//
// public Speaker() {
// }
//
// public Speaker(int id, String name, String title, String bio, String photo,
// int schedule_id) {
// this._id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.photo = photo;
// this.schedule_id = schedule_id;
// }
//
// public int getID() {
// return this._id;
// }
//
// public void setID(int id) {
// this._id = id;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getTitle() {
// return this.title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getBio() {
// return this.bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio;
// }
//
// public String getPhoto() {
// return this.photo;
// }
//
// public void setPhoto(String photo) {
// this.photo = photo;
// }
//
// public int getScheduleID() {
// return this.schedule_id;
// }
//
// public void setScheduleID(int schedule_id) {
// this.schedule_id = schedule_id;
// }
//
// }
//
// Path: src/org/devcon/android/util/AnimateFirstDisplayListener.java
// public class AnimateFirstDisplayListener extends SimpleImageLoadingListener {
//
// static final List<String> displayedImages = Collections
// .synchronizedList(new LinkedList<String>());
//
// @Override
// public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
// if (loadedImage != null) {
// ImageView imageView = (ImageView) view;
// boolean firstDisplay = !displayedImages.contains(imageUri);
// if (firstDisplay) {
// FadeInBitmapDisplayer.animate(imageView, 500);
// displayedImages.add(imageUri);
// }
// }
// }
// }
| import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.ImageLoadingListener;
import org.devcon.android.R;
import org.devcon.android.objects.Speaker;
import org.devcon.android.util.AnimateFirstDisplayListener;
import java.util.ArrayList;
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter; | package org.devcon.android.adapter;
public class SpeakerAdapter extends ArrayAdapter<Speaker> implements
StickyListHeadersAdapter {
private final Context mContext;
private final ArrayList<Speaker> mSpeaker;
private final LayoutInflater mInflater; | // Path: src/org/devcon/android/objects/Speaker.java
// public class Speaker implements Serializable{
// public int _id;
// public String name;
// public String title;
// public String bio;
// public String photo;
// public int schedule_id;
//
// public Speaker() {
// }
//
// public Speaker(int id, String name, String title, String bio, String photo,
// int schedule_id) {
// this._id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.photo = photo;
// this.schedule_id = schedule_id;
// }
//
// public int getID() {
// return this._id;
// }
//
// public void setID(int id) {
// this._id = id;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getTitle() {
// return this.title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getBio() {
// return this.bio;
// }
//
// public void setBio(String bio) {
// this.bio = bio;
// }
//
// public String getPhoto() {
// return this.photo;
// }
//
// public void setPhoto(String photo) {
// this.photo = photo;
// }
//
// public int getScheduleID() {
// return this.schedule_id;
// }
//
// public void setScheduleID(int schedule_id) {
// this.schedule_id = schedule_id;
// }
//
// }
//
// Path: src/org/devcon/android/util/AnimateFirstDisplayListener.java
// public class AnimateFirstDisplayListener extends SimpleImageLoadingListener {
//
// static final List<String> displayedImages = Collections
// .synchronizedList(new LinkedList<String>());
//
// @Override
// public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
// if (loadedImage != null) {
// ImageView imageView = (ImageView) view;
// boolean firstDisplay = !displayedImages.contains(imageUri);
// if (firstDisplay) {
// FadeInBitmapDisplayer.animate(imageView, 500);
// displayedImages.add(imageUri);
// }
// }
// }
// }
// Path: src/org/devcon/android/adapter/SpeakerAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.ImageLoadingListener;
import org.devcon.android.R;
import org.devcon.android.objects.Speaker;
import org.devcon.android.util.AnimateFirstDisplayListener;
import java.util.ArrayList;
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
package org.devcon.android.adapter;
public class SpeakerAdapter extends ArrayAdapter<Speaker> implements
StickyListHeadersAdapter {
private final Context mContext;
private final ArrayList<Speaker> mSpeaker;
private final LayoutInflater mInflater; | private final ImageLoadingListener animateFirstListener = new AnimateFirstDisplayListener(); |
DevConMyanmar/devcon-android-2013 | src/org/devcon/android/adapter/FavouriteAdapter.java | // Path: src/org/devcon/android/db/StorageUtil.java
// public class StorageUtil {
//
// private Context mContext;
//
// public static StorageUtil getInstance(Context context) {
// return new StorageUtil(context);
// }
//
// private StorageUtil(Context context) {
// mContext = context;
// }
//
// public Object ReadArrayListFromSD(String filename) {
// try {
// FileInputStream fis = mContext.openFileInput(filename + ".dat");
// ObjectInputStream ois = new ObjectInputStream(fis);
// Object obj = ois.readObject();
// fis.close();
// return obj;
//
// } catch (Exception e) {
// e.printStackTrace();
// return new ArrayList<Object>();
// }
// }
//
// public <E> void SaveArrayListToSD(String filename, ArrayList<E> list) {
// try {
// FileOutputStream fos = mContext.openFileOutput(filename + ".dat", Context.MODE_PRIVATE);
// ObjectOutputStream oos = new ObjectOutputStream(fos);
// oos.writeObject(list);
// fos.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/org/devcon/android/objects/Talk.java
// public class Talk implements Serializable {
// public int _id;
// public String sch_id;
// public String title;
// public String time;
// public String date;
// public String speaker;
// public int speaker_id;
// public String desc;
// public boolean fav;
//
// public Talk() {
// }
//
// public Talk(int id, String time, String date, String title, String speaker, int speaker_id, String desc,
// boolean fav) {
// this._id = id;
// this.time = time;
// this.date = date;
// this.title = title;
// this.speaker = speaker;
// this.speaker_id = speaker_id;
// this.desc = desc;
// this.fav = fav;
// }
//
// public int getID() {
// return this._id;
// }
//
// public void setID(int id) {
// this._id = id;
// }
//
// public String getTitle() {
// return this.title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getTime() {
// return this.time;
// }
//
// public void setTime(String time) {
// this.time = time;
// }
//
// public String getSpeaker() {
// return this.speaker;
// }
//
// public void setSpeaker(String speaker) {
// this.speaker = speaker;
// }
//
// public String getDesc() {
// return this.desc;
// }
//
// public void setDesc(String desc) {
// this.desc = desc;
// }
//
// public boolean getFav() {
// return this.fav;
// }
//
// public void setFav(boolean fav) {
// this.fav = fav;
// }
//
// public int getSpeaker_id() {
// return speaker_id;
// }
//
// public void setSpeaker_id(int speaker_id) {
// this.speaker_id = speaker_id;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
//
// }
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static void LOGD(final String tag, String message) {
// // just for the sake of Android Lint. sigh
//
// Throwable throwable = new Throwable();
// StackTraceElement[] e = throwable.getStackTrace();
// String c_name = e[1].getMethodName();
//
// if (BuildConfig.DEBUG)
// Log.i(tag, "[" + c_name + "] " + message);
// else if (Log.isLoggable(tag, Log.DEBUG))
// Log.i(tag, "[" + c_name + "] " + message);
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static String makeLogTag(String str) {
// if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
// return LOG_PREFIX
// + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH
// - 1);
// }
//
// return LOG_PREFIX + str;
// }
| import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
import org.devcon.android.R;
import org.devcon.android.db.StorageUtil;
import org.devcon.android.objects.Talk;
import java.util.ArrayList;
import static org.devcon.android.util.LogUtil.LOGD;
import static org.devcon.android.util.LogUtil.makeLogTag; | package org.devcon.android.adapter;
public class FavouriteAdapter extends ArrayAdapter<Talk> {
private Context mContext;
private ArrayList<Talk> mTalk = new ArrayList<Talk>();
String talkID;
| // Path: src/org/devcon/android/db/StorageUtil.java
// public class StorageUtil {
//
// private Context mContext;
//
// public static StorageUtil getInstance(Context context) {
// return new StorageUtil(context);
// }
//
// private StorageUtil(Context context) {
// mContext = context;
// }
//
// public Object ReadArrayListFromSD(String filename) {
// try {
// FileInputStream fis = mContext.openFileInput(filename + ".dat");
// ObjectInputStream ois = new ObjectInputStream(fis);
// Object obj = ois.readObject();
// fis.close();
// return obj;
//
// } catch (Exception e) {
// e.printStackTrace();
// return new ArrayList<Object>();
// }
// }
//
// public <E> void SaveArrayListToSD(String filename, ArrayList<E> list) {
// try {
// FileOutputStream fos = mContext.openFileOutput(filename + ".dat", Context.MODE_PRIVATE);
// ObjectOutputStream oos = new ObjectOutputStream(fos);
// oos.writeObject(list);
// fos.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/org/devcon/android/objects/Talk.java
// public class Talk implements Serializable {
// public int _id;
// public String sch_id;
// public String title;
// public String time;
// public String date;
// public String speaker;
// public int speaker_id;
// public String desc;
// public boolean fav;
//
// public Talk() {
// }
//
// public Talk(int id, String time, String date, String title, String speaker, int speaker_id, String desc,
// boolean fav) {
// this._id = id;
// this.time = time;
// this.date = date;
// this.title = title;
// this.speaker = speaker;
// this.speaker_id = speaker_id;
// this.desc = desc;
// this.fav = fav;
// }
//
// public int getID() {
// return this._id;
// }
//
// public void setID(int id) {
// this._id = id;
// }
//
// public String getTitle() {
// return this.title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getTime() {
// return this.time;
// }
//
// public void setTime(String time) {
// this.time = time;
// }
//
// public String getSpeaker() {
// return this.speaker;
// }
//
// public void setSpeaker(String speaker) {
// this.speaker = speaker;
// }
//
// public String getDesc() {
// return this.desc;
// }
//
// public void setDesc(String desc) {
// this.desc = desc;
// }
//
// public boolean getFav() {
// return this.fav;
// }
//
// public void setFav(boolean fav) {
// this.fav = fav;
// }
//
// public int getSpeaker_id() {
// return speaker_id;
// }
//
// public void setSpeaker_id(int speaker_id) {
// this.speaker_id = speaker_id;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
//
// }
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static void LOGD(final String tag, String message) {
// // just for the sake of Android Lint. sigh
//
// Throwable throwable = new Throwable();
// StackTraceElement[] e = throwable.getStackTrace();
// String c_name = e[1].getMethodName();
//
// if (BuildConfig.DEBUG)
// Log.i(tag, "[" + c_name + "] " + message);
// else if (Log.isLoggable(tag, Log.DEBUG))
// Log.i(tag, "[" + c_name + "] " + message);
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static String makeLogTag(String str) {
// if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
// return LOG_PREFIX
// + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH
// - 1);
// }
//
// return LOG_PREFIX + str;
// }
// Path: src/org/devcon/android/adapter/FavouriteAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
import org.devcon.android.R;
import org.devcon.android.db.StorageUtil;
import org.devcon.android.objects.Talk;
import java.util.ArrayList;
import static org.devcon.android.util.LogUtil.LOGD;
import static org.devcon.android.util.LogUtil.makeLogTag;
package org.devcon.android.adapter;
public class FavouriteAdapter extends ArrayAdapter<Talk> {
private Context mContext;
private ArrayList<Talk> mTalk = new ArrayList<Talk>();
String talkID;
| private static final String TAG = makeLogTag(FavouriteAdapter.class); |
DevConMyanmar/devcon-android-2013 | src/org/devcon/android/adapter/FavouriteAdapter.java | // Path: src/org/devcon/android/db/StorageUtil.java
// public class StorageUtil {
//
// private Context mContext;
//
// public static StorageUtil getInstance(Context context) {
// return new StorageUtil(context);
// }
//
// private StorageUtil(Context context) {
// mContext = context;
// }
//
// public Object ReadArrayListFromSD(String filename) {
// try {
// FileInputStream fis = mContext.openFileInput(filename + ".dat");
// ObjectInputStream ois = new ObjectInputStream(fis);
// Object obj = ois.readObject();
// fis.close();
// return obj;
//
// } catch (Exception e) {
// e.printStackTrace();
// return new ArrayList<Object>();
// }
// }
//
// public <E> void SaveArrayListToSD(String filename, ArrayList<E> list) {
// try {
// FileOutputStream fos = mContext.openFileOutput(filename + ".dat", Context.MODE_PRIVATE);
// ObjectOutputStream oos = new ObjectOutputStream(fos);
// oos.writeObject(list);
// fos.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/org/devcon/android/objects/Talk.java
// public class Talk implements Serializable {
// public int _id;
// public String sch_id;
// public String title;
// public String time;
// public String date;
// public String speaker;
// public int speaker_id;
// public String desc;
// public boolean fav;
//
// public Talk() {
// }
//
// public Talk(int id, String time, String date, String title, String speaker, int speaker_id, String desc,
// boolean fav) {
// this._id = id;
// this.time = time;
// this.date = date;
// this.title = title;
// this.speaker = speaker;
// this.speaker_id = speaker_id;
// this.desc = desc;
// this.fav = fav;
// }
//
// public int getID() {
// return this._id;
// }
//
// public void setID(int id) {
// this._id = id;
// }
//
// public String getTitle() {
// return this.title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getTime() {
// return this.time;
// }
//
// public void setTime(String time) {
// this.time = time;
// }
//
// public String getSpeaker() {
// return this.speaker;
// }
//
// public void setSpeaker(String speaker) {
// this.speaker = speaker;
// }
//
// public String getDesc() {
// return this.desc;
// }
//
// public void setDesc(String desc) {
// this.desc = desc;
// }
//
// public boolean getFav() {
// return this.fav;
// }
//
// public void setFav(boolean fav) {
// this.fav = fav;
// }
//
// public int getSpeaker_id() {
// return speaker_id;
// }
//
// public void setSpeaker_id(int speaker_id) {
// this.speaker_id = speaker_id;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
//
// }
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static void LOGD(final String tag, String message) {
// // just for the sake of Android Lint. sigh
//
// Throwable throwable = new Throwable();
// StackTraceElement[] e = throwable.getStackTrace();
// String c_name = e[1].getMethodName();
//
// if (BuildConfig.DEBUG)
// Log.i(tag, "[" + c_name + "] " + message);
// else if (Log.isLoggable(tag, Log.DEBUG))
// Log.i(tag, "[" + c_name + "] " + message);
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static String makeLogTag(String str) {
// if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
// return LOG_PREFIX
// + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH
// - 1);
// }
//
// return LOG_PREFIX + str;
// }
| import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
import org.devcon.android.R;
import org.devcon.android.db.StorageUtil;
import org.devcon.android.objects.Talk;
import java.util.ArrayList;
import static org.devcon.android.util.LogUtil.LOGD;
import static org.devcon.android.util.LogUtil.makeLogTag; | package org.devcon.android.adapter;
public class FavouriteAdapter extends ArrayAdapter<Talk> {
private Context mContext;
private ArrayList<Talk> mTalk = new ArrayList<Talk>();
String talkID;
private static final String TAG = makeLogTag(FavouriteAdapter.class);
| // Path: src/org/devcon/android/db/StorageUtil.java
// public class StorageUtil {
//
// private Context mContext;
//
// public static StorageUtil getInstance(Context context) {
// return new StorageUtil(context);
// }
//
// private StorageUtil(Context context) {
// mContext = context;
// }
//
// public Object ReadArrayListFromSD(String filename) {
// try {
// FileInputStream fis = mContext.openFileInput(filename + ".dat");
// ObjectInputStream ois = new ObjectInputStream(fis);
// Object obj = ois.readObject();
// fis.close();
// return obj;
//
// } catch (Exception e) {
// e.printStackTrace();
// return new ArrayList<Object>();
// }
// }
//
// public <E> void SaveArrayListToSD(String filename, ArrayList<E> list) {
// try {
// FileOutputStream fos = mContext.openFileOutput(filename + ".dat", Context.MODE_PRIVATE);
// ObjectOutputStream oos = new ObjectOutputStream(fos);
// oos.writeObject(list);
// fos.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/org/devcon/android/objects/Talk.java
// public class Talk implements Serializable {
// public int _id;
// public String sch_id;
// public String title;
// public String time;
// public String date;
// public String speaker;
// public int speaker_id;
// public String desc;
// public boolean fav;
//
// public Talk() {
// }
//
// public Talk(int id, String time, String date, String title, String speaker, int speaker_id, String desc,
// boolean fav) {
// this._id = id;
// this.time = time;
// this.date = date;
// this.title = title;
// this.speaker = speaker;
// this.speaker_id = speaker_id;
// this.desc = desc;
// this.fav = fav;
// }
//
// public int getID() {
// return this._id;
// }
//
// public void setID(int id) {
// this._id = id;
// }
//
// public String getTitle() {
// return this.title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getTime() {
// return this.time;
// }
//
// public void setTime(String time) {
// this.time = time;
// }
//
// public String getSpeaker() {
// return this.speaker;
// }
//
// public void setSpeaker(String speaker) {
// this.speaker = speaker;
// }
//
// public String getDesc() {
// return this.desc;
// }
//
// public void setDesc(String desc) {
// this.desc = desc;
// }
//
// public boolean getFav() {
// return this.fav;
// }
//
// public void setFav(boolean fav) {
// this.fav = fav;
// }
//
// public int getSpeaker_id() {
// return speaker_id;
// }
//
// public void setSpeaker_id(int speaker_id) {
// this.speaker_id = speaker_id;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
//
// }
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static void LOGD(final String tag, String message) {
// // just for the sake of Android Lint. sigh
//
// Throwable throwable = new Throwable();
// StackTraceElement[] e = throwable.getStackTrace();
// String c_name = e[1].getMethodName();
//
// if (BuildConfig.DEBUG)
// Log.i(tag, "[" + c_name + "] " + message);
// else if (Log.isLoggable(tag, Log.DEBUG))
// Log.i(tag, "[" + c_name + "] " + message);
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static String makeLogTag(String str) {
// if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
// return LOG_PREFIX
// + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH
// - 1);
// }
//
// return LOG_PREFIX + str;
// }
// Path: src/org/devcon/android/adapter/FavouriteAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
import org.devcon.android.R;
import org.devcon.android.db.StorageUtil;
import org.devcon.android.objects.Talk;
import java.util.ArrayList;
import static org.devcon.android.util.LogUtil.LOGD;
import static org.devcon.android.util.LogUtil.makeLogTag;
package org.devcon.android.adapter;
public class FavouriteAdapter extends ArrayAdapter<Talk> {
private Context mContext;
private ArrayList<Talk> mTalk = new ArrayList<Talk>();
String talkID;
private static final String TAG = makeLogTag(FavouriteAdapter.class);
| private StorageUtil store; |
DevConMyanmar/devcon-android-2013 | src/org/devcon/android/adapter/FavouriteAdapter.java | // Path: src/org/devcon/android/db/StorageUtil.java
// public class StorageUtil {
//
// private Context mContext;
//
// public static StorageUtil getInstance(Context context) {
// return new StorageUtil(context);
// }
//
// private StorageUtil(Context context) {
// mContext = context;
// }
//
// public Object ReadArrayListFromSD(String filename) {
// try {
// FileInputStream fis = mContext.openFileInput(filename + ".dat");
// ObjectInputStream ois = new ObjectInputStream(fis);
// Object obj = ois.readObject();
// fis.close();
// return obj;
//
// } catch (Exception e) {
// e.printStackTrace();
// return new ArrayList<Object>();
// }
// }
//
// public <E> void SaveArrayListToSD(String filename, ArrayList<E> list) {
// try {
// FileOutputStream fos = mContext.openFileOutput(filename + ".dat", Context.MODE_PRIVATE);
// ObjectOutputStream oos = new ObjectOutputStream(fos);
// oos.writeObject(list);
// fos.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/org/devcon/android/objects/Talk.java
// public class Talk implements Serializable {
// public int _id;
// public String sch_id;
// public String title;
// public String time;
// public String date;
// public String speaker;
// public int speaker_id;
// public String desc;
// public boolean fav;
//
// public Talk() {
// }
//
// public Talk(int id, String time, String date, String title, String speaker, int speaker_id, String desc,
// boolean fav) {
// this._id = id;
// this.time = time;
// this.date = date;
// this.title = title;
// this.speaker = speaker;
// this.speaker_id = speaker_id;
// this.desc = desc;
// this.fav = fav;
// }
//
// public int getID() {
// return this._id;
// }
//
// public void setID(int id) {
// this._id = id;
// }
//
// public String getTitle() {
// return this.title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getTime() {
// return this.time;
// }
//
// public void setTime(String time) {
// this.time = time;
// }
//
// public String getSpeaker() {
// return this.speaker;
// }
//
// public void setSpeaker(String speaker) {
// this.speaker = speaker;
// }
//
// public String getDesc() {
// return this.desc;
// }
//
// public void setDesc(String desc) {
// this.desc = desc;
// }
//
// public boolean getFav() {
// return this.fav;
// }
//
// public void setFav(boolean fav) {
// this.fav = fav;
// }
//
// public int getSpeaker_id() {
// return speaker_id;
// }
//
// public void setSpeaker_id(int speaker_id) {
// this.speaker_id = speaker_id;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
//
// }
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static void LOGD(final String tag, String message) {
// // just for the sake of Android Lint. sigh
//
// Throwable throwable = new Throwable();
// StackTraceElement[] e = throwable.getStackTrace();
// String c_name = e[1].getMethodName();
//
// if (BuildConfig.DEBUG)
// Log.i(tag, "[" + c_name + "] " + message);
// else if (Log.isLoggable(tag, Log.DEBUG))
// Log.i(tag, "[" + c_name + "] " + message);
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static String makeLogTag(String str) {
// if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
// return LOG_PREFIX
// + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH
// - 1);
// }
//
// return LOG_PREFIX + str;
// }
| import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
import org.devcon.android.R;
import org.devcon.android.db.StorageUtil;
import org.devcon.android.objects.Talk;
import java.util.ArrayList;
import static org.devcon.android.util.LogUtil.LOGD;
import static org.devcon.android.util.LogUtil.makeLogTag; |
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
View vi = convertView;
if (vi == null || vi.getTag() == null) {
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// don't forget to inflate the same layout
vi = inflater.inflate(R.layout.row_favourite, null);
holder = getHolder(vi);
assert vi != null;
vi.setTag(holder);
} else {
holder = (ViewHolder) vi.getTag();
}
// set the data here
holder.tvTime.setText(mTalk.get(position).time);
holder.tvTitle.setText(mTalk.get(position).title);
holder.tvSpeaker.setText(mTalk.get(position).speaker);
holder.btnFav.setFocusableInTouchMode(false);
holder.btnFav.setFocusable(false);
holder.btnFav.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// say 'meow~' when you click it ;-)
talks.get(mTalk.get(position)._id).fav = false;
store.SaveArrayListToSD("talks", talks); | // Path: src/org/devcon/android/db/StorageUtil.java
// public class StorageUtil {
//
// private Context mContext;
//
// public static StorageUtil getInstance(Context context) {
// return new StorageUtil(context);
// }
//
// private StorageUtil(Context context) {
// mContext = context;
// }
//
// public Object ReadArrayListFromSD(String filename) {
// try {
// FileInputStream fis = mContext.openFileInput(filename + ".dat");
// ObjectInputStream ois = new ObjectInputStream(fis);
// Object obj = ois.readObject();
// fis.close();
// return obj;
//
// } catch (Exception e) {
// e.printStackTrace();
// return new ArrayList<Object>();
// }
// }
//
// public <E> void SaveArrayListToSD(String filename, ArrayList<E> list) {
// try {
// FileOutputStream fos = mContext.openFileOutput(filename + ".dat", Context.MODE_PRIVATE);
// ObjectOutputStream oos = new ObjectOutputStream(fos);
// oos.writeObject(list);
// fos.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/org/devcon/android/objects/Talk.java
// public class Talk implements Serializable {
// public int _id;
// public String sch_id;
// public String title;
// public String time;
// public String date;
// public String speaker;
// public int speaker_id;
// public String desc;
// public boolean fav;
//
// public Talk() {
// }
//
// public Talk(int id, String time, String date, String title, String speaker, int speaker_id, String desc,
// boolean fav) {
// this._id = id;
// this.time = time;
// this.date = date;
// this.title = title;
// this.speaker = speaker;
// this.speaker_id = speaker_id;
// this.desc = desc;
// this.fav = fav;
// }
//
// public int getID() {
// return this._id;
// }
//
// public void setID(int id) {
// this._id = id;
// }
//
// public String getTitle() {
// return this.title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getTime() {
// return this.time;
// }
//
// public void setTime(String time) {
// this.time = time;
// }
//
// public String getSpeaker() {
// return this.speaker;
// }
//
// public void setSpeaker(String speaker) {
// this.speaker = speaker;
// }
//
// public String getDesc() {
// return this.desc;
// }
//
// public void setDesc(String desc) {
// this.desc = desc;
// }
//
// public boolean getFav() {
// return this.fav;
// }
//
// public void setFav(boolean fav) {
// this.fav = fav;
// }
//
// public int getSpeaker_id() {
// return speaker_id;
// }
//
// public void setSpeaker_id(int speaker_id) {
// this.speaker_id = speaker_id;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
//
// }
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static void LOGD(final String tag, String message) {
// // just for the sake of Android Lint. sigh
//
// Throwable throwable = new Throwable();
// StackTraceElement[] e = throwable.getStackTrace();
// String c_name = e[1].getMethodName();
//
// if (BuildConfig.DEBUG)
// Log.i(tag, "[" + c_name + "] " + message);
// else if (Log.isLoggable(tag, Log.DEBUG))
// Log.i(tag, "[" + c_name + "] " + message);
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static String makeLogTag(String str) {
// if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
// return LOG_PREFIX
// + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH
// - 1);
// }
//
// return LOG_PREFIX + str;
// }
// Path: src/org/devcon/android/adapter/FavouriteAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
import org.devcon.android.R;
import org.devcon.android.db.StorageUtil;
import org.devcon.android.objects.Talk;
import java.util.ArrayList;
import static org.devcon.android.util.LogUtil.LOGD;
import static org.devcon.android.util.LogUtil.makeLogTag;
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
View vi = convertView;
if (vi == null || vi.getTag() == null) {
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// don't forget to inflate the same layout
vi = inflater.inflate(R.layout.row_favourite, null);
holder = getHolder(vi);
assert vi != null;
vi.setTag(holder);
} else {
holder = (ViewHolder) vi.getTag();
}
// set the data here
holder.tvTime.setText(mTalk.get(position).time);
holder.tvTitle.setText(mTalk.get(position).title);
holder.tvSpeaker.setText(mTalk.get(position).speaker);
holder.btnFav.setFocusableInTouchMode(false);
holder.btnFav.setFocusable(false);
holder.btnFav.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// say 'meow~' when you click it ;-)
talks.get(mTalk.get(position)._id).fav = false;
store.SaveArrayListToSD("talks", talks); | LOGD(TAG, "id: " + talkID + " meow~"); |
DevConMyanmar/devcon-android-2013 | src/org/devcon/android/FeedbackActivity.java | // Path: src/org/devcon/android/util/AppConfig.java
// public class AppConfig {
//
//
// public static final long CONFERENCE_START_MILLIS = ParserUtils
// .parseTime("2013-11-23T09:00:00.000-07:00");
// public static final long CONFERENCE_END_MILLIS = ParserUtils
// .parseTime("2013-12-24T23:00:00.000-07:00");
//
// public static long getCurrentTime() {
// return System.currentTimeMillis();
// }
//
// public static final String BASE_URL = "http://devconmyanmar.herokuapp.com/api/v1/";
// public static final String SPEAKERS_URL = BASE_URL + "speakers";
// public static final String TALKS_URL= BASE_URL + "schedules";
// // TODO
// public static final String FEEDBACKS_URL = BASE_URL + "feedbacks";
//
// public static final String DUMMY_PHOTO_URL = "http://devconmyanmar.org/2013/wp-content/uploads/2013/10/default-speaker-150x150.png";
//
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static void LOGD(final String tag, String message) {
// // just for the sake of Android Lint. sigh
//
// Throwable throwable = new Throwable();
// StackTraceElement[] e = throwable.getStackTrace();
// String c_name = e[1].getMethodName();
//
// if (BuildConfig.DEBUG)
// Log.i(tag, "[" + c_name + "] " + message);
// else if (Log.isLoggable(tag, Log.DEBUG))
// Log.i(tag, "[" + c_name + "] " + message);
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static String makeLogTag(String str) {
// if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
// return LOG_PREFIX
// + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH
// - 1);
// }
//
// return LOG_PREFIX + str;
// }
| import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import android.text.format.Time;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RatingBar;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.MenuItem;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import org.apache.http.Header;
import org.devcon.android.util.AppConfig;
import static org.devcon.android.util.LogUtil.LOGD;
import static org.devcon.android.util.LogUtil.makeLogTag; | title.setText(talkTitle);
submit.setOnClickListener(new AdapterView.OnClickListener() {
@Override
public void onClick(View v) {
try {
manager = getPackageManager().getPackageInfo(
getPackageName(), 0);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
params.put("android_id", Secure.getString(
getApplicationContext().getContentResolver(),
Secure.ANDROID_ID));
Time now = new Time();
now.setToNow();
String versionName = manager.versionName;
params.put(getResources().getString(R.string.overall_rating),
(int) overall.getRating());
params.put(getResources().getString(R.string.useful),
(int) useful.getRating());
params.put(getResources().getString(R.string.content),
(int) content.getRating());
params.put(getResources().getString(R.string.speaker),
(int) speaker.getRating());
// that sucks but it works
params.put("anything", "" + msg.getText()); | // Path: src/org/devcon/android/util/AppConfig.java
// public class AppConfig {
//
//
// public static final long CONFERENCE_START_MILLIS = ParserUtils
// .parseTime("2013-11-23T09:00:00.000-07:00");
// public static final long CONFERENCE_END_MILLIS = ParserUtils
// .parseTime("2013-12-24T23:00:00.000-07:00");
//
// public static long getCurrentTime() {
// return System.currentTimeMillis();
// }
//
// public static final String BASE_URL = "http://devconmyanmar.herokuapp.com/api/v1/";
// public static final String SPEAKERS_URL = BASE_URL + "speakers";
// public static final String TALKS_URL= BASE_URL + "schedules";
// // TODO
// public static final String FEEDBACKS_URL = BASE_URL + "feedbacks";
//
// public static final String DUMMY_PHOTO_URL = "http://devconmyanmar.org/2013/wp-content/uploads/2013/10/default-speaker-150x150.png";
//
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static void LOGD(final String tag, String message) {
// // just for the sake of Android Lint. sigh
//
// Throwable throwable = new Throwable();
// StackTraceElement[] e = throwable.getStackTrace();
// String c_name = e[1].getMethodName();
//
// if (BuildConfig.DEBUG)
// Log.i(tag, "[" + c_name + "] " + message);
// else if (Log.isLoggable(tag, Log.DEBUG))
// Log.i(tag, "[" + c_name + "] " + message);
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static String makeLogTag(String str) {
// if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
// return LOG_PREFIX
// + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH
// - 1);
// }
//
// return LOG_PREFIX + str;
// }
// Path: src/org/devcon/android/FeedbackActivity.java
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import android.text.format.Time;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RatingBar;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.MenuItem;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import org.apache.http.Header;
import org.devcon.android.util.AppConfig;
import static org.devcon.android.util.LogUtil.LOGD;
import static org.devcon.android.util.LogUtil.makeLogTag;
title.setText(talkTitle);
submit.setOnClickListener(new AdapterView.OnClickListener() {
@Override
public void onClick(View v) {
try {
manager = getPackageManager().getPackageInfo(
getPackageName(), 0);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
params.put("android_id", Secure.getString(
getApplicationContext().getContentResolver(),
Secure.ANDROID_ID));
Time now = new Time();
now.setToNow();
String versionName = manager.versionName;
params.put(getResources().getString(R.string.overall_rating),
(int) overall.getRating());
params.put(getResources().getString(R.string.useful),
(int) useful.getRating());
params.put(getResources().getString(R.string.content),
(int) content.getRating());
params.put(getResources().getString(R.string.speaker),
(int) speaker.getRating());
// that sucks but it works
params.put("anything", "" + msg.getText()); | LOGD(TAG, "anything " + msg.getText()); |
DevConMyanmar/devcon-android-2013 | src/org/devcon/android/FeedbackActivity.java | // Path: src/org/devcon/android/util/AppConfig.java
// public class AppConfig {
//
//
// public static final long CONFERENCE_START_MILLIS = ParserUtils
// .parseTime("2013-11-23T09:00:00.000-07:00");
// public static final long CONFERENCE_END_MILLIS = ParserUtils
// .parseTime("2013-12-24T23:00:00.000-07:00");
//
// public static long getCurrentTime() {
// return System.currentTimeMillis();
// }
//
// public static final String BASE_URL = "http://devconmyanmar.herokuapp.com/api/v1/";
// public static final String SPEAKERS_URL = BASE_URL + "speakers";
// public static final String TALKS_URL= BASE_URL + "schedules";
// // TODO
// public static final String FEEDBACKS_URL = BASE_URL + "feedbacks";
//
// public static final String DUMMY_PHOTO_URL = "http://devconmyanmar.org/2013/wp-content/uploads/2013/10/default-speaker-150x150.png";
//
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static void LOGD(final String tag, String message) {
// // just for the sake of Android Lint. sigh
//
// Throwable throwable = new Throwable();
// StackTraceElement[] e = throwable.getStackTrace();
// String c_name = e[1].getMethodName();
//
// if (BuildConfig.DEBUG)
// Log.i(tag, "[" + c_name + "] " + message);
// else if (Log.isLoggable(tag, Log.DEBUG))
// Log.i(tag, "[" + c_name + "] " + message);
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static String makeLogTag(String str) {
// if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
// return LOG_PREFIX
// + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH
// - 1);
// }
//
// return LOG_PREFIX + str;
// }
| import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import android.text.format.Time;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RatingBar;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.MenuItem;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import org.apache.http.Header;
import org.devcon.android.util.AppConfig;
import static org.devcon.android.util.LogUtil.LOGD;
import static org.devcon.android.util.LogUtil.makeLogTag; | params.put(getResources().getString(R.string.overall_rating),
(int) overall.getRating());
params.put(getResources().getString(R.string.useful),
(int) useful.getRating());
params.put(getResources().getString(R.string.content),
(int) content.getRating());
params.put(getResources().getString(R.string.speaker),
(int) speaker.getRating());
// that sucks but it works
params.put("anything", "" + msg.getText());
LOGD(TAG, "anything " + msg.getText());
params.put(getResources().getString(R.string.package_name),
getApplicationContext().getPackageName());
params.put(getResources().getString(R.string.version_name),
versionName);
params.put(getResources().getString(R.string.current_time),
now.toString());
params.add(getResources().getString(R.string.network_name),
String.valueOf(tele.getNetworkType()));
params.add(getResources().getString(R.string.phone_type),
String.valueOf(tele.getPhoneType()));
params.put(getResources().getString(R.string.api),
android.os.Build.VERSION.SDK_INT);
params.put(getResources().getString(R.string.model),
android.os.Build.MODEL);
params.put(getResources().getString(R.string.vendor),
android.os.Build.MANUFACTURER);
| // Path: src/org/devcon/android/util/AppConfig.java
// public class AppConfig {
//
//
// public static final long CONFERENCE_START_MILLIS = ParserUtils
// .parseTime("2013-11-23T09:00:00.000-07:00");
// public static final long CONFERENCE_END_MILLIS = ParserUtils
// .parseTime("2013-12-24T23:00:00.000-07:00");
//
// public static long getCurrentTime() {
// return System.currentTimeMillis();
// }
//
// public static final String BASE_URL = "http://devconmyanmar.herokuapp.com/api/v1/";
// public static final String SPEAKERS_URL = BASE_URL + "speakers";
// public static final String TALKS_URL= BASE_URL + "schedules";
// // TODO
// public static final String FEEDBACKS_URL = BASE_URL + "feedbacks";
//
// public static final String DUMMY_PHOTO_URL = "http://devconmyanmar.org/2013/wp-content/uploads/2013/10/default-speaker-150x150.png";
//
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static void LOGD(final String tag, String message) {
// // just for the sake of Android Lint. sigh
//
// Throwable throwable = new Throwable();
// StackTraceElement[] e = throwable.getStackTrace();
// String c_name = e[1].getMethodName();
//
// if (BuildConfig.DEBUG)
// Log.i(tag, "[" + c_name + "] " + message);
// else if (Log.isLoggable(tag, Log.DEBUG))
// Log.i(tag, "[" + c_name + "] " + message);
// }
//
// Path: src/org/devcon/android/util/LogUtil.java
// public static String makeLogTag(String str) {
// if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
// return LOG_PREFIX
// + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH
// - 1);
// }
//
// return LOG_PREFIX + str;
// }
// Path: src/org/devcon/android/FeedbackActivity.java
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import android.text.format.Time;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RatingBar;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.MenuItem;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import org.apache.http.Header;
import org.devcon.android.util.AppConfig;
import static org.devcon.android.util.LogUtil.LOGD;
import static org.devcon.android.util.LogUtil.makeLogTag;
params.put(getResources().getString(R.string.overall_rating),
(int) overall.getRating());
params.put(getResources().getString(R.string.useful),
(int) useful.getRating());
params.put(getResources().getString(R.string.content),
(int) content.getRating());
params.put(getResources().getString(R.string.speaker),
(int) speaker.getRating());
// that sucks but it works
params.put("anything", "" + msg.getText());
LOGD(TAG, "anything " + msg.getText());
params.put(getResources().getString(R.string.package_name),
getApplicationContext().getPackageName());
params.put(getResources().getString(R.string.version_name),
versionName);
params.put(getResources().getString(R.string.current_time),
now.toString());
params.add(getResources().getString(R.string.network_name),
String.valueOf(tele.getNetworkType()));
params.add(getResources().getString(R.string.phone_type),
String.valueOf(tele.getPhoneType()));
params.put(getResources().getString(R.string.api),
android.os.Build.VERSION.SDK_INT);
params.put(getResources().getString(R.string.model),
android.os.Build.MODEL);
params.put(getResources().getString(R.string.vendor),
android.os.Build.MANUFACTURER);
| String url = AppConfig.FEEDBACKS_URL; |
yenrab/doing_more_with_java | StoreServlet.java | // Path: LoginHandler.java
// public class LoginHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
// String userName = (String)dataMap.get("uname");
// String password = (String)dataMap.get("pword");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUser(userName, password);
// HashMap<String,Object>responseMap = new HashMap<>();
// String sessionID = "";
// if(foundUser != null){
// UUID sessionUUID = UUID.randomUUID();
// sessionID = sessionUUID.toString();
// foundUser.setSession(sessionID);
// theModel.updateUser(foundUser);
// responseMap.put("id",sessionID);
// }
// responseMap.put("id",sessionID);
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: LogoutHandler.java
// public class LogoutHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
//
// String sessionID = (String)dataMap.get("id");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUserBySessionID(sessionID);
// if(foundUser != null){
// foundUser.setSession("");
// theModel.updateUser(foundUser);
// }
// HashMap<String,Object> responseMap = new HashMap<>();
// responseMap.put("id","");
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: RegistrationHandler.java
// public class RegistrationHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
// String userName = (String)dataMap.get("uname");
// String password = (String)dataMap.get("pword");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUser(userName, password);
// HashMap<String,Object>responseMap = new HashMap<>();
// String sessionID = "";
// if(foundUser == null){
// UUID sessionUUID = UUID.randomUUID();
// sessionID = sessionUUID.toString();
// User aUser = new User();
// aUser.setSession(sessionID);
// aUser.setUname(userName);
// aUser.setPword(password);
// theModel.addUser(aUser);
// responseMap.put("id",sessionID);
// }
// responseMap.put("id",sessionID);
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
| import com.doing.more.java.example.appcontrol.ApplicationController;
import com.doing.more.java.example.handlers.LoginHandler;
import com.doing.more.java.example.handlers.LogoutHandler;
import com.doing.more.java.example.handlers.RegistrationHandler;
import json.JSONInputStream;
import json.JSONOutputStream;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap; | package com.doing.more.java.example;
@WebServlet(name = "StoreServlet")
public class StoreServlet extends HttpServlet {
private ApplicationController theAppController = new ApplicationController();
private StoreModel theModel = new StoreModel();
public void init(){ | // Path: LoginHandler.java
// public class LoginHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
// String userName = (String)dataMap.get("uname");
// String password = (String)dataMap.get("pword");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUser(userName, password);
// HashMap<String,Object>responseMap = new HashMap<>();
// String sessionID = "";
// if(foundUser != null){
// UUID sessionUUID = UUID.randomUUID();
// sessionID = sessionUUID.toString();
// foundUser.setSession(sessionID);
// theModel.updateUser(foundUser);
// responseMap.put("id",sessionID);
// }
// responseMap.put("id",sessionID);
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: LogoutHandler.java
// public class LogoutHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
//
// String sessionID = (String)dataMap.get("id");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUserBySessionID(sessionID);
// if(foundUser != null){
// foundUser.setSession("");
// theModel.updateUser(foundUser);
// }
// HashMap<String,Object> responseMap = new HashMap<>();
// responseMap.put("id","");
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: RegistrationHandler.java
// public class RegistrationHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
// String userName = (String)dataMap.get("uname");
// String password = (String)dataMap.get("pword");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUser(userName, password);
// HashMap<String,Object>responseMap = new HashMap<>();
// String sessionID = "";
// if(foundUser == null){
// UUID sessionUUID = UUID.randomUUID();
// sessionID = sessionUUID.toString();
// User aUser = new User();
// aUser.setSession(sessionID);
// aUser.setUname(userName);
// aUser.setPword(password);
// theModel.addUser(aUser);
// responseMap.put("id",sessionID);
// }
// responseMap.put("id",sessionID);
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
// Path: StoreServlet.java
import com.doing.more.java.example.appcontrol.ApplicationController;
import com.doing.more.java.example.handlers.LoginHandler;
import com.doing.more.java.example.handlers.LogoutHandler;
import com.doing.more.java.example.handlers.RegistrationHandler;
import json.JSONInputStream;
import json.JSONOutputStream;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
package com.doing.more.java.example;
@WebServlet(name = "StoreServlet")
public class StoreServlet extends HttpServlet {
private ApplicationController theAppController = new ApplicationController();
private StoreModel theModel = new StoreModel();
public void init(){ | theAppController.mapCommand("register", new RegistrationHandler()); |
yenrab/doing_more_with_java | StoreServlet.java | // Path: LoginHandler.java
// public class LoginHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
// String userName = (String)dataMap.get("uname");
// String password = (String)dataMap.get("pword");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUser(userName, password);
// HashMap<String,Object>responseMap = new HashMap<>();
// String sessionID = "";
// if(foundUser != null){
// UUID sessionUUID = UUID.randomUUID();
// sessionID = sessionUUID.toString();
// foundUser.setSession(sessionID);
// theModel.updateUser(foundUser);
// responseMap.put("id",sessionID);
// }
// responseMap.put("id",sessionID);
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: LogoutHandler.java
// public class LogoutHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
//
// String sessionID = (String)dataMap.get("id");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUserBySessionID(sessionID);
// if(foundUser != null){
// foundUser.setSession("");
// theModel.updateUser(foundUser);
// }
// HashMap<String,Object> responseMap = new HashMap<>();
// responseMap.put("id","");
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: RegistrationHandler.java
// public class RegistrationHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
// String userName = (String)dataMap.get("uname");
// String password = (String)dataMap.get("pword");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUser(userName, password);
// HashMap<String,Object>responseMap = new HashMap<>();
// String sessionID = "";
// if(foundUser == null){
// UUID sessionUUID = UUID.randomUUID();
// sessionID = sessionUUID.toString();
// User aUser = new User();
// aUser.setSession(sessionID);
// aUser.setUname(userName);
// aUser.setPword(password);
// theModel.addUser(aUser);
// responseMap.put("id",sessionID);
// }
// responseMap.put("id",sessionID);
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
| import com.doing.more.java.example.appcontrol.ApplicationController;
import com.doing.more.java.example.handlers.LoginHandler;
import com.doing.more.java.example.handlers.LogoutHandler;
import com.doing.more.java.example.handlers.RegistrationHandler;
import json.JSONInputStream;
import json.JSONOutputStream;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap; | package com.doing.more.java.example;
@WebServlet(name = "StoreServlet")
public class StoreServlet extends HttpServlet {
private ApplicationController theAppController = new ApplicationController();
private StoreModel theModel = new StoreModel();
public void init(){
theAppController.mapCommand("register", new RegistrationHandler()); | // Path: LoginHandler.java
// public class LoginHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
// String userName = (String)dataMap.get("uname");
// String password = (String)dataMap.get("pword");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUser(userName, password);
// HashMap<String,Object>responseMap = new HashMap<>();
// String sessionID = "";
// if(foundUser != null){
// UUID sessionUUID = UUID.randomUUID();
// sessionID = sessionUUID.toString();
// foundUser.setSession(sessionID);
// theModel.updateUser(foundUser);
// responseMap.put("id",sessionID);
// }
// responseMap.put("id",sessionID);
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: LogoutHandler.java
// public class LogoutHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
//
// String sessionID = (String)dataMap.get("id");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUserBySessionID(sessionID);
// if(foundUser != null){
// foundUser.setSession("");
// theModel.updateUser(foundUser);
// }
// HashMap<String,Object> responseMap = new HashMap<>();
// responseMap.put("id","");
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: RegistrationHandler.java
// public class RegistrationHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
// String userName = (String)dataMap.get("uname");
// String password = (String)dataMap.get("pword");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUser(userName, password);
// HashMap<String,Object>responseMap = new HashMap<>();
// String sessionID = "";
// if(foundUser == null){
// UUID sessionUUID = UUID.randomUUID();
// sessionID = sessionUUID.toString();
// User aUser = new User();
// aUser.setSession(sessionID);
// aUser.setUname(userName);
// aUser.setPword(password);
// theModel.addUser(aUser);
// responseMap.put("id",sessionID);
// }
// responseMap.put("id",sessionID);
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
// Path: StoreServlet.java
import com.doing.more.java.example.appcontrol.ApplicationController;
import com.doing.more.java.example.handlers.LoginHandler;
import com.doing.more.java.example.handlers.LogoutHandler;
import com.doing.more.java.example.handlers.RegistrationHandler;
import json.JSONInputStream;
import json.JSONOutputStream;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
package com.doing.more.java.example;
@WebServlet(name = "StoreServlet")
public class StoreServlet extends HttpServlet {
private ApplicationController theAppController = new ApplicationController();
private StoreModel theModel = new StoreModel();
public void init(){
theAppController.mapCommand("register", new RegistrationHandler()); | theAppController.mapCommand("login", new LoginHandler()); |
yenrab/doing_more_with_java | StoreServlet.java | // Path: LoginHandler.java
// public class LoginHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
// String userName = (String)dataMap.get("uname");
// String password = (String)dataMap.get("pword");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUser(userName, password);
// HashMap<String,Object>responseMap = new HashMap<>();
// String sessionID = "";
// if(foundUser != null){
// UUID sessionUUID = UUID.randomUUID();
// sessionID = sessionUUID.toString();
// foundUser.setSession(sessionID);
// theModel.updateUser(foundUser);
// responseMap.put("id",sessionID);
// }
// responseMap.put("id",sessionID);
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: LogoutHandler.java
// public class LogoutHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
//
// String sessionID = (String)dataMap.get("id");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUserBySessionID(sessionID);
// if(foundUser != null){
// foundUser.setSession("");
// theModel.updateUser(foundUser);
// }
// HashMap<String,Object> responseMap = new HashMap<>();
// responseMap.put("id","");
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: RegistrationHandler.java
// public class RegistrationHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
// String userName = (String)dataMap.get("uname");
// String password = (String)dataMap.get("pword");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUser(userName, password);
// HashMap<String,Object>responseMap = new HashMap<>();
// String sessionID = "";
// if(foundUser == null){
// UUID sessionUUID = UUID.randomUUID();
// sessionID = sessionUUID.toString();
// User aUser = new User();
// aUser.setSession(sessionID);
// aUser.setUname(userName);
// aUser.setPword(password);
// theModel.addUser(aUser);
// responseMap.put("id",sessionID);
// }
// responseMap.put("id",sessionID);
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
| import com.doing.more.java.example.appcontrol.ApplicationController;
import com.doing.more.java.example.handlers.LoginHandler;
import com.doing.more.java.example.handlers.LogoutHandler;
import com.doing.more.java.example.handlers.RegistrationHandler;
import json.JSONInputStream;
import json.JSONOutputStream;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap; | package com.doing.more.java.example;
@WebServlet(name = "StoreServlet")
public class StoreServlet extends HttpServlet {
private ApplicationController theAppController = new ApplicationController();
private StoreModel theModel = new StoreModel();
public void init(){
theAppController.mapCommand("register", new RegistrationHandler());
theAppController.mapCommand("login", new LoginHandler()); | // Path: LoginHandler.java
// public class LoginHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
// String userName = (String)dataMap.get("uname");
// String password = (String)dataMap.get("pword");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUser(userName, password);
// HashMap<String,Object>responseMap = new HashMap<>();
// String sessionID = "";
// if(foundUser != null){
// UUID sessionUUID = UUID.randomUUID();
// sessionID = sessionUUID.toString();
// foundUser.setSession(sessionID);
// theModel.updateUser(foundUser);
// responseMap.put("id",sessionID);
// }
// responseMap.put("id",sessionID);
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: LogoutHandler.java
// public class LogoutHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
//
// String sessionID = (String)dataMap.get("id");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUserBySessionID(sessionID);
// if(foundUser != null){
// foundUser.setSession("");
// theModel.updateUser(foundUser);
// }
// HashMap<String,Object> responseMap = new HashMap<>();
// responseMap.put("id","");
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: RegistrationHandler.java
// public class RegistrationHandler implements Handler {
// @Override
// public void handleIt(HashMap<String, Object> dataMap) {
// String userName = (String)dataMap.get("uname");
// String password = (String)dataMap.get("pword");
// StoreModel theModel = (StoreModel)dataMap.get("model");
// User foundUser = theModel.getUser(userName, password);
// HashMap<String,Object>responseMap = new HashMap<>();
// String sessionID = "";
// if(foundUser == null){
// UUID sessionUUID = UUID.randomUUID();
// sessionID = sessionUUID.toString();
// User aUser = new User();
// aUser.setSession(sessionID);
// aUser.setUname(userName);
// aUser.setPword(password);
// theModel.addUser(aUser);
// responseMap.put("id",sessionID);
// }
// responseMap.put("id",sessionID);
// JSONOutputStream outToClient = (JSONOutputStream)dataMap.get("toClient");
// try {
// outToClient.writeObject(responseMap);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
// Path: StoreServlet.java
import com.doing.more.java.example.appcontrol.ApplicationController;
import com.doing.more.java.example.handlers.LoginHandler;
import com.doing.more.java.example.handlers.LogoutHandler;
import com.doing.more.java.example.handlers.RegistrationHandler;
import json.JSONInputStream;
import json.JSONOutputStream;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
package com.doing.more.java.example;
@WebServlet(name = "StoreServlet")
public class StoreServlet extends HttpServlet {
private ApplicationController theAppController = new ApplicationController();
private StoreModel theModel = new StoreModel();
public void init(){
theAppController.mapCommand("register", new RegistrationHandler());
theAppController.mapCommand("login", new LoginHandler()); | theAppController.mapCommand("logout", new LogoutHandler()); |
yenrab/doing_more_with_java | StoreModel.java | // Path: User.java
// @Entity
// @Table(name = "app_user")
// public class User {
//
// @Id
// @GeneratedValue
// private Integer id;
// private String uname;
// private String pword;
// private int active;
// private int manager_level;
// private String session;
//
// /*
// * one User can have many phone numbers. CascadeType.ALL causes associated
// * phone numbers to be deleted when a User is deleted.
// */
// @ManyToMany(cascade=CascadeType.ALL)
// @JoinTable(
// name="user_number",
// joinColumns = { @JoinColumn( name="user_id") },
// inverseJoinColumns = @JoinColumn( name="phone_id")
// )
// private Set<PhoneNumber> phoneNumbers;
// public User() {
// this.active = 1;
// this.manager_level = 0;
// this.session = "";
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", uname='" + uname + '\'' +
// ", pword='" + pword + '\'' +
// ", active=" + active +
// ", manager_level=" + manager_level +
// ", session='" + session + '\'' +
// ", phoneNumbers=" + phoneNumbers +
// '}';
// }
//
// public Integer getId() {
// return id;
// }
// public void setId(Integer id) {
// this.id = id;
// }
// public String getUname() {
// return uname;
// }
// public void setUname(String uname) {
// this.uname = uname;
// }
// public String getPword() {
// return pword;
// }
// public void setPword(String pword) {
// this.pword = pword;
// }
// public Set<PhoneNumber> getPhoneNumbers() {
// return phoneNumbers;
// }
//
// public int getManager_level() {
// return manager_level;
// }
//
// public void setManager_level(int manager_level) {
// this.manager_level = manager_level;
// }
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
//
// public void setActive(int anIndicator){
// this.active = anIndicator;
// }
//
// public int getActive(){
// return this.active;
// }
// }
| import com.doing.more.java.example.User;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import java.lang.Exception;
import java.util.ArrayList;
import java.util.List;
import java.util.Set; | package com.doing.more.java.example;
/**
* Created by lee on 8/27/15.
*/
public class StoreModel {
private HibernateConfig theHibernateConfiguration;
public StoreModel(){
this.theHibernateConfiguration = new HibernateConfig();
} | // Path: User.java
// @Entity
// @Table(name = "app_user")
// public class User {
//
// @Id
// @GeneratedValue
// private Integer id;
// private String uname;
// private String pword;
// private int active;
// private int manager_level;
// private String session;
//
// /*
// * one User can have many phone numbers. CascadeType.ALL causes associated
// * phone numbers to be deleted when a User is deleted.
// */
// @ManyToMany(cascade=CascadeType.ALL)
// @JoinTable(
// name="user_number",
// joinColumns = { @JoinColumn( name="user_id") },
// inverseJoinColumns = @JoinColumn( name="phone_id")
// )
// private Set<PhoneNumber> phoneNumbers;
// public User() {
// this.active = 1;
// this.manager_level = 0;
// this.session = "";
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", uname='" + uname + '\'' +
// ", pword='" + pword + '\'' +
// ", active=" + active +
// ", manager_level=" + manager_level +
// ", session='" + session + '\'' +
// ", phoneNumbers=" + phoneNumbers +
// '}';
// }
//
// public Integer getId() {
// return id;
// }
// public void setId(Integer id) {
// this.id = id;
// }
// public String getUname() {
// return uname;
// }
// public void setUname(String uname) {
// this.uname = uname;
// }
// public String getPword() {
// return pword;
// }
// public void setPword(String pword) {
// this.pword = pword;
// }
// public Set<PhoneNumber> getPhoneNumbers() {
// return phoneNumbers;
// }
//
// public int getManager_level() {
// return manager_level;
// }
//
// public void setManager_level(int manager_level) {
// this.manager_level = manager_level;
// }
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
//
// public void setActive(int anIndicator){
// this.active = anIndicator;
// }
//
// public int getActive(){
// return this.active;
// }
// }
// Path: StoreModel.java
import com.doing.more.java.example.User;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import java.lang.Exception;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
package com.doing.more.java.example;
/**
* Created by lee on 8/27/15.
*/
public class StoreModel {
private HibernateConfig theHibernateConfiguration;
public StoreModel(){
this.theHibernateConfiguration = new HibernateConfig();
} | public void addUser(User aUser){ |
yenrab/doing_more_with_java | LoginHandler.java | // Path: StoreModel.java
// public class StoreModel {
// private HibernateConfig theHibernateConfiguration;
// public StoreModel(){
// this.theHibernateConfiguration = new HibernateConfig();
// }
// public void addUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.save(aUser);
// transaction.commit();
// }
// public void updateUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.merge(aUser);
// transaction.commit();
// }
//
// public ArrayList getAllUsers(){
// return this.getAll("");
// }
// public ArrayList getAllCustomers(){
// return this.getAll(" where u.manager_level == 0");
// }
// public ArrayList getAllManagers(){
// return this.getAll(" where u.manager_level > 0");
// }
// public ArrayList getAllManagersByLevel(int aLevel){
// return this.getAll(" where u.manager_level == "+aLevel);
// }
// private ArrayList getAll(String whereClause){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query allUsersQuery = theSession.createQuery("select u from User as u order by u.id" + whereClause);
// List userList = allUsersQuery.list();
// return new ArrayList(userList);
// }
//
// public User getUser(String aName, String aPassword){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.uname="+aName+ "and u.pword = "+aPassword);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// public User getUserBySessionID(String aSessionID){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.session="+aSessionID);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// }
//
// Path: User.java
// @Entity
// @Table(name = "app_user")
// public class User {
//
// @Id
// @GeneratedValue
// private Integer id;
// private String uname;
// private String pword;
// private int active;
// private int manager_level;
// private String session;
//
// /*
// * one User can have many phone numbers. CascadeType.ALL causes associated
// * phone numbers to be deleted when a User is deleted.
// */
// @ManyToMany(cascade=CascadeType.ALL)
// @JoinTable(
// name="user_number",
// joinColumns = { @JoinColumn( name="user_id") },
// inverseJoinColumns = @JoinColumn( name="phone_id")
// )
// private Set<PhoneNumber> phoneNumbers;
// public User() {
// this.active = 1;
// this.manager_level = 0;
// this.session = "";
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", uname='" + uname + '\'' +
// ", pword='" + pword + '\'' +
// ", active=" + active +
// ", manager_level=" + manager_level +
// ", session='" + session + '\'' +
// ", phoneNumbers=" + phoneNumbers +
// '}';
// }
//
// public Integer getId() {
// return id;
// }
// public void setId(Integer id) {
// this.id = id;
// }
// public String getUname() {
// return uname;
// }
// public void setUname(String uname) {
// this.uname = uname;
// }
// public String getPword() {
// return pword;
// }
// public void setPword(String pword) {
// this.pword = pword;
// }
// public Set<PhoneNumber> getPhoneNumbers() {
// return phoneNumbers;
// }
//
// public int getManager_level() {
// return manager_level;
// }
//
// public void setManager_level(int manager_level) {
// this.manager_level = manager_level;
// }
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
//
// public void setActive(int anIndicator){
// this.active = anIndicator;
// }
//
// public int getActive(){
// return this.active;
// }
// }
| import com.doing.more.java.example.StoreModel;
import com.doing.more.java.example.User;
import com.doing.more.java.example.appcontrol.Handler;
import json.JSONOutputStream;
import java.util.HashMap;
import java.util.UUID; | package com.doing.more.java.example.handlers;
public class LoginHandler implements Handler {
@Override
public void handleIt(HashMap<String, Object> dataMap) {
String userName = (String)dataMap.get("uname");
String password = (String)dataMap.get("pword"); | // Path: StoreModel.java
// public class StoreModel {
// private HibernateConfig theHibernateConfiguration;
// public StoreModel(){
// this.theHibernateConfiguration = new HibernateConfig();
// }
// public void addUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.save(aUser);
// transaction.commit();
// }
// public void updateUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.merge(aUser);
// transaction.commit();
// }
//
// public ArrayList getAllUsers(){
// return this.getAll("");
// }
// public ArrayList getAllCustomers(){
// return this.getAll(" where u.manager_level == 0");
// }
// public ArrayList getAllManagers(){
// return this.getAll(" where u.manager_level > 0");
// }
// public ArrayList getAllManagersByLevel(int aLevel){
// return this.getAll(" where u.manager_level == "+aLevel);
// }
// private ArrayList getAll(String whereClause){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query allUsersQuery = theSession.createQuery("select u from User as u order by u.id" + whereClause);
// List userList = allUsersQuery.list();
// return new ArrayList(userList);
// }
//
// public User getUser(String aName, String aPassword){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.uname="+aName+ "and u.pword = "+aPassword);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// public User getUserBySessionID(String aSessionID){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.session="+aSessionID);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// }
//
// Path: User.java
// @Entity
// @Table(name = "app_user")
// public class User {
//
// @Id
// @GeneratedValue
// private Integer id;
// private String uname;
// private String pword;
// private int active;
// private int manager_level;
// private String session;
//
// /*
// * one User can have many phone numbers. CascadeType.ALL causes associated
// * phone numbers to be deleted when a User is deleted.
// */
// @ManyToMany(cascade=CascadeType.ALL)
// @JoinTable(
// name="user_number",
// joinColumns = { @JoinColumn( name="user_id") },
// inverseJoinColumns = @JoinColumn( name="phone_id")
// )
// private Set<PhoneNumber> phoneNumbers;
// public User() {
// this.active = 1;
// this.manager_level = 0;
// this.session = "";
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", uname='" + uname + '\'' +
// ", pword='" + pword + '\'' +
// ", active=" + active +
// ", manager_level=" + manager_level +
// ", session='" + session + '\'' +
// ", phoneNumbers=" + phoneNumbers +
// '}';
// }
//
// public Integer getId() {
// return id;
// }
// public void setId(Integer id) {
// this.id = id;
// }
// public String getUname() {
// return uname;
// }
// public void setUname(String uname) {
// this.uname = uname;
// }
// public String getPword() {
// return pword;
// }
// public void setPword(String pword) {
// this.pword = pword;
// }
// public Set<PhoneNumber> getPhoneNumbers() {
// return phoneNumbers;
// }
//
// public int getManager_level() {
// return manager_level;
// }
//
// public void setManager_level(int manager_level) {
// this.manager_level = manager_level;
// }
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
//
// public void setActive(int anIndicator){
// this.active = anIndicator;
// }
//
// public int getActive(){
// return this.active;
// }
// }
// Path: LoginHandler.java
import com.doing.more.java.example.StoreModel;
import com.doing.more.java.example.User;
import com.doing.more.java.example.appcontrol.Handler;
import json.JSONOutputStream;
import java.util.HashMap;
import java.util.UUID;
package com.doing.more.java.example.handlers;
public class LoginHandler implements Handler {
@Override
public void handleIt(HashMap<String, Object> dataMap) {
String userName = (String)dataMap.get("uname");
String password = (String)dataMap.get("pword"); | StoreModel theModel = (StoreModel)dataMap.get("model"); |
yenrab/doing_more_with_java | LoginHandler.java | // Path: StoreModel.java
// public class StoreModel {
// private HibernateConfig theHibernateConfiguration;
// public StoreModel(){
// this.theHibernateConfiguration = new HibernateConfig();
// }
// public void addUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.save(aUser);
// transaction.commit();
// }
// public void updateUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.merge(aUser);
// transaction.commit();
// }
//
// public ArrayList getAllUsers(){
// return this.getAll("");
// }
// public ArrayList getAllCustomers(){
// return this.getAll(" where u.manager_level == 0");
// }
// public ArrayList getAllManagers(){
// return this.getAll(" where u.manager_level > 0");
// }
// public ArrayList getAllManagersByLevel(int aLevel){
// return this.getAll(" where u.manager_level == "+aLevel);
// }
// private ArrayList getAll(String whereClause){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query allUsersQuery = theSession.createQuery("select u from User as u order by u.id" + whereClause);
// List userList = allUsersQuery.list();
// return new ArrayList(userList);
// }
//
// public User getUser(String aName, String aPassword){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.uname="+aName+ "and u.pword = "+aPassword);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// public User getUserBySessionID(String aSessionID){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.session="+aSessionID);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// }
//
// Path: User.java
// @Entity
// @Table(name = "app_user")
// public class User {
//
// @Id
// @GeneratedValue
// private Integer id;
// private String uname;
// private String pword;
// private int active;
// private int manager_level;
// private String session;
//
// /*
// * one User can have many phone numbers. CascadeType.ALL causes associated
// * phone numbers to be deleted when a User is deleted.
// */
// @ManyToMany(cascade=CascadeType.ALL)
// @JoinTable(
// name="user_number",
// joinColumns = { @JoinColumn( name="user_id") },
// inverseJoinColumns = @JoinColumn( name="phone_id")
// )
// private Set<PhoneNumber> phoneNumbers;
// public User() {
// this.active = 1;
// this.manager_level = 0;
// this.session = "";
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", uname='" + uname + '\'' +
// ", pword='" + pword + '\'' +
// ", active=" + active +
// ", manager_level=" + manager_level +
// ", session='" + session + '\'' +
// ", phoneNumbers=" + phoneNumbers +
// '}';
// }
//
// public Integer getId() {
// return id;
// }
// public void setId(Integer id) {
// this.id = id;
// }
// public String getUname() {
// return uname;
// }
// public void setUname(String uname) {
// this.uname = uname;
// }
// public String getPword() {
// return pword;
// }
// public void setPword(String pword) {
// this.pword = pword;
// }
// public Set<PhoneNumber> getPhoneNumbers() {
// return phoneNumbers;
// }
//
// public int getManager_level() {
// return manager_level;
// }
//
// public void setManager_level(int manager_level) {
// this.manager_level = manager_level;
// }
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
//
// public void setActive(int anIndicator){
// this.active = anIndicator;
// }
//
// public int getActive(){
// return this.active;
// }
// }
| import com.doing.more.java.example.StoreModel;
import com.doing.more.java.example.User;
import com.doing.more.java.example.appcontrol.Handler;
import json.JSONOutputStream;
import java.util.HashMap;
import java.util.UUID; | package com.doing.more.java.example.handlers;
public class LoginHandler implements Handler {
@Override
public void handleIt(HashMap<String, Object> dataMap) {
String userName = (String)dataMap.get("uname");
String password = (String)dataMap.get("pword");
StoreModel theModel = (StoreModel)dataMap.get("model"); | // Path: StoreModel.java
// public class StoreModel {
// private HibernateConfig theHibernateConfiguration;
// public StoreModel(){
// this.theHibernateConfiguration = new HibernateConfig();
// }
// public void addUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.save(aUser);
// transaction.commit();
// }
// public void updateUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.merge(aUser);
// transaction.commit();
// }
//
// public ArrayList getAllUsers(){
// return this.getAll("");
// }
// public ArrayList getAllCustomers(){
// return this.getAll(" where u.manager_level == 0");
// }
// public ArrayList getAllManagers(){
// return this.getAll(" where u.manager_level > 0");
// }
// public ArrayList getAllManagersByLevel(int aLevel){
// return this.getAll(" where u.manager_level == "+aLevel);
// }
// private ArrayList getAll(String whereClause){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query allUsersQuery = theSession.createQuery("select u from User as u order by u.id" + whereClause);
// List userList = allUsersQuery.list();
// return new ArrayList(userList);
// }
//
// public User getUser(String aName, String aPassword){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.uname="+aName+ "and u.pword = "+aPassword);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// public User getUserBySessionID(String aSessionID){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.session="+aSessionID);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// }
//
// Path: User.java
// @Entity
// @Table(name = "app_user")
// public class User {
//
// @Id
// @GeneratedValue
// private Integer id;
// private String uname;
// private String pword;
// private int active;
// private int manager_level;
// private String session;
//
// /*
// * one User can have many phone numbers. CascadeType.ALL causes associated
// * phone numbers to be deleted when a User is deleted.
// */
// @ManyToMany(cascade=CascadeType.ALL)
// @JoinTable(
// name="user_number",
// joinColumns = { @JoinColumn( name="user_id") },
// inverseJoinColumns = @JoinColumn( name="phone_id")
// )
// private Set<PhoneNumber> phoneNumbers;
// public User() {
// this.active = 1;
// this.manager_level = 0;
// this.session = "";
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", uname='" + uname + '\'' +
// ", pword='" + pword + '\'' +
// ", active=" + active +
// ", manager_level=" + manager_level +
// ", session='" + session + '\'' +
// ", phoneNumbers=" + phoneNumbers +
// '}';
// }
//
// public Integer getId() {
// return id;
// }
// public void setId(Integer id) {
// this.id = id;
// }
// public String getUname() {
// return uname;
// }
// public void setUname(String uname) {
// this.uname = uname;
// }
// public String getPword() {
// return pword;
// }
// public void setPword(String pword) {
// this.pword = pword;
// }
// public Set<PhoneNumber> getPhoneNumbers() {
// return phoneNumbers;
// }
//
// public int getManager_level() {
// return manager_level;
// }
//
// public void setManager_level(int manager_level) {
// this.manager_level = manager_level;
// }
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
//
// public void setActive(int anIndicator){
// this.active = anIndicator;
// }
//
// public int getActive(){
// return this.active;
// }
// }
// Path: LoginHandler.java
import com.doing.more.java.example.StoreModel;
import com.doing.more.java.example.User;
import com.doing.more.java.example.appcontrol.Handler;
import json.JSONOutputStream;
import java.util.HashMap;
import java.util.UUID;
package com.doing.more.java.example.handlers;
public class LoginHandler implements Handler {
@Override
public void handleIt(HashMap<String, Object> dataMap) {
String userName = (String)dataMap.get("uname");
String password = (String)dataMap.get("pword");
StoreModel theModel = (StoreModel)dataMap.get("model"); | User foundUser = theModel.getUser(userName, password); |
yenrab/doing_more_with_java | LogoutHandler.java | // Path: StoreModel.java
// public class StoreModel {
// private HibernateConfig theHibernateConfiguration;
// public StoreModel(){
// this.theHibernateConfiguration = new HibernateConfig();
// }
// public void addUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.save(aUser);
// transaction.commit();
// }
// public void updateUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.merge(aUser);
// transaction.commit();
// }
//
// public ArrayList getAllUsers(){
// return this.getAll("");
// }
// public ArrayList getAllCustomers(){
// return this.getAll(" where u.manager_level == 0");
// }
// public ArrayList getAllManagers(){
// return this.getAll(" where u.manager_level > 0");
// }
// public ArrayList getAllManagersByLevel(int aLevel){
// return this.getAll(" where u.manager_level == "+aLevel);
// }
// private ArrayList getAll(String whereClause){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query allUsersQuery = theSession.createQuery("select u from User as u order by u.id" + whereClause);
// List userList = allUsersQuery.list();
// return new ArrayList(userList);
// }
//
// public User getUser(String aName, String aPassword){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.uname="+aName+ "and u.pword = "+aPassword);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// public User getUserBySessionID(String aSessionID){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.session="+aSessionID);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// }
//
// Path: User.java
// @Entity
// @Table(name = "app_user")
// public class User {
//
// @Id
// @GeneratedValue
// private Integer id;
// private String uname;
// private String pword;
// private int active;
// private int manager_level;
// private String session;
//
// /*
// * one User can have many phone numbers. CascadeType.ALL causes associated
// * phone numbers to be deleted when a User is deleted.
// */
// @ManyToMany(cascade=CascadeType.ALL)
// @JoinTable(
// name="user_number",
// joinColumns = { @JoinColumn( name="user_id") },
// inverseJoinColumns = @JoinColumn( name="phone_id")
// )
// private Set<PhoneNumber> phoneNumbers;
// public User() {
// this.active = 1;
// this.manager_level = 0;
// this.session = "";
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", uname='" + uname + '\'' +
// ", pword='" + pword + '\'' +
// ", active=" + active +
// ", manager_level=" + manager_level +
// ", session='" + session + '\'' +
// ", phoneNumbers=" + phoneNumbers +
// '}';
// }
//
// public Integer getId() {
// return id;
// }
// public void setId(Integer id) {
// this.id = id;
// }
// public String getUname() {
// return uname;
// }
// public void setUname(String uname) {
// this.uname = uname;
// }
// public String getPword() {
// return pword;
// }
// public void setPword(String pword) {
// this.pword = pword;
// }
// public Set<PhoneNumber> getPhoneNumbers() {
// return phoneNumbers;
// }
//
// public int getManager_level() {
// return manager_level;
// }
//
// public void setManager_level(int manager_level) {
// this.manager_level = manager_level;
// }
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
//
// public void setActive(int anIndicator){
// this.active = anIndicator;
// }
//
// public int getActive(){
// return this.active;
// }
// }
| import com.doing.more.java.example.StoreModel;
import com.doing.more.java.example.User;
import com.doing.more.java.example.appcontrol.Handler;
import json.JSONOutputStream;
import java.util.HashMap; | package com.doing.more.java.example.handlers;
public class LogoutHandler implements Handler {
@Override
public void handleIt(HashMap<String, Object> dataMap) {
String sessionID = (String)dataMap.get("id"); | // Path: StoreModel.java
// public class StoreModel {
// private HibernateConfig theHibernateConfiguration;
// public StoreModel(){
// this.theHibernateConfiguration = new HibernateConfig();
// }
// public void addUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.save(aUser);
// transaction.commit();
// }
// public void updateUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.merge(aUser);
// transaction.commit();
// }
//
// public ArrayList getAllUsers(){
// return this.getAll("");
// }
// public ArrayList getAllCustomers(){
// return this.getAll(" where u.manager_level == 0");
// }
// public ArrayList getAllManagers(){
// return this.getAll(" where u.manager_level > 0");
// }
// public ArrayList getAllManagersByLevel(int aLevel){
// return this.getAll(" where u.manager_level == "+aLevel);
// }
// private ArrayList getAll(String whereClause){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query allUsersQuery = theSession.createQuery("select u from User as u order by u.id" + whereClause);
// List userList = allUsersQuery.list();
// return new ArrayList(userList);
// }
//
// public User getUser(String aName, String aPassword){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.uname="+aName+ "and u.pword = "+aPassword);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// public User getUserBySessionID(String aSessionID){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.session="+aSessionID);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// }
//
// Path: User.java
// @Entity
// @Table(name = "app_user")
// public class User {
//
// @Id
// @GeneratedValue
// private Integer id;
// private String uname;
// private String pword;
// private int active;
// private int manager_level;
// private String session;
//
// /*
// * one User can have many phone numbers. CascadeType.ALL causes associated
// * phone numbers to be deleted when a User is deleted.
// */
// @ManyToMany(cascade=CascadeType.ALL)
// @JoinTable(
// name="user_number",
// joinColumns = { @JoinColumn( name="user_id") },
// inverseJoinColumns = @JoinColumn( name="phone_id")
// )
// private Set<PhoneNumber> phoneNumbers;
// public User() {
// this.active = 1;
// this.manager_level = 0;
// this.session = "";
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", uname='" + uname + '\'' +
// ", pword='" + pword + '\'' +
// ", active=" + active +
// ", manager_level=" + manager_level +
// ", session='" + session + '\'' +
// ", phoneNumbers=" + phoneNumbers +
// '}';
// }
//
// public Integer getId() {
// return id;
// }
// public void setId(Integer id) {
// this.id = id;
// }
// public String getUname() {
// return uname;
// }
// public void setUname(String uname) {
// this.uname = uname;
// }
// public String getPword() {
// return pword;
// }
// public void setPword(String pword) {
// this.pword = pword;
// }
// public Set<PhoneNumber> getPhoneNumbers() {
// return phoneNumbers;
// }
//
// public int getManager_level() {
// return manager_level;
// }
//
// public void setManager_level(int manager_level) {
// this.manager_level = manager_level;
// }
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
//
// public void setActive(int anIndicator){
// this.active = anIndicator;
// }
//
// public int getActive(){
// return this.active;
// }
// }
// Path: LogoutHandler.java
import com.doing.more.java.example.StoreModel;
import com.doing.more.java.example.User;
import com.doing.more.java.example.appcontrol.Handler;
import json.JSONOutputStream;
import java.util.HashMap;
package com.doing.more.java.example.handlers;
public class LogoutHandler implements Handler {
@Override
public void handleIt(HashMap<String, Object> dataMap) {
String sessionID = (String)dataMap.get("id"); | StoreModel theModel = (StoreModel)dataMap.get("model"); |
yenrab/doing_more_with_java | LogoutHandler.java | // Path: StoreModel.java
// public class StoreModel {
// private HibernateConfig theHibernateConfiguration;
// public StoreModel(){
// this.theHibernateConfiguration = new HibernateConfig();
// }
// public void addUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.save(aUser);
// transaction.commit();
// }
// public void updateUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.merge(aUser);
// transaction.commit();
// }
//
// public ArrayList getAllUsers(){
// return this.getAll("");
// }
// public ArrayList getAllCustomers(){
// return this.getAll(" where u.manager_level == 0");
// }
// public ArrayList getAllManagers(){
// return this.getAll(" where u.manager_level > 0");
// }
// public ArrayList getAllManagersByLevel(int aLevel){
// return this.getAll(" where u.manager_level == "+aLevel);
// }
// private ArrayList getAll(String whereClause){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query allUsersQuery = theSession.createQuery("select u from User as u order by u.id" + whereClause);
// List userList = allUsersQuery.list();
// return new ArrayList(userList);
// }
//
// public User getUser(String aName, String aPassword){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.uname="+aName+ "and u.pword = "+aPassword);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// public User getUserBySessionID(String aSessionID){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.session="+aSessionID);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// }
//
// Path: User.java
// @Entity
// @Table(name = "app_user")
// public class User {
//
// @Id
// @GeneratedValue
// private Integer id;
// private String uname;
// private String pword;
// private int active;
// private int manager_level;
// private String session;
//
// /*
// * one User can have many phone numbers. CascadeType.ALL causes associated
// * phone numbers to be deleted when a User is deleted.
// */
// @ManyToMany(cascade=CascadeType.ALL)
// @JoinTable(
// name="user_number",
// joinColumns = { @JoinColumn( name="user_id") },
// inverseJoinColumns = @JoinColumn( name="phone_id")
// )
// private Set<PhoneNumber> phoneNumbers;
// public User() {
// this.active = 1;
// this.manager_level = 0;
// this.session = "";
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", uname='" + uname + '\'' +
// ", pword='" + pword + '\'' +
// ", active=" + active +
// ", manager_level=" + manager_level +
// ", session='" + session + '\'' +
// ", phoneNumbers=" + phoneNumbers +
// '}';
// }
//
// public Integer getId() {
// return id;
// }
// public void setId(Integer id) {
// this.id = id;
// }
// public String getUname() {
// return uname;
// }
// public void setUname(String uname) {
// this.uname = uname;
// }
// public String getPword() {
// return pword;
// }
// public void setPword(String pword) {
// this.pword = pword;
// }
// public Set<PhoneNumber> getPhoneNumbers() {
// return phoneNumbers;
// }
//
// public int getManager_level() {
// return manager_level;
// }
//
// public void setManager_level(int manager_level) {
// this.manager_level = manager_level;
// }
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
//
// public void setActive(int anIndicator){
// this.active = anIndicator;
// }
//
// public int getActive(){
// return this.active;
// }
// }
| import com.doing.more.java.example.StoreModel;
import com.doing.more.java.example.User;
import com.doing.more.java.example.appcontrol.Handler;
import json.JSONOutputStream;
import java.util.HashMap; | package com.doing.more.java.example.handlers;
public class LogoutHandler implements Handler {
@Override
public void handleIt(HashMap<String, Object> dataMap) {
String sessionID = (String)dataMap.get("id");
StoreModel theModel = (StoreModel)dataMap.get("model"); | // Path: StoreModel.java
// public class StoreModel {
// private HibernateConfig theHibernateConfiguration;
// public StoreModel(){
// this.theHibernateConfiguration = new HibernateConfig();
// }
// public void addUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.save(aUser);
// transaction.commit();
// }
// public void updateUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.merge(aUser);
// transaction.commit();
// }
//
// public ArrayList getAllUsers(){
// return this.getAll("");
// }
// public ArrayList getAllCustomers(){
// return this.getAll(" where u.manager_level == 0");
// }
// public ArrayList getAllManagers(){
// return this.getAll(" where u.manager_level > 0");
// }
// public ArrayList getAllManagersByLevel(int aLevel){
// return this.getAll(" where u.manager_level == "+aLevel);
// }
// private ArrayList getAll(String whereClause){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query allUsersQuery = theSession.createQuery("select u from User as u order by u.id" + whereClause);
// List userList = allUsersQuery.list();
// return new ArrayList(userList);
// }
//
// public User getUser(String aName, String aPassword){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.uname="+aName+ "and u.pword = "+aPassword);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// public User getUserBySessionID(String aSessionID){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.session="+aSessionID);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// }
//
// Path: User.java
// @Entity
// @Table(name = "app_user")
// public class User {
//
// @Id
// @GeneratedValue
// private Integer id;
// private String uname;
// private String pword;
// private int active;
// private int manager_level;
// private String session;
//
// /*
// * one User can have many phone numbers. CascadeType.ALL causes associated
// * phone numbers to be deleted when a User is deleted.
// */
// @ManyToMany(cascade=CascadeType.ALL)
// @JoinTable(
// name="user_number",
// joinColumns = { @JoinColumn( name="user_id") },
// inverseJoinColumns = @JoinColumn( name="phone_id")
// )
// private Set<PhoneNumber> phoneNumbers;
// public User() {
// this.active = 1;
// this.manager_level = 0;
// this.session = "";
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", uname='" + uname + '\'' +
// ", pword='" + pword + '\'' +
// ", active=" + active +
// ", manager_level=" + manager_level +
// ", session='" + session + '\'' +
// ", phoneNumbers=" + phoneNumbers +
// '}';
// }
//
// public Integer getId() {
// return id;
// }
// public void setId(Integer id) {
// this.id = id;
// }
// public String getUname() {
// return uname;
// }
// public void setUname(String uname) {
// this.uname = uname;
// }
// public String getPword() {
// return pword;
// }
// public void setPword(String pword) {
// this.pword = pword;
// }
// public Set<PhoneNumber> getPhoneNumbers() {
// return phoneNumbers;
// }
//
// public int getManager_level() {
// return manager_level;
// }
//
// public void setManager_level(int manager_level) {
// this.manager_level = manager_level;
// }
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
//
// public void setActive(int anIndicator){
// this.active = anIndicator;
// }
//
// public int getActive(){
// return this.active;
// }
// }
// Path: LogoutHandler.java
import com.doing.more.java.example.StoreModel;
import com.doing.more.java.example.User;
import com.doing.more.java.example.appcontrol.Handler;
import json.JSONOutputStream;
import java.util.HashMap;
package com.doing.more.java.example.handlers;
public class LogoutHandler implements Handler {
@Override
public void handleIt(HashMap<String, Object> dataMap) {
String sessionID = (String)dataMap.get("id");
StoreModel theModel = (StoreModel)dataMap.get("model"); | User foundUser = theModel.getUserBySessionID(sessionID); |
yenrab/doing_more_with_java | RegistrationHandler.java | // Path: StoreModel.java
// public class StoreModel {
// private HibernateConfig theHibernateConfiguration;
// public StoreModel(){
// this.theHibernateConfiguration = new HibernateConfig();
// }
// public void addUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.save(aUser);
// transaction.commit();
// }
// public void updateUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.merge(aUser);
// transaction.commit();
// }
//
// public ArrayList getAllUsers(){
// return this.getAll("");
// }
// public ArrayList getAllCustomers(){
// return this.getAll(" where u.manager_level == 0");
// }
// public ArrayList getAllManagers(){
// return this.getAll(" where u.manager_level > 0");
// }
// public ArrayList getAllManagersByLevel(int aLevel){
// return this.getAll(" where u.manager_level == "+aLevel);
// }
// private ArrayList getAll(String whereClause){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query allUsersQuery = theSession.createQuery("select u from User as u order by u.id" + whereClause);
// List userList = allUsersQuery.list();
// return new ArrayList(userList);
// }
//
// public User getUser(String aName, String aPassword){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.uname="+aName+ "and u.pword = "+aPassword);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// public User getUserBySessionID(String aSessionID){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.session="+aSessionID);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// }
//
// Path: User.java
// @Entity
// @Table(name = "app_user")
// public class User {
//
// @Id
// @GeneratedValue
// private Integer id;
// private String uname;
// private String pword;
// private int active;
// private int manager_level;
// private String session;
//
// /*
// * one User can have many phone numbers. CascadeType.ALL causes associated
// * phone numbers to be deleted when a User is deleted.
// */
// @ManyToMany(cascade=CascadeType.ALL)
// @JoinTable(
// name="user_number",
// joinColumns = { @JoinColumn( name="user_id") },
// inverseJoinColumns = @JoinColumn( name="phone_id")
// )
// private Set<PhoneNumber> phoneNumbers;
// public User() {
// this.active = 1;
// this.manager_level = 0;
// this.session = "";
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", uname='" + uname + '\'' +
// ", pword='" + pword + '\'' +
// ", active=" + active +
// ", manager_level=" + manager_level +
// ", session='" + session + '\'' +
// ", phoneNumbers=" + phoneNumbers +
// '}';
// }
//
// public Integer getId() {
// return id;
// }
// public void setId(Integer id) {
// this.id = id;
// }
// public String getUname() {
// return uname;
// }
// public void setUname(String uname) {
// this.uname = uname;
// }
// public String getPword() {
// return pword;
// }
// public void setPword(String pword) {
// this.pword = pword;
// }
// public Set<PhoneNumber> getPhoneNumbers() {
// return phoneNumbers;
// }
//
// public int getManager_level() {
// return manager_level;
// }
//
// public void setManager_level(int manager_level) {
// this.manager_level = manager_level;
// }
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
//
// public void setActive(int anIndicator){
// this.active = anIndicator;
// }
//
// public int getActive(){
// return this.active;
// }
// }
| import com.doing.more.java.example.StoreModel;
import com.doing.more.java.example.User;
import com.doing.more.java.example.appcontrol.Handler;
import json.JSONOutputStream;
import java.util.HashMap;
import java.util.UUID; | package com.doing.more.java.example.handlers;
public class RegistrationHandler implements Handler {
@Override
public void handleIt(HashMap<String, Object> dataMap) {
String userName = (String)dataMap.get("uname");
String password = (String)dataMap.get("pword"); | // Path: StoreModel.java
// public class StoreModel {
// private HibernateConfig theHibernateConfiguration;
// public StoreModel(){
// this.theHibernateConfiguration = new HibernateConfig();
// }
// public void addUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.save(aUser);
// transaction.commit();
// }
// public void updateUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.merge(aUser);
// transaction.commit();
// }
//
// public ArrayList getAllUsers(){
// return this.getAll("");
// }
// public ArrayList getAllCustomers(){
// return this.getAll(" where u.manager_level == 0");
// }
// public ArrayList getAllManagers(){
// return this.getAll(" where u.manager_level > 0");
// }
// public ArrayList getAllManagersByLevel(int aLevel){
// return this.getAll(" where u.manager_level == "+aLevel);
// }
// private ArrayList getAll(String whereClause){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query allUsersQuery = theSession.createQuery("select u from User as u order by u.id" + whereClause);
// List userList = allUsersQuery.list();
// return new ArrayList(userList);
// }
//
// public User getUser(String aName, String aPassword){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.uname="+aName+ "and u.pword = "+aPassword);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// public User getUserBySessionID(String aSessionID){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.session="+aSessionID);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// }
//
// Path: User.java
// @Entity
// @Table(name = "app_user")
// public class User {
//
// @Id
// @GeneratedValue
// private Integer id;
// private String uname;
// private String pword;
// private int active;
// private int manager_level;
// private String session;
//
// /*
// * one User can have many phone numbers. CascadeType.ALL causes associated
// * phone numbers to be deleted when a User is deleted.
// */
// @ManyToMany(cascade=CascadeType.ALL)
// @JoinTable(
// name="user_number",
// joinColumns = { @JoinColumn( name="user_id") },
// inverseJoinColumns = @JoinColumn( name="phone_id")
// )
// private Set<PhoneNumber> phoneNumbers;
// public User() {
// this.active = 1;
// this.manager_level = 0;
// this.session = "";
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", uname='" + uname + '\'' +
// ", pword='" + pword + '\'' +
// ", active=" + active +
// ", manager_level=" + manager_level +
// ", session='" + session + '\'' +
// ", phoneNumbers=" + phoneNumbers +
// '}';
// }
//
// public Integer getId() {
// return id;
// }
// public void setId(Integer id) {
// this.id = id;
// }
// public String getUname() {
// return uname;
// }
// public void setUname(String uname) {
// this.uname = uname;
// }
// public String getPword() {
// return pword;
// }
// public void setPword(String pword) {
// this.pword = pword;
// }
// public Set<PhoneNumber> getPhoneNumbers() {
// return phoneNumbers;
// }
//
// public int getManager_level() {
// return manager_level;
// }
//
// public void setManager_level(int manager_level) {
// this.manager_level = manager_level;
// }
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
//
// public void setActive(int anIndicator){
// this.active = anIndicator;
// }
//
// public int getActive(){
// return this.active;
// }
// }
// Path: RegistrationHandler.java
import com.doing.more.java.example.StoreModel;
import com.doing.more.java.example.User;
import com.doing.more.java.example.appcontrol.Handler;
import json.JSONOutputStream;
import java.util.HashMap;
import java.util.UUID;
package com.doing.more.java.example.handlers;
public class RegistrationHandler implements Handler {
@Override
public void handleIt(HashMap<String, Object> dataMap) {
String userName = (String)dataMap.get("uname");
String password = (String)dataMap.get("pword"); | StoreModel theModel = (StoreModel)dataMap.get("model"); |
yenrab/doing_more_with_java | RegistrationHandler.java | // Path: StoreModel.java
// public class StoreModel {
// private HibernateConfig theHibernateConfiguration;
// public StoreModel(){
// this.theHibernateConfiguration = new HibernateConfig();
// }
// public void addUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.save(aUser);
// transaction.commit();
// }
// public void updateUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.merge(aUser);
// transaction.commit();
// }
//
// public ArrayList getAllUsers(){
// return this.getAll("");
// }
// public ArrayList getAllCustomers(){
// return this.getAll(" where u.manager_level == 0");
// }
// public ArrayList getAllManagers(){
// return this.getAll(" where u.manager_level > 0");
// }
// public ArrayList getAllManagersByLevel(int aLevel){
// return this.getAll(" where u.manager_level == "+aLevel);
// }
// private ArrayList getAll(String whereClause){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query allUsersQuery = theSession.createQuery("select u from User as u order by u.id" + whereClause);
// List userList = allUsersQuery.list();
// return new ArrayList(userList);
// }
//
// public User getUser(String aName, String aPassword){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.uname="+aName+ "and u.pword = "+aPassword);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// public User getUserBySessionID(String aSessionID){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.session="+aSessionID);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// }
//
// Path: User.java
// @Entity
// @Table(name = "app_user")
// public class User {
//
// @Id
// @GeneratedValue
// private Integer id;
// private String uname;
// private String pword;
// private int active;
// private int manager_level;
// private String session;
//
// /*
// * one User can have many phone numbers. CascadeType.ALL causes associated
// * phone numbers to be deleted when a User is deleted.
// */
// @ManyToMany(cascade=CascadeType.ALL)
// @JoinTable(
// name="user_number",
// joinColumns = { @JoinColumn( name="user_id") },
// inverseJoinColumns = @JoinColumn( name="phone_id")
// )
// private Set<PhoneNumber> phoneNumbers;
// public User() {
// this.active = 1;
// this.manager_level = 0;
// this.session = "";
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", uname='" + uname + '\'' +
// ", pword='" + pword + '\'' +
// ", active=" + active +
// ", manager_level=" + manager_level +
// ", session='" + session + '\'' +
// ", phoneNumbers=" + phoneNumbers +
// '}';
// }
//
// public Integer getId() {
// return id;
// }
// public void setId(Integer id) {
// this.id = id;
// }
// public String getUname() {
// return uname;
// }
// public void setUname(String uname) {
// this.uname = uname;
// }
// public String getPword() {
// return pword;
// }
// public void setPword(String pword) {
// this.pword = pword;
// }
// public Set<PhoneNumber> getPhoneNumbers() {
// return phoneNumbers;
// }
//
// public int getManager_level() {
// return manager_level;
// }
//
// public void setManager_level(int manager_level) {
// this.manager_level = manager_level;
// }
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
//
// public void setActive(int anIndicator){
// this.active = anIndicator;
// }
//
// public int getActive(){
// return this.active;
// }
// }
| import com.doing.more.java.example.StoreModel;
import com.doing.more.java.example.User;
import com.doing.more.java.example.appcontrol.Handler;
import json.JSONOutputStream;
import java.util.HashMap;
import java.util.UUID; | package com.doing.more.java.example.handlers;
public class RegistrationHandler implements Handler {
@Override
public void handleIt(HashMap<String, Object> dataMap) {
String userName = (String)dataMap.get("uname");
String password = (String)dataMap.get("pword");
StoreModel theModel = (StoreModel)dataMap.get("model"); | // Path: StoreModel.java
// public class StoreModel {
// private HibernateConfig theHibernateConfiguration;
// public StoreModel(){
// this.theHibernateConfiguration = new HibernateConfig();
// }
// public void addUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.save(aUser);
// transaction.commit();
// }
// public void updateUser(User aUser){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// theSession.merge(aUser);
// transaction.commit();
// }
//
// public ArrayList getAllUsers(){
// return this.getAll("");
// }
// public ArrayList getAllCustomers(){
// return this.getAll(" where u.manager_level == 0");
// }
// public ArrayList getAllManagers(){
// return this.getAll(" where u.manager_level > 0");
// }
// public ArrayList getAllManagersByLevel(int aLevel){
// return this.getAll(" where u.manager_level == "+aLevel);
// }
// private ArrayList getAll(String whereClause){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query allUsersQuery = theSession.createQuery("select u from User as u order by u.id" + whereClause);
// List userList = allUsersQuery.list();
// return new ArrayList(userList);
// }
//
// public User getUser(String aName, String aPassword){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.uname="+aName+ "and u.pword = "+aPassword);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// public User getUserBySessionID(String aSessionID){
// Session theSession = this.theHibernateConfiguration.getCurrentSession();
// Transaction transaction = theSession.beginTransaction();
// Query singleUserQuery = theSession.createQuery("select u from User as u where u.session="+aSessionID);
// User theUser = (User)singleUserQuery.uniqueResult();
// return theUser;
// }
// }
//
// Path: User.java
// @Entity
// @Table(name = "app_user")
// public class User {
//
// @Id
// @GeneratedValue
// private Integer id;
// private String uname;
// private String pword;
// private int active;
// private int manager_level;
// private String session;
//
// /*
// * one User can have many phone numbers. CascadeType.ALL causes associated
// * phone numbers to be deleted when a User is deleted.
// */
// @ManyToMany(cascade=CascadeType.ALL)
// @JoinTable(
// name="user_number",
// joinColumns = { @JoinColumn( name="user_id") },
// inverseJoinColumns = @JoinColumn( name="phone_id")
// )
// private Set<PhoneNumber> phoneNumbers;
// public User() {
// this.active = 1;
// this.manager_level = 0;
// this.session = "";
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", uname='" + uname + '\'' +
// ", pword='" + pword + '\'' +
// ", active=" + active +
// ", manager_level=" + manager_level +
// ", session='" + session + '\'' +
// ", phoneNumbers=" + phoneNumbers +
// '}';
// }
//
// public Integer getId() {
// return id;
// }
// public void setId(Integer id) {
// this.id = id;
// }
// public String getUname() {
// return uname;
// }
// public void setUname(String uname) {
// this.uname = uname;
// }
// public String getPword() {
// return pword;
// }
// public void setPword(String pword) {
// this.pword = pword;
// }
// public Set<PhoneNumber> getPhoneNumbers() {
// return phoneNumbers;
// }
//
// public int getManager_level() {
// return manager_level;
// }
//
// public void setManager_level(int manager_level) {
// this.manager_level = manager_level;
// }
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
//
// public void setActive(int anIndicator){
// this.active = anIndicator;
// }
//
// public int getActive(){
// return this.active;
// }
// }
// Path: RegistrationHandler.java
import com.doing.more.java.example.StoreModel;
import com.doing.more.java.example.User;
import com.doing.more.java.example.appcontrol.Handler;
import json.JSONOutputStream;
import java.util.HashMap;
import java.util.UUID;
package com.doing.more.java.example.handlers;
public class RegistrationHandler implements Handler {
@Override
public void handleIt(HashMap<String, Object> dataMap) {
String userName = (String)dataMap.get("uname");
String password = (String)dataMap.get("pword");
StoreModel theModel = (StoreModel)dataMap.get("model"); | User foundUser = theModel.getUser(userName, password); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.