001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019 020package org.apache.isis.objectstore.jdo.applib.service.settings; 021 022 023import javax.jdo.annotations.IdentityType; 024 025import org.apache.isis.applib.annotation.MemberOrder; 026import org.apache.isis.applib.annotation.Named; 027import org.apache.isis.applib.annotation.Title; 028import org.apache.isis.applib.services.settings.SettingType; 029import org.apache.isis.applib.services.settings.UserSetting; 030import org.apache.isis.objectstore.jdo.applib.service.JdoColumnLength; 031 032@javax.jdo.annotations.PersistenceCapable( 033 identityType = IdentityType.APPLICATION, 034 objectIdClass=UserSettingJdoPK.class, 035 table="IsisUserSetting") 036@javax.jdo.annotations.Queries({ 037 @javax.jdo.annotations.Query( 038 name = "findByUserAndKey", language = "JDOQL", 039 value = "SELECT " 040 + "FROM org.apache.isis.objectstore.jdo.applib.service.settings.UserSettingJdo " 041 + "WHERE user == :user " 042 + "&& key == :key ") 043 ,@javax.jdo.annotations.Query( 044 name = "findByUser", language = "JDOQL", 045 value = "SELECT " 046 + "FROM org.apache.isis.objectstore.jdo.applib.service.settings.UserSettingJdo " 047 + "WHERE user == :user " 048 + "ORDER BY key") 049 ,@javax.jdo.annotations.Query( 050 name = "findAll", language = "JDOQL", 051 value = "SELECT " 052 + "FROM org.apache.isis.objectstore.jdo.applib.service.settings.UserSettingJdo " 053 + "ORDER BY user, key") 054}) 055// can't see how to specify this order in the primary key; however HSQLDB objects :-( 056//@javax.jdo.annotations.Unique(name="USER_KEY_IDX", members={"user","key"}) 057@Named("User Setting") 058public class UserSettingJdo extends SettingAbstractJdo implements UserSetting { 059 060 061 private String user; 062 063 @javax.jdo.annotations.Column(length=JdoColumnLength.USER_NAME) 064 @javax.jdo.annotations.PrimaryKey 065 @Title(sequence="5", append=": ") 066 @MemberOrder(sequence = "5") 067 public String getUser() { 068 return user; 069 } 070 071 public void setUser(final String user) { 072 this.user = user; 073 } 074 075 // ////////////////////////////////////// 076 077 @javax.jdo.annotations.Column(length=JdoColumnLength.SettingAbstract.SETTING_KEY) 078 @javax.jdo.annotations.PrimaryKey 079 @Title(sequence="10") 080 @Override 081 public String getKey() { 082 return super.getKey(); 083 } 084 @Override 085 public void setKey(String key) { 086 super.setKey(key); 087 } 088 089 // ////////////////////////////////////// 090 091 @javax.jdo.annotations.Column(length=JdoColumnLength.DESCRIPTION) 092 @javax.jdo.annotations.Persistent 093 @Override 094 public String getDescription() { 095 return super.getDescription(); 096 } 097 @Override 098 public void setDescription(String description) { 099 super.setDescription(description); 100 } 101 102 // ////////////////////////////////////// 103 104 @javax.jdo.annotations.Column(allowsNull="false", length=JdoColumnLength.SettingAbstract.VALUE_RAW) 105 @javax.jdo.annotations.Persistent 106 @Title(prepend=" = ", sequence="30") 107 @Override 108 public String getValueRaw() { 109 return super.getValueRaw(); 110 } 111 @Override 112 public void setValueRaw(String valueAsRaw) { 113 super.setValueRaw(valueAsRaw); 114 } 115 116 // ////////////////////////////////////// 117 118 @javax.jdo.annotations.Column(allowsNull="false", length=JdoColumnLength.SettingAbstract.SETTING_TYPE) 119 @javax.jdo.annotations.Persistent 120 @Override 121 public SettingType getType() { 122 return super.getType(); 123 } 124 @Override 125 public void setType(SettingType type) { 126 super.setType(type); 127 } 128 129}