001package co.codewizards.cloudstore.local.persistence;
002
003import static co.codewizards.cloudstore.core.util.Util.*;
004
005import java.util.UUID;
006
007import javax.jdo.annotations.NullValue;
008import javax.jdo.annotations.PersistenceCapable;
009import javax.jdo.annotations.Persistent;
010import javax.jdo.annotations.Queries;
011import javax.jdo.annotations.Query;
012import javax.jdo.annotations.Unique;
013
014@PersistenceCapable
015@Unique(name="RemoteRepositoryRequest_repositoryId", members="repositoryId")
016@Queries({
017        @Query(name="getRemoteRepositoryRequest_repositoryId", value="SELECT UNIQUE WHERE this.repositoryId == :repositoryId"),
018        @Query(name="getRemoteRepositoryRequestsChangedBefore_changed", value="SELECT WHERE this.changed < :changed")
019})
020public class RemoteRepositoryRequest extends Entity {
021
022        public RemoteRepositoryRequest() { }
023
024        @Persistent(nullValue=NullValue.EXCEPTION)
025        private String repositoryId;
026
027        @Persistent(nullValue=NullValue.EXCEPTION)
028        private byte[] publicKey;
029
030        @Persistent(nullValue=NullValue.EXCEPTION)
031        private String localPathPrefix;
032
033        public UUID getRepositoryId() {
034                return repositoryId == null ? null : UUID.fromString(repositoryId);
035        }
036        public void setRepositoryId(UUID repositoryId) {
037                if (! equal(this.getRepositoryId(), repositoryId))
038                        this.repositoryId = repositoryId == null ? null : repositoryId.toString();
039        }
040
041        public byte[] getPublicKey() {
042                return publicKey;
043        }
044
045        public void setPublicKey(byte[] publicKey) {
046                if (! equal(this.publicKey, publicKey))
047                        this.publicKey = publicKey;
048        }
049
050        public String getLocalPathPrefix() {
051                return localPathPrefix;
052        }
053        public void setLocalPathPrefix(String localPathPrefix) {
054                if (! equal(this.localPathPrefix, localPathPrefix))
055                        this.localPathPrefix = localPathPrefix;
056        }
057}