├── examples ├── readme.txt └── example │ ├── src │ ├── nosql │ │ └── Persistence.java │ └── com │ │ └── example │ │ └── db │ │ └── User.java │ └── .project ├── src ├── main │ └── java │ │ ├── nosql │ │ └── Persistence.java │ │ ├── com │ │ ├── impetus │ │ │ └── annovention │ │ │ │ ├── .svn │ │ │ │ ├── prop-base │ │ │ │ │ ├── Filter.java.svn-base │ │ │ │ │ ├── Discoverer.java.svn-base │ │ │ │ │ ├── FilterImpl.java.svn-base │ │ │ │ │ └── ClasspathDiscoverer.java.svn-base │ │ │ │ ├── all-wcprops │ │ │ │ └── text-base │ │ │ │ │ └── Filter.java.svn-base │ │ │ │ ├── resource │ │ │ │ ├── .svn │ │ │ │ │ ├── prop-base │ │ │ │ │ │ ├── ClassFileIterator.java.svn-base │ │ │ │ │ │ ├── JarFileIterator.java.svn-base │ │ │ │ │ │ └── ResourceIterator.java.svn-base │ │ │ │ │ ├── all-wcprops │ │ │ │ │ ├── text-base │ │ │ │ │ │ └── ResourceIterator.java.svn-base │ │ │ │ │ └── entries │ │ │ │ └── ResourceIterator.java │ │ │ │ ├── listener │ │ │ │ ├── .svn │ │ │ │ │ ├── prop-base │ │ │ │ │ │ ├── AnnotationDiscoveryListener.java.svn-base │ │ │ │ │ │ ├── ClassAnnotationDiscoveryListener.java.svn-base │ │ │ │ │ │ ├── FieldAnnotationDiscoveryListener.java.svn-base │ │ │ │ │ │ └── MethodAnnotationDiscoveryListener.java.svn-base │ │ │ │ │ ├── all-wcprops │ │ │ │ │ └── text-base │ │ │ │ │ │ ├── AnnotationDiscoveryListener.java.svn-base │ │ │ │ │ │ ├── ClassAnnotationDiscoveryListener.java.svn-base │ │ │ │ │ │ ├── FieldAnnotationDiscoveryListener.java.svn-base │ │ │ │ │ │ └── MethodAnnotationDiscoveryListener.java.svn-base │ │ │ │ ├── AnnotationDiscoveryListener.java │ │ │ │ ├── ClassAnnotationDiscoveryListener.java │ │ │ │ ├── FieldAnnotationDiscoveryListener.java │ │ │ │ └── MethodAnnotationDiscoveryListener.java │ │ │ │ └── Filter.java │ │ └── alvazan │ │ │ ├── orm │ │ │ ├── parser │ │ │ │ └── antlr │ │ │ │ │ ├── ChildSide.java │ │ │ │ │ ├── JoinType.java │ │ │ │ │ ├── PartitionMeta.java │ │ │ │ │ ├── MetaFacade.java │ │ │ │ │ ├── StateAttribute.java │ │ │ │ │ └── ParsedNode.java │ │ │ ├── api │ │ │ │ ├── base │ │ │ │ │ ├── anno │ │ │ │ │ │ ├── NoSqlInheritanceType.java │ │ │ │ │ │ ├── NoSqlTransient.java │ │ │ │ │ │ ├── NoSqlQueries.java │ │ │ │ │ │ ├── NoSqlQuery.java │ │ │ │ │ │ ├── NoSqlDiscriminatorColumn.java │ │ │ │ │ │ ├── NoSqlEmbeddable.java │ │ │ │ │ │ ├── NoSqlManyToOne.java │ │ │ │ │ │ ├── NoSqlOneToOne.java │ │ │ │ │ │ ├── NoSqlIndexed.java │ │ │ │ │ │ ├── NoSqlEmbedded.java │ │ │ │ │ │ ├── NoSqlPartitionByThisField.java │ │ │ │ │ │ ├── NoSqlInheritance.java │ │ │ │ │ │ ├── NoSqlTTL.java │ │ │ │ │ │ ├── NoSqlOneToMany.java │ │ │ │ │ │ ├── NoSqlManyToMany.java │ │ │ │ │ │ ├── NoSqlVirtualCf.java │ │ │ │ │ │ ├── NoSqlConverter.java │ │ │ │ │ │ ├── NoSqlEntity.java │ │ │ │ │ │ ├── NoSqlId.java │ │ │ │ │ │ └── NoSqlColumn.java │ │ │ │ │ ├── spi │ │ │ │ │ │ └── KeyGenerator.java │ │ │ │ │ ├── ToOneProvider.java │ │ │ │ │ ├── Indexing.java │ │ │ │ │ ├── NoSqlEntityManagerFactory.java │ │ │ │ │ ├── DbTypeEnum.java │ │ │ │ │ ├── CursorToMany.java │ │ │ │ │ ├── NoSqlDao.java │ │ │ │ │ ├── MetaLayer.java │ │ │ │ │ └── CursorToManyImpl.java │ │ │ │ ├── z8spi │ │ │ │ │ ├── action │ │ │ │ │ │ ├── RemoveEnum.java │ │ │ │ │ │ ├── Action.java │ │ │ │ │ │ ├── PersistIndex.java │ │ │ │ │ │ ├── RemoveColumn.java │ │ │ │ │ │ ├── Remove.java │ │ │ │ │ │ ├── RemoveIndex.java │ │ │ │ │ │ ├── Persist.java │ │ │ │ │ │ └── Column.java │ │ │ │ │ ├── MetaLoader.java │ │ │ │ │ ├── MetaLookup.java │ │ │ │ │ ├── meta │ │ │ │ │ │ ├── ViewInfo.java │ │ │ │ │ │ ├── NoSqlTypedRowProxy.java │ │ │ │ │ │ ├── PartitionTypeInfo.java │ │ │ │ │ │ ├── IndexData.java │ │ │ │ │ │ ├── DboColumnMarkerMeta.java │ │ │ │ │ │ ├── TypeInfo.java │ │ │ │ │ │ ├── DboDatabaseMeta.java │ │ │ │ │ │ ├── InfoForIndex.java │ │ │ │ │ │ └── ReflectionUtil.java │ │ │ │ │ ├── ColumnType.java │ │ │ │ │ ├── BatchListener.java │ │ │ │ │ ├── SpiConstants.java │ │ │ │ │ ├── conv │ │ │ │ │ │ ├── Precondition.java │ │ │ │ │ │ └── Converter.java │ │ │ │ │ ├── Cache.java │ │ │ │ │ ├── iter │ │ │ │ │ │ ├── DirectCursor.java │ │ │ │ │ │ ├── Cursor.java │ │ │ │ │ │ ├── EmptyCursor.java │ │ │ │ │ │ ├── StringLocal.java │ │ │ │ │ │ ├── AbstractCursor.java │ │ │ │ │ │ ├── ProxyTempCursor.java │ │ │ │ │ │ ├── IterableWrappingCursor.java │ │ │ │ │ │ ├── ListWrappingCursor.java │ │ │ │ │ │ ├── IndiceToVirtual.java │ │ │ │ │ │ └── AbstractIterator.java │ │ │ │ │ ├── CacheThreadLocal.java │ │ │ │ │ ├── RowHolder.java │ │ │ │ │ ├── CreateCfCallback.java │ │ │ │ │ ├── Key.java │ │ │ │ │ ├── KeyValue.java │ │ │ │ │ ├── Row.java │ │ │ │ │ └── ColumnSliceInfo.java │ │ │ │ ├── exc │ │ │ │ │ ├── ParseException.java │ │ │ │ │ ├── RowNotFoundException.java │ │ │ │ │ ├── TooManyResultException.java │ │ │ │ │ ├── TypeMismatchException.java │ │ │ │ │ ├── NoSqlOrmException.java │ │ │ │ │ ├── PkIsNullException.java │ │ │ │ │ ├── StorageMissingEntitesException.java │ │ │ │ │ └── ChildWithNoPkException.java │ │ │ │ ├── z3api │ │ │ │ │ ├── TimeValColumn.java │ │ │ │ │ └── QueryResult.java │ │ │ │ └── z5api │ │ │ │ │ ├── NoConversion.java │ │ │ │ │ ├── QueryParser.java │ │ │ │ │ ├── SpiQueryAdapter.java │ │ │ │ │ ├── SpiMetaQuery.java │ │ │ │ │ └── IndexPoint.java │ │ │ ├── logging │ │ │ │ └── ScanType.java │ │ │ ├── impl │ │ │ │ └── meta │ │ │ │ │ └── data │ │ │ │ │ ├── collections │ │ │ │ │ ├── CacheLoadCallback.java │ │ │ │ │ ├── SimpleSet.java │ │ │ │ │ └── ToOneProviderProxy.java │ │ │ │ │ ├── NoSqlProxy.java │ │ │ │ │ ├── Tuple.java │ │ │ │ │ ├── MetaComparator.java │ │ │ │ │ ├── readme.txt │ │ │ │ │ ├── EmbedInfo.java │ │ │ │ │ ├── MetaClass.java │ │ │ │ │ ├── IdInfo.java │ │ │ │ │ └── MetaField.java │ │ │ ├── layer9z │ │ │ │ └── spi │ │ │ │ │ └── db │ │ │ │ │ ├── inmemory │ │ │ │ │ ├── SortType.java │ │ │ │ │ ├── NoSqlDatabase.java │ │ │ │ │ ├── DecimalComparator.java │ │ │ │ │ ├── IntegerComparator.java │ │ │ │ │ ├── Utf8Comparator.java │ │ │ │ │ └── PrefixComparator.java │ │ │ │ │ ├── cassandracql3 │ │ │ │ │ ├── StartQueryListener.java │ │ │ │ │ ├── Info.java │ │ │ │ │ └── CursorReturnsEmptyRows2.java │ │ │ │ │ ├── cassandra │ │ │ │ │ ├── StartQueryListener.java │ │ │ │ │ ├── GenericComposite.java │ │ │ │ │ ├── Info.java │ │ │ │ │ └── CursorReturnsEmptyRows.java │ │ │ │ │ ├── mongodb │ │ │ │ │ ├── Info.java │ │ │ │ │ └── CursorReturnsEmptyRows2.java │ │ │ │ │ └── hbase │ │ │ │ │ ├── Info.java │ │ │ │ │ └── CursorReturnsEmptyRowsHbase.java │ │ │ ├── layer0 │ │ │ │ └── base │ │ │ │ │ ├── IterProxy.java │ │ │ │ │ ├── AutoCreateEnum.java │ │ │ │ │ ├── DebugCursor.java │ │ │ │ │ ├── IterableNotCounting.java │ │ │ │ │ ├── IterableCounting.java │ │ │ │ │ └── MetaLayerImpl.java │ │ │ ├── layer3 │ │ │ │ └── typed │ │ │ │ │ ├── TypedRowImpl.java │ │ │ │ │ ├── IterableTypedProxy.java │ │ │ │ │ ├── TypedProxyWrappingCursor.java │ │ │ │ │ ├── IterableProxy.java │ │ │ │ │ ├── IterableReverseProxy.java │ │ │ │ │ └── CursorProxyDirect.java │ │ │ └── layer5 │ │ │ │ └── nosql │ │ │ │ └── cache │ │ │ │ └── EmptyCache.java │ │ │ ├── play │ │ │ ├── NoSqlConfig.java │ │ │ ├── NoSqlInterface.java │ │ │ └── logging │ │ │ │ ├── ByDate.java │ │ │ │ ├── Answer.java │ │ │ │ ├── MyRejectHandler.java │ │ │ │ ├── ServersThatLog.java │ │ │ │ └── MDCLevelFilter.java │ │ │ └── ssql │ │ │ └── cmdline │ │ │ ├── Key.java │ │ │ ├── InvalidCommand.java │ │ │ ├── CmdUpdate.java │ │ │ ├── ColFamilyData.java │ │ │ ├── CmdDelete.java │ │ │ └── PlayOptions.java │ │ ├── org │ │ └── playorm │ │ │ └── cron │ │ │ ├── api │ │ │ ├── CronListener.java │ │ │ ├── CronService.java │ │ │ ├── PlayOrmCronJob.java │ │ │ └── CronServiceFactory.java │ │ │ ├── impl │ │ │ ├── CurrentTime.java │ │ │ ├── CurrentTimeImpl.java │ │ │ ├── HashGeneratorImpl.java │ │ │ ├── HashGenerator.java │ │ │ ├── ServerComparator.java │ │ │ ├── Config.java │ │ │ ├── db │ │ │ │ └── MonitorProperty.java │ │ │ └── CopyUtil.java │ │ │ └── bindings │ │ │ └── CronServiceFactoryImpl.java │ │ └── logback.xml ├── test │ └── java │ │ ├── nosql │ │ └── Persistence2.java │ │ ├── com │ │ └── alvazan │ │ │ └── test │ │ │ ├── db │ │ │ ├── AccountMiddle.java │ │ │ ├── CustomerAttr.java │ │ │ ├── Localization.java │ │ │ ├── Marker.java │ │ │ ├── DGPrefixedAttribute.java │ │ │ ├── EntityWithIntKey.java │ │ │ ├── PartSecurity.java │ │ │ ├── InheritedNestedC.java │ │ │ ├── EntityWithDateTimeKey.java │ │ │ ├── InheritanceToOneSpecific.java │ │ │ ├── Child.java │ │ │ ├── InheritedNestedB.java │ │ │ ├── InheritanceToOne.java │ │ │ ├── NonVirtSub2.java │ │ │ ├── InheritanceSub2.java │ │ │ ├── ExpiringEntity.java │ │ │ ├── ForCollection.java │ │ │ ├── ForSet.java │ │ │ ├── InheritedNestedBaseForB.java │ │ │ ├── EntityWithUUIDKey.java │ │ │ ├── InheritedNestedA.java │ │ │ ├── InheritanceToMany.java │ │ │ ├── NonVirtSuper.java │ │ │ ├── InheritedNestedBaseForC.java │ │ │ ├── EmbeddedEntityWithNoId.java │ │ │ ├── InheritanceToManySpecific.java │ │ │ ├── InheritanceSuper.java │ │ │ ├── AccountSuper.java │ │ │ ├── SomeEntity.java │ │ │ ├── EmbeddedEmail2.java │ │ │ ├── EmailAccountXref.java │ │ │ ├── NonVirtSub1.java │ │ │ └── InheritanceSub1.java │ │ │ ├── Config.java │ │ │ └── TestMarker.java │ │ └── org │ │ └── playorm │ │ └── cron │ │ └── test │ │ ├── MockListener.java │ │ ├── MockTime.java │ │ └── MockHash.java └── resources │ ├── jar │ └── play-1.2.5.jar │ ├── play2plugin │ └── plugin2.1.jar │ └── debug │ └── DebugOnWindows_playorm-cli.bat ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── readme.md ├── tools ├── playorm-cli └── playorm-cli.bat └── todo.txt /examples/readme.txt: -------------------------------------------------------------------------------- 1 | The examples directory 2 | -------------------------------------------------------------------------------- /src/main/java/nosql/Persistence.java: -------------------------------------------------------------------------------- 1 | package nosql; 2 | 3 | public class Persistence { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/test/java/nosql/Persistence2.java: -------------------------------------------------------------------------------- 1 | package nosql; 2 | 3 | public class Persistence2 { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /examples/example/src/nosql/Persistence.java: -------------------------------------------------------------------------------- 1 | package nosql; 2 | 3 | public class Persistence { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/resources/jar/play-1.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deanhiller/playorm/HEAD/src/resources/jar/play-1.2.5.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deanhiller/playorm/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/.svn/prop-base/Filter.java.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 10 4 | text/plain 5 | END 6 | -------------------------------------------------------------------------------- /src/resources/play2plugin/plugin2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deanhiller/playorm/HEAD/src/resources/play2plugin/plugin2.1.jar -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/.svn/prop-base/Discoverer.java.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 10 4 | text/plain 5 | END 6 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/.svn/prop-base/FilterImpl.java.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 10 4 | text/plain 5 | END 6 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/.svn/prop-base/ClasspathDiscoverer.java.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 10 4 | text/plain 5 | END 6 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/resource/.svn/prop-base/ClassFileIterator.java.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 10 4 | text/plain 5 | END 6 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/resource/.svn/prop-base/JarFileIterator.java.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 10 4 | text/plain 5 | END 6 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/resource/.svn/prop-base/ResourceIterator.java.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 10 4 | text/plain 5 | END 6 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/parser/antlr/ChildSide.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.parser.antlr; 2 | 3 | public enum ChildSide { 4 | RIGHT, LEFT; 5 | } 6 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/AccountMiddle.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | public class AccountMiddle extends AccountSuper { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/listener/.svn/prop-base/AnnotationDiscoveryListener.java.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 10 4 | text/plain 5 | END 6 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/listener/.svn/prop-base/ClassAnnotationDiscoveryListener.java.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 10 4 | text/plain 5 | END 6 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/listener/.svn/prop-base/FieldAnnotationDiscoveryListener.java.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 10 4 | text/plain 5 | END 6 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/listener/.svn/prop-base/MethodAnnotationDiscoveryListener.java.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 10 4 | text/plain 5 | END 6 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlInheritanceType.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | public enum NoSqlInheritanceType { 4 | SINGLE_TABLE; 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/logging/ScanType.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.logging; 2 | 3 | public enum ScanType { 4 | 5 | FIND, COLUMN_SLICE, RANGE_SLICE, NON_CONTIGUOUS; 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/org/playorm/cron/api/CronListener.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.api; 2 | 3 | public interface CronListener { 4 | 5 | public void monitorFired(PlayOrmCronJob m); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/action/RemoveEnum.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.action; 2 | 3 | public enum RemoveEnum { 4 | REMOVE_ENTIRE_ROW, REMOVE_COLUMNS_FROM_ROW; 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/MetaLoader.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi; 2 | 3 | 4 | public interface MetaLoader { 5 | 6 | T find(Class class1, Object id); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/MetaLookup.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi; 2 | 3 | 4 | public interface MetaLookup { 5 | 6 | T find(Class class1, Object colFamily); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/spi/KeyGenerator.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.spi; 2 | 3 | public interface KeyGenerator { 4 | 5 | public Object generateNewKey(Object entity); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/meta/ViewInfo.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.meta; 2 | 3 | public interface ViewInfo { 4 | 5 | DboTableMeta getTableMeta(); 6 | 7 | String getAlias(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/play/NoSqlConfig.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.play; 2 | 3 | import java.util.Map; 4 | 5 | public interface NoSqlConfig { 6 | 7 | void configure(Map props); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/playorm/cron/impl/CurrentTime.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.impl; 2 | 3 | import org.joda.time.DateTime; 4 | 5 | public interface CurrentTime { 6 | 7 | DateTime currentTime(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/impl/meta/data/collections/CacheLoadCallback.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.impl.meta.data.collections; 2 | 3 | public interface CacheLoadCallback { 4 | 5 | void loadCacheIfNeeded(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/play/NoSqlInterface.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.play; 2 | 3 | import com.alvazan.orm.api.base.NoSqlEntityManager; 4 | 5 | public interface NoSqlInterface { 6 | public NoSqlEntityManager em(); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/ColumnType.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi; 2 | 3 | public enum ColumnType { 4 | 5 | ANY_EXCEPT_COMPOSITE, COMPOSITE_STRINGPREFIX, COMPOSITE_DECIMALPREFIX, COMPOSITE_INTEGERPREFIX; 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/inmemory/SortType.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.inmemory; 2 | 3 | public enum SortType { 4 | UTF8, INTEGER, DECIMAL, BYTES, UTF8_PREFIX, INTEGER_PREFIX, DECIMAL_PREFIX; 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | output 2 | eclipsegen 3 | examples/example/bin 4 | .gradle 5 | .project 6 | .classpath 7 | .settings 8 | /bin 9 | playorm.iml 10 | playorm.ipr 11 | playorm.iws 12 | .idea 13 | gradle-app.setting 14 | local.gradle -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/action/Action.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.action; 2 | 3 | import com.alvazan.orm.api.z8spi.meta.DboTableMeta; 4 | 5 | public interface Action { 6 | 7 | DboTableMeta getColFamily(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/BatchListener.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi; 2 | 3 | public interface BatchListener { 4 | 5 | public void beforeFetchingNextBatch(); 6 | 7 | public void afterFetchingNextBatch(int numFetched); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jul 31 11:39:02 CEST 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.6-bin.zip 7 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/ToOneProvider.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base; 2 | 3 | public class ToOneProvider { 4 | 5 | protected T inst; 6 | 7 | public T get() { 8 | return inst; 9 | } 10 | 11 | public void set(T inst) { 12 | this.inst = inst; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/meta/NoSqlTypedRowProxy.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.meta; 2 | 3 | import java.util.Map; 4 | 5 | 6 | public interface NoSqlTypedRowProxy { 7 | 8 | void __cacheIndexedValues(); 9 | 10 | Map __getOriginalValues(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/playorm/cron/impl/CurrentTimeImpl.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.impl; 2 | 3 | import org.joda.time.DateTime; 4 | 5 | public class CurrentTimeImpl implements CurrentTime { 6 | 7 | @Override 8 | public DateTime currentTime() { 9 | return new DateTime(); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | Now working on a typescript webpieces version at [TryTami.com](https://trytami.com) 2 | 3 | ***All code will remain on github but documentation can be found at http://buffalosw.com/wiki/playorm-documentation/ and the feature list can be found at http://buffalosw.com/products/playorm/*** 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/SpiConstants.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi; 2 | 3 | public class SpiConstants { 4 | 5 | public static final String CASSANDRA_BUILDER = "nosql.cassandra.builder"; 6 | public static final String CASSANDRA_CF_CREATE_CALLBACK = "nosql.cassandra.createcfcallback"; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/conv/Precondition.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.conv; 2 | 3 | public class Precondition { 4 | 5 | public static void check(Object field, String name) { 6 | if(field == null) 7 | throw new IllegalArgumentException("parameter="+name+" is null and that is not allowed"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/impl/meta/data/NoSqlProxy.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.impl.meta.data; 2 | 3 | import java.lang.reflect.Field; 4 | import java.util.Map; 5 | 6 | 7 | public interface NoSqlProxy { 8 | 9 | void __markInitializedAndCacheIndexedValues(); 10 | 11 | Map __getOriginalValues(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/Cache.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi; 2 | 3 | import com.alvazan.orm.api.z8spi.meta.DboTableMeta; 4 | 5 | 6 | 7 | public interface Cache { 8 | 9 | RowHolder fromCache(DboTableMeta colFamily, byte[] key); 10 | 11 | void cacheRow(DboTableMeta colFamily, byte[] b, Row value); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/conv/Converter.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.conv; 2 | 3 | public interface Converter { 4 | 5 | byte[] convertToNoSql(Object value); 6 | 7 | Object convertFromNoSql(byte[] value); 8 | 9 | Object convertStringToType(String value); 10 | 11 | String convertTypeToString(Object dbValue); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/action/PersistIndex.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.action; 2 | 3 | 4 | 5 | public class PersistIndex extends RemoveIndex implements Action { 6 | private int ttl; 7 | 8 | public void setRowTtl(int rowTTL) { 9 | this.ttl = rowTTL; 10 | } 11 | 12 | public int getRowTtl() { 13 | return ttl; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/cassandracql3/StartQueryListener.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.cassandracql3; 2 | 3 | import java.util.List; 4 | import java.util.concurrent.Future; 5 | 6 | import com.datastax.driver.core.ResultSet; 7 | 8 | public interface StartQueryListener { 9 | 10 | List> start(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/playorm/cron/impl/HashGeneratorImpl.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.impl; 2 | 3 | public class HashGeneratorImpl implements HashGenerator { 4 | 5 | @Override 6 | public int generate(int monitorHash, int numUpWebNodes) { 7 | //java's module returns negative numbers if hash is negative here. 8 | return Math.abs(monitorHash) % numUpWebNodes; 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/playorm/cron/impl/HashGenerator.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.impl; 2 | 3 | public interface HashGenerator { 4 | 5 | /** 6 | * Returns the node number this should run on 7 | * 8 | * @param monitorHash 9 | * @param numUpWebNodes 10 | * @return the node number this should run on 11 | */ 12 | int generate(int monitorHash, int numUpWebNodes); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/iter/DirectCursor.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.iter; 2 | 3 | import com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder; 4 | 5 | public interface DirectCursor { 6 | 7 | public Holder nextImpl(); 8 | 9 | public Holder previousImpl(); 10 | 11 | public void beforeFirst(); 12 | 13 | public void afterLast(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/CacheThreadLocal.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi; 2 | 3 | public class CacheThreadLocal { 4 | 5 | private static ThreadLocal cacheLocal = new ThreadLocal(); 6 | 7 | public static void setCache(Cache cache) { 8 | cacheLocal.set(cache); 9 | } 10 | public static Cache getCache() { 11 | return cacheLocal.get(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/CustomerAttr.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 4 | 5 | @NoSqlEntity 6 | public class CustomerAttr extends DGPrefixedAttribute { 7 | private int roll; 8 | 9 | public int getRoll() { 10 | return roll; 11 | } 12 | 13 | public void setRoll(int roll) { 14 | this.roll = roll; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/Localization.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 4 | 5 | @NoSqlEntity 6 | public class Localization extends DGPrefixedAttribute { 7 | private String add; 8 | 9 | public String getAdd() { 10 | return add; 11 | } 12 | 13 | public void setAdd(String add) { 14 | this.add = add; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlTransient.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.FIELD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface NoSqlTransient { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/iter/Cursor.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.iter; 2 | 3 | public interface Cursor { 4 | 5 | /** 6 | * Resets this Cursor to be be before the first element so you can call next again and start all over 7 | */ 8 | void beforeFirst(); 9 | 10 | boolean next(); 11 | 12 | T getCurrent(); 13 | 14 | void afterLast(); 15 | 16 | boolean previous(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/playorm/cron/impl/ServerComparator.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.impl; 2 | 3 | import java.util.Comparator; 4 | 5 | import org.playorm.cron.impl.db.WebNodeDbo; 6 | 7 | public class ServerComparator implements Comparator { 8 | 9 | @Override 10 | public int compare(WebNodeDbo o1, WebNodeDbo o2) { 11 | return o1.getWebServerName().compareTo(o2.getWebServerName()); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlQueries.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.TYPE) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface NoSqlQueries { 11 | NoSqlQuery[] value(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/playorm/cron/impl/Config.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.impl; 2 | 3 | public class Config { 4 | 5 | private long rate; 6 | private String hostName; 7 | 8 | public Config(long rate, String host) { 9 | this.rate = rate; 10 | this.hostName = host; 11 | } 12 | 13 | public long getRate() { 14 | return rate; 15 | } 16 | 17 | public String getHostName() { 18 | return hostName; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/ssql/cmdline/Key.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.ssql.cmdline; 2 | 3 | public class Key { 4 | 5 | private Integer index; 6 | private String colName; 7 | 8 | public Key(Integer index, String colName) { 9 | this.index = index; 10 | this.colName = colName; 11 | } 12 | public Integer getIndex() { 13 | return index; 14 | } 15 | public String getColName() { 16 | return colName; 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlQuery.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.TYPE) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface NoSqlQuery { 11 | String name(); 12 | String query(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlDiscriminatorColumn.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.TYPE) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface NoSqlDiscriminatorColumn { 11 | String value(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlEmbeddable.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.TYPE) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface NoSqlEmbeddable { 11 | String virtualCfName() default ""; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlManyToOne.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.FIELD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface NoSqlManyToOne { 11 | String columnName() default ""; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlOneToOne.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.FIELD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface NoSqlOneToOne { 11 | String columnName() default ""; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/cassandra/StartQueryListener.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.cassandra; 2 | 3 | import java.util.List; 4 | import java.util.concurrent.Future; 5 | 6 | import com.netflix.astyanax.connectionpool.OperationResult; 7 | import com.netflix.astyanax.model.ColumnList; 8 | 9 | public interface StartQueryListener { 10 | 11 | List>>> start(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /examples/example/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | example 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlIndexed.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.FIELD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface NoSqlIndexed { 11 | String indexName() default ""; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/impl/meta/data/Tuple.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.impl.meta.data; 2 | 3 | public class Tuple { 4 | private D proxy; 5 | private Object entityId; 6 | public D getProxy() { 7 | return proxy; 8 | } 9 | public void setProxy(D proxy) { 10 | this.proxy = proxy; 11 | } 12 | public Object getEntityId() { 13 | return entityId; 14 | } 15 | public void setEntityId(Object entityId) { 16 | this.entityId = entityId; 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/parser/antlr/JoinType.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.parser.antlr; 2 | 3 | public enum JoinType { 4 | 5 | NONE, 6 | /** 7 | * SIDE_OUTER is either left or right, but is ALWAYS determined by the primary table in JoinInfo.java 8 | * such that we don't care as the primary table is put in the primary so it could be left or right join 9 | * but we get to treat them the same. 10 | */ 11 | LEFT_OUTER, OUTER, INNER; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/playorm/cron/api/CronService.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.api; 2 | 3 | import java.util.List; 4 | 5 | 6 | 7 | public interface CronService { 8 | 9 | void start(); 10 | 11 | void addListener(CronListener listener); 12 | 13 | 14 | void saveMonitor(PlayOrmCronJob monitor); 15 | 16 | PlayOrmCronJob getMonitor(String id); 17 | 18 | List getMonitors(List ids); 19 | 20 | void deleteMonitor(String id); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlEmbedded.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.FIELD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface NoSqlEmbedded { 11 | 12 | String columnNamePrefix() default ""; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/impl/meta/data/MetaComparator.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.impl.meta.data; 2 | 3 | import java.util.Comparator; 4 | 5 | @SuppressWarnings("rawtypes") 6 | public class MetaComparator implements Comparator { 7 | 8 | @Override 9 | public int compare(MetaAbstractClass o1, MetaAbstractClass o2) { 10 | return o1.getMetaClass().getSimpleName().compareToIgnoreCase(o2.getMetaClass().getSimpleName()); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/Indexing.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base; 2 | 3 | public class Indexing { 4 | 5 | private static ThreadLocal forced = new ThreadLocal(); 6 | 7 | public static void setForcedIndexing(boolean isForced) { 8 | forced.set(isForced); 9 | } 10 | 11 | public static boolean isForcedIndexing() { 12 | Boolean bool = forced.get(); 13 | if(bool == null) 14 | return false; 15 | return bool; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlPartitionByThisField.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.FIELD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface NoSqlPartitionByThisField { 11 | String indexName() default ""; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/Marker.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 4 | import com.alvazan.orm.api.base.anno.NoSqlId; 5 | 6 | @NoSqlEntity 7 | /** Marker entity. It has no fields except primary key. */ 8 | public class Marker { 9 | 10 | @NoSqlId 11 | private String id; 12 | 13 | public String getId() { 14 | return id; 15 | } 16 | 17 | public void setId(String id) { 18 | this.id = id; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/NoSqlEntityManagerFactory.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base; 2 | 3 | import java.util.List; 4 | 5 | public interface NoSqlEntityManagerFactory { 6 | 7 | public NoSqlEntityManager createEntityManager(); 8 | 9 | @SuppressWarnings("rawtypes") 10 | void rescan(List classes, ClassLoader cl); 11 | 12 | /** 13 | * Releases the entire pool of connections and disconnects from the nosql store. 14 | */ 15 | void close(); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/RowHolder.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi; 2 | 3 | public class RowHolder { 4 | 5 | private T value; 6 | private byte[] key; 7 | 8 | public RowHolder(byte[] key, T v) { 9 | this.key = key; 10 | this.value = v; 11 | } 12 | 13 | public RowHolder(byte[] key) { 14 | this.key = key; 15 | } 16 | 17 | public T getValue() { 18 | return value; 19 | } 20 | 21 | public byte[] getKey() { 22 | return key; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/DGPrefixedAttribute.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlId; 4 | import com.alvazan.orm.api.base.anno.NoSqlIndexed; 5 | 6 | public class DGPrefixedAttribute implements Cloneable { 7 | @NoSqlId(usegenerator = false) 8 | @NoSqlIndexed 9 | // @Field 10 | private String id; 11 | 12 | public String getId() { 13 | return id; 14 | } 15 | 16 | public void setId(String id) { 17 | this.id = id; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/play/logging/ByDate.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.play.logging; 2 | 3 | import java.util.Comparator; 4 | 5 | import org.joda.time.LocalDateTime; 6 | 7 | public class ByDate implements Comparator { 8 | 9 | @Override 10 | public int compare(LogEvent o1, LogEvent o2) { 11 | LocalDateTime t1 = o1.getTime(); 12 | LocalDateTime t2 = o2.getTime(); 13 | 14 | if(t1.isBefore(t2)) 15 | return 1; 16 | else if(t1.isAfter(t2)) 17 | return -1; 18 | return 0; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/exc/ParseException.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.exc; 2 | 3 | public class ParseException extends RuntimeException { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public ParseException() { 8 | } 9 | 10 | public ParseException(String message) { 11 | super(message); 12 | } 13 | 14 | public ParseException(Throwable cause) { 15 | super(cause); 16 | } 17 | 18 | public ParseException(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/org/playorm/cron/test/MockListener.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.test; 2 | 3 | import org.playorm.cron.api.CronListener; 4 | import org.playorm.cron.api.PlayOrmCronJob; 5 | 6 | public class MockListener implements CronListener { 7 | 8 | private PlayOrmCronJob lastFired; 9 | 10 | @Override 11 | public void monitorFired(PlayOrmCronJob m) { 12 | this.lastFired = m; 13 | } 14 | 15 | public PlayOrmCronJob getLastFiredMonitor() { 16 | PlayOrmCronJob temp = lastFired; 17 | lastFired = null; 18 | return temp; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlInheritance.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.TYPE) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface NoSqlInheritance { 11 | @SuppressWarnings("rawtypes") 12 | Class[] subclassesToScan(); 13 | NoSqlInheritanceType strategy(); 14 | String discriminatorColumnName() default ""; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/iter/EmptyCursor.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.iter; 2 | 3 | 4 | public class EmptyCursor extends AbstractCursor { 5 | 6 | @Override 7 | public void beforeFirst() { 8 | } 9 | 10 | @Override 11 | public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder nextImpl() { 12 | return null; 13 | } 14 | 15 | @Override 16 | public void afterLast() { 17 | } 18 | 19 | @Override 20 | public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder previousImpl() { 21 | return null; 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/ssql/cmdline/InvalidCommand.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.ssql.cmdline; 2 | 3 | public class InvalidCommand extends RuntimeException { 4 | 5 | /** 6 | * 7 | */ 8 | private static final long serialVersionUID = 1L; 9 | 10 | public InvalidCommand() { 11 | super(); 12 | } 13 | 14 | public InvalidCommand(String message, Throwable cause) { 15 | super(message, cause); 16 | } 17 | 18 | public InvalidCommand(String message) { 19 | super(message); 20 | } 21 | 22 | public InvalidCommand(Throwable cause) { 23 | super(cause); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/play/logging/Answer.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.play.logging; 2 | 3 | public class Answer { 4 | 5 | private Integer answer; 6 | private int row; 7 | 8 | public Answer(Integer answer, int row) { 9 | this.answer = answer; 10 | this.row = row; 11 | } 12 | 13 | public Integer getAnswer() { 14 | return answer; 15 | } 16 | 17 | public void setAnswer(Integer answer) { 18 | this.answer = answer; 19 | } 20 | 21 | public int getRow() { 22 | return row; 23 | } 24 | 25 | public void setRow(int row) { 26 | this.row = row; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/exc/RowNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.exc; 2 | 3 | 4 | public class RowNotFoundException extends NoSqlOrmException { 5 | 6 | private static final long serialVersionUID = 1L; 7 | 8 | public RowNotFoundException() { 9 | super(); 10 | } 11 | 12 | public RowNotFoundException(String message, Throwable cause) { 13 | super(message, cause); 14 | } 15 | 16 | public RowNotFoundException(String message) { 17 | super(message); 18 | } 19 | 20 | public RowNotFoundException(Throwable cause) { 21 | super(cause); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlTTL.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * Field contains TTL (Time to live) for entity 11 | * in seconds. Field must be int or Integer 12 | */ 13 | @Target({ElementType.FIELD}) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Documented 16 | public @interface NoSqlTTL { 17 | /* no arguments */ 18 | } -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/exc/TooManyResultException.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.exc; 2 | 3 | 4 | public class TooManyResultException extends NoSqlOrmException { 5 | 6 | private static final long serialVersionUID = 1L; 7 | 8 | public TooManyResultException() { 9 | super(); 10 | } 11 | 12 | public TooManyResultException(String message, Throwable cause) { 13 | super(message, cause); 14 | } 15 | 16 | public TooManyResultException(String message) { 17 | super(message); 18 | } 19 | 20 | public TooManyResultException(Throwable cause) { 21 | super(cause); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/exc/TypeMismatchException.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.exc; 2 | 3 | 4 | public class TypeMismatchException extends NoSqlOrmException { 5 | 6 | private static final long serialVersionUID = 1L; 7 | 8 | public TypeMismatchException() { 9 | super(); 10 | } 11 | 12 | public TypeMismatchException(String message, Throwable cause) { 13 | super(message, cause); 14 | } 15 | 16 | public TypeMismatchException(String message) { 17 | super(message); 18 | } 19 | 20 | public TypeMismatchException(Throwable cause) { 21 | super(cause); 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/parser/antlr/PartitionMeta.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.parser.antlr; 2 | 3 | import com.alvazan.orm.api.z8spi.meta.DboColumnMeta; 4 | 5 | public class PartitionMeta { 6 | 7 | private DboColumnMeta partitionColumn; 8 | private ParsedNode node; 9 | 10 | public PartitionMeta(DboColumnMeta partitionColumn, ParsedNode node) { 11 | this.partitionColumn = partitionColumn; 12 | this.node = node; 13 | } 14 | 15 | public DboColumnMeta getPartitionColumn() { 16 | return partitionColumn; 17 | } 18 | 19 | public ParsedNode getNode() { 20 | return node; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/org/playorm/cron/test/MockTime.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.test; 2 | 3 | import org.joda.time.DateTime; 4 | import org.playorm.cron.impl.CurrentTime; 5 | 6 | public class MockTime implements CurrentTime { 7 | 8 | private DateTime time; 9 | 10 | public void addReturnTime(int millis) { 11 | time = new DateTime(millis); 12 | } 13 | 14 | @Override 15 | public DateTime currentTime() { 16 | if(time == null) { 17 | throw new IllegalStateException("call addREturnTime from test case first"); 18 | } 19 | DateTime temp = time; 20 | time = null; 21 | return temp; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/cassandra/GenericComposite.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.cassandra; 2 | 3 | import com.netflix.astyanax.annotations.Component; 4 | 5 | public class GenericComposite { 6 | 7 | @Component(ordinal=0) 8 | private byte[] indexedValue; 9 | @Component(ordinal=1) 10 | private byte[] pk; 11 | 12 | byte[] getIndexedValue() { 13 | return indexedValue; 14 | } 15 | void setIndexedValue(byte[] value) { 16 | this.indexedValue = value; 17 | } 18 | byte[] getPk() { 19 | return pk; 20 | } 21 | void setPk(byte[] pk) { 22 | this.pk = pk; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/CreateCfCallback.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi; 2 | 3 | 4 | 5 | public interface CreateCfCallback { 6 | 7 | /** 8 | * For cassandra, def param is hte ColumnFamilyDefinition and you return that 9 | * @param cfName 10 | * @param def 11 | * @return 12 | */ 13 | public Object modifyColumnFamily(String cfName, Object def); 14 | /** 15 | * For cassandra, def param is the KeyspaceDefinition and you return that 16 | * @param cfName 17 | * @param def 18 | * @return 19 | */ 20 | public Object configureKeySpace(String keyspaceName, Object def); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/Key.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi; 2 | 3 | public class Key { 4 | private byte[] key; 5 | private boolean inclusive; 6 | 7 | public Key() {}; 8 | public Key(byte[] key, boolean inclusive) { 9 | this.key = key; 10 | this.inclusive = inclusive; 11 | } 12 | 13 | public byte[] getKey() { 14 | return key; 15 | } 16 | public void setKey(byte[] key) { 17 | this.key = key; 18 | } 19 | public boolean isInclusive() { 20 | return inclusive; 21 | } 22 | public void setInclusive(boolean inclusive) { 23 | this.inclusive = inclusive; 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z3api/TimeValColumn.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z3api; 2 | 3 | import java.math.BigInteger; 4 | 5 | public class TimeValColumn { 6 | 7 | private long time; 8 | private Object val; 9 | private Long timestamp; 10 | 11 | public TimeValColumn(BigInteger pk, Object val, Long timestamp) { 12 | this.time = pk.longValue(); 13 | this.val = val; 14 | this.timestamp = timestamp; 15 | } 16 | 17 | public long getTime() { 18 | return time; 19 | } 20 | 21 | public Object getVal() { 22 | return val; 23 | } 24 | 25 | public Long getTimestamp() { 26 | return timestamp; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/meta/PartitionTypeInfo.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.meta; 2 | 3 | 4 | public class PartitionTypeInfo { 5 | 6 | private String partitionBy; 7 | private String partitionId; 8 | private Object colMeta; 9 | 10 | public PartitionTypeInfo(String by, String id, Object colMeta) { 11 | partitionBy = by; 12 | partitionId = id; 13 | this.colMeta = colMeta; 14 | } 15 | public String getPartitionBy() { 16 | return partitionBy; 17 | } 18 | public String getPartitionId() { 19 | return partitionId; 20 | } 21 | public Object getColMeta() { 22 | return colMeta; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/playorm/cron/impl/db/MonitorProperty.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.impl.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlEmbeddable; 4 | import com.alvazan.orm.api.base.anno.NoSqlId; 5 | 6 | @NoSqlEmbeddable 7 | public class MonitorProperty { 8 | 9 | @NoSqlId 10 | private String key; 11 | 12 | private String value; 13 | 14 | public String getKey() { 15 | return key; 16 | } 17 | 18 | public void setKey(String key) { 19 | this.key = key; 20 | } 21 | 22 | public String getValue() { 23 | return value; 24 | } 25 | 26 | public void setValue(String value) { 27 | this.value = value; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/EntityWithIntKey.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 4 | import com.alvazan.orm.api.base.anno.NoSqlId; 5 | 6 | @NoSqlEntity 7 | public class EntityWithIntKey { 8 | 9 | @NoSqlId(usegenerator=false) 10 | private int id; 11 | 12 | private String something; 13 | 14 | public int getId() { 15 | return id; 16 | } 17 | 18 | public void setId(int id) { 19 | this.id = id; 20 | } 21 | 22 | public String getSomething() { 23 | return something; 24 | } 25 | 26 | public void setSomething(String something) { 27 | this.something = something; 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlOneToMany.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.FIELD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface NoSqlOneToMany { 11 | 12 | String columnName() default ""; 13 | 14 | /** 15 | * When using Map instead of a List, the field in entityType() needs to 16 | * be specified here... 17 | * @return The key field name for the map 18 | */ 19 | String keyFieldForMap() default ""; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlManyToMany.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.FIELD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface NoSqlManyToMany { 11 | 12 | String columnName() default ""; 13 | 14 | /** 15 | * When using Map instead of a List, the field in entityType() needs to 16 | * be specified here... 17 | * @return The key field name for the map 18 | */ 19 | String keyFieldForMap() default ""; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z5api/NoConversion.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z5api; 2 | 3 | import com.alvazan.orm.api.z8spi.conv.Converter; 4 | 5 | public class NoConversion implements Converter { 6 | @Override 7 | public byte[] convertToNoSql(Object value) { 8 | return null; 9 | } 10 | @Override 11 | public Object convertFromNoSql(byte[] value) { 12 | return null; 13 | } 14 | @Override 15 | public Object convertStringToType(String value) { 16 | // TODO Auto-generated method stub 17 | return null; 18 | } 19 | @Override 20 | public String convertTypeToString(Object dbValue) { 21 | // TODO Auto-generated method stub 22 | return null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/iter/StringLocal.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.iter; 2 | 3 | public class StringLocal { 4 | 5 | private static final ThreadLocal SPACES = new ThreadLocal(); 6 | 7 | private static String get() { 8 | String val = SPACES.get(); 9 | if(val == null) 10 | return ""; 11 | return val; 12 | } 13 | 14 | public static void set(int numSpaces) { 15 | String s = ""; 16 | for(int i = 0; i < numSpaces; i++) { 17 | s+=" "; 18 | } 19 | SPACES.set(s); 20 | } 21 | 22 | public static String getAndAdd() { 23 | String tabs = get(); 24 | set(tabs.length()+3); 25 | return "\n"+get(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/exc/NoSqlOrmException.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.exc; 2 | 3 | public class NoSqlOrmException extends RuntimeException { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public NoSqlOrmException() { 8 | super(); 9 | } 10 | 11 | public NoSqlOrmException(String arg0, Throwable arg1, boolean arg2, 12 | boolean arg3) { 13 | // super(arg0, arg1, arg2, arg3); 14 | } 15 | 16 | public NoSqlOrmException(String arg0, Throwable arg1) { 17 | super(arg0, arg1); 18 | } 19 | 20 | public NoSqlOrmException(String arg0) { 21 | super(arg0); 22 | } 23 | 24 | public NoSqlOrmException(Throwable arg0) { 25 | super(arg0); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/exc/PkIsNullException.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.exc; 2 | 3 | 4 | public class PkIsNullException extends NoSqlOrmException { 5 | 6 | private static final long serialVersionUID = 1L; 7 | 8 | public PkIsNullException() { 9 | super(); 10 | } 11 | 12 | public PkIsNullException(String arg0, Throwable arg1, boolean arg2, 13 | boolean arg3) { 14 | super(arg0, arg1, arg2, arg3); 15 | } 16 | 17 | public PkIsNullException(String arg0, Throwable arg1) { 18 | super(arg0, arg1); 19 | } 20 | 21 | public PkIsNullException(String arg0) { 22 | super(arg0); 23 | } 24 | 25 | public PkIsNullException(Throwable arg0) { 26 | super(arg0); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/parser/antlr/MetaFacade.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.parser.antlr; 2 | 3 | import java.util.Map; 4 | 5 | import com.alvazan.orm.api.z8spi.meta.DboColumnMeta; 6 | import com.alvazan.orm.api.z8spi.meta.DboTableMeta; 7 | 8 | public interface MetaFacade { 9 | 10 | DboTableMeta getColumnFamily(String tableName); 11 | 12 | DboColumnMeta getColumnMeta(DboTableMeta metaClass, String columnName); 13 | 14 | DboColumnMeta getFkMetaIfExist(DboTableMeta tableMeta, String column); 15 | 16 | ParsedNode createExpression(int nodeType); 17 | 18 | Map getAttributeUsedCount(); 19 | 20 | void setAttributeUserCount(Map attributeUsedCount); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/exc/StorageMissingEntitesException.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.exc; 2 | 3 | 4 | 5 | @SuppressWarnings("rawtypes") 6 | public class StorageMissingEntitesException extends NoSqlOrmException { 7 | 8 | private static final long serialVersionUID = 1L; 9 | private final Iterable foundElements; 10 | 11 | public StorageMissingEntitesException() { 12 | super(); 13 | foundElements = null; 14 | } 15 | public StorageMissingEntitesException(Iterable foundElements2, String message, RowNotFoundException e) { 16 | super(message); 17 | this.foundElements = foundElements2; 18 | } 19 | public Iterable getFoundElements() { 20 | return foundElements; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /tools/playorm-cli: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Use JAVA_HOME if set, otherwise look for java in PATH 4 | if [ -x $JAVA_HOME/bin/java ]; then 5 | JAVA=$JAVA_HOME/bin/java 6 | else 7 | JAVA=`which java` 8 | fi 9 | 10 | for jar in ../output/jardist/*.jar; do 11 | CLASSPATH=$CLASSPATH:$jar 12 | done 13 | 14 | for jar in ../lib/*.jar; do 15 | CLASSPATH=$CLASSPATH:$jar 16 | done 17 | 18 | # Add classes so that it works in development 19 | CLASSPATH=../bin:$CLASSPATH 20 | 21 | if [ -z $CLASSPATH ]; then 22 | echo "You must set the CLASSPATH var" >&2 23 | exit 1 24 | fi 25 | 26 | $JAVA -ea -cp $CLASSPATH -Xmx256M \ 27 | com.alvazan.ssql.cmdline.PlayOrm "$@" 28 | 29 | # vi:ai sw=4 ts=4 tw=0 et 30 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer0/base/IterProxy.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer0.base; 2 | 3 | import java.util.Iterator; 4 | 5 | import com.alvazan.orm.api.z8spi.conv.Precondition; 6 | import com.alvazan.orm.api.z8spi.iter.AbstractIterator; 7 | 8 | public class IterProxy extends AbstractIterator { 9 | 10 | private Iterator iterator; 11 | 12 | public IterProxy(Iterator iter) { 13 | Precondition.check(iter, "iter"); 14 | this.iterator = iter; 15 | } 16 | 17 | @Override 18 | public com.alvazan.orm.api.z8spi.iter.AbstractIterator.IterHolder nextImpl() { 19 | if(!iterator.hasNext()) 20 | return null; 21 | return new IterHolder(iterator.next()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/resource/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 68 4 | /svn/!svn/ver/7/trunk/src/main/java/com/impetus/annovention/resource 5 | END 6 | ClassFileIterator.java 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 91 10 | /svn/!svn/ver/7/trunk/src/main/java/com/impetus/annovention/resource/ClassFileIterator.java 11 | END 12 | ResourceIterator.java 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 90 16 | /svn/!svn/ver/7/trunk/src/main/java/com/impetus/annovention/resource/ResourceIterator.java 17 | END 18 | JarFileIterator.java 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 89 22 | /svn/!svn/ver/7/trunk/src/main/java/com/impetus/annovention/resource/JarFileIterator.java 23 | END 24 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/PartSecurity.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 4 | import com.alvazan.orm.api.base.anno.NoSqlId; 5 | import com.alvazan.orm.api.base.anno.NoSqlIndexed; 6 | 7 | @NoSqlEntity 8 | public class PartSecurity { 9 | 10 | @NoSqlId 11 | private String id; 12 | 13 | @NoSqlIndexed 14 | private String securityType; 15 | 16 | public String getId() { 17 | return id; 18 | } 19 | 20 | public void setId(String id) { 21 | this.id = id; 22 | } 23 | 24 | public String getSecurityType() { 25 | return securityType; 26 | } 27 | 28 | public void setSecurityType(String securityType) { 29 | this.securityType = securityType; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/exc/ChildWithNoPkException.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.exc; 2 | 3 | 4 | public class ChildWithNoPkException extends NoSqlOrmException { 5 | 6 | private static final long serialVersionUID = 1L; 7 | 8 | public ChildWithNoPkException() { 9 | super(); 10 | } 11 | 12 | public ChildWithNoPkException(String arg0, Throwable arg1, boolean arg2, 13 | boolean arg3) { 14 | super(arg0, arg1, arg2, arg3); 15 | } 16 | 17 | public ChildWithNoPkException(String arg0, Throwable arg1) { 18 | super(arg0, arg1); 19 | } 20 | 21 | public ChildWithNoPkException(String arg0) { 22 | super(arg0); 23 | } 24 | 25 | public ChildWithNoPkException(Throwable arg0) { 26 | super(arg0); 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/InheritedNestedC.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @COPYRIGHT (C) 2010 Hotel Reservation Service (HRS) Robert Ragge GmbH 3 | * 4 | * All rights reserved 5 | */ 6 | package com.alvazan.test.db; 7 | 8 | import com.alvazan.orm.api.base.anno.NoSqlDiscriminatorColumn; 9 | 10 | /** 11 | * @author Robert Stupp (last modified by $Author$) 12 | * @version $Revision$ $Date$ 13 | */ 14 | @NoSqlDiscriminatorColumn("nestedC") 15 | public class InheritedNestedC extends InheritedNestedBaseForC { 16 | private String helloWorld; 17 | 18 | public String getHelloWorld() { 19 | return helloWorld; 20 | } 21 | 22 | public void setHelloWorld(String helloWorld) { 23 | this.helloWorld = helloWorld; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/EntityWithDateTimeKey.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import org.joda.time.LocalDateTime; 4 | 5 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 6 | import com.alvazan.orm.api.base.anno.NoSqlId; 7 | 8 | @NoSqlEntity 9 | public class EntityWithDateTimeKey { 10 | 11 | @NoSqlId(usegenerator=false) 12 | private LocalDateTime id; 13 | 14 | private String something; 15 | 16 | public LocalDateTime getId() { 17 | return id; 18 | } 19 | 20 | public void setId(LocalDateTime id) { 21 | this.id = id; 22 | } 23 | 24 | public String getSomething() { 25 | return something; 26 | } 27 | 28 | public void setSomething(String something) { 29 | this.something = something; 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlVirtualCf.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.TYPE) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface NoSqlVirtualCf { 11 | /** 12 | * You can put a whole slew of tables in ONE ColumnFamily. This maps which column family the entity 13 | * will be stored in. 14 | * @return Name of the Virtual columnFamily in which this entity will be stored. 15 | */ 16 | String storedInCf(); 17 | 18 | //This will be the prefix of every key for this entity 19 | //String keyPrefix(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer0/base/AutoCreateEnum.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer0.base; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public enum AutoCreateEnum { 7 | UPDATE("update"), FAIL_IF_NOT_VALID("validate"), CREATE_ONLY("create"); 8 | 9 | private static Map mapping = new HashMap(); 10 | static { 11 | for(AutoCreateEnum a : AutoCreateEnum.values()) { 12 | mapping.put(a.getValue(), a); 13 | } 14 | } 15 | 16 | private String value; 17 | private AutoCreateEnum(String val) { 18 | this.value = val; 19 | } 20 | 21 | public String getValue() { 22 | return value; 23 | } 24 | 25 | public static AutoCreateEnum translate(String val) { 26 | return mapping.get(val); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/parser/antlr/StateAttribute.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.parser.antlr; 2 | 3 | import com.alvazan.orm.api.z8spi.meta.DboColumnMeta; 4 | 5 | public class StateAttribute { 6 | 7 | private DboColumnMeta columnInfo; 8 | private ViewInfoImpl tableInfo; 9 | private String textInSql; 10 | 11 | public StateAttribute(ViewInfoImpl tableInfo, DboColumnMeta columnName2, String textInSql) { 12 | this.tableInfo = tableInfo; 13 | this.columnInfo = columnName2; 14 | this.textInSql = textInSql; 15 | } 16 | 17 | public String getTextInSql() { 18 | return textInSql; 19 | } 20 | 21 | 22 | public ViewInfoImpl getViewInfo() { 23 | return tableInfo; 24 | } 25 | 26 | public DboColumnMeta getColumnInfo() { 27 | return columnInfo; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/InheritanceToOneSpecific.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 4 | import com.alvazan.orm.api.base.anno.NoSqlId; 5 | import com.alvazan.orm.api.base.anno.NoSqlManyToOne; 6 | 7 | @NoSqlEntity 8 | public class InheritanceToOneSpecific { 9 | 10 | @NoSqlId 11 | private String id; 12 | 13 | @NoSqlManyToOne 14 | private InheritanceSub1 inheritance; 15 | 16 | public String getId() { 17 | return id; 18 | } 19 | 20 | public void setId(String id) { 21 | this.id = id; 22 | } 23 | 24 | public InheritanceSub1 getInheritance() { 25 | return inheritance; 26 | } 27 | 28 | public void setInheritance(InheritanceSub1 nameToEntity) { 29 | this.inheritance = nameToEntity; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/DbTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public enum DbTypeEnum { 7 | CASSANDRA("cassandra"), IN_MEMORY("inmemory"), MONGODB("mongodb"), HBASE("hbase"),CQL("cql"); 8 | 9 | private static final Map LOOKUP = new HashMap(); 10 | 11 | //HADOOP 12 | static { 13 | for(DbTypeEnum type : DbTypeEnum.values()) { 14 | LOOKUP.put(type.getValue(), type); 15 | } 16 | } 17 | 18 | private String value; 19 | 20 | private DbTypeEnum(String val) { 21 | this.value = val; 22 | } 23 | 24 | private String getValue() { 25 | return value; 26 | } 27 | 28 | public static DbTypeEnum lookup(String val) { 29 | return LOOKUP.get(val); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 60 4 | /svn/!svn/ver/12/trunk/src/main/java/com/impetus/annovention 5 | END 6 | Filter.java 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 71 10 | /svn/!svn/ver/7/trunk/src/main/java/com/impetus/annovention/Filter.java 11 | END 12 | Discoverer.java 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 76 16 | /svn/!svn/ver/12/trunk/src/main/java/com/impetus/annovention/Discoverer.java 17 | END 18 | FilterImpl.java 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 75 22 | /svn/!svn/ver/7/trunk/src/main/java/com/impetus/annovention/FilterImpl.java 23 | END 24 | ClasspathDiscoverer.java 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 85 28 | /svn/!svn/ver/12/trunk/src/main/java/com/impetus/annovention/ClasspathDiscoverer.java 29 | END 30 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/inmemory/NoSqlDatabase.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.inmemory; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import javax.inject.Singleton; 7 | 8 | @Singleton 9 | public class NoSqlDatabase { 10 | 11 | private Map nameToTable = new HashMap(); 12 | 13 | public Table findTable(String name) { 14 | return nameToTable.get(name); 15 | } 16 | 17 | public void putTable(String name, Table table) { 18 | nameToTable.put(name, table); 19 | } 20 | 21 | public void clear() { 22 | nameToTable.clear(); 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | String db = ""; 28 | for(Table t : nameToTable.values()) { 29 | db += "\n"+t+"\n\n"; 30 | } 31 | return db; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/action/RemoveColumn.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.action; 2 | 3 | import com.alvazan.orm.api.z8spi.meta.DboTableMeta; 4 | 5 | public class RemoveColumn implements Action { 6 | private DboTableMeta colFamily; 7 | private byte[] rowKey; 8 | private byte[] column; 9 | 10 | public DboTableMeta getColFamily() { 11 | return colFamily; 12 | } 13 | 14 | public void setColFamily(DboTableMeta colFamily2) { 15 | this.colFamily = colFamily2; 16 | } 17 | 18 | public byte[] getRowKey() { 19 | return rowKey; 20 | } 21 | 22 | public void setRowKey(byte[] rowKey) { 23 | this.rowKey = rowKey; 24 | } 25 | 26 | public byte[] getColumn() { 27 | return column; 28 | } 29 | 30 | public void setColumn(byte[] columnName) { 31 | this.column = columnName; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlConverter.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import com.alvazan.orm.api.z8spi.conv.Converter; 9 | 10 | @Target({ElementType.FIELD}) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | public @interface NoSqlConverter { 13 | /** 14 | * You can supply your own converter for a field here which will override all 15 | * standard conversions even for primitives. You just translate back and 16 | * forth from the byte[] for us and we wire that in. 17 | * @return An object of Class which extends Converter 18 | */ 19 | Class converter(); 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/KeyValue.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi; 2 | 3 | import com.alvazan.orm.api.exc.RowNotFoundException; 4 | 5 | 6 | public class KeyValue { 7 | 8 | private Object key; 9 | private T value; 10 | 11 | private RowNotFoundException e; 12 | 13 | public Object getKey() { 14 | return key; 15 | } 16 | public void setKey(Object key) { 17 | this.key = key; 18 | } 19 | public T getValue() { 20 | if(e != null) 21 | throw new RowNotFoundException("Row was referenced in index, but not found in nosql store. key="+key, e); 22 | return value; 23 | } 24 | public void setValue(T value) { 25 | this.value = value; 26 | } 27 | public void setException(RowNotFoundException exc) { 28 | this.e = exc; 29 | } 30 | public RowNotFoundException getException() { 31 | return e; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/Child.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 4 | import com.alvazan.orm.api.base.anno.NoSqlId; 5 | import com.alvazan.orm.api.base.anno.NoSqlIndexed; 6 | 7 | @NoSqlEntity 8 | public class Child { 9 | 10 | @NoSqlId 11 | private String id; 12 | 13 | @NoSqlIndexed 14 | private String name; 15 | 16 | @NoSqlIndexed 17 | private int age; 18 | 19 | public String getId() { 20 | return id; 21 | } 22 | 23 | public void setId(String id) { 24 | this.id = id; 25 | } 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | 35 | public int getAge() { 36 | return age; 37 | } 38 | 39 | public void setAge(int age) { 40 | this.age = age; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/InheritedNestedB.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @COPYRIGHT (C) 2010 Hotel Reservation Service (HRS) Robert Ragge GmbH 3 | * 4 | * All rights reserved 5 | */ 6 | package com.alvazan.test.db; 7 | 8 | import com.alvazan.orm.api.base.anno.NoSqlDiscriminatorColumn; 9 | import com.alvazan.orm.api.base.anno.NoSqlOneToMany; 10 | 11 | import java.util.HashSet; 12 | import java.util.Set; 13 | 14 | /** 15 | * @author Robert Stupp (last modified by $Author$) 16 | * @version $Revision$ $Date$ 17 | */ 18 | @NoSqlDiscriminatorColumn("nestedB") 19 | public class InheritedNestedB extends InheritedNestedBaseForB { 20 | @NoSqlOneToMany(columnName = "cs") 21 | private Set cs = new HashSet(); 22 | 23 | public Set getCs() { 24 | return cs; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlEntity.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.TYPE) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface NoSqlEntity { 11 | /** 12 | * This is the NAME of the column family OR the name of the virtual column family IF you use @NoSqlVirtualCf annotation 13 | * Virtual Cf's are for when you play to have 1000's of Cf's as EVERY node in cassandra uses more memory every time you 14 | * add a CF :(. If you want nearly infinite CF's, you need to use virtual CF's which is what we did for a project. 15 | * @return name of the Column Family 16 | */ 17 | String columnfamily() default ""; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/ssql/cmdline/CmdUpdate.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.ssql.cmdline; 2 | 3 | import com.alvazan.orm.api.base.NoSqlEntityManager; 4 | import com.alvazan.orm.api.exc.ParseException; 5 | import com.alvazan.orm.api.z3api.NoSqlTypedSession; 6 | 7 | public class CmdUpdate { 8 | 9 | void processUpdate(String cmd, NoSqlEntityManager mgr) { 10 | NoSqlTypedSession s = mgr.getTypedSession(); 11 | try { 12 | int count = s.executeQuery(cmd); 13 | mgr.flush(); 14 | println(count + " row updated"); 15 | } catch(ParseException e) { 16 | Throwable childExc = e.getCause(); 17 | throw new InvalidCommand("Scalable-SQL command was invalid. Reason="+childExc.getMessage()+" AND you may want to add -v option to playcli to get more info", e); 18 | } 19 | } 20 | 21 | private void println(String msg) { 22 | System.out.println(msg); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/org/playorm/cron/test/MockHash.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.test; 2 | 3 | import org.playorm.cron.impl.HashGenerator; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | public class MockHash implements HashGenerator { 8 | 9 | private static final Logger log = LoggerFactory.getLogger(MockHash.class); 10 | private Integer nodeNum; 11 | 12 | public void addReturnValue(Integer nodeNum) { 13 | log.info("add return value="+nodeNum); 14 | this.nodeNum = nodeNum; 15 | } 16 | 17 | @Override 18 | public int generate(int monitorHash, int numUpWebNodes) { 19 | log.info("generate number="+nodeNum); 20 | if(nodeNum == null) 21 | throw new IllegalArgumentException("you need to call addReturnValue before this is called in the test"); 22 | Integer temp = nodeNum; 23 | nodeNum = null; 24 | return temp; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/InheritanceToOne.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.ToOneProvider; 4 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 5 | import com.alvazan.orm.api.base.anno.NoSqlId; 6 | import com.alvazan.orm.api.base.anno.NoSqlManyToOne; 7 | 8 | @NoSqlEntity 9 | public class InheritanceToOne { 10 | 11 | @NoSqlId 12 | private String id; 13 | 14 | @NoSqlManyToOne 15 | private ToOneProvider inheritance = new ToOneProvider(); 16 | 17 | public String getId() { 18 | return id; 19 | } 20 | 21 | public void setId(String id) { 22 | this.id = id; 23 | } 24 | 25 | public InheritanceSuper getInheritance() { 26 | return inheritance.get(); 27 | } 28 | 29 | public void setInheritance(InheritanceSuper nameToEntity) { 30 | inheritance.set(nameToEntity); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer3/typed/TypedRowImpl.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer3.typed; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.alvazan.orm.api.z8spi.meta.DboTableMeta; 7 | import com.alvazan.orm.api.z8spi.meta.TypedColumn; 8 | import com.alvazan.orm.api.z8spi.meta.TypedRow; 9 | import com.alvazan.orm.api.z8spi.meta.ViewInfo; 10 | 11 | public class TypedRowImpl extends TypedRow { 12 | 13 | private Map originalValues = new HashMap(); 14 | 15 | public TypedRowImpl(ViewInfo view, DboTableMeta metaClass) { 16 | super(view, metaClass); 17 | } 18 | 19 | public Map getOriginalValues() { 20 | return originalValues; 21 | } 22 | 23 | public void setOriginalValues(Map originalValues) { 24 | this.originalValues = originalValues; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/NonVirtSub2.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlDiscriminatorColumn; 4 | import com.alvazan.orm.api.base.anno.NoSqlIndexed; 5 | 6 | @NoSqlDiscriminatorColumn(value="sub2") 7 | public class NonVirtSub2 extends NonVirtSuper { 8 | 9 | private String description; 10 | @NoSqlIndexed 11 | private int numBalls; 12 | 13 | @NoSqlIndexed 14 | private String color; 15 | 16 | @NoSqlIndexed 17 | private String color2; 18 | 19 | @NoSqlIndexed 20 | private String color3; 21 | 22 | public String getDescription() { 23 | return description; 24 | } 25 | public void setDescription(String name) { 26 | this.description = name; 27 | } 28 | public int getNumBalls() { 29 | return numBalls; 30 | } 31 | public void setNumBalls(int numBalls) { 32 | this.numBalls = numBalls; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/InheritanceSub2.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlDiscriminatorColumn; 4 | import com.alvazan.orm.api.base.anno.NoSqlIndexed; 5 | 6 | @NoSqlDiscriminatorColumn(value="sub2") 7 | public class InheritanceSub2 extends InheritanceSuper { 8 | 9 | private String description; 10 | @NoSqlIndexed 11 | private int numBalls; 12 | 13 | @NoSqlIndexed 14 | private String color; 15 | 16 | @NoSqlIndexed 17 | private String color2; 18 | 19 | @NoSqlIndexed 20 | private String color3; 21 | 22 | public String getDescription() { 23 | return description; 24 | } 25 | public void setDescription(String name) { 26 | this.description = name; 27 | } 28 | public int getNumBalls() { 29 | return numBalls; 30 | } 31 | public void setNumBalls(int numBalls) { 32 | this.numBalls = numBalls; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/play/logging/MyRejectHandler.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.play.logging; 2 | 3 | import java.util.concurrent.BlockingQueue; 4 | import java.util.concurrent.RejectedExecutionHandler; 5 | import java.util.concurrent.ThreadPoolExecutor; 6 | 7 | public class MyRejectHandler implements RejectedExecutionHandler { 8 | 9 | private AsyncAppender appender; 10 | 11 | public MyRejectHandler(AsyncAppender appender) { 12 | this.appender = appender; 13 | } 14 | 15 | @Override 16 | public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { 17 | appender.addWarn("WARNINNG, the queue is full, the system will slow down now as logging is a bottleneck"); 18 | BlockingQueue queue = executor.getQueue(); 19 | try { 20 | queue.put(r); 21 | } catch (InterruptedException e) { 22 | appender.addError("Could not put in queue", e); 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/ExpiringEntity.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 4 | import com.alvazan.orm.api.base.anno.NoSqlId; 5 | import com.alvazan.orm.api.base.anno.NoSqlIndexed; 6 | import com.alvazan.orm.api.base.anno.NoSqlTTL; 7 | 8 | @NoSqlEntity 9 | public class ExpiringEntity { 10 | 11 | @NoSqlId 12 | private long id; 13 | 14 | @NoSqlTTL 15 | private int ttl; 16 | 17 | @NoSqlIndexed 18 | private String name; 19 | 20 | public long getId() { 21 | return id; 22 | } 23 | 24 | public void setId(long id) { 25 | this.id = id; 26 | } 27 | 28 | public int getTtl() { 29 | return ttl; 30 | } 31 | 32 | public void setTtl(int ttl) { 33 | this.ttl = ttl; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z5api/QueryParser.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z5api; 2 | 3 | import com.alvazan.orm.api.z8spi.MetaLoader; 4 | import com.alvazan.orm.layer5.query.ScannerForQuery; 5 | import com.google.inject.ImplementedBy; 6 | 7 | @ImplementedBy(ScannerForQuery.class) 8 | public interface QueryParser { 9 | 10 | public SpiMetaQuery parseQueryForAdHoc(String query, MetaLoader mgr); 11 | 12 | /** 13 | * For ORM layer that want to use TABLE as the alias instead of typing Entity name which allows 14 | * you to refactor code without named queries breaking ;). 15 | * 16 | * @param query the s-sql query 17 | * @param targetTable name of the columnFamily 18 | * @param errorMsg 19 | * @return Meta Query for the provider 20 | */ 21 | public SpiMetaQuery parseQueryForOrm(String query, String targetTable, String errorMsg); 22 | 23 | public void close(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/CursorToMany.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base; 2 | 3 | import com.alvazan.orm.api.z8spi.iter.Cursor; 4 | 5 | /** 6 | * For situations on very wide rows where you don't want to run out of memory, you can use a CursorToMany. 7 | * 8 | * @author dhiller2 9 | * 10 | * @param 11 | */ 12 | public interface CursorToMany extends Cursor { 13 | 14 | /** 15 | * When you call this method, it remove the current item AND moves back to previous item or points to just before the first item if at the beginning 16 | * of the list. This allows you to call cursor.next(), cursor.removeCurrent(), cursor.next(), cursor.removeCurrent repeatedly. 17 | */ 18 | void removeCurrent(); 19 | 20 | /** 21 | * Adds an element at the end of the cursor to be saved to the database. 22 | * 23 | * @param element 24 | */ 25 | void addElement(T element); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/play/logging/ServersThatLog.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.play.logging; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.alvazan.orm.api.base.anno.NoSqlEmbedded; 7 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 8 | import com.alvazan.orm.api.base.anno.NoSqlId; 9 | 10 | @NoSqlEntity 11 | public class ServersThatLog { 12 | 13 | public static final String THE_ONE_KEY = "servers.that.log"; 14 | 15 | @NoSqlId(usegenerator=false) 16 | private String id; 17 | 18 | @NoSqlEmbedded 19 | private List servers = new ArrayList(); 20 | 21 | public String getId() { 22 | return id; 23 | } 24 | 25 | public void setId(String id) { 26 | this.id = id; 27 | } 28 | 29 | public List getServers() { 30 | return servers; 31 | } 32 | 33 | public void setServers(List servers) { 34 | this.servers = servers; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/impl/meta/data/readme.txt: -------------------------------------------------------------------------------- 1 | ScannerForXXX are singleton classes that do the scanning and should be doing all the parsing to create the meta objects for fields, queries, classes, etc. etc. MetaXXXX.java are the meta classes that are filled in and used at runtime. These classes are all looked up in hashmaps and do the translation from nosql to objects and back as well as translation between objects and the indexing formats too. 2 | 3 | NoSqlProxyImpl is the main proxy class that remains empty until a method is called on the object(except for getId() of course since it has that form the current table). Once a method is called on that object, it fills itself in by going to the database and getting the data and using the meta objects to fill itself in. 4 | 5 | MetaQuery should only be doing translation of ORM parameters if needed. All parsing should really be done in ScannerForQuery or something of that nature. -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/ForCollection.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | 6 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 7 | import com.alvazan.orm.api.base.anno.NoSqlId; 8 | import com.alvazan.orm.api.base.anno.NoSqlOneToMany; 9 | 10 | @NoSqlEntity 11 | public class ForCollection { 12 | 13 | @NoSqlId 14 | private String id; 15 | 16 | private String name; 17 | 18 | @NoSqlOneToMany 19 | private Collection activities = new ArrayList(); 20 | 21 | public String getId() { 22 | return id; 23 | } 24 | 25 | public void setId(String id) { 26 | this.id = id; 27 | } 28 | 29 | public String getName() { 30 | return name; 31 | } 32 | 33 | public void setName(String name) { 34 | this.name = name; 35 | } 36 | 37 | public Collection getActivities() { 38 | return activities; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/inmemory/DecimalComparator.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.inmemory; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.Comparator; 5 | 6 | import com.alvazan.orm.api.z8spi.conv.ByteArray; 7 | import com.alvazan.orm.api.z8spi.conv.StandardConverters; 8 | 9 | public class DecimalComparator implements Comparator { 10 | 11 | @Override 12 | public int compare(ByteArray o1, ByteArray o2) { 13 | if(o1.getKey() == null && o2.getKey() != null) 14 | return -1; 15 | else if(o2.getKey() == null && o1.getKey() != null) 16 | return 1; 17 | else if(o2.getKey() == null && o1.getKey() == null) 18 | return 0; 19 | 20 | BigDecimal left = StandardConverters.convertFromBytes(BigDecimal.class, o1.getKey()); 21 | BigDecimal right = StandardConverters.convertFromBytes(BigDecimal.class, o2.getKey()); 22 | return left.compareTo(right); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/ForSet.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import java.util.Collection; 4 | import java.util.HashSet; 5 | import java.util.Set; 6 | 7 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 8 | import com.alvazan.orm.api.base.anno.NoSqlId; 9 | import com.alvazan.orm.api.base.anno.NoSqlOneToMany; 10 | 11 | @NoSqlEntity 12 | public class ForSet { 13 | 14 | @NoSqlId 15 | private String id; 16 | 17 | private String name; 18 | 19 | @NoSqlOneToMany 20 | private Set activities = new HashSet(); 21 | 22 | public String getId() { 23 | return id; 24 | } 25 | 26 | public void setId(String id) { 27 | this.id = id; 28 | } 29 | 30 | public String getName() { 31 | return name; 32 | } 33 | 34 | public void setName(String name) { 35 | this.name = name; 36 | } 37 | 38 | public Collection getActivities() { 39 | return activities; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/meta/IndexData.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.meta; 2 | 3 | import com.alvazan.orm.api.z8spi.action.IndexColumn; 4 | import com.alvazan.orm.api.z8spi.conv.StandardConverters; 5 | 6 | public class IndexData { 7 | private String columnFamilyName; 8 | private String rowKey; 9 | private IndexColumn indexColumn = new IndexColumn(); 10 | 11 | public void setColumnFamilyName(String indexTableName) { 12 | this.columnFamilyName = indexTableName; 13 | } 14 | 15 | public void setRowKey(String key) { 16 | this.rowKey = key; 17 | } 18 | 19 | public String getColumnFamilyName() { 20 | return columnFamilyName; 21 | } 22 | 23 | public String getRowKey() { 24 | return rowKey; 25 | } 26 | 27 | public byte[] getRowKeyBytes() { 28 | return StandardConverters.convertToBytes(rowKey); 29 | } 30 | 31 | public IndexColumn getIndexColumn() { 32 | return indexColumn; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/inmemory/IntegerComparator.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.inmemory; 2 | 3 | import java.math.BigInteger; 4 | import java.util.Comparator; 5 | 6 | import com.alvazan.orm.api.z8spi.conv.ByteArray; 7 | import com.alvazan.orm.api.z8spi.conv.StandardConverters; 8 | 9 | public class IntegerComparator implements Comparator { 10 | 11 | @Override 12 | public int compare(ByteArray o1, ByteArray o2) { 13 | if(o1.getKey() == null && o2.getKey() != null) 14 | return -1; 15 | else if(o2.getKey() == null && o1.getKey() != null) 16 | return 1; 17 | else if(o2.getKey() == null && o1.getKey() == null) 18 | return 0; 19 | 20 | BigInteger left = StandardConverters.convertFromBytes(BigInteger.class, o1.getKey()); 21 | BigInteger right = StandardConverters.convertFromBytes(BigInteger.class, o2.getKey()); 22 | 23 | return left.compareTo(right); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/parser/antlr/ParsedNode.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.parser.antlr; 2 | 3 | import java.util.List; 4 | 5 | 6 | 7 | 8 | 9 | public interface ParsedNode { 10 | 11 | int getType(); 12 | 13 | ParsedNode getParent(); 14 | 15 | ParsedNode getChild(ChildSide side); 16 | 17 | void setChild(ChildSide left, ParsedNode nodeToMove); 18 | 19 | String getAliasAndColumn(); 20 | 21 | //For join optimization... 22 | ViewInfoImpl getViewInfo(); 23 | boolean isAndOrType(); 24 | void setJoinMeta(JoinMeta info); 25 | JoinMeta getJoinMeta(); 26 | 27 | boolean isConstant(); 28 | boolean isParameter(); 29 | 30 | void replace(ParsedNode oldChild, ParsedNode newChild); 31 | ParsedNode getOppositeChild(ParsedNode first); 32 | 33 | boolean isBetweenExpression(); 34 | 35 | List getChildrenForIn(); 36 | void setChildrenForIn(List listOfNode); 37 | boolean isInExpression(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /tools/playorm-cli.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if "%OS%" == "Windows_NT" setlocal 4 | 5 | if NOT DEFINED JAVA_HOME goto :err 6 | 7 | REM Ensure that any user defined CLASSPATH variables are not used on startup 8 | set CLASSPATH= 9 | 10 | REM For each jar in the lib directory call append to build the CLASSPATH variable. 11 | for %%i in ("..\output\jardist\*.jar") do call :append "%%i" 12 | for %%j in ("..\lib\*.jar") do call :append "%%j" 13 | 14 | goto okClasspath 15 | 16 | :append 17 | set CLASSPATH=%CLASSPATH%;%1 18 | goto :eof 19 | 20 | :okClasspath 21 | REM Include the \classes directory so it works in development 22 | set PLAYORM_CLASSPATH="..\bin";%CLASSPATH%; 23 | goto runCli 24 | 25 | :runCli 26 | "%JAVA_HOME%\bin\java" -cp %PLAYORM_CLASSPATH% com.alvazan.ssql.cmdline.PlayOrm %* 27 | goto finally 28 | 29 | :err 30 | echo The JAVA_HOME environment variable must be set to run this program! 31 | pause 32 | 33 | :finally 34 | 35 | ENDLOCAL 36 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/mongodb/Info.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.mongodb; 2 | 3 | import com.alvazan.orm.api.z8spi.ColumnType; 4 | import com.alvazan.orm.api.z8spi.conv.StorageTypeEnum; 5 | import com.mongodb.DBCollection; 6 | 7 | public class Info { 8 | 9 | private StorageTypeEnum rowKeyType; 10 | private ColumnType columnType; 11 | private DBCollection dbObj; 12 | 13 | public ColumnType getColumnType() { 14 | return columnType; 15 | } 16 | 17 | public void setColumnType(ColumnType columnType) { 18 | this.columnType = columnType; 19 | } 20 | 21 | public void setDbObj(DBCollection cf) { 22 | this.dbObj = cf; 23 | } 24 | 25 | public DBCollection getDbObj() { 26 | return dbObj; 27 | } 28 | 29 | public StorageTypeEnum getRowKeyType() { 30 | return rowKeyType; 31 | } 32 | 33 | public void setRowKeyType(StorageTypeEnum rowKeyType) { 34 | this.rowKeyType = rowKeyType; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/Config.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test; 2 | 3 | import com.alvazan.orm.api.base.DbTypeEnum; 4 | 5 | public class Config { 6 | 7 | private DbTypeEnum serverType; 8 | private String clusterName; 9 | private String seeds; 10 | 11 | public Config(DbTypeEnum serverType, String clusterName, String seeds) { 12 | this.serverType = serverType; 13 | this.clusterName = clusterName; 14 | this.seeds = seeds; 15 | } 16 | 17 | public DbTypeEnum getServerType() { 18 | return serverType; 19 | } 20 | 21 | public void setServerType(DbTypeEnum serverType) { 22 | this.serverType = serverType; 23 | } 24 | 25 | public String getClusterName() { 26 | return clusterName; 27 | } 28 | 29 | public void setClusterName(String clusterName) { 30 | this.clusterName = clusterName; 31 | } 32 | 33 | public String getSeeds() { 34 | return seeds; 35 | } 36 | 37 | public void setSeeds(String seeds) { 38 | this.seeds = seeds; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/Row.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi; 2 | 3 | import java.util.Collection; 4 | import java.util.List; 5 | 6 | import com.alvazan.orm.api.z8spi.action.Column; 7 | import com.alvazan.orm.api.z8spi.action.IndexColumn; 8 | import com.alvazan.orm.layer9z.spi.db.inmemory.RowImpl; 9 | import com.google.inject.ImplementedBy; 10 | 11 | @ImplementedBy(RowImpl.class) 12 | public interface Row { 13 | 14 | byte[] getKey(); 15 | 16 | void setKey(byte[] key); 17 | 18 | Collection getColumns(); 19 | 20 | Column getColumn(byte[] key); 21 | 22 | void put(Column col); 23 | 24 | void remove(byte[] name); 25 | 26 | Collection columnSlice(byte[] from, byte[] to); 27 | 28 | Collection columnSlice(Key from, Key to); 29 | 30 | Collection columnByPrefix(byte[] prefix); 31 | 32 | Row deepCopy(); 33 | 34 | void addColumns(List columns); 35 | 36 | void removeColumns(Collection columnNames); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/cassandracql3/Info.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.cassandracql3; 2 | 3 | import com.alvazan.orm.api.z8spi.ColumnType; 4 | import com.alvazan.orm.api.z8spi.conv.StorageTypeEnum; 5 | import com.datastax.driver.core.TableMetadata; 6 | 7 | public class Info { 8 | 9 | private StorageTypeEnum rowKeyType; 10 | private ColumnType columnType; 11 | private TableMetadata tableMetadata; 12 | public StorageTypeEnum getRowKeyType() { 13 | return rowKeyType; 14 | } 15 | public void setRowKeyType(StorageTypeEnum rowKeyType) { 16 | this.rowKeyType = rowKeyType; 17 | } 18 | public ColumnType getColumnType() { 19 | return columnType; 20 | } 21 | public void setColumnType(ColumnType columnType) { 22 | this.columnType = columnType; 23 | } 24 | public TableMetadata getTableMetadata() { 25 | return tableMetadata; 26 | } 27 | public void setTableMetadata(TableMetadata tableMetadata) { 28 | this.tableMetadata = tableMetadata; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/hbase/Info.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.hbase; 2 | 3 | import org.apache.hadoop.hbase.HColumnDescriptor; 4 | 5 | import com.alvazan.orm.api.z8spi.ColumnType; 6 | import com.alvazan.orm.api.z8spi.conv.StorageTypeEnum; 7 | 8 | public class Info { 9 | 10 | private StorageTypeEnum rowKeyType; 11 | private ColumnType columnType; 12 | private HColumnDescriptor colFamily; 13 | 14 | public HColumnDescriptor getColFamily() { 15 | return colFamily; 16 | } 17 | 18 | public void setColFamily(HColumnDescriptor colFamily) { 19 | this.colFamily = colFamily; 20 | } 21 | 22 | public ColumnType getColumnType() { 23 | return columnType; 24 | } 25 | 26 | public void setColumnType(ColumnType columnType) { 27 | this.columnType = columnType; 28 | } 29 | 30 | public StorageTypeEnum getRowKeyType() { 31 | return rowKeyType; 32 | } 33 | 34 | public void setRowKeyType(StorageTypeEnum rowKeyType) { 35 | this.rowKeyType = rowKeyType; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/InheritedNestedBaseForB.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @COPYRIGHT (C) 2010 Hotel Reservation Service (HRS) Robert Ragge GmbH 3 | * 4 | * All rights reserved 5 | */ 6 | package com.alvazan.test.db; 7 | 8 | import com.alvazan.orm.api.base.anno.NoSqlInheritance; 9 | import com.alvazan.orm.api.base.anno.NoSqlInheritanceType; 10 | import com.alvazan.orm.api.base.anno.NoSqlId; 11 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 12 | 13 | /** 14 | * @author Robert Stupp (last modified by $Author$) 15 | * @version $Revision$ $Date$ 16 | */ 17 | @NoSqlEntity 18 | @NoSqlInheritance(discriminatorColumnName = "discr", strategy = NoSqlInheritanceType.SINGLE_TABLE, subclassesToScan = { 19 | InheritedNestedB.class 20 | }) 21 | public class InheritedNestedBaseForB { 22 | @NoSqlId 23 | private String idForB; 24 | 25 | public String getIdForB() { 26 | return idForB; 27 | } 28 | 29 | public void setIdForB(String idForB) { 30 | this.idForB = idForB; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/listener/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 69 4 | /svn/!svn/ver/11/trunk/src/main/java/com/impetus/annovention/listener 5 | END 6 | AnnotationDiscoveryListener.java 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 101 10 | /svn/!svn/ver/7/trunk/src/main/java/com/impetus/annovention/listener/AnnotationDiscoveryListener.java 11 | END 12 | MethodAnnotationDiscoveryListener.java 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 108 16 | /svn/!svn/ver/11/trunk/src/main/java/com/impetus/annovention/listener/MethodAnnotationDiscoveryListener.java 17 | END 18 | FieldAnnotationDiscoveryListener.java 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 106 22 | /svn/!svn/ver/7/trunk/src/main/java/com/impetus/annovention/listener/FieldAnnotationDiscoveryListener.java 23 | END 24 | ClassAnnotationDiscoveryListener.java 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 106 28 | /svn/!svn/ver/7/trunk/src/main/java/com/impetus/annovention/listener/ClassAnnotationDiscoveryListener.java 29 | END 30 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/EntityWithUUIDKey.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | 4 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 5 | import com.alvazan.orm.api.base.anno.NoSqlId; 6 | import com.alvazan.orm.api.base.anno.NoSqlIndexed; 7 | import com.alvazan.orm.api.base.anno.NoSqlManyToOne; 8 | import com.eaio.uuid.UUID; 9 | 10 | @NoSqlEntity 11 | public class EntityWithUUIDKey { 12 | 13 | @NoSqlId 14 | private UUID id; 15 | 16 | @NoSqlIndexed 17 | private String something; 18 | 19 | @NoSqlManyToOne 20 | private Account account; 21 | 22 | public Account getAccount() { 23 | return account; 24 | } 25 | 26 | public void setAccount(Account account) { 27 | this.account = account; 28 | } 29 | 30 | public UUID getId() { 31 | return id; 32 | } 33 | 34 | public void setId(UUID id) { 35 | this.id = id; 36 | } 37 | 38 | public String getSomething() { 39 | return something; 40 | } 41 | 42 | public void setSomething(String something) { 43 | this.something = something; 44 | } 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/NoSqlDao.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base; 2 | 3 | import com.alvazan.orm.api.z8spi.KeyValue; 4 | import com.alvazan.orm.api.z8spi.iter.Cursor; 5 | import com.alvazan.orm.api.z8spi.meta.DboTableMeta; 6 | 7 | public class NoSqlDao { 8 | 9 | public static Cursor> findAllTables(NoSqlEntityManager mgr) { 10 | Query query = mgr.createNamedQuery(DboTableMeta.class, "findAll"); 11 | return query.getResults(); 12 | } 13 | 14 | public static Cursor> findTablesWithPrefix(NoSqlEntityManager mgr, String prefix) { 15 | Query query = mgr.createNamedQuery(DboTableMeta.class, "findLike"); 16 | query.setParameter("prefix", prefix); 17 | //Just tack on ONE letter that is definitely LARGER than any other character they can supply 18 | //and we will be able to get all results with that prefix.. 19 | String lastValue = prefix+"\uffff"; 20 | query.setParameter("modifiedPrefix", lastValue); 21 | return query.getResults(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/action/Remove.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.action; 2 | 3 | import java.util.Collection; 4 | 5 | import com.alvazan.orm.api.z8spi.meta.DboTableMeta; 6 | 7 | 8 | public class Remove implements Action { 9 | private DboTableMeta colFamily; 10 | private byte[] rowKey; 11 | private RemoveEnum action; 12 | private Collection columns; 13 | 14 | public RemoveEnum getAction() { 15 | return action; 16 | } 17 | public void setAction(RemoveEnum action) { 18 | this.action = action; 19 | } 20 | public DboTableMeta getColFamily() { 21 | return colFamily; 22 | } 23 | public void setColFamily(DboTableMeta colFamily2) { 24 | this.colFamily = colFamily2; 25 | } 26 | public byte[] getRowKey() { 27 | return rowKey; 28 | } 29 | public void setRowKey(byte[] rowKey) { 30 | this.rowKey = rowKey; 31 | } 32 | public Collection getColumns() { 33 | return columns; 34 | } 35 | public void setColumns(Collection columnNames) { 36 | this.columns = columnNames; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/resources/debug/DebugOnWindows_playorm-cli.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if "%OS%" == "Windows_NT" setlocal 4 | 5 | if NOT DEFINED JAVA_HOME goto :err 6 | 7 | REM Ensure that any user defined CLASSPATH variables are not used on startup 8 | set CLASSPATH= 9 | 10 | REM For each jar in the lib directory call append to build the CLASSPATH variable. 11 | for %%i in ("..\..\..\output\jardist\*.jar") do call :append "%%i" 12 | 13 | goto okClasspath 14 | 15 | :append 16 | set CLASSPATH=%CLASSPATH%;%1 17 | goto :eof 18 | 19 | :okClasspath 20 | REM Include the \classes directory so it works in development 21 | set PLAYORM_CLASSPATH="..\..\..\bin";%CLASSPATH%; 22 | 23 | SET A_PORT=8000 24 | SET A_DBG=-Xdebug -Xrunjdwp:transport=dt_socket,address=127.0.0.1:8000,suspend=y 25 | goto runCli 26 | 27 | 28 | :runCli 29 | "%JAVA_HOME%\bin\java" %A_DBG% -cp %PLAYORM_CLASSPATH% com.alvazan.ssql.cmdline.PlayOrm %* 30 | goto finally 31 | 32 | :err 33 | echo The JAVA_HOME environment variable must be set to run this program! 34 | pause 35 | 36 | :finally 37 | 38 | ENDLOCAL 39 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/InheritedNestedA.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @COPYRIGHT (C) 2010 Hotel Reservation Service (HRS) Robert Ragge GmbH 3 | * 4 | * All rights reserved 5 | */ 6 | package com.alvazan.test.db; 7 | 8 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 9 | import com.alvazan.orm.api.base.anno.NoSqlId; 10 | import com.alvazan.orm.api.base.anno.NoSqlOneToMany; 11 | 12 | import java.util.HashSet; 13 | import java.util.Set; 14 | 15 | /** 16 | * @author Robert Stupp (last modified by $Author$) 17 | * @version $Revision$ $Date$ 18 | */ 19 | @NoSqlEntity 20 | public class InheritedNestedA { 21 | @NoSqlId 22 | private int idForA; 23 | 24 | @NoSqlOneToMany(columnName = "bs") 25 | private Set setOfB = new HashSet(); 26 | 27 | public int getIdForA() { 28 | return idForA; 29 | } 30 | 31 | public void setIdForA(int idForA) { 32 | this.idForA = idForA; 33 | } 34 | 35 | public Set getSetOfB() { 36 | return setOfB; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/example/src/com/example/db/User.java: -------------------------------------------------------------------------------- 1 | package com.example.db; 2 | 3 | 4 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 5 | import com.alvazan.orm.api.base.anno.NoSqlId; 6 | import com.alvazan.orm.api.base.anno.NoSqlIndexed; 7 | 8 | 9 | @NoSqlEntity 10 | public class User { 11 | 12 | @NoSqlId 13 | private String id; 14 | 15 | @NoSqlIndexed 16 | private String name; 17 | 18 | @NoSqlIndexed 19 | private int age; 20 | 21 | private String lastName; 22 | 23 | 24 | public String getId() { 25 | return id; 26 | } 27 | 28 | public void setId(String id) { 29 | this.id = id; 30 | } 31 | 32 | public int getAge() { 33 | return age; 34 | } 35 | 36 | public void setAge(int age) { 37 | this.age = age; 38 | } 39 | 40 | public String getName() { 41 | return name; 42 | } 43 | 44 | public void setName(String name) { 45 | this.name = name; 46 | } 47 | 48 | public String getLastName() { 49 | return lastName; 50 | } 51 | 52 | public void setLastName(String lastName) { 53 | this.lastName = lastName; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/listener/AnnotationDiscoveryListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Impetus Infotech. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.impetus.annovention.listener; 17 | 18 | /** 19 | * The Interface AnnotationDiscoveryListener. 20 | * 21 | * @author animesh.kumar 22 | */ 23 | public interface AnnotationDiscoveryListener { 24 | 25 | /** 26 | * @return Array of supported annotations names 27 | */ 28 | String[] supportedAnnotations(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/inmemory/Utf8Comparator.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.inmemory; 2 | 3 | import java.util.Comparator; 4 | 5 | import com.alvazan.orm.api.z8spi.conv.ByteArray; 6 | import com.alvazan.orm.api.z8spi.conv.StandardConverters; 7 | 8 | public class Utf8Comparator implements Comparator { 9 | 10 | @Override 11 | public int compare(ByteArray o1, ByteArray o2) { 12 | if(o1.getKey() == null && o2.getKey() != null) 13 | return -1; 14 | else if(o2.getKey() == null && o1.getKey() != null) 15 | return 1; 16 | else if(o2.getKey() == null && o1.getKey() == null) 17 | return 0; 18 | 19 | String left = StandardConverters.convertFromBytes(String.class, o1.getKey()); 20 | String right = StandardConverters.convertFromBytes(String.class, o2.getKey()); 21 | int result = left.compareTo(right); 22 | if(result != 0) 23 | return result; 24 | 25 | //otherwise, in the case of certain composites, we must now compare ByteArrays to match cassandra 26 | return o1.compareTo(o2); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/InheritanceToMany.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 7 | import com.alvazan.orm.api.base.anno.NoSqlId; 8 | import com.alvazan.orm.api.base.anno.NoSqlOneToMany; 9 | 10 | @NoSqlEntity 11 | public class InheritanceToMany { 12 | 13 | @NoSqlId 14 | private String id; 15 | 16 | @NoSqlOneToMany(keyFieldForMap="lastName") 17 | private final Map nameToEntity = new HashMap(); 18 | 19 | public String getId() { 20 | return id; 21 | } 22 | 23 | public void setId(String id) { 24 | this.id = id; 25 | } 26 | 27 | public Map getNameToEntity() { 28 | return nameToEntity; 29 | } 30 | 31 | // public void setNameToEntity(Map nameToEntity) { 32 | // this.nameToEntity = nameToEntity; 33 | // } 34 | 35 | public void addEntity(InheritanceSuper entity) { 36 | nameToEntity.put(entity.getLastName(), entity); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/impl/meta/data/collections/SimpleSet.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.impl.meta.data.collections; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import java.util.Set; 6 | 7 | import com.alvazan.orm.api.z8spi.conv.Converter; 8 | 9 | @SuppressWarnings({ "rawtypes", "unchecked" }) 10 | public class SimpleSet extends SimpleAbstractCollection implements Set { 11 | 12 | @SuppressWarnings("unused") 13 | private static final long serialVersionUID = 1L; 14 | 15 | public SimpleSet(Converter converter, List keys) { 16 | super(converter, keys); 17 | } 18 | 19 | public SimpleSet(List keys) { 20 | super(keys); 21 | } 22 | 23 | public Object clone() throws CloneNotSupportedException { 24 | SimpleSet v = (SimpleSet) super.clone(); 25 | SimpleSet[] current = this.toArray(new SimpleSet[0]); 26 | SimpleSet[] clone = Arrays.copyOf(current, this.size()); 27 | List asList = Arrays.asList(clone); 28 | v.addAll(asList); 29 | 30 | return v; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/NonVirtSuper.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 4 | import com.alvazan.orm.api.base.anno.NoSqlId; 5 | import com.alvazan.orm.api.base.anno.NoSqlInheritance; 6 | import com.alvazan.orm.api.base.anno.NoSqlInheritanceType; 7 | 8 | @NoSqlEntity 9 | @NoSqlInheritance(subclassesToScan={NonVirtSub1.class, NonVirtSub2.class}, 10 | strategy=NoSqlInheritanceType.SINGLE_TABLE, discriminatorColumnName="classType") 11 | public class NonVirtSuper { 12 | 13 | @NoSqlId 14 | private String id; 15 | 16 | private long num; 17 | 18 | private String lastName; 19 | 20 | public String getId() { 21 | return id; 22 | } 23 | 24 | public void setId(String id) { 25 | this.id = id; 26 | } 27 | 28 | public long getNum() { 29 | return num; 30 | } 31 | 32 | public void setNum(long num) { 33 | this.num = num; 34 | } 35 | 36 | public String getLastName() { 37 | return lastName; 38 | } 39 | 40 | public void setLastName(String lastName) { 41 | this.lastName = lastName; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/listener/.svn/text-base/AnnotationDiscoveryListener.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Impetus Infotech. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.impetus.annovention.listener; 17 | 18 | /** 19 | * The Interface AnnotationDiscoveryListener. 20 | * 21 | * @author animesh.kumar 22 | */ 23 | public interface AnnotationDiscoveryListener { 24 | 25 | /** 26 | * @return Array of supported annotations names 27 | */ 28 | String[] supportedAnnotations(); 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/InheritedNestedBaseForC.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @COPYRIGHT (C) 2010 Hotel Reservation Service (HRS) Robert Ragge GmbH 3 | * 4 | * All rights reserved 5 | */ 6 | package com.alvazan.test.db; 7 | 8 | import com.alvazan.orm.api.base.anno.NoSqlInheritance; 9 | import com.alvazan.orm.api.base.anno.NoSqlInheritanceType; 10 | import com.alvazan.orm.api.base.anno.NoSqlId; 11 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 12 | 13 | /** 14 | * @author Robert Stupp (last modified by $Author$) 15 | * @version $Revision$ $Date$ 16 | */ 17 | @NoSqlEntity 18 | @NoSqlInheritance( // 19 | discriminatorColumnName = "discr", // 20 | strategy = NoSqlInheritanceType.SINGLE_TABLE, // 21 | subclassesToScan = { // 22 | InheritedNestedC.class }) 23 | public class InheritedNestedBaseForC { 24 | 25 | @NoSqlId 26 | private long idForC; 27 | 28 | public long getIdForC() { 29 | return idForC; 30 | } 31 | 32 | public void setIdForC(long idForC) { 33 | this.idForC = idForC; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/.svn/text-base/Filter.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Impetus Infotech. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.impetus.annovention; 17 | 18 | /** 19 | * Interface to filter out filenames. 20 | * 21 | * @author animesh.kumar 22 | */ 23 | public interface Filter { 24 | 25 | /** 26 | * If true, the file is accepted, else rejected. 27 | * 28 | * @param filename 29 | * @return 30 | */ 31 | boolean accepts(String filename); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/Filter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Impetus Infotech. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.impetus.annovention; 17 | 18 | /** 19 | * Interface to filter out filenames. 20 | * 21 | * @author animesh.kumar 22 | */ 23 | public interface Filter { 24 | 25 | /** 26 | * If true, the file is accepted, else rejected. 27 | * 28 | * @param filename 29 | * @return file is accepted or not 30 | */ 31 | boolean accepts(String filename); 32 | } 33 | -------------------------------------------------------------------------------- /todo.txt: -------------------------------------------------------------------------------- 1 | map/reduce failing with classloader issue 2 | 3 | 4 | finish PLAY plugin for NoSql stuff to make that easier...only need to add edits now to playframework plugin and we are good..later add gui for queries 5 | 6 | do a TimeUUID for PlayOrm with a type1 style UUID (ie. not random) and allow queries on time range as well. 7 | 8 | make sure query on LocalDateTime works and add test case as well 9 | 10 | test query by a data format like 10/2/21 10:15:37.893 11 | 12 | add queries/indexing of @Embedded stuff as well 13 | 14 | Add the in clause in S-SQL so we can also do a findAll without findAll method at all 15 | 16 | tests for extra data so we can read in row AND read in data we don't have schema for as well to tack on to entity 17 | 18 | Add generic Map to suck in additional columns we don't have schema for as well 19 | 20 | playframework plugin as well using query interface in development mode 21 | 22 | delayed joins not working yet 23 | 24 | 25 | allow to query on non-index fields!!! 26 | 27 | add support for hadoop first and then mongodb after that as well 28 | 29 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/meta/DboColumnMarkerMeta.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.meta; 2 | 3 | import com.alvazan.orm.api.z8spi.Row; 4 | import com.alvazan.orm.api.z8spi.conv.StorageTypeEnum; 5 | 6 | public class DboColumnMarkerMeta extends DboColumnMeta { 7 | 8 | @Override 9 | public boolean isPartitionedByThisColumn() { 10 | return false; 11 | } 12 | 13 | @Override 14 | public String getIndexTableName() { 15 | throw new UnsupportedOperationException("Indexing marker column is not supported"); 16 | } 17 | 18 | @Override 19 | public Class getClassType() { 20 | return byte[].class; 21 | } 22 | 23 | @Override 24 | public StorageTypeEnum getStorageType() { 25 | return StorageTypeEnum.NULL; 26 | } 27 | 28 | @Override 29 | public void translateToColumn(InfoForIndex info) { 30 | // TODO Auto-generated method stub 31 | 32 | } 33 | 34 | @Override 35 | public void translateFromColumn(Row row, TypedRow inst) { 36 | // TODO Auto-generated method stub 37 | 38 | } 39 | 40 | @Override 41 | public String fetchColumnValueAsString(TypedRow row) { 42 | return ""; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/EmbeddedEntityWithNoId.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlEmbeddable; 4 | 5 | @NoSqlEmbeddable 6 | public class EmbeddedEntityWithNoId { 7 | 8 | private String id; 9 | 10 | private String name; 11 | 12 | private String type; 13 | 14 | private boolean something = true; 15 | 16 | private int number = 23; 17 | 18 | public String getId() { 19 | return id; 20 | } 21 | 22 | public void setId(String id) { 23 | this.id = id; 24 | } 25 | 26 | public String getName() { 27 | return name; 28 | } 29 | 30 | public void setName(String name) { 31 | this.name = name; 32 | } 33 | 34 | public String getType() { 35 | return type; 36 | } 37 | 38 | public void setType(String type) { 39 | this.type = type; 40 | } 41 | 42 | public boolean isSomething() { 43 | return something; 44 | } 45 | 46 | public void setSomething(boolean something) { 47 | this.something = something; 48 | } 49 | 50 | public int getNumber() { 51 | return number; 52 | } 53 | 54 | public void setNumber(int number) { 55 | this.number = number; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer0/base/DebugCursor.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer0.base; 2 | 3 | import com.alvazan.orm.api.z5api.IndexColumnInfo; 4 | import com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder; 5 | import com.alvazan.orm.api.z8spi.iter.DirectCursor; 6 | 7 | public class DebugCursor implements DirectCursor { 8 | 9 | private DirectCursor cursor; 10 | private boolean alreadyRan; 11 | 12 | public DebugCursor(DirectCursor cursor) { 13 | this.cursor = cursor; 14 | } 15 | 16 | @Override 17 | public Holder nextImpl() { 18 | return cursor.nextImpl(); 19 | } 20 | 21 | @Override 22 | public Holder previousImpl() { 23 | return cursor.previousImpl(); 24 | } 25 | 26 | @Override 27 | public void beforeFirst() { 28 | if(alreadyRan) 29 | throw new IllegalArgumentException("This cursor cannot be reset"); 30 | alreadyRan = true; 31 | } 32 | 33 | @Override 34 | public void afterLast() { 35 | if(alreadyRan) 36 | throw new IllegalArgumentException("This cursor cannot be reset"); 37 | alreadyRan = true; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/inmemory/PrefixComparator.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.inmemory; 2 | 3 | import java.util.Comparator; 4 | 5 | import com.alvazan.orm.api.z8spi.conv.ByteArray; 6 | import com.alvazan.orm.layer9z.spi.db.inmemory.IndexedRow.OurKey; 7 | 8 | public class PrefixComparator implements Comparator { 9 | 10 | private Comparator comparator; 11 | public PrefixComparator(Comparator comparator) { 12 | this.comparator = comparator; 13 | } 14 | @Override 15 | public int compare(OurKey o1, OurKey o2) { 16 | int result = comparator.compare(o1.getPrefix(), o2.getPrefix()); 17 | if(result != 0) 18 | return result; 19 | 20 | //If prefixes are equal, we still need to sort them and order doesn't really matter so we will sort by 21 | //the postfix ByteArray 22 | 23 | //If postfix is null, it is greater than everything and should ONLY be used when querying anyways!!! 24 | if(o2.getPostfix() == null) 25 | return -1; 26 | else if(o1.getPostfix() == null) 27 | return 1; 28 | 29 | return o1.getPostfix().compareTo(o2.getPostfix()); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/InheritanceToManySpecific.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.alvazan.orm.api.base.CursorToMany; 7 | import com.alvazan.orm.api.base.CursorToManyImpl; 8 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 9 | import com.alvazan.orm.api.base.anno.NoSqlId; 10 | import com.alvazan.orm.api.base.anno.NoSqlManyToMany; 11 | import com.alvazan.orm.api.base.anno.NoSqlOneToMany; 12 | 13 | @NoSqlEntity 14 | public class InheritanceToManySpecific { 15 | 16 | @NoSqlId 17 | private String id; 18 | 19 | @NoSqlManyToMany 20 | private List inheritance = new ArrayList(); 21 | 22 | @NoSqlOneToMany 23 | private CursorToMany anotherSet = new CursorToManyImpl(); 24 | 25 | public String getId() { 26 | return id; 27 | } 28 | 29 | public void setId(String id) { 30 | this.id = id; 31 | } 32 | 33 | public List getInheritance() { 34 | return inheritance; 35 | } 36 | 37 | public void addSomething(InheritanceSub1 sub) { 38 | inheritance.add(sub); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/MetaLayer.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base; 2 | 3 | public interface MetaLayer { 4 | 5 | /** 6 | * Mainly for framework code but a nice way to get the key of an unknown entity 7 | * where you don't care about the entity but just need that dang key 8 | * @param entity 9 | * @return The desired rowkey 10 | */ 11 | public Object getKey(Object entity); 12 | 13 | /** 14 | * Determining if an Entity is managed by this manager is not just a test of whether @Entity annotation exists as there 15 | * are cases like inheritance where subclasses do not have that annotation but are managed by the ORM. 16 | * @param type 17 | * @return true if the entity is managed by this Manager 18 | */ 19 | public boolean isManagedEntity(Class type); 20 | 21 | public String getKeyFieldName(Class type); 22 | 23 | /** 24 | * Takes the id in String form and convert it to the correct id form whatever that may be 25 | * as far as Long, String, etc. etc. 26 | * 27 | * @param entityType 28 | * @return converted Id 29 | */ 30 | public Object convertIdFromString(Class entityType, String idAsString); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/action/RemoveIndex.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.action; 2 | 3 | import com.alvazan.orm.api.z8spi.meta.DboTableMeta; 4 | 5 | 6 | 7 | 8 | public class RemoveIndex implements Action { 9 | private DboTableMeta colFamily; 10 | private byte[] rowKey; 11 | private IndexColumn column; 12 | private String indexCfName; 13 | 14 | public DboTableMeta getColFamily() { 15 | return colFamily; 16 | } 17 | public void setColFamily(DboTableMeta indexColFamily) { 18 | this.colFamily = indexColFamily; 19 | } 20 | public byte[] getRowKey() { 21 | return rowKey; 22 | } 23 | public void setRowKey(byte[] rowKey) { 24 | this.rowKey = rowKey; 25 | } 26 | public IndexColumn getColumn() { 27 | return column; 28 | } 29 | public void setColumn(IndexColumn column) { 30 | this.column = column; 31 | } 32 | @Override 33 | public String toString() { 34 | return "indexChg to:"+colFamily.getColumnFamily()+"."+column.getColumnName(); 35 | } 36 | public String getIndexCfName() { 37 | return indexCfName; 38 | } 39 | public void setIndexCfName(String indexCfName) { 40 | this.indexCfName = indexCfName; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer5/nosql/cache/EmptyCache.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer5.nosql.cache; 2 | 3 | import com.alvazan.orm.api.z8spi.Cache; 4 | import com.alvazan.orm.api.z8spi.Row; 5 | import com.alvazan.orm.api.z8spi.RowHolder; 6 | import com.alvazan.orm.api.z8spi.meta.DboTableMeta; 7 | 8 | public class EmptyCache implements Cache { 9 | 10 | private Cache realCache; 11 | private boolean skipCache; 12 | private boolean cacheResults; 13 | 14 | public EmptyCache(Cache c, boolean skipCache, boolean cacheResults) { 15 | if(c == null) 16 | throw new IllegalArgumentException("c can't be null"); 17 | realCache = c; 18 | this.skipCache = skipCache; 19 | this.cacheResults = cacheResults; 20 | } 21 | 22 | @Override 23 | public RowHolder fromCache(DboTableMeta colFamily, byte[] key) { 24 | if(skipCache) 25 | return null; 26 | return realCache.fromCache(colFamily, key); 27 | } 28 | 29 | //For queries we want to cache every row still....we just get all values from database 30 | @Override 31 | public void cacheRow(DboTableMeta colFamily, byte[] b, Row value) { 32 | if(cacheResults) 33 | realCache.cacheRow(colFamily, b, value); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z5api/SpiQueryAdapter.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z5api; 2 | 3 | import java.util.Set; 4 | 5 | import com.alvazan.orm.api.z8spi.iter.DirectCursor; 6 | import com.alvazan.orm.api.z8spi.meta.ViewInfo; 7 | 8 | 9 | public interface SpiQueryAdapter { 10 | 11 | public void setParameter(String parameterName, byte[] value); 12 | 13 | /** 14 | * 15 | * @param alreadyJoinedViews you give us an EMPTY Set and we fill it with views that we had to join because of where expression. For performance 16 | * we do not do the other joins as the rows coming back have them directly 17 | * @param indexedColumn Name of the indexed Column 18 | * @return A Cursor of IndexColumnInfo type 19 | */ 20 | public DirectCursor getResultList(Set alreadyJoinedViews, String indexedColumn); 21 | 22 | /** 23 | * The Iterable from getResults() is only loaded with 'batchSize' at a time from the nosql store so as you iterate 24 | * GC should be releasing memory for the previous 500 while the Iterable loads the next 500. 25 | * 26 | * @param batchSize 27 | */ 28 | public void setBatchSize(int batchSize); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/InheritanceSuper.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 4 | import com.alvazan.orm.api.base.anno.NoSqlId; 5 | import com.alvazan.orm.api.base.anno.NoSqlInheritance; 6 | import com.alvazan.orm.api.base.anno.NoSqlInheritanceType; 7 | import com.alvazan.orm.api.base.anno.NoSqlVirtualCf; 8 | 9 | @NoSqlEntity 10 | @NoSqlVirtualCf(storedInCf="ourstuff") 11 | @NoSqlInheritance(subclassesToScan={InheritanceSub1.class, InheritanceSub2.class}, 12 | strategy=NoSqlInheritanceType.SINGLE_TABLE, discriminatorColumnName="classType") 13 | public class InheritanceSuper { 14 | 15 | @NoSqlId 16 | private String id; 17 | 18 | private long num; 19 | 20 | private String lastName; 21 | 22 | public String getId() { 23 | return id; 24 | } 25 | 26 | public void setId(String id) { 27 | this.id = id; 28 | } 29 | 30 | public long getNum() { 31 | return num; 32 | } 33 | 34 | public void setNum(long num) { 35 | this.num = num; 36 | } 37 | 38 | public String getLastName() { 39 | return lastName; 40 | } 41 | 42 | public void setLastName(String lastName) { 43 | this.lastName = lastName; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/resource/ResourceIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Impetus Infotech. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.impetus.annovention.resource; 17 | 18 | import java.io.InputStream; 19 | 20 | /** 21 | * Interface for Resource Iterator, usually files. 22 | * 23 | * @author animesh.kumar 24 | */ 25 | public interface ResourceIterator { 26 | 27 | /** 28 | * Please close after use. 29 | * 30 | * @return null if no more streams left to iterate on 31 | */ 32 | InputStream next(); 33 | 34 | /** 35 | * Close. 36 | */ 37 | void close(); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/impl/meta/data/EmbedInfo.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.impl.meta.data; 2 | 3 | import com.alvazan.orm.api.z8spi.conv.Converter; 4 | //This is just a DTO to wire few parameters for MetaEmbeddedSimple.java 5 | public class EmbedInfo { 6 | 7 | private Converter converter; 8 | private Converter valConverter; 9 | private Class type; 10 | private Class valueType; 11 | 12 | public Converter getConverter() { 13 | return this.converter; 14 | } 15 | 16 | public void setConverter(Converter converter) { 17 | this.converter = converter; 18 | } 19 | 20 | public Converter getValConverter() { 21 | return this.valConverter; 22 | } 23 | 24 | public void setValConverter(Converter valConverter) { 25 | this.valConverter = valConverter; 26 | } 27 | 28 | public Class getType() { 29 | return this.type; 30 | } 31 | 32 | public void setType(Class type) { 33 | this.type = type; 34 | } 35 | 36 | public Class getValueType() { 37 | return this.valueType; 38 | } 39 | 40 | public void setValueType(Class valueType) { 41 | this.valueType = valueType; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/listener/ClassAnnotationDiscoveryListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Impetus Infotech. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.impetus.annovention.listener; 17 | 18 | /** 19 | * The Interface ClassAnnotationDiscoveryListener. 20 | * 21 | * @author animesh.kumar 22 | */ 23 | public interface ClassAnnotationDiscoveryListener extends AnnotationDiscoveryListener { 24 | 25 | /** 26 | * Gets called by the Discoverer with class-name of the class where annotation is found. 27 | * 28 | * @param clazz 29 | * @param annotation 30 | */ 31 | void discovered(String clazz, String annotation); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/resource/.svn/text-base/ResourceIterator.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Impetus Infotech. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.impetus.annovention.resource; 17 | 18 | import java.io.InputStream; 19 | 20 | /** 21 | * Interface for Resource Iterator, usually files. 22 | * 23 | * @author animesh.kumar 24 | */ 25 | public interface ResourceIterator { 26 | 27 | /** 28 | * Please close after use. 29 | * 30 | * @return null if no more streams left to iterate on 31 | */ 32 | InputStream next(); 33 | 34 | /** 35 | * Close. 36 | */ 37 | void close(); 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/AccountSuper.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.NoSqlEntityManager; 4 | import com.alvazan.orm.api.base.Query; 5 | import com.alvazan.orm.api.base.anno.NoSqlIndexed; 6 | import com.alvazan.orm.api.base.anno.NoSqlQueries; 7 | import com.alvazan.orm.api.base.anno.NoSqlQuery; 8 | @NoSqlQueries({ 9 | @NoSqlQuery(name ="findByField", query = "select u from TABLE as u where :someField = u.someField") 10 | }) 11 | public class AccountSuper { 12 | 13 | @NoSqlIndexed 14 | private int someField; 15 | @NoSqlIndexed 16 | private Boolean isActive; 17 | 18 | public int getSomeField() { 19 | return someField; 20 | } 21 | 22 | public void setSomeField(int someField) { 23 | this.someField = someField; 24 | } 25 | 26 | public Boolean getIsActive() { 27 | return isActive; 28 | } 29 | 30 | public void setIsActive(Boolean indexedColumn) { 31 | this.isActive = indexedColumn; 32 | } 33 | 34 | public static AccountSuper findByField(NoSqlEntityManager mgr, int field) { 35 | Query query = mgr.createNamedQuery(AccountSuper.class, "findByField"); 36 | query.setParameter("someField", field); 37 | return query.getSingleObject(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/action/Persist.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.action; 2 | 3 | import java.util.List; 4 | 5 | import com.alvazan.orm.api.z8spi.conv.ByteArray; 6 | import com.alvazan.orm.api.z8spi.meta.DboTableMeta; 7 | 8 | 9 | 10 | public class Persist implements Action { 11 | private DboTableMeta colFamily; 12 | private byte[] rowKey; 13 | private long timestamp; 14 | private List columns; 15 | 16 | public long getTimestamp() { 17 | return timestamp; 18 | } 19 | public void setTimestamp(long timestamp) { 20 | this.timestamp = timestamp; 21 | } 22 | public DboTableMeta getColFamily() { 23 | return colFamily; 24 | } 25 | public void setColFamily(DboTableMeta colFamily) { 26 | this.colFamily = colFamily; 27 | } 28 | public byte[] getRowKey() { 29 | return rowKey; 30 | } 31 | public void setRowKey(byte[] rowKey) { 32 | this.rowKey = rowKey; 33 | } 34 | public List getColumns() { 35 | return columns; 36 | } 37 | public void setColumns(List columns) { 38 | this.columns = columns; 39 | } 40 | @Override 41 | public String toString() { 42 | return "CF="+colFamily.getColumnFamily()+" rowkey="+new ByteArray(rowKey)+" columns="+this.columns; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/iter/AbstractCursor.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.iter; 2 | 3 | 4 | public abstract class AbstractCursor implements DirectCursor,Cursor { 5 | 6 | private Holder currentValue; 7 | 8 | @Override 9 | public final boolean next() { 10 | currentValue = nextImpl(); 11 | if(currentValue == null) { 12 | //There is NO next value so screw it, return false 13 | return false; 14 | } 15 | return true; 16 | } 17 | 18 | @Override 19 | public final boolean previous() { 20 | currentValue = previousImpl(); 21 | if(currentValue == null) { 22 | //There is NO previous value so screw it, return false 23 | return false; 24 | } 25 | return true; 26 | } 27 | 28 | public abstract Holder nextImpl(); 29 | 30 | public abstract Holder previousImpl(); 31 | 32 | @Override 33 | public final T getCurrent() { 34 | if(currentValue == null) 35 | throw new IllegalArgumentException("There is no value at this position"); 36 | return currentValue.getValue(); 37 | } 38 | 39 | public static class Holder { 40 | private T value; 41 | public Holder(T val) { 42 | this.value = val; 43 | } 44 | public T getValue() { 45 | return value; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/listener/.svn/text-base/ClassAnnotationDiscoveryListener.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Impetus Infotech. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.impetus.annovention.listener; 17 | 18 | /** 19 | * The Interface ClassAnnotationDiscoveryListener. 20 | * 21 | * @author animesh.kumar 22 | */ 23 | public interface ClassAnnotationDiscoveryListener extends AnnotationDiscoveryListener { 24 | 25 | /** 26 | * Gets called by the Discoverer with class-name of the class where annotation is found. 27 | * 28 | * @param clazz 29 | * @param annotation 30 | */ 31 | void discovered(String clazz, String annotation); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/play/logging/MDCLevelFilter.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.play.logging; 2 | 3 | import org.slf4j.MDC; 4 | import org.slf4j.Marker; 5 | 6 | import ch.qos.logback.classic.Level; 7 | import ch.qos.logback.classic.Logger; 8 | import ch.qos.logback.classic.turbo.MatchingFilter; 9 | import ch.qos.logback.core.spi.FilterReply; 10 | 11 | public class MDCLevelFilter extends MatchingFilter { 12 | 13 | private String mdcFilter; 14 | private String value; 15 | private Level level; 16 | 17 | @Override 18 | public FilterReply decide(Marker marker, Logger logger, Level level, 19 | String format, Object[] params, Throwable t) { 20 | if (mdcFilter == null) { 21 | return FilterReply.NEUTRAL; 22 | } 23 | 24 | if(CassandraAppender.isInTryCatch()) 25 | return onMatch; 26 | 27 | String value = MDC.get(mdcFilter); 28 | if (this.value.equals(value)) { 29 | if(level.levelInt <= this.level.levelInt) 30 | return onMatch; 31 | } 32 | return onMismatch; 33 | } 34 | 35 | public void setValue(String value) { 36 | this.value = value; 37 | } 38 | 39 | public void setMDCKey(String mdcKey) { 40 | this.mdcFilter = mdcKey; 41 | } 42 | public void setThisLevelOrBelow(Level level) { 43 | this.level = level; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/SomeEntity.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import java.util.Collection; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 8 | import com.alvazan.orm.api.base.anno.NoSqlId; 9 | import com.alvazan.orm.api.base.anno.NoSqlOneToMany; 10 | 11 | @NoSqlEntity 12 | public class SomeEntity { 13 | 14 | @NoSqlId 15 | private String id; 16 | 17 | private String name; 18 | 19 | @NoSqlOneToMany(keyFieldForMap="name") 20 | private Map activities = new HashMap(); 21 | 22 | public String getId() { 23 | return id; 24 | } 25 | 26 | public void setId(String id) { 27 | this.id = id; 28 | } 29 | 30 | public String getName() { 31 | return name; 32 | } 33 | 34 | public void setName(String name) { 35 | this.name = name; 36 | } 37 | 38 | public void putActivity(Activity act) { 39 | activities.put(act.getName(), act); 40 | } 41 | 42 | public Activity getActivity(String name) { 43 | return activities.get(name); 44 | } 45 | 46 | public Collection getActivities() { 47 | return activities.values(); 48 | } 49 | 50 | public void remove(String name2) { 51 | activities.remove(name2); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/impl/meta/data/MetaClass.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.impl.meta.data; 2 | 3 | import java.util.List; 4 | 5 | import com.alvazan.orm.api.z5api.NoSqlSession; 6 | import com.alvazan.orm.api.z5api.SpiMetaQuery; 7 | import com.alvazan.orm.api.z8spi.KeyValue; 8 | import com.alvazan.orm.api.z8spi.Row; 9 | import com.alvazan.orm.api.z8spi.meta.DboTableMeta; 10 | import com.alvazan.orm.api.z8spi.meta.IndexData; 11 | import com.alvazan.orm.api.z8spi.meta.RowToPersist; 12 | 13 | 14 | 15 | 16 | public interface MetaClass { 17 | 18 | Class getMetaClass(); 19 | 20 | String getColumnFamily(); 21 | 22 | MetaIdField getIdField(); 23 | 24 | MetaTTLField getTtlField(); 25 | 26 | boolean hasIndexedField(T entity); 27 | 28 | SpiMetaQuery getNamedQuery(Class clazz, String name); 29 | 30 | KeyValue translateFromRow(Row row, NoSqlSession session); 31 | 32 | RowToPersist translateToRow(T entity); 33 | 34 | Object fetchId(T entity); 35 | 36 | //byte[] convertIdToNoSql(Object pk); 37 | 38 | List findIndexRemoves(NoSqlProxy proxy, byte[] rowKey); 39 | 40 | MetaField getMetaFieldByCol(Class targetSubclass, String columnName); 41 | 42 | boolean isPartitioned(); 43 | 44 | DboTableMeta getMetaDbo(); 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/playorm/cron/bindings/CronServiceFactoryImpl.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.bindings; 2 | 3 | import java.util.Map; 4 | 5 | import org.playorm.cron.api.CronService; 6 | import org.playorm.cron.api.CronServiceFactory; 7 | import org.playorm.cron.impl.CronServiceImpl; 8 | 9 | import com.alvazan.orm.api.base.NoSqlEntityManagerFactory; 10 | import com.google.inject.Guice; 11 | import com.google.inject.Injector; 12 | 13 | public class CronServiceFactoryImpl extends CronServiceFactory { 14 | 15 | @Override 16 | protected CronService createService(Map properties) { 17 | Injector injector = Guice.createInjector(new CronProdBindings(properties)); 18 | CronServiceImpl impl = injector.getInstance(CronServiceImpl.class); 19 | 20 | Object factoryObj = properties.get(CronServiceFactory.NOSQL_MGR_FACTORY); 21 | if(factoryObj == null) 22 | throw new IllegalArgumentException("NOSQL_MGR_FACTORY is required and must be set"); 23 | else if(!(factoryObj instanceof NoSqlEntityManagerFactory)) 24 | throw new IllegalArgumentException("NOSQL_MGR_FACTORY is not an instance of NoSqlEntityManagerFactory"); 25 | NoSqlEntityManagerFactory factory = (NoSqlEntityManagerFactory) factoryObj; 26 | impl.setFactory(factory); 27 | return impl; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/TestMarker.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test; 2 | 3 | import static org.junit.Assert.assertNotNull; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.BeforeClass; 8 | import org.junit.Test; 9 | 10 | import com.alvazan.orm.api.base.NoSqlEntityManager; 11 | import com.alvazan.orm.api.base.NoSqlEntityManagerFactory; 12 | import com.alvazan.test.db.Marker; 13 | 14 | public class TestMarker { 15 | 16 | private static NoSqlEntityManagerFactory factory; 17 | private NoSqlEntityManager mgr; 18 | 19 | @BeforeClass 20 | public static void setup() { 21 | factory = FactorySingleton.createFactoryOnce(); 22 | } 23 | 24 | @Before 25 | public void createEntityManager() { 26 | mgr = factory.createEntityManager(); 27 | } 28 | 29 | @After 30 | public void clearDatabase() { 31 | NoSqlEntityManager other = factory.createEntityManager(); 32 | other.clearDatabase(true); 33 | } 34 | 35 | @Test 36 | public void testInsertAndLoadMarker() { 37 | Marker m = new Marker(); 38 | m.setId("one"); 39 | 40 | // persist marker 41 | mgr.put(m); 42 | mgr.flush(); 43 | 44 | // check if marker was saved 45 | mgr.clear(); 46 | assertNotNull("marker object not persisted into database", mgr.find(Marker.class, "one")); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/impl/meta/data/collections/ToOneProviderProxy.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.impl.meta.data.collections; 2 | 3 | import com.alvazan.orm.api.base.ToOneProvider; 4 | import com.alvazan.orm.api.z5api.NoSqlSession; 5 | import com.alvazan.orm.api.z8spi.Row; 6 | import com.alvazan.orm.impl.meta.data.MetaAbstractClass; 7 | import com.alvazan.orm.impl.meta.data.Tuple; 8 | 9 | public class ToOneProviderProxy extends ToOneProvider { 10 | 11 | private MetaAbstractClass classMeta; 12 | private byte[] value; 13 | private NoSqlSession session; 14 | 15 | public ToOneProviderProxy(MetaAbstractClass classMeta, byte[] value, 16 | NoSqlSession session) { 17 | this.classMeta = classMeta; 18 | this.value = value; 19 | this.session = session; 20 | } 21 | 22 | @Override 23 | public T get() { 24 | if(inst == null) { 25 | byte[] virtualKey = classMeta.getIdField().getMetaIdDbo().formVirtRowKey(value); 26 | Row row = session.find(classMeta.getMetaDbo(), virtualKey); 27 | if(row == null) 28 | throw new RuntimeException("corrupt databuse? as we could not find the row corresponding this this key"); 29 | Tuple tuple = classMeta.convertIdToProxy(row, session, value, null); 30 | inst = tuple.getProxy(); 31 | } 32 | return inst; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer0/base/IterableNotCounting.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer0.base; 2 | 3 | import java.util.Iterator; 4 | 5 | import com.alvazan.orm.api.z8spi.conv.Precondition; 6 | import com.alvazan.orm.api.z8spi.iter.AbstractIterator; 7 | 8 | public class IterableNotCounting implements Iterable { 9 | 10 | private AbstractIterator keysIterator; 11 | private boolean alreadyRun = false; 12 | 13 | public IterableNotCounting(AbstractIterator keysIterator2) { 14 | Precondition.check(keysIterator2, "keysIterator2"); 15 | this.keysIterator = keysIterator2; 16 | } 17 | 18 | @Override 19 | public Iterator iterator() { 20 | if(alreadyRun) 21 | throw new IllegalStateException("BUG, This iterable can only be run once as it is proxy to an Iterator that CAN ONLY be run once"); 22 | alreadyRun = true; 23 | return new IteratorNotCounting(keysIterator); 24 | } 25 | private static class IteratorNotCounting extends AbstractIterator { 26 | private AbstractIterator keysIterator; 27 | 28 | public IteratorNotCounting(AbstractIterator keysIterator2) { 29 | this.keysIterator = keysIterator2; 30 | } 31 | @Override 32 | public IterHolder nextImpl() { 33 | return keysIterator.nextImpl(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/impl/meta/data/IdInfo.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.impl.meta.data; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | import com.alvazan.orm.api.base.spi.KeyGenerator; 6 | import com.alvazan.orm.api.z8spi.conv.Converter; 7 | 8 | @SuppressWarnings("rawtypes") 9 | public class IdInfo { 10 | private Method idMethod; 11 | private boolean useGenerator; 12 | private KeyGenerator gen; 13 | private Converter converter; 14 | private MetaAbstractClass metaClass; 15 | public Method getIdMethod() { 16 | return idMethod; 17 | } 18 | public void setIdMethod(Method idMethod) { 19 | this.idMethod = idMethod; 20 | } 21 | public boolean isUseGenerator() { 22 | return useGenerator; 23 | } 24 | public void setUseGenerator(boolean useGenerator) { 25 | this.useGenerator = useGenerator; 26 | } 27 | public KeyGenerator getGen() { 28 | return gen; 29 | } 30 | public void setGen(KeyGenerator gen) { 31 | this.gen = gen; 32 | } 33 | public Converter getConverter() { 34 | return converter; 35 | } 36 | public void setConverter(Converter converter) { 37 | this.converter = converter; 38 | } 39 | public MetaAbstractClass getMetaClass() { 40 | return metaClass; 41 | } 42 | public void setMetaClass(MetaAbstractClass metaClass) { 43 | this.metaClass = metaClass; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/meta/TypeInfo.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.meta; 2 | 3 | import com.alvazan.orm.api.z8spi.conv.StorageTypeEnum; 4 | 5 | 6 | 7 | 8 | 9 | 10 | /** 11 | * NOTE: The type information is either from another constant or from the column's type so we have to 12 | * compare against one or the other in this bean. 13 | * 14 | * @author dhiller 15 | * 16 | */ 17 | public class TypeInfo { 18 | 19 | private StorageTypeEnum constantType; 20 | /** 21 | * NOTE: The type information is either from another constant or from the column's type so we have to 22 | * compare against one or the other field in this bean. 23 | */ 24 | private DboColumnMeta columnInfo; 25 | 26 | public TypeInfo(StorageTypeEnum type) { 27 | this.constantType = type; 28 | } 29 | 30 | public TypeInfo(DboColumnMeta columnInfo) { 31 | this.columnInfo = columnInfo; 32 | } 33 | 34 | public StorageTypeEnum getConstantType() { 35 | return constantType; 36 | } 37 | 38 | public void setConstantType(StorageTypeEnum constantType) { 39 | this.constantType = constantType; 40 | } 41 | 42 | public DboColumnMeta getColumnInfo() { 43 | return columnInfo; 44 | } 45 | 46 | public void setColumnInfo(DboColumnMeta columnName) { 47 | this.columnInfo = columnName; 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/listener/FieldAnnotationDiscoveryListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Impetus Infotech. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.impetus.annovention.listener; 17 | 18 | 19 | /** 20 | * The Interface FieldAnnotationDiscoveryListener. 21 | * 22 | * @author animesh.kumar 23 | */ 24 | public interface FieldAnnotationDiscoveryListener extends AnnotationDiscoveryListener { 25 | 26 | /** 27 | * Gets called by the Discoverer with class-name of the class, field-name of the field 28 | * where annotation is found. 29 | * 30 | * @param clazz 31 | * @param field 32 | * @param annotation 33 | */ 34 | void discovered(String clazz, String field, String annotation); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/iter/ProxyTempCursor.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.iter; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.ListIterator; 6 | 7 | 8 | 9 | public class ProxyTempCursor extends AbstractCursor { 10 | 11 | private ListIterator items; 12 | 13 | public ProxyTempCursor(Collection items) { 14 | this.items=new ArrayList(items).listIterator(); 15 | beforeFirst(); 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | String tabs = StringLocal.getAndAdd(); 21 | String retVal = "ProxyTempCursor["+tabs+items+tabs+"]"; 22 | StringLocal.set(tabs.length()); 23 | return retVal; 24 | } 25 | 26 | @Override 27 | public void beforeFirst() { 28 | while(items.hasPrevious()) items.previous(); 29 | } 30 | 31 | @Override 32 | public void afterLast() { 33 | while(items.hasNext()) items.next(); 34 | } 35 | 36 | @Override 37 | public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder nextImpl() { 38 | if(!items.hasNext()) 39 | return null; 40 | return new Holder(items.next()); 41 | } 42 | 43 | @Override 44 | public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder previousImpl() { 45 | if(!items.hasPrevious()) 46 | return null; 47 | return new Holder(items.previous()); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/listener/.svn/text-base/FieldAnnotationDiscoveryListener.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Impetus Infotech. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.impetus.annovention.listener; 17 | 18 | 19 | /** 20 | * The Interface FieldAnnotationDiscoveryListener. 21 | * 22 | * @author animesh.kumar 23 | */ 24 | public interface FieldAnnotationDiscoveryListener extends AnnotationDiscoveryListener { 25 | 26 | /** 27 | * Gets called by the Discoverer with class-name of the class, field-name of the field 28 | * where annotation is found. 29 | * 30 | * @param clazz 31 | * @param field 32 | * @param annotation 33 | */ 34 | void discovered(String clazz, String field, String annotation); 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/EmbeddedEmail2.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.anno.NoSqlEmbeddable; 4 | import com.alvazan.orm.api.base.anno.NoSqlId; 5 | import com.alvazan.orm.api.base.anno.NoSqlIndexed; 6 | 7 | @NoSqlEmbeddable 8 | public class EmbeddedEmail2 extends EmbeddedEmail { 9 | private static final String MAIN = "main"; 10 | 11 | @NoSqlId 12 | private int idkey; 13 | 14 | @NoSqlIndexed 15 | private String name; 16 | 17 | @NoSqlIndexed 18 | private String type; 19 | 20 | private boolean something = true; 21 | 22 | private int number = 36; 23 | 24 | public int getIdkey() { 25 | return idkey; 26 | } 27 | 28 | public void setIdkey(int idkey) { 29 | this.idkey = idkey; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public void setName(String name) { 37 | this.name = name; 38 | } 39 | 40 | public String getType() { 41 | return type; 42 | } 43 | 44 | public void setType(String type) { 45 | this.type = type; 46 | } 47 | 48 | public boolean isSomething() { 49 | return something; 50 | } 51 | 52 | public void setSomething(boolean something) { 53 | this.something = something; 54 | } 55 | 56 | public int getNumber() { 57 | return number; 58 | } 59 | 60 | public void setNumber(int number) { 61 | this.number = number; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/playorm/cron/api/PlayOrmCronJob.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.api; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class PlayOrmCronJob { 7 | 8 | private String id; 9 | 10 | private String type; 11 | 12 | private Long epochOffset; 13 | 14 | private long timePeriodMillis; 15 | 16 | private Map properties = new HashMap(); 17 | 18 | public String getId() { 19 | return id; 20 | } 21 | 22 | public void setId(String id) { 23 | this.id = id; 24 | } 25 | 26 | public long getTimePeriodMillis() { 27 | return timePeriodMillis; 28 | } 29 | 30 | public void setTimePeriodMillis(long timePeriodMillis) { 31 | this.timePeriodMillis = timePeriodMillis; 32 | } 33 | 34 | public Map getProperties() { 35 | return properties; 36 | } 37 | 38 | public void addProperty(String name, String value) { 39 | properties.put(name, value); 40 | } 41 | 42 | public void removeProperty(String name) { 43 | properties.remove(name); 44 | } 45 | 46 | public Long getEpochOffset() { 47 | return epochOffset; 48 | } 49 | 50 | public void setEpochOffset(Long epochOffset) { 51 | this.epochOffset = epochOffset; 52 | } 53 | 54 | public String getType() { 55 | return type; 56 | } 57 | 58 | public void setType(String type) { 59 | this.type = type; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/meta/DboDatabaseMeta.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.meta; 2 | 3 | import java.util.Collection; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import javax.inject.Singleton; 8 | 9 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 10 | import com.alvazan.orm.api.base.anno.NoSqlId; 11 | import com.alvazan.orm.api.base.anno.NoSqlOneToMany; 12 | 13 | @Singleton 14 | @NoSqlEntity 15 | public class DboDatabaseMeta { 16 | 17 | /** 18 | * This is the key for the SINGLE row of DboDatabaseMeta that exists in the nosql store. 19 | */ 20 | public static final String META_DB_ROWKEY = "nosqlorm"; 21 | 22 | @NoSqlId(usegenerator=false) 23 | private String id = META_DB_ROWKEY; 24 | 25 | @NoSqlOneToMany(keyFieldForMap="columnFamily") 26 | private Map colFamilyToMeta = new HashMap(); 27 | 28 | public String getId() { 29 | return id; 30 | } 31 | 32 | public void setId(String id) { 33 | this.id = id; 34 | } 35 | 36 | public void addMetaClassDbo(DboTableMeta metaClass) { 37 | colFamilyToMeta.put(metaClass.getColumnFamily(), metaClass); 38 | } 39 | 40 | public DboTableMeta getMeta(String tableName) { 41 | return colFamilyToMeta.get(tableName); 42 | } 43 | 44 | public Collection getAllTables() { 45 | return colFamilyToMeta.values(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/playorm/cron/impl/CopyUtil.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.impl; 2 | 3 | import org.playorm.cron.api.PlayOrmCronJob; 4 | import org.playorm.cron.impl.db.MonitorDbo; 5 | 6 | public class CopyUtil { 7 | 8 | public static MonitorDbo copy(PlayOrmCronJob monitor) { 9 | if(monitor == null) 10 | return null; 11 | MonitorDbo m = new MonitorDbo(); 12 | m.setId(monitor.getId()); 13 | m.setTimePeriodMillis(monitor.getTimePeriodMillis()); 14 | m.setEpochOffset(monitor.getEpochOffset()); 15 | m.setType(monitor.getType()); 16 | String props = ""; 17 | for(String key : monitor.getProperties().keySet()) { 18 | String value = monitor.getProperties().get(key); 19 | props += key+"="+value+"|"; 20 | } 21 | m.setRawProperties(props); 22 | return m; 23 | } 24 | 25 | public static PlayOrmCronJob copy(MonitorDbo monitor) { 26 | if(monitor == null) 27 | return null; 28 | PlayOrmCronJob mon = new PlayOrmCronJob(); 29 | mon.setId(monitor.getId()); 30 | mon.setTimePeriodMillis(monitor.getTimePeriodMillis()); 31 | mon.setType(monitor.getType()); 32 | mon.setEpochOffset(monitor.getEpochOffset()); 33 | String props = monitor.getRawProperties(); 34 | String[] propsArray = props.split("\\|"); 35 | for(String prop : propsArray) { 36 | String[] kv = prop.split("="); 37 | mon.addProperty(kv[0], kv[1]); 38 | } 39 | return mon; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/iter/IterableWrappingCursor.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.iter; 2 | 3 | import java.util.Iterator; 4 | 5 | import com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder; 6 | 7 | public class IterableWrappingCursor implements DirectCursor { 8 | 9 | private Iterable iter; 10 | private Iterator currentIterator; 11 | 12 | public IterableWrappingCursor(Iterable iter) { 13 | this.iter = iter; 14 | } 15 | 16 | @Override 17 | public String toString() { 18 | String tabs = StringLocal.getAndAdd(); 19 | String retVal = "IteratorWrappingCursor(iteratorWrappingCursor)["+tabs+iter+tabs+"]"; 20 | StringLocal.set(tabs.length()); 21 | return retVal; 22 | } 23 | 24 | 25 | @Override 26 | public Holder nextImpl() { 27 | if (currentIterator == null) 28 | beforeFirst(); 29 | if (!currentIterator.hasNext()) 30 | return null; 31 | return new Holder(currentIterator.next()); 32 | } 33 | 34 | @Override 35 | public Holder previousImpl() { 36 | throw new UnsupportedOperationException("We can't go backward on a cursor that is wrapping an iterator"); 37 | } 38 | 39 | @Override 40 | public void beforeFirst() { 41 | currentIterator = iter.iterator(); 42 | 43 | } 44 | 45 | @Override 46 | public void afterLast() { 47 | throw new UnsupportedOperationException("We can't go backward on a cursor that is wrapping an iterator"); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/ssql/cmdline/ColFamilyData.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.ssql.cmdline; 2 | 3 | import com.alvazan.orm.api.z8spi.meta.DboColumnMeta; 4 | import com.alvazan.orm.api.z8spi.meta.DboTableMeta; 5 | 6 | public class ColFamilyData { 7 | 8 | private String colFamily; 9 | private String column; 10 | private String partitionBy; 11 | private String partitionId; 12 | private DboTableMeta tableMeta; 13 | private DboColumnMeta columnMeta; 14 | 15 | public String getColFamily() { 16 | return colFamily; 17 | } 18 | public void setColFamily(String colFamily) { 19 | this.colFamily = colFamily; 20 | } 21 | public String getColumn() { 22 | return column; 23 | } 24 | public void setColumn(String column) { 25 | this.column = column; 26 | } 27 | public String getPartitionBy() { 28 | return partitionBy; 29 | } 30 | public void setPartitionBy(String partitionBy) { 31 | this.partitionBy = partitionBy; 32 | } 33 | public String getPartitionId() { 34 | return partitionId; 35 | } 36 | public void setPartitionId(String partitionId) { 37 | this.partitionId = partitionId; 38 | } 39 | public void setTableMeta(DboTableMeta meta) { 40 | this.tableMeta = meta; 41 | } 42 | public void setColumnMeta(DboColumnMeta colMeta) { 43 | this.columnMeta = colMeta; 44 | } 45 | public DboTableMeta getTableMeta() { 46 | return tableMeta; 47 | } 48 | public DboColumnMeta getColumnMeta() { 49 | return columnMeta; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/EmailAccountXref.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import java.util.List; 4 | 5 | import com.alvazan.orm.api.base.NoSqlEntityManager; 6 | import com.alvazan.orm.api.base.Query; 7 | import com.alvazan.orm.api.base.anno.NoSqlEntity; 8 | import com.alvazan.orm.api.base.anno.NoSqlId; 9 | import com.alvazan.orm.api.base.anno.NoSqlManyToOne; 10 | import com.alvazan.orm.api.base.anno.NoSqlQuery; 11 | 12 | @NoSqlEntity 13 | @NoSqlQuery(name="findAll", query="select e from TABLE as e") 14 | public class EmailAccountXref { 15 | 16 | @NoSqlId 17 | private String id; 18 | 19 | @NoSqlManyToOne 20 | private Account account; 21 | 22 | @NoSqlManyToOne 23 | private User user; 24 | 25 | public EmailAccountXref() {} 26 | 27 | public EmailAccountXref(User user, Account acc) { 28 | this.user = user; 29 | this.account = acc; 30 | this.user.addAccount(this); 31 | this.account.addEmail(this); 32 | } 33 | 34 | public String getId() { 35 | return id; 36 | } 37 | 38 | public void setId(String id) { 39 | this.id = id; 40 | } 41 | 42 | public Account getAccount() { 43 | return account; 44 | } 45 | 46 | public User getEmail() { 47 | return user; 48 | } 49 | 50 | public static List findAll(NoSqlEntityManager mgr) { 51 | Query query = mgr.createNamedQuery(EmailAccountXref.class, "findAll"); 52 | return query.getResultList(0, null); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/cassandra/Info.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.cassandra; 2 | 3 | import com.alvazan.orm.api.z8spi.ColumnType; 4 | import com.alvazan.orm.api.z8spi.conv.StorageTypeEnum; 5 | import com.netflix.astyanax.model.ColumnFamily; 6 | import com.netflix.astyanax.serializers.AnnotatedCompositeSerializer; 7 | 8 | @SuppressWarnings("rawtypes") 9 | public class Info { 10 | 11 | private StorageTypeEnum rowKeyType; 12 | private ColumnType columnType; 13 | private AnnotatedCompositeSerializer compositeSerializer; 14 | private ColumnFamily columnFamilyObj; 15 | 16 | public ColumnType getColumnType() { 17 | return columnType; 18 | } 19 | 20 | public void setColumnType(ColumnType columnType) { 21 | this.columnType = columnType; 22 | } 23 | 24 | public void setCompositeSerializer( 25 | AnnotatedCompositeSerializer bigIntSer) { 26 | this.compositeSerializer = bigIntSer; 27 | } 28 | 29 | public void setColumnFamilyObj(ColumnFamily cf) { 30 | this.columnFamilyObj = cf; 31 | } 32 | 33 | public AnnotatedCompositeSerializer getCompositeSerializer() { 34 | return compositeSerializer; 35 | } 36 | 37 | public ColumnFamily getColumnFamilyObj() { 38 | return columnFamilyObj; 39 | } 40 | 41 | public StorageTypeEnum getRowKeyType() { 42 | return rowKeyType; 43 | } 44 | 45 | public void setRowKeyType(StorageTypeEnum rowKeyType) { 46 | this.rowKeyType = rowKeyType; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/iter/ListWrappingCursor.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.iter; 2 | 3 | import java.util.List; 4 | import java.util.ListIterator; 5 | 6 | import com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder; 7 | 8 | public class ListWrappingCursor implements DirectCursor { 9 | 10 | private List backingList; 11 | private ListIterator backingListIterator; 12 | 13 | public ListWrappingCursor(List list) { 14 | backingList = list; 15 | this.backingListIterator = list.listIterator(); 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | String tabs = StringLocal.getAndAdd(); 21 | String retVal = "ListWrappingCursor(ListWrappingCursor)["+tabs+backingListIterator+tabs+"]"; 22 | StringLocal.set(tabs.length()); 23 | return retVal; 24 | } 25 | 26 | 27 | @Override 28 | public Holder nextImpl() { 29 | if (backingListIterator.hasNext()) 30 | return new Holder(backingListIterator.next()); 31 | return null; 32 | } 33 | 34 | @Override 35 | public Holder previousImpl() { 36 | if (backingListIterator.hasPrevious()) 37 | return new Holder(backingListIterator.previous()); 38 | return null; 39 | } 40 | 41 | @Override 42 | public void beforeFirst() { 43 | backingListIterator = backingList.listIterator(); 44 | } 45 | 46 | @Override 47 | public void afterLast() { 48 | while (backingListIterator.hasNext()) 49 | backingListIterator.next(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer3/typed/IterableTypedProxy.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer3.typed; 2 | 3 | import java.util.Iterator; 4 | 5 | import com.alvazan.orm.api.z8spi.conv.Precondition; 6 | import com.alvazan.orm.api.z8spi.meta.DboColumnMeta; 7 | 8 | public class IterableTypedProxy implements Iterable { 9 | 10 | private DboColumnMeta idMeta; 11 | private Iterable keys; 12 | 13 | public IterableTypedProxy(DboColumnMeta idMeta, Iterable keys2) { 14 | Precondition.check(keys2, "keys"); 15 | this.idMeta = idMeta; 16 | this.keys = keys2; 17 | } 18 | 19 | @Override 20 | public Iterator iterator() { 21 | return new TypedIteratorProxy(idMeta, keys.iterator()); 22 | } 23 | 24 | private static class TypedIteratorProxy implements Iterator { 25 | 26 | private DboColumnMeta idMeta; 27 | private Iterator iterator; 28 | 29 | public TypedIteratorProxy(DboColumnMeta idMeta, Iterator iterator) { 30 | this.idMeta = idMeta; 31 | this.iterator = iterator; 32 | } 33 | 34 | @Override 35 | public boolean hasNext() { 36 | return iterator.hasNext(); 37 | } 38 | 39 | @Override 40 | public byte[] next() { 41 | T k = iterator.next(); 42 | byte[] rowK = idMeta.convertToStorage2(k); 43 | return rowK; 44 | } 45 | 46 | @Override 47 | public void remove() { 48 | throw new UnsupportedOperationException("not supported and won't ever be"); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer3/typed/TypedProxyWrappingCursor.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer3.typed; 2 | 3 | import com.alvazan.orm.api.z8spi.conv.Precondition; 4 | import com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder; 5 | import com.alvazan.orm.api.z8spi.iter.DirectCursor; 6 | import com.alvazan.orm.api.z8spi.meta.DboColumnMeta; 7 | 8 | public class TypedProxyWrappingCursor implements DirectCursor { 9 | 10 | private DboColumnMeta idMeta; 11 | private DirectCursor keys; 12 | 13 | public TypedProxyWrappingCursor(DboColumnMeta idMeta, DirectCursor keys2) { 14 | Precondition.check(keys2, "keys"); 15 | this.idMeta = idMeta; 16 | this.keys = keys2; 17 | } 18 | 19 | 20 | @Override 21 | public Holder nextImpl() { 22 | Holder nextKey = keys.nextImpl(); 23 | if (nextKey == null) 24 | return null; 25 | T k = nextKey.getValue(); 26 | byte[] rowK = idMeta.convertToStorage2(k); 27 | return new Holder(rowK); 28 | } 29 | 30 | @Override 31 | public Holder previousImpl() { 32 | Holder nextKey = keys.previousImpl(); 33 | if (nextKey == null) 34 | return null; 35 | T k = nextKey.getValue(); 36 | byte[] rowK = idMeta.convertToStorage2(k); 37 | return new Holder(rowK); 38 | } 39 | 40 | @Override 41 | public void beforeFirst() { 42 | keys.beforeFirst(); 43 | } 44 | 45 | @Override 46 | public void afterLast() { 47 | keys.afterLast(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/ssql/cmdline/CmdDelete.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.ssql.cmdline; 2 | 3 | import com.alvazan.orm.api.base.NoSqlEntityManager; 4 | import com.alvazan.orm.api.exc.ParseException; 5 | import com.alvazan.orm.api.z3api.NoSqlTypedSession; 6 | 7 | public class CmdDelete { 8 | void processDelete(String cmd, NoSqlEntityManager mgr) { 9 | NoSqlTypedSession s = mgr.getTypedSession(); 10 | try { 11 | int count = s.executeQuery(cmd); 12 | mgr.flush(); 13 | println(count + " row deleted"); 14 | } catch (ParseException e) { 15 | Throwable childExc = e.getCause(); 16 | throw new InvalidCommand( 17 | "Scalable-SQL command was invalid. Reason=" 18 | + childExc.getMessage() 19 | + " AND you may want to add -v option to playcli to get more info", e); 20 | } 21 | } 22 | 23 | void processDeleteColumn(String cmd, NoSqlEntityManager mgr) { 24 | NoSqlTypedSession s = mgr.getTypedSession(); 25 | try { 26 | int count = s.executeQuery(cmd); 27 | mgr.flush(); 28 | println("Column deleted from " + count + " rows"); 29 | } catch (ParseException e) { 30 | Throwable childExc = e.getCause(); 31 | throw new InvalidCommand( 32 | "Scalable-SQL command was invalid. Reason=" 33 | + childExc.getMessage() 34 | + " AND you may want to add -v option to playcli to get more info", e); 35 | } 36 | } 37 | 38 | 39 | private void println(String msg) { 40 | System.out.println(msg); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | e.level.toInt() <= INFO.toInt() 8 | 9 | 10 | DENY 11 | NEUTRAL 12 | 13 | 14 | 15 | %date{ISO8601} %X{sessionid}-%X{user} %caller{1} %-4level: %message%n 16 | 17 | 18 | 19 | 20 | 21 | warn 22 | 23 | 24 | 25 | %date{ISO8601} %X{sessionid}-%X{user} %caller{1} %-4level: %message%n 26 | 27 | System.err 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/listener/MethodAnnotationDiscoveryListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Impetus Infotech. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.impetus.annovention.listener; 17 | 18 | 19 | /** 20 | * The Interface AnnotationDiscoveryListener. 21 | * 22 | * @author animesh.kumar 23 | */ 24 | public interface MethodAnnotationDiscoveryListener extends AnnotationDiscoveryListener { 25 | 26 | /** 27 | * Gets called by the Discoverer with class-name of the class, method-name of the method 28 | * where annotation is found. 29 | * 30 | * 31 | * @param clazz 32 | * @param method 33 | * @param signature (read: http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf) 34 | * @param annotation 35 | */ 36 | void discovered(String clazz, String method, String signature, String annotation); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/listener/.svn/text-base/MethodAnnotationDiscoveryListener.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Impetus Infotech. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.impetus.annovention.listener; 17 | 18 | 19 | /** 20 | * The Interface AnnotationDiscoveryListener. 21 | * 22 | * @author animesh.kumar 23 | */ 24 | public interface MethodAnnotationDiscoveryListener extends AnnotationDiscoveryListener { 25 | 26 | /** 27 | * Gets called by the Discoverer with class-name of the class, method-name of the method 28 | * where annotation is found. 29 | * 30 | * 31 | * @param clazz 32 | * @param method 33 | * @param signature (read: http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf) 34 | * @param annotation 35 | */ 36 | void discovered(String clazz, String method, String signature, String annotation); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlId.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import com.alvazan.orm.api.base.spi.KeyGenerator; 9 | import com.alvazan.orm.api.base.spi.UniqueKeyGenerator; 10 | import com.alvazan.orm.api.z5api.NoConversion; 11 | import com.alvazan.orm.api.z8spi.conv.Converter; 12 | 13 | @Target({ElementType.FIELD}) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface NoSqlId { 16 | // @SuppressWarnings("rawtypes") 17 | // Class targetEntity() default void.class; 18 | 19 | Class generation() default UniqueKeyGenerator.class; 20 | 21 | /** 22 | * true to use the KeyGenerator supplied in generation attribute, false to 23 | * manually set the key value every time. 24 | */ 25 | boolean usegenerator() default true; 26 | 27 | /** 28 | * Deprecated: Use @NoSqlConverter instead 29 | * 30 | * You can supply your own converter for a field here which will override all 31 | * standard conversions even for primitives. You just translate back and 32 | * forth from the byte[] for us and we wire that in. 33 | * @return An object of Class which extends Converter 34 | */ 35 | @Deprecated 36 | Class customConverter() default NoConversion.class; 37 | 38 | String columnName() default ""; 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/impl/meta/data/MetaField.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.impl.meta.data; 2 | 3 | import java.lang.reflect.Field; 4 | import java.util.List; 5 | 6 | import com.alvazan.orm.api.z5api.NoSqlSession; 7 | import com.alvazan.orm.api.z8spi.Row; 8 | import com.alvazan.orm.api.z8spi.meta.DboColumnMeta; 9 | import com.alvazan.orm.api.z8spi.meta.IndexData; 10 | import com.alvazan.orm.api.z8spi.meta.InfoForIndex; 11 | 12 | public interface MetaField { 13 | 14 | public String getColumnName(); 15 | 16 | public DboColumnMeta getMetaDbo(); 17 | 18 | /** 19 | * For when we are translating from nosql row, this is called on each field/column to translate 20 | */ 21 | public void translateFromColumn(Row column, OWNER entity, NoSqlSession session); 22 | /** 23 | * For when we are translating TO nosql row, this is called on each field/column 24 | */ 25 | public void translateToColumn(InfoForIndex info); 26 | 27 | public void removingEntity(InfoForIndex info, List indexRemoves, byte[] rowKey); 28 | 29 | public Field getField(); 30 | 31 | public Object getFieldRawValue(OWNER entity); 32 | 33 | /** 34 | * For when Query.setParameter is called, we need to translate into byte[] to search the index for the value 35 | * @param value 36 | * @return byte array for the value object 37 | */ 38 | public byte[] translateValue(Object value); 39 | 40 | public Object fetchField(Object entity); 41 | public String translateToString(Object fieldsValue); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer3/typed/IterableProxy.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer3.typed; 2 | 3 | import java.util.Iterator; 4 | 5 | import com.alvazan.orm.api.z8spi.conv.Precondition; 6 | import com.alvazan.orm.api.z8spi.iter.Cursor; 7 | 8 | public class IterableProxy implements 9 | Iterable { 10 | 11 | private Cursor cursor; 12 | 13 | public IterableProxy(Cursor cursor) { 14 | Precondition.check(cursor, "cursor"); 15 | this.cursor = cursor; 16 | } 17 | 18 | @Override 19 | public Iterator iterator() { 20 | //restart cursor 21 | cursor.beforeFirst(); 22 | return new IteratorProxy(cursor); 23 | } 24 | 25 | private static class IteratorProxy implements Iterator { 26 | 27 | private Cursor cursor; 28 | private T cachedValue; 29 | 30 | public IteratorProxy(Cursor cursor) { 31 | this.cursor = cursor; 32 | } 33 | 34 | @Override 35 | public boolean hasNext() { 36 | if(cachedValue != null) 37 | return true; 38 | boolean hasNext = cursor.next(); 39 | if(hasNext) 40 | cachedValue = cursor.getCurrent(); 41 | return hasNext; 42 | } 43 | 44 | @Override 45 | public T next() { 46 | if(!hasNext()) 47 | throw new IllegalStateException("You should call hasNext first!!! This iterator has no more values"); 48 | 49 | T temp = cachedValue; 50 | cachedValue = null; 51 | return temp; 52 | } 53 | 54 | @Override 55 | public void remove() { 56 | throw new UnsupportedOperationException("not supported"); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/CursorToManyImpl.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * This is used so you do not blow out your memory on a very wide row especially when you only want to display a few of the 8 | * results. 9 | * 10 | * @author dhiller2 11 | * 12 | * @param 13 | */ 14 | public class CursorToManyImpl implements CursorToMany { 15 | 16 | private List list = new ArrayList(); 17 | private int index; 18 | 19 | public CursorToManyImpl() { 20 | } 21 | 22 | public CursorToManyImpl(List elements) { 23 | this.list.addAll(elements); 24 | } 25 | 26 | @Override 27 | public void beforeFirst() { 28 | index = -1; 29 | } 30 | 31 | @Override 32 | public void afterLast() { 33 | index = -1; 34 | if (list!=null) 35 | index=list.size(); 36 | } 37 | 38 | @Override 39 | public boolean next() { 40 | index++; 41 | if(index < list.size()) 42 | return true; 43 | return false; 44 | } 45 | 46 | @Override 47 | public boolean previous() { 48 | index--; 49 | if(index >= 0) 50 | return true; 51 | return false; 52 | } 53 | 54 | @Override 55 | public T getCurrent() { 56 | return list.get(index); 57 | } 58 | 59 | @Override 60 | public void removeCurrent() { 61 | list.remove(index); 62 | index--; 63 | } 64 | 65 | @Override 66 | public void addElement(T element) { 67 | this.list.add(element); 68 | } 69 | 70 | public List getElementsToAdd() { 71 | return list; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/meta/InfoForIndex.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.meta; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | 7 | 8 | public class InfoForIndex { 9 | 10 | private T entity; 11 | private RowToPersist row; 12 | private String virtualCf; 13 | @SuppressWarnings("rawtypes") 14 | private Map fieldToValue; 15 | private List partitions; 16 | 17 | @SuppressWarnings("rawtypes") 18 | public InfoForIndex(T entity2, RowToPersist row2, String virtualCf, 19 | Map fieldToValue2, List partitions) { 20 | this.entity = entity2; 21 | this.row = row2; 22 | this.virtualCf = virtualCf; 23 | this.fieldToValue = fieldToValue2; 24 | this.partitions = partitions; 25 | } 26 | 27 | public T getEntity() { 28 | return entity; 29 | } 30 | public void setEntity(T entity) { 31 | this.entity = entity; 32 | } 33 | public RowToPersist getRow() { 34 | return row; 35 | } 36 | public void setRow(RowToPersist row) { 37 | this.row = row; 38 | } 39 | public String getColumnFamily() { 40 | return virtualCf; 41 | } 42 | public void setColumnFamily(String columnFamily) { 43 | this.virtualCf = columnFamily; 44 | } 45 | @SuppressWarnings("rawtypes") 46 | public Map getFieldToValue() { 47 | return fieldToValue; 48 | } 49 | @SuppressWarnings("rawtypes") 50 | public void setFieldToValue(Map fieldToValue) { 51 | this.fieldToValue = fieldToValue; 52 | } 53 | public List getPartitions() { 54 | return partitions; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer3/typed/IterableReverseProxy.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer3.typed; 2 | 3 | import java.util.Iterator; 4 | 5 | import com.alvazan.orm.api.z8spi.conv.Precondition; 6 | import com.alvazan.orm.api.z8spi.iter.Cursor; 7 | 8 | public class IterableReverseProxy implements 9 | Iterable { 10 | 11 | private Cursor cursor; 12 | 13 | public IterableReverseProxy(Cursor cursor) { 14 | Precondition.check(cursor, "cursor"); 15 | this.cursor = cursor; 16 | } 17 | 18 | @Override 19 | public Iterator iterator() { 20 | //restart cursor 21 | cursor.afterLast(); 22 | return new IteratorProxy(cursor); 23 | } 24 | 25 | private static class IteratorProxy implements Iterator { 26 | 27 | private Cursor cursor; 28 | private T cachedValue; 29 | 30 | public IteratorProxy(Cursor cursor) { 31 | this.cursor = cursor; 32 | } 33 | 34 | @Override 35 | public boolean hasNext() { 36 | if(cachedValue != null) 37 | return true; 38 | boolean hasNext = cursor.previous(); 39 | if(hasNext) 40 | cachedValue = cursor.getCurrent(); 41 | return hasNext; 42 | } 43 | 44 | @Override 45 | public T next() { 46 | if(!hasNext()) 47 | throw new IllegalStateException("You should call hasNext first!!! This iterator has no more values"); 48 | 49 | T temp = cachedValue; 50 | cachedValue = null; 51 | return temp; 52 | } 53 | 54 | @Override 55 | public void remove() { 56 | throw new UnsupportedOperationException("not supported"); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/impetus/annovention/resource/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 12 5 | http://annovention.googlecode.com/svn/trunk/src/main/java/com/impetus/annovention/resource 6 | http://annovention.googlecode.com/svn 7 | 8 | 9 | 10 | 2010-07-26T09:56:15.852041Z 11 | 7 12 | smile.animesh 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | bb2110f8-4f5b-1a6c-0aad-fea764941dd5 28 | 29 | ClassFileIterator.java 30 | file 31 | 32 | 33 | 34 | 35 | 2012-07-18T14:18:12.000000Z 36 | 14ff421d7717843d37a44e9c57b387db 37 | 2010-07-26T09:56:15.852041Z 38 | 7 39 | smile.animesh 40 | has-props 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 2571 62 | 63 | ResourceIterator.java 64 | file 65 | 66 | 67 | 68 | 69 | 2012-07-18T14:18:12.000000Z 70 | ec493d99eca77a1d587d2ee4120b4447 71 | 2010-07-26T09:56:15.852041Z 72 | 7 73 | smile.animesh 74 | has-props 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 1025 96 | 97 | JarFileIterator.java 98 | file 99 | 100 | 101 | 102 | 103 | 2012-07-18T14:18:12.000000Z 104 | 06459d7d7c21637bc08a60c151c8a966 105 | 2010-07-26T09:56:15.852041Z 106 | 7 107 | smile.animesh 108 | has-props 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 4393 130 | 131 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/base/anno/NoSqlColumn.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.base.anno; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import com.alvazan.orm.api.z5api.NoConversion; 9 | import com.alvazan.orm.api.z8spi.conv.Converter; 10 | 11 | @Target({ElementType.FIELD}) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface NoSqlColumn { 14 | String columnName() default ""; 15 | 16 | /** 17 | * Unused at this point but eventually we may allow fields that have are declared like so 18 | * 19 | * private Car car; 20 | * 21 | * but targetEntity may specify a subtype like Honda such that we would create a Honda object 22 | * and put it into the Car field here. I am not sure if this would be used or not so we 23 | * have left it unimplemented 24 | * @return Class name of the subtype 25 | */ 26 | @SuppressWarnings("rawtypes") 27 | Class targetEntity() default void.class; 28 | 29 | /** 30 | * Deprecated: Use @NoSqlConverter instead!!! 31 | * 32 | * You can supply your own converter for a field here which will override all 33 | * standard conversions even for primitives. You just translate back and 34 | * forth from the byte[] for us and we wire that in. 35 | * @return An object of Class which extends Converter 36 | */ 37 | @Deprecated 38 | Class customConverter() default NoConversion.class; 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z3api/QueryResult.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z3api; 2 | 3 | import java.util.List; 4 | 5 | import com.alvazan.orm.api.z5api.IndexColumnInfo; 6 | import com.alvazan.orm.api.z8spi.KeyValue; 7 | import com.alvazan.orm.api.z8spi.iter.Cursor; 8 | import com.alvazan.orm.api.z8spi.meta.TypedRow; 9 | import com.alvazan.orm.api.z8spi.meta.ViewInfo; 10 | 11 | public interface QueryResult { 12 | 13 | /** 14 | * This cursor is a cursor into JUST the row keys of the entites that match the query. 15 | * @return A Cursor of IndexColumnInfo 16 | */ 17 | Cursor getCursor(); 18 | 19 | List getViews(); 20 | 21 | /** 22 | * This cursor on every cursor.next/cursor.getCurrent returns a List of the joined rows so you 23 | * could display in a command line or GUI tool the results(and page the results). 24 | * @return A Cursor having list of TypedRow objects 25 | */ 26 | Cursor> getAllViewsCursor(); 27 | 28 | /** 29 | * This cursor ONLY returns the primary View's rows and NOT the rows that were joined with though the 30 | * primary view usually contains the other row keys in a ManyToOne or OneToOne case anyways. 31 | * @return A Cursor 32 | */ 33 | Cursor> getPrimaryViewCursor(); 34 | 35 | Iterable> getPrimaryViewIter(); 36 | 37 | /** 38 | * Sometimes an Iterable is way more convenient 39 | * @return An iterator over the elements in the QueryResult 40 | */ 41 | Iterable> getAllViewsIter(); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer0/base/IterableCounting.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer0.base; 2 | 3 | import java.util.Iterator; 4 | 5 | import com.alvazan.orm.api.z8spi.conv.Precondition; 6 | import com.alvazan.orm.api.z8spi.iter.AbstractIterator; 7 | 8 | public class IterableCounting implements Iterable { 9 | 10 | private AbstractIterator keysIterator; 11 | private boolean alreadyRun = false; 12 | private int batchSize; 13 | public IterableCounting(AbstractIterator keysIterator, int batchSize2) { 14 | Precondition.check(keysIterator, "keysIterator"); 15 | this.keysIterator = keysIterator; 16 | this.batchSize = batchSize2; 17 | } 18 | 19 | @Override 20 | public Iterator iterator() { 21 | if(alreadyRun) 22 | throw new IllegalStateException("BUG, This iterable can only be run once as it is proxy to an Iterator that CAN ONLY be run once"); 23 | alreadyRun = true; 24 | return new CountingIterator(keysIterator, batchSize); 25 | } 26 | 27 | private static class CountingIterator extends AbstractIterator{ 28 | private AbstractIterator keysIterator; 29 | private int count = 0; 30 | private int batchSize; 31 | public CountingIterator(AbstractIterator keysIterator, int batchSize2) { 32 | this.keysIterator = keysIterator; 33 | this.batchSize = batchSize2; 34 | } 35 | 36 | @Override 37 | public com.alvazan.orm.api.z8spi.iter.AbstractIterator.IterHolder nextImpl() { 38 | if(count >= batchSize) 39 | return null; 40 | count++; 41 | return keysIterator.nextImpl(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer0/base/MetaLayerImpl.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer0.base; 2 | 3 | import javax.inject.Inject; 4 | 5 | import com.alvazan.orm.api.base.MetaLayer; 6 | import com.alvazan.orm.api.z8spi.meta.DboColumnIdMeta; 7 | import com.alvazan.orm.impl.meta.data.MetaClass; 8 | import com.alvazan.orm.impl.meta.data.MetaInfo; 9 | 10 | @SuppressWarnings("rawtypes") 11 | public class MetaLayerImpl implements MetaLayer { 12 | 13 | @Inject 14 | private MetaInfo metaInfo; 15 | 16 | @SuppressWarnings({ "unchecked" }) 17 | @Override 18 | public Object getKey(Object entity) { 19 | MetaClass metaClass = getMetaClass(entity.getClass()); 20 | return metaClass.fetchId(entity); 21 | } 22 | 23 | private MetaClass getMetaClass(Class type) { 24 | MetaClass meta = metaInfo.getMetaClass(type); 25 | if(meta == null) 26 | throw new IllegalArgumentException("Meta information not found on class="+type.getSimpleName()); 27 | return meta; 28 | } 29 | 30 | @Override 31 | public boolean isManagedEntity(Class type) { 32 | MetaClass metaClass = metaInfo.getMetaClass(type); 33 | return metaClass != null; 34 | } 35 | 36 | @Override 37 | public String getKeyFieldName(Class type) { 38 | MetaClass meta = getMetaClass(type); 39 | return meta.getIdField().getFieldName(); 40 | } 41 | 42 | @Override 43 | public Object convertIdFromString(Class entityType, String idAsString) { 44 | MetaClass meta = getMetaClass(entityType); 45 | DboColumnIdMeta idMeta = meta.getIdField().getMetaIdDbo(); 46 | return idMeta.convertStringToType(idAsString); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/iter/IndiceToVirtual.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.iter; 2 | 3 | import com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder; 4 | import com.alvazan.orm.api.z8spi.meta.DboTableMeta; 5 | 6 | public class IndiceToVirtual implements DirectCursor { 7 | 8 | private DboTableMeta meta; 9 | private DirectCursor noSqlKeys; 10 | 11 | public IndiceToVirtual(DboTableMeta meta, DirectCursor noSqlKeys) { 12 | this.meta = meta; 13 | this.noSqlKeys = noSqlKeys; 14 | } 15 | 16 | @Override 17 | public String toString() { 18 | String tabs = StringLocal.getAndAdd(); 19 | String retVal = "IndiceToVirtual(keyToVirtualKeyTranslatorCursor)["+tabs+noSqlKeys+tabs+"]"; 20 | StringLocal.set(tabs.length()); 21 | return retVal; 22 | } 23 | 24 | 25 | @Override 26 | public Holder nextImpl() { 27 | Holder nextHolder = noSqlKeys.nextImpl(); 28 | if (nextHolder == null) 29 | return null; 30 | byte[] next = nextHolder.getValue(); 31 | return new Holder(meta.getIdColumnMeta().formVirtRowKey(next)); 32 | } 33 | 34 | @Override 35 | public Holder previousImpl() { 36 | Holder nextHolder = noSqlKeys.previousImpl(); 37 | if (nextHolder == null) 38 | return null; 39 | byte[] next = nextHolder.getValue(); 40 | return new Holder(meta.getIdColumnMeta().formVirtRowKey(next)); 41 | } 42 | 43 | @Override 44 | public void beforeFirst() { 45 | noSqlKeys.beforeFirst(); 46 | 47 | } 48 | 49 | @Override 50 | public void afterLast() { 51 | noSqlKeys.afterLast(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/cassandra/CursorReturnsEmptyRows.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.cassandra; 2 | 3 | import com.alvazan.orm.api.z8spi.KeyValue; 4 | import com.alvazan.orm.api.z8spi.Row; 5 | import com.alvazan.orm.api.z8spi.iter.AbstractCursor; 6 | import com.alvazan.orm.api.z8spi.iter.DirectCursor; 7 | 8 | public class CursorReturnsEmptyRows extends AbstractCursor> { 9 | 10 | private DirectCursor keys; 11 | public CursorReturnsEmptyRows(DirectCursor keys) { 12 | if(keys == null) 13 | throw new IllegalArgumentException("keys cannot be null"); 14 | this.keys = keys; 15 | beforeFirst(); 16 | } 17 | 18 | @Override 19 | public void beforeFirst() { 20 | keys.beforeFirst(); 21 | } 22 | 23 | @Override 24 | public void afterLast() { 25 | keys.afterLast(); 26 | } 27 | 28 | @Override 29 | public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder> nextImpl() { 30 | Holder holder = keys.nextImpl(); 31 | if (holder == null) 32 | return null; 33 | 34 | byte[] key = holder.getValue(); 35 | KeyValue kv = new KeyValue(); 36 | kv.setKey(key); 37 | 38 | return new Holder>(kv); 39 | } 40 | 41 | @Override 42 | public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder> previousImpl() { 43 | Holder holder = keys.previousImpl(); 44 | if (holder == null) 45 | return null; 46 | 47 | byte[] key = holder.getValue(); 48 | KeyValue kv = new KeyValue(); 49 | kv.setKey(key); 50 | 51 | return new Holder>(kv); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/mongodb/CursorReturnsEmptyRows2.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.mongodb; 2 | 3 | import com.alvazan.orm.api.z8spi.KeyValue; 4 | import com.alvazan.orm.api.z8spi.Row; 5 | import com.alvazan.orm.api.z8spi.iter.AbstractCursor; 6 | import com.alvazan.orm.api.z8spi.iter.DirectCursor; 7 | 8 | public class CursorReturnsEmptyRows2 extends AbstractCursor> { 9 | 10 | private DirectCursor keys; 11 | public CursorReturnsEmptyRows2(DirectCursor keys) { 12 | if(keys == null) 13 | throw new IllegalArgumentException("keys cannot be null"); 14 | this.keys = keys; 15 | beforeFirst(); 16 | } 17 | 18 | @Override 19 | public void beforeFirst() { 20 | keys.beforeFirst(); 21 | } 22 | 23 | @Override 24 | public void afterLast() { 25 | keys.afterLast(); 26 | } 27 | 28 | @Override 29 | public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder> nextImpl() { 30 | Holder holder = keys.nextImpl(); 31 | if (holder == null) 32 | return null; 33 | 34 | byte[] key = holder.getValue(); 35 | KeyValue kv = new KeyValue(); 36 | kv.setKey(key); 37 | 38 | return new Holder>(kv); 39 | } 40 | 41 | @Override 42 | public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder> previousImpl() { 43 | Holder holder = keys.previousImpl(); 44 | if (holder == null) 45 | return null; 46 | 47 | byte[] key = holder.getValue(); 48 | KeyValue kv = new KeyValue(); 49 | kv.setKey(key); 50 | 51 | return new Holder>(kv); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/hbase/CursorReturnsEmptyRowsHbase.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.hbase; 2 | 3 | import com.alvazan.orm.api.z8spi.KeyValue; 4 | import com.alvazan.orm.api.z8spi.Row; 5 | import com.alvazan.orm.api.z8spi.iter.AbstractCursor; 6 | import com.alvazan.orm.api.z8spi.iter.DirectCursor; 7 | 8 | public class CursorReturnsEmptyRowsHbase extends AbstractCursor> { 9 | 10 | private DirectCursor keys; 11 | 12 | public CursorReturnsEmptyRowsHbase(DirectCursor keys) { 13 | if (keys == null) 14 | throw new IllegalArgumentException("keys cannot be null"); 15 | this.keys = keys; 16 | beforeFirst(); 17 | } 18 | 19 | @Override 20 | public void beforeFirst() { 21 | keys.beforeFirst(); 22 | } 23 | 24 | @Override 25 | public void afterLast() { 26 | keys.afterLast(); 27 | } 28 | 29 | @Override 30 | public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder> nextImpl() { 31 | Holder holder = keys.nextImpl(); 32 | if (holder == null) 33 | return null; 34 | 35 | byte[] key = holder.getValue(); 36 | KeyValue kv = new KeyValue(); 37 | kv.setKey(key); 38 | 39 | return new Holder>(kv); 40 | } 41 | 42 | @Override 43 | public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder> previousImpl() { 44 | Holder holder = keys.previousImpl(); 45 | if (holder == null) 46 | return null; 47 | 48 | byte[] key = holder.getValue(); 49 | KeyValue kv = new KeyValue(); 50 | kv.setKey(key); 51 | 52 | return new Holder>(kv); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/ColumnSliceInfo.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | 5 | import com.alvazan.orm.api.z8spi.meta.DboTableMeta; 6 | 7 | public class ColumnSliceInfo { 8 | 9 | private byte[] rowKey; 10 | private DboTableMeta colFamily; 11 | private byte[] from; 12 | private byte[] to; 13 | private Class columnNameType; 14 | 15 | public ColumnSliceInfo(DboTableMeta realColFamily, byte[] rowKey2, byte[] from2, byte[] to2, Class columnNameType2) { 16 | this.colFamily = realColFamily; 17 | this.rowKey = rowKey2; 18 | this.from = from2; 19 | this.to = to2; 20 | this.columnNameType = columnNameType2; 21 | } 22 | 23 | public byte[] getRowKey() { 24 | return rowKey; 25 | } 26 | 27 | public DboTableMeta getColFamily() { 28 | return this.colFamily; 29 | } 30 | 31 | public byte[] getFrom() { 32 | return this.from; 33 | } 34 | 35 | public byte[] getTo() { 36 | return this.to; 37 | } 38 | 39 | public Class getColumnNameType() { 40 | return this.columnNameType; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | String retVal = "CF= " + colFamily.getColumnFamily() + " rowKey= " + toUTF8(rowKey); 46 | return retVal; 47 | } 48 | 49 | private String toUTF8(byte[] data) { 50 | try { 51 | return new String(data, "UTF8"); 52 | } catch (UnsupportedEncodingException e) { 53 | throw new RuntimeException(e); 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer9z/spi/db/cassandracql3/CursorReturnsEmptyRows2.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer9z.spi.db.cassandracql3; 2 | 3 | import com.alvazan.orm.api.z8spi.KeyValue; 4 | import com.alvazan.orm.api.z8spi.Row; 5 | import com.alvazan.orm.api.z8spi.iter.AbstractCursor; 6 | import com.alvazan.orm.api.z8spi.iter.DirectCursor; 7 | 8 | public class CursorReturnsEmptyRows2 extends AbstractCursor> { 9 | 10 | private DirectCursor keys; 11 | public CursorReturnsEmptyRows2(DirectCursor keys) { 12 | if(keys == null) 13 | throw new IllegalArgumentException("keys cannot be null"); 14 | this.keys = keys; 15 | beforeFirst(); 16 | } 17 | 18 | @Override 19 | public void beforeFirst() { 20 | keys.beforeFirst(); 21 | } 22 | 23 | @Override 24 | public void afterLast() { 25 | keys.afterLast(); 26 | } 27 | 28 | @Override 29 | public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder> nextImpl() { 30 | Holder holder = keys.nextImpl(); 31 | if (holder == null) 32 | return null; 33 | 34 | byte[] key = holder.getValue(); 35 | KeyValue kv = new KeyValue(); 36 | kv.setKey(key); 37 | 38 | return new Holder>(kv); 39 | } 40 | 41 | @Override 42 | public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder> previousImpl() { 43 | Holder holder = keys.previousImpl(); 44 | if (holder == null) 45 | return null; 46 | 47 | byte[] key = holder.getValue(); 48 | KeyValue kv = new KeyValue(); 49 | kv.setKey(key); 50 | 51 | return new Holder>(kv); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/action/Column.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.action; 2 | 3 | import com.alvazan.orm.api.z8spi.conv.ByteArray; 4 | 5 | public class Column { 6 | private byte[] name; 7 | private byte[] value; 8 | private Long timestamp; 9 | private Integer ttl; 10 | 11 | public Column() {} 12 | 13 | public Column(byte[] name, byte[] value) { 14 | this.name = name; 15 | this.value = value; 16 | } 17 | 18 | public byte[] getValue() { 19 | return value; 20 | } 21 | public void setValue(byte[] value) { 22 | this.value = value; 23 | } 24 | public Long getTimestamp() { 25 | return timestamp; 26 | } 27 | public void setTimestamp(Long timestamp) { 28 | this.timestamp = timestamp; 29 | } 30 | public byte[] getName() { 31 | return name; 32 | } 33 | public void setName(byte[] name) { 34 | this.name = name; 35 | } 36 | public Integer getTtl() { 37 | return ttl; 38 | } 39 | public void setTtl(Integer ttl) { 40 | this.ttl = ttl; 41 | } 42 | 43 | @Override 44 | public Object clone() throws CloneNotSupportedException { 45 | return super.clone(); 46 | } 47 | 48 | public Column copy() { 49 | //perhaps should deep copy here but we don't... 50 | Column c = new Column(); 51 | c.name = name; 52 | c.timestamp = timestamp; 53 | //THIS MAKES us perform exactly like cassandra in that a 0 length byte or string is same as null!!! 54 | if(value != null && value.length != 0) 55 | c.value = value; 56 | c.ttl = ttl; 57 | return c; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "colName="+new ByteArray(name)+"/value="+new ByteArray(value); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/iter/AbstractIterator.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.iter; 2 | 3 | import java.util.Iterator; 4 | 5 | public abstract class AbstractIterator implements Iterator{ 6 | 7 | private IterHolder nextValue; 8 | 9 | @Override 10 | public final boolean hasNext() { 11 | if(nextValue != null) { 12 | //DO NOT get nextImpl yet since he has not called next yet to clear out the next value 13 | //field so just keep returning true instead!!! 14 | return true; 15 | } 16 | //Okay, let's get the next value here and see if there actually is one 17 | nextValue = nextImpl(); 18 | if(nextValue == null) { 19 | //There is NO next value so screw it, return false 20 | return false; 21 | } 22 | return true; 23 | } 24 | 25 | public abstract IterHolder nextImpl(); 26 | 27 | @Override 28 | public final T next() { 29 | IterHolder temp = nextValue; 30 | if(temp == null) { 31 | //Here, they may call next to get the first element WITHOUT calling hasNext, so we call hasNext 32 | if(!hasNext()) 33 | throw new IllegalArgumentException("This cursor has run out of value. Call hasNext() to avoid this exception and check before calling next()!!!!"); 34 | temp = nextValue; 35 | } 36 | nextValue = null; 37 | return temp.getValue(); 38 | } 39 | 40 | @Override 41 | public void remove() { 42 | throw new UnsupportedOperationException("not supported"); 43 | } 44 | 45 | public static class IterHolder { 46 | private T value; 47 | public IterHolder(T val) { 48 | this.value = val; 49 | } 50 | public T getValue() { 51 | return value; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z5api/SpiMetaQuery.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z5api; 2 | 3 | import java.util.List; 4 | 5 | import com.alvazan.orm.api.z8spi.meta.TypeInfo; 6 | import com.alvazan.orm.api.z8spi.meta.TypedColumn; 7 | import com.alvazan.orm.api.z8spi.meta.ViewInfo; 8 | 9 | public interface SpiMetaQuery { 10 | 11 | /** 12 | * We will call this method EVERY time we want to run a query so that the SpiIndexQuery can have 13 | * state and store parameters!!! 14 | * 15 | * NOTE: SpiIndexQuery typically has a prototype pattern where it has the query that will just 16 | * be cloned as the adapter is created so the adapter can use it, and so one indexQuery can 17 | * have many SpiQueryAdapters associated with it that came from the same query but threads supply 18 | * different parameters to it. 19 | * 20 | 21 | * @param session 22 | * @return A BRAND NEW instance of SpiQueryAdapter(must not be one you have returned previously) 23 | */ 24 | public SpiQueryAdapter createQueryInstanceFromQuery(NoSqlSession session); 25 | 26 | public TypeInfo getMetaFieldByParameter(String name); 27 | 28 | public String getQuery(); 29 | 30 | List getTargetViews(); 31 | 32 | /** 33 | * Join happens after rows returned because don't need indices as it would just slow it down. 34 | * @return List of ViewInfo 35 | */ 36 | public List getViewsDelayedJoin(); 37 | 38 | /** 39 | * Join happens from indices during the query 40 | * @return List of ViewInfo 41 | */ 42 | public List getViewsEagerJoin(); 43 | 44 | public List getUpdateList(); 45 | 46 | public String getQueryType(); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z8spi/meta/ReflectionUtil.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z8spi.meta; 2 | 3 | import java.lang.reflect.Field; 4 | 5 | import com.alvazan.orm.api.exc.TypeMismatchException; 6 | 7 | public class ReflectionUtil { 8 | 9 | public static T create(Class c) { 10 | try { 11 | return c.newInstance(); 12 | } catch (InstantiationException e) { 13 | throw new RuntimeException(e); 14 | } catch (IllegalAccessException e) { 15 | throw new RuntimeException(e); 16 | } 17 | } 18 | 19 | public static void putFieldValue(Object entity, Field field, Object value) { 20 | try { 21 | //NOTE: There was some kind of major bug where if we run field.set on a javassist.util.Proxy object 22 | // and when we set field entity.id, not only 23 | //did entity.id get modified, BUT entity.nameToValue ALSO was modified for some dang 24 | //reason and I am not sure why, so NOW instead of using field.set on javassist.util.Proxy 25 | //we are going to call a special method on the Proxy to try to set the field instead 26 | field.set(entity, value); 27 | } catch (IllegalArgumentException e) { 28 | throw new RuntimeException(e); 29 | } catch (IllegalAccessException e) { 30 | throw new RuntimeException(e); 31 | } 32 | } 33 | 34 | public static Object fetchFieldValue(Object entity, Field field) { 35 | try { 36 | return field.get(entity); 37 | } catch (IllegalArgumentException e) { 38 | throw new TypeMismatchException("Entity='"+entity.getClass()+"' was passed to field of a different type. field='"+field+"'", e); 39 | } catch (IllegalAccessException e) { 40 | throw new RuntimeException(e); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/layer3/typed/CursorProxyDirect.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.layer3.typed; 2 | 3 | import com.alvazan.orm.api.z5api.IndexColumnInfo; 4 | import com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder; 5 | import com.alvazan.orm.api.z8spi.iter.Cursor; 6 | import com.alvazan.orm.api.z8spi.iter.DirectCursor; 7 | import com.alvazan.orm.api.z8spi.iter.StringLocal; 8 | 9 | public class CursorProxyDirect implements Cursor { 10 | 11 | private DirectCursor iter; 12 | private Holder cached; 13 | 14 | public CursorProxyDirect(DirectCursor iter) { 15 | this.iter = iter; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | String tabs = StringLocal.getAndAdd(); 21 | String retVal = "CursorProxyDirect["+tabs+iter+tabs+"]"; 22 | StringLocal.set(tabs.length()); 23 | return retVal; 24 | } 25 | 26 | @Override 27 | public void beforeFirst() { 28 | iter.beforeFirst(); 29 | } 30 | 31 | @Override 32 | public void afterLast() { 33 | iter.afterLast(); 34 | } 35 | 36 | @Override 37 | public boolean next() { 38 | cached = iter.nextImpl(); 39 | if(cached == null) 40 | return false; 41 | return true; 42 | } 43 | 44 | @Override 45 | public boolean previous() { 46 | cached = iter.previousImpl(); 47 | if(cached == null) 48 | return false; 49 | return true; 50 | } 51 | 52 | @Override 53 | public IndexColumnInfo getCurrent() { 54 | if(cached == null) 55 | throw new IllegalArgumentException("You should test for true/false when calling next as you are not within the limits currently of the list of values"); 56 | return cached.getValue(); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/orm/api/z5api/IndexPoint.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.orm.api.z5api; 2 | 3 | import com.alvazan.orm.api.z8spi.action.IndexColumn; 4 | import com.alvazan.orm.api.z8spi.meta.DboColumnIdMeta; 5 | import com.alvazan.orm.api.z8spi.meta.DboColumnMeta; 6 | 7 | public class IndexPoint { 8 | 9 | private DboColumnIdMeta idMeta; 10 | private DboColumnMeta colMeta; 11 | private byte[] rowKey; 12 | private byte[] indexedValue; 13 | private Integer ttl; 14 | 15 | public IndexPoint(DboColumnIdMeta idMeta, IndexColumn col, DboColumnMeta colMeta) { 16 | this.idMeta = idMeta; 17 | this.colMeta = colMeta; 18 | rowKey = col.getPrimaryKey(); 19 | indexedValue = col.getIndexedValue(); 20 | ttl = col.getTtl(); 21 | } 22 | 23 | @Override 24 | public String toString() { 25 | return getIndexedValueAsString()+"."+getKeyAsString(); 26 | } 27 | 28 | public Object getKey() { 29 | return idMeta.convertFromStorage2(rowKey); 30 | } 31 | public String getKeyAsString() { 32 | Object obj = getKey(); 33 | return idMeta.convertTypeToString(obj); 34 | } 35 | 36 | public byte[] getRawKey() { 37 | return rowKey; 38 | } 39 | 40 | public byte[] getRawIndexedValue() { 41 | return indexedValue; 42 | } 43 | 44 | public Object getIndexedValue() { 45 | return colMeta.convertFromStorage2(indexedValue); 46 | } 47 | public String getIndexedValueAsString() { 48 | Object obj = getIndexedValue(); 49 | return colMeta.convertTypeToString(obj); 50 | } 51 | 52 | public DboColumnMeta getColumnMeta() { 53 | return colMeta; 54 | } 55 | 56 | public DboColumnIdMeta getRowKeyMeta() { 57 | return idMeta; 58 | } 59 | 60 | public Integer getTtl() { 61 | return ttl; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/playorm/cron/api/CronServiceFactory.java: -------------------------------------------------------------------------------- 1 | package org.playorm.cron.api; 2 | 3 | import java.util.Map; 4 | 5 | public abstract class CronServiceFactory { 6 | 7 | private static final String OUR_IMPL = "org.playorm.cron.bindings.CronServiceFactoryImpl"; 8 | 9 | public static final String SCAN_RATE_MILLIS = "org.playorm.monitor.scanrate"; 10 | public static final String HOST_UNIQUE_NAME = "org.playorm.monitor.host"; 11 | 12 | private volatile static CronService singleton; 13 | 14 | public static CronService getSingleton(Map properties) { 15 | //double checked locking is ONLY ok if you use the keyword volatile in java 16 | synchronized(CronServiceFactory.class) { 17 | if(singleton == null) 18 | singleton = create(properties); 19 | } 20 | return singleton; 21 | } 22 | 23 | public synchronized static CronService create(Map properties) { 24 | CronServiceFactory newInstance = createInstance(OUR_IMPL); 25 | return newInstance.createService(properties); 26 | } 27 | 28 | public static final String NOSQL_MGR_FACTORY = "org.playorm.monitor.factory"; 29 | 30 | protected abstract CronService createService(Map properties); 31 | 32 | private static CronServiceFactory createInstance(String impl) { 33 | try { 34 | Class clazz = Class.forName(impl); 35 | CronServiceFactory newInstance = (CronServiceFactory) clazz.newInstance(); 36 | return newInstance; 37 | } catch (ClassNotFoundException e) { 38 | throw new RuntimeException(e); 39 | } catch (InstantiationException e) { 40 | throw new RuntimeException(e); 41 | } catch (IllegalAccessException e) { 42 | throw new RuntimeException(e); 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/alvazan/ssql/cmdline/PlayOptions.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.ssql.cmdline; 2 | 3 | import org.kohsuke.args4j.Option; 4 | 5 | public class PlayOptions { 6 | 7 | @Option(name="-t",usage="where VAL can be inmemory or cassandra", required=true) 8 | private String type; 9 | 10 | @Option(name="-k",usage="where VAL is keyspace if using type of cassandra") 11 | private String keyspace; 12 | 13 | @Option(name="-s", usage="where VAL is Comma delimeted list of seeds with NO spaces such as host1:9160,host2:9160") 14 | private String seeds; 15 | 16 | @Option(name="-c",usage="(optional)The Consistency Level which is normally set to CL_QUOROM for X nodes or ONE for a single node install, defaults to CL_QUOROM") 17 | private String consistencyLevel; 18 | 19 | @Option(name="-v",usage="Turn on verbose logging") 20 | private boolean isVerbose; 21 | 22 | public String getType() { 23 | return type; 24 | } 25 | 26 | public void setType(String type) { 27 | this.type = type; 28 | } 29 | 30 | public String getKeyspace() { 31 | return keyspace; 32 | } 33 | 34 | public void setKeyspace(String keyspace) { 35 | this.keyspace = keyspace; 36 | } 37 | 38 | public String getSeeds() { 39 | return seeds; 40 | } 41 | 42 | public void setSeeds(String seeds) { 43 | this.seeds = seeds; 44 | } 45 | 46 | public boolean isVerbose() { 47 | return isVerbose; 48 | } 49 | 50 | public void setVerbose(boolean isVerbose) { 51 | this.isVerbose = isVerbose; 52 | } 53 | 54 | public String getConsistencyLevel() { 55 | return consistencyLevel; 56 | } 57 | 58 | public void setConsistencyLevel(String consistencyLevel) { 59 | this.consistencyLevel = consistencyLevel; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/NonVirtSub1.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.NoSqlEntityManager; 4 | import com.alvazan.orm.api.base.Query; 5 | import com.alvazan.orm.api.base.anno.NoSqlDiscriminatorColumn; 6 | import com.alvazan.orm.api.base.anno.NoSqlIndexed; 7 | import com.alvazan.orm.api.base.anno.NoSqlQueries; 8 | import com.alvazan.orm.api.base.anno.NoSqlQuery; 9 | import com.alvazan.orm.api.z8spi.KeyValue; 10 | import com.alvazan.orm.api.z8spi.iter.Cursor; 11 | 12 | @NoSqlDiscriminatorColumn(value="sub1") 13 | @NoSqlQueries({ 14 | @NoSqlQuery(name="findAll", query="select s from TABLE as s"), 15 | @NoSqlQuery(name ="findById", query = "select u from TABLE as u where :id = u.id"), 16 | @NoSqlQuery(name="findByName", query="select s from TABLE as s where s.name = :name") 17 | }) 18 | public class NonVirtSub1 extends NonVirtSuper { 19 | 20 | @NoSqlIndexed 21 | private String name; 22 | 23 | private String diff; 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | 33 | public String getDiff() { 34 | return diff; 35 | } 36 | 37 | public void setDiff(String diff) { 38 | this.diff = diff; 39 | } 40 | 41 | public static Cursor> findAll(NoSqlEntityManager mgr) { 42 | Query query = mgr.createNamedQuery(NonVirtSub1.class, "findAll"); 43 | return query.getResults("name"); 44 | } 45 | 46 | public static NonVirtSub1 findByName(NoSqlEntityManager mgr, String name) { 47 | Query query = mgr.createNamedQuery(NonVirtSub1.class, "findByName"); 48 | query.setParameter("name", name); 49 | return query.getSingleObject(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/com/alvazan/test/db/InheritanceSub1.java: -------------------------------------------------------------------------------- 1 | package com.alvazan.test.db; 2 | 3 | import com.alvazan.orm.api.base.NoSqlEntityManager; 4 | import com.alvazan.orm.api.base.Query; 5 | import com.alvazan.orm.api.base.anno.NoSqlDiscriminatorColumn; 6 | import com.alvazan.orm.api.base.anno.NoSqlIndexed; 7 | import com.alvazan.orm.api.base.anno.NoSqlQueries; 8 | import com.alvazan.orm.api.base.anno.NoSqlQuery; 9 | import com.alvazan.orm.api.z8spi.KeyValue; 10 | import com.alvazan.orm.api.z8spi.iter.Cursor; 11 | 12 | @NoSqlDiscriminatorColumn(value="sub1") 13 | @NoSqlQueries({ 14 | @NoSqlQuery(name="findAll", query="select s from TABLE as s"), 15 | @NoSqlQuery(name ="findById", query = "select u from TABLE as u where :id = u.id"), 16 | @NoSqlQuery(name="findByName", query="select s from TABLE as s where s.name = :name") 17 | }) 18 | public class InheritanceSub1 extends InheritanceSuper { 19 | 20 | @NoSqlIndexed 21 | private String name; 22 | 23 | private String diff; 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | 33 | public String getDiff() { 34 | return diff; 35 | } 36 | 37 | public void setDiff(String diff) { 38 | this.diff = diff; 39 | } 40 | 41 | public static Cursor> findAll(NoSqlEntityManager mgr) { 42 | Query query = mgr.createNamedQuery(InheritanceSub1.class, "findAll"); 43 | return query.getResults("name"); 44 | } 45 | 46 | public static InheritanceSub1 findByName(NoSqlEntityManager mgr, String name) { 47 | Query query = mgr.createNamedQuery(InheritanceSub1.class, "findByName"); 48 | query.setParameter("name", name); 49 | return query.getSingleObject(); 50 | } 51 | } 52 | --------------------------------------------------------------------------------