id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
153,400
jbundle/jbundle
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java
BaseMessageRecordDesc.getMessageDataDesc
public MessageDataDesc getMessageDataDesc(String strParam) { if (strParam == null) return this; if (strParam.equals(this.getKey())) return this; if (m_messageDataDescChildren == null) { m_messageDataDescChildren = new HashMap<String,MessageDataDesc>(); this.setupMessageDataDesc(); } return (MessageDataDesc)m_messageDataDescChildren.get(strParam); }
java
public MessageDataDesc getMessageDataDesc(String strParam) { if (strParam == null) return this; if (strParam.equals(this.getKey())) return this; if (m_messageDataDescChildren == null) { m_messageDataDescChildren = new HashMap<String,MessageDataDesc>(); this.setupMessageDataDesc(); } return (MessageDataDesc)m_messageDataDescChildren.get(strParam); }
[ "public", "MessageDataDesc", "getMessageDataDesc", "(", "String", "strParam", ")", "{", "if", "(", "strParam", "==", "null", ")", "return", "this", ";", "if", "(", "strParam", ".", "equals", "(", "this", ".", "getKey", "(", ")", ")", ")", "return", "this", ";", "if", "(", "m_messageDataDescChildren", "==", "null", ")", "{", "m_messageDataDescChildren", "=", "new", "HashMap", "<", "String", ",", "MessageDataDesc", ">", "(", ")", ";", "this", ".", "setupMessageDataDesc", "(", ")", ";", "}", "return", "(", "MessageDataDesc", ")", "m_messageDataDescChildren", ".", "get", "(", "strParam", ")", ";", "}" ]
Get the data description for this param.
[ "Get", "the", "data", "description", "for", "this", "param", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java#L134-L146
153,401
jbundle/jbundle
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java
BaseMessageRecordDesc.isSingleDetail
public boolean isSingleDetail(Rec record) { boolean bSingleDetail = true; if (Boolean.toString(false).equals(this.getMessage().getMessageHeader().get(BaseMessageHeader.SINGLE_DETAIL_PARAM))) return false; return bSingleDetail; }
java
public boolean isSingleDetail(Rec record) { boolean bSingleDetail = true; if (Boolean.toString(false).equals(this.getMessage().getMessageHeader().get(BaseMessageHeader.SINGLE_DETAIL_PARAM))) return false; return bSingleDetail; }
[ "public", "boolean", "isSingleDetail", "(", "Rec", "record", ")", "{", "boolean", "bSingleDetail", "=", "true", ";", "if", "(", "Boolean", ".", "toString", "(", "false", ")", ".", "equals", "(", "this", ".", "getMessage", "(", ")", ".", "getMessageHeader", "(", ")", ".", "get", "(", "BaseMessageHeader", ".", "SINGLE_DETAIL_PARAM", ")", ")", ")", "return", "false", ";", "return", "bSingleDetail", ";", "}" ]
Does this message only include a single booking detail item?.
[ "Does", "this", "message", "only", "include", "a", "single", "booking", "detail", "item?", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java#L193-L201
153,402
jbundle/jbundle
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java
BaseMessageRecordDesc.putRawRecordData
public int putRawRecordData(Rec record) { if (this.getNodeType() == BaseMessageRecordDesc.NON_UNIQUE_NODE) this.getMessage().createNewNode(this.getFullKey(null)); return super.putRawRecordData(record); }
java
public int putRawRecordData(Rec record) { if (this.getNodeType() == BaseMessageRecordDesc.NON_UNIQUE_NODE) this.getMessage().createNewNode(this.getFullKey(null)); return super.putRawRecordData(record); }
[ "public", "int", "putRawRecordData", "(", "Rec", "record", ")", "{", "if", "(", "this", ".", "getNodeType", "(", ")", "==", "BaseMessageRecordDesc", ".", "NON_UNIQUE_NODE", ")", "this", ".", "getMessage", "(", ")", ".", "createNewNode", "(", "this", ".", "getFullKey", "(", "null", ")", ")", ";", "return", "super", ".", "putRawRecordData", "(", "record", ")", ";", "}" ]
Move the correct fields from this current record to the map. If this method is used, is must be overidden to move the correct fields. @param record The record to get the data from.
[ "Move", "the", "correct", "fields", "from", "this", "current", "record", "to", "the", "map", ".", "If", "this", "method", "is", "used", "is", "must", "be", "overidden", "to", "move", "the", "correct", "fields", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java#L234-L239
153,403
jbundle/jbundle
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java
BaseMessageRecordDesc.putRawProperties
public void putRawProperties(PropertyOwner propertyOwner) { if (m_messageDataDescChildren != null) { for (String strKey : m_messageDataDescChildren.keySet()) { m_messageDataDescChildren.get(strKey).putRawProperties(propertyOwner); } } }
java
public void putRawProperties(PropertyOwner propertyOwner) { if (m_messageDataDescChildren != null) { for (String strKey : m_messageDataDescChildren.keySet()) { m_messageDataDescChildren.get(strKey).putRawProperties(propertyOwner); } } }
[ "public", "void", "putRawProperties", "(", "PropertyOwner", "propertyOwner", ")", "{", "if", "(", "m_messageDataDescChildren", "!=", "null", ")", "{", "for", "(", "String", "strKey", ":", "m_messageDataDescChildren", ".", "keySet", "(", ")", ")", "{", "m_messageDataDescChildren", ".", "get", "(", "strKey", ")", ".", "putRawProperties", "(", "propertyOwner", ")", ";", "}", "}", "}" ]
Move the data from this propertyowner to this message.
[ "Move", "the", "data", "from", "this", "propertyowner", "to", "this", "message", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java#L356-L365
153,404
jbundle/jbundle
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java
BaseMessageRecordDesc.put
public void put(String strKey, Object objValue) { if (this.getMessageFieldDesc(strKey) != null) this.getMessageFieldDesc(strKey).put(objValue); else if (this.getMessage() != null) this.getMessage().putNative(this.getFullKey(strKey), objValue); }
java
public void put(String strKey, Object objValue) { if (this.getMessageFieldDesc(strKey) != null) this.getMessageFieldDesc(strKey).put(objValue); else if (this.getMessage() != null) this.getMessage().putNative(this.getFullKey(strKey), objValue); }
[ "public", "void", "put", "(", "String", "strKey", ",", "Object", "objValue", ")", "{", "if", "(", "this", ".", "getMessageFieldDesc", "(", "strKey", ")", "!=", "null", ")", "this", ".", "getMessageFieldDesc", "(", "strKey", ")", ".", "put", "(", "objValue", ")", ";", "else", "if", "(", "this", ".", "getMessage", "(", ")", "!=", "null", ")", "this", ".", "getMessage", "(", ")", ".", "putNative", "(", "this", ".", "getFullKey", "(", "strKey", ")", ",", "objValue", ")", ";", "}" ]
Convenience method - Put the value for this param in the map. If it is not the correct object type, convert it first.
[ "Convenience", "method", "-", "Put", "the", "value", "for", "this", "param", "in", "the", "map", ".", "If", "it", "is", "not", "the", "correct", "object", "type", "convert", "it", "first", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java#L370-L376
153,405
jbundle/jbundle
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java
BaseMessageRecordDesc.get
public Object get(String strKey) { Object data = null; if (this.getMessageFieldDesc(strKey) != null) data = this.getMessageFieldDesc(strKey).get(); else if (this.getMessage() != null) data = this.getMessage().getNative(this.getFullKey(strKey)); return data; }
java
public Object get(String strKey) { Object data = null; if (this.getMessageFieldDesc(strKey) != null) data = this.getMessageFieldDesc(strKey).get(); else if (this.getMessage() != null) data = this.getMessage().getNative(this.getFullKey(strKey)); return data; }
[ "public", "Object", "get", "(", "String", "strKey", ")", "{", "Object", "data", "=", "null", ";", "if", "(", "this", ".", "getMessageFieldDesc", "(", "strKey", ")", "!=", "null", ")", "data", "=", "this", ".", "getMessageFieldDesc", "(", "strKey", ")", ".", "get", "(", ")", ";", "else", "if", "(", "this", ".", "getMessage", "(", ")", "!=", "null", ")", "data", "=", "this", ".", "getMessage", "(", ")", ".", "getNative", "(", "this", ".", "getFullKey", "(", "strKey", ")", ")", ";", "return", "data", ";", "}" ]
Convenience method - Get the data at this key. @param trxMessage The raw internal trx message. @return The new Internal message with additional/refined data.
[ "Convenience", "method", "-", "Get", "the", "data", "at", "this", "key", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java#L382-L390
153,406
jbundle/jbundle
thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java
BaseMessageRecordDesc.moveRequestInfoToReply
public void moveRequestInfoToReply(Message messageRequest) { if (m_messageDataDescChildren != null) { for (String strKey : m_messageDataDescChildren.keySet()) { MessageDataDesc messageDataDesc = m_messageDataDescChildren.get(strKey); MessageDataDesc requestMessageDataDesc = ((BaseMessage)messageRequest).getMessageDataDesc(messageDataDesc.getFullKey(null)); if (requestMessageDataDesc != null) messageDataDesc.moveRequestInfoToReply(messageRequest); } } }
java
public void moveRequestInfoToReply(Message messageRequest) { if (m_messageDataDescChildren != null) { for (String strKey : m_messageDataDescChildren.keySet()) { MessageDataDesc messageDataDesc = m_messageDataDescChildren.get(strKey); MessageDataDesc requestMessageDataDesc = ((BaseMessage)messageRequest).getMessageDataDesc(messageDataDesc.getFullKey(null)); if (requestMessageDataDesc != null) messageDataDesc.moveRequestInfoToReply(messageRequest); } } }
[ "public", "void", "moveRequestInfoToReply", "(", "Message", "messageRequest", ")", "{", "if", "(", "m_messageDataDescChildren", "!=", "null", ")", "{", "for", "(", "String", "strKey", ":", "m_messageDataDescChildren", ".", "keySet", "(", ")", ")", "{", "MessageDataDesc", "messageDataDesc", "=", "m_messageDataDescChildren", ".", "get", "(", "strKey", ")", ";", "MessageDataDesc", "requestMessageDataDesc", "=", "(", "(", "BaseMessage", ")", "messageRequest", ")", ".", "getMessageDataDesc", "(", "messageDataDesc", ".", "getFullKey", "(", "null", ")", ")", ";", "if", "(", "requestMessageDataDesc", "!=", "null", ")", "messageDataDesc", ".", "moveRequestInfoToReply", "(", "messageRequest", ")", ";", "}", "}", "}" ]
Move the pertinenent information from the request to this reply message. Override this to actually move information.
[ "Move", "the", "pertinenent", "information", "from", "the", "request", "to", "this", "reply", "message", ".", "Override", "this", "to", "actually", "move", "information", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageRecordDesc.java#L466-L478
153,407
simter/simter-jwt
src/main/java/tech/simter/jwt/JWT.java
JWT.verify
public static JWT verify(String jwt, String secret) { return verify(jwt, secret == null ? null : secret.getBytes(StandardCharsets.UTF_8)); }
java
public static JWT verify(String jwt, String secret) { return verify(jwt, secret == null ? null : secret.getBytes(StandardCharsets.UTF_8)); }
[ "public", "static", "JWT", "verify", "(", "String", "jwt", ",", "String", "secret", ")", "{", "return", "verify", "(", "jwt", ",", "secret", "==", "null", "?", "null", ":", "secret", ".", "getBytes", "(", "StandardCharsets", ".", "UTF_8", ")", ")", ";", "}" ]
Verify whether the JWT is valid. If valid return the decoded instance. @param jwt jwt @param secret signature key @return the decoded jwt instance @throws DecodeException if jwt is illegal
[ "Verify", "whether", "the", "JWT", "is", "valid", ".", "If", "valid", "return", "the", "decoded", "instance", "." ]
fea8d520e8eeb26c2ab9f5eeb2bd3f5a6c0e4433
https://github.com/simter/simter-jwt/blob/fea8d520e8eeb26c2ab9f5eeb2bd3f5a6c0e4433/src/main/java/tech/simter/jwt/JWT.java#L52-L54
153,408
jbundle/jbundle
main/calendar/src/main/java/org/jbundle/main/calendar/db/AnnivMaster.java
AnnivMaster.removeAppointments
public void removeAppointments(Anniversary recAnniversary) { SubFileFilter listener = new SubFileFilter(this); recAnniversary.addListener(listener); try { recAnniversary.close(); while (recAnniversary.hasNext()) { recAnniversary.next(); recAnniversary.edit(); recAnniversary.remove(); } } catch (DBException ex) { ex.printStackTrace(); } finally { recAnniversary.removeListener(listener, true); } }
java
public void removeAppointments(Anniversary recAnniversary) { SubFileFilter listener = new SubFileFilter(this); recAnniversary.addListener(listener); try { recAnniversary.close(); while (recAnniversary.hasNext()) { recAnniversary.next(); recAnniversary.edit(); recAnniversary.remove(); } } catch (DBException ex) { ex.printStackTrace(); } finally { recAnniversary.removeListener(listener, true); } }
[ "public", "void", "removeAppointments", "(", "Anniversary", "recAnniversary", ")", "{", "SubFileFilter", "listener", "=", "new", "SubFileFilter", "(", "this", ")", ";", "recAnniversary", ".", "addListener", "(", "listener", ")", ";", "try", "{", "recAnniversary", ".", "close", "(", ")", ";", "while", "(", "recAnniversary", ".", "hasNext", "(", ")", ")", "{", "recAnniversary", ".", "next", "(", ")", ";", "recAnniversary", ".", "edit", "(", ")", ";", "recAnniversary", ".", "remove", "(", ")", ";", "}", "}", "catch", "(", "DBException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "finally", "{", "recAnniversary", ".", "removeListener", "(", "listener", ",", "true", ")", ";", "}", "}" ]
RemoveAppointments Method.
[ "RemoveAppointments", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/calendar/src/main/java/org/jbundle/main/calendar/db/AnnivMaster.java#L194-L212
153,409
jbundle/jbundle
main/calendar/src/main/java/org/jbundle/main/calendar/db/AnnivMaster.java
AnnivMaster.addAppointments
public void addAppointments(Anniversary recAnniversary, Calendar calStart, Calendar calEnd) { try { Converter.initGlobals(); Calendar calendar = Converter.gCalendar; Record recRepeat = ((ReferenceField)this.getField(AnnivMaster.REPEAT_INTERVAL_ID)).getReference(); String strRepeat = null; if (recRepeat != null) strRepeat = recRepeat.getField(RepeatInterval.DESCRIPTION).toString(); char chRepeat; if ((strRepeat == null) || (strRepeat.length() == 0)) chRepeat = 'Y'; else chRepeat = strRepeat.toUpperCase().charAt(0); int iRepeatCode; if (chRepeat == 'D') iRepeatCode = Calendar.DATE; else if (chRepeat == 'W') iRepeatCode = Calendar.WEEK_OF_YEAR; else if (chRepeat == 'M') iRepeatCode = Calendar.MONTH; else iRepeatCode = Calendar.YEAR; short sRepeatCount = (short)this.getField(AnnivMaster.REPEAT_COUNT).getValue(); if (sRepeatCount == 0) sRepeatCount = 1; Date timeStart = ((DateTimeField)this.getField(AnnivMaster.START_DATE_TIME)).getDateTime(); Date timeEnd = ((DateTimeField)this.getField(AnnivMaster.END_DATE_TIME)).getDateTime(); long lTimeLength = -1; if (timeEnd != null) lTimeLength = timeEnd.getTime() - timeStart.getTime(); calendar.setTime(timeStart); for (int i = 0; i < 100; i++) { if ((calendar.after(calStart)) && (calendar.before(calEnd))) { timeStart = calendar.getTime(); timeEnd = null; if (lTimeLength != -1) timeEnd = new Date(timeStart.getTime() + lTimeLength); recAnniversary.addNew(); ((DateTimeField)recAnniversary.getField(Anniversary.START_DATE_TIME)).setDateTime(timeStart, false, DBConstants.SCREEN_MOVE); if (timeEnd != null) ((DateTimeField)recAnniversary.getField(Anniversary.END_DATE_TIME)).setDateTime(timeEnd, false, DBConstants.SCREEN_MOVE); recAnniversary.getField(Anniversary.DESCRIPTION).moveFieldToThis(this.getField(AnnivMaster.DESCRIPTION)); ((ReferenceField)recAnniversary.getField(Anniversary.ANNIV_MASTER_ID)).setReference(this); recAnniversary.getField(Anniversary.CALENDAR_CATEGORY_ID).moveFieldToThis(this.getField(AnnivMaster.CALENDAR_CATEGORY_ID)); recAnniversary.getField(Anniversary.HIDDEN).moveFieldToThis(this.getField(AnnivMaster.HIDDEN)); // Don't move properties (you will have to read the AnnivMaster to get the properties) recAnniversary.add(); } calendar.add(iRepeatCode, sRepeatCount); } } catch (DBException ex) { ex.printStackTrace(); } }
java
public void addAppointments(Anniversary recAnniversary, Calendar calStart, Calendar calEnd) { try { Converter.initGlobals(); Calendar calendar = Converter.gCalendar; Record recRepeat = ((ReferenceField)this.getField(AnnivMaster.REPEAT_INTERVAL_ID)).getReference(); String strRepeat = null; if (recRepeat != null) strRepeat = recRepeat.getField(RepeatInterval.DESCRIPTION).toString(); char chRepeat; if ((strRepeat == null) || (strRepeat.length() == 0)) chRepeat = 'Y'; else chRepeat = strRepeat.toUpperCase().charAt(0); int iRepeatCode; if (chRepeat == 'D') iRepeatCode = Calendar.DATE; else if (chRepeat == 'W') iRepeatCode = Calendar.WEEK_OF_YEAR; else if (chRepeat == 'M') iRepeatCode = Calendar.MONTH; else iRepeatCode = Calendar.YEAR; short sRepeatCount = (short)this.getField(AnnivMaster.REPEAT_COUNT).getValue(); if (sRepeatCount == 0) sRepeatCount = 1; Date timeStart = ((DateTimeField)this.getField(AnnivMaster.START_DATE_TIME)).getDateTime(); Date timeEnd = ((DateTimeField)this.getField(AnnivMaster.END_DATE_TIME)).getDateTime(); long lTimeLength = -1; if (timeEnd != null) lTimeLength = timeEnd.getTime() - timeStart.getTime(); calendar.setTime(timeStart); for (int i = 0; i < 100; i++) { if ((calendar.after(calStart)) && (calendar.before(calEnd))) { timeStart = calendar.getTime(); timeEnd = null; if (lTimeLength != -1) timeEnd = new Date(timeStart.getTime() + lTimeLength); recAnniversary.addNew(); ((DateTimeField)recAnniversary.getField(Anniversary.START_DATE_TIME)).setDateTime(timeStart, false, DBConstants.SCREEN_MOVE); if (timeEnd != null) ((DateTimeField)recAnniversary.getField(Anniversary.END_DATE_TIME)).setDateTime(timeEnd, false, DBConstants.SCREEN_MOVE); recAnniversary.getField(Anniversary.DESCRIPTION).moveFieldToThis(this.getField(AnnivMaster.DESCRIPTION)); ((ReferenceField)recAnniversary.getField(Anniversary.ANNIV_MASTER_ID)).setReference(this); recAnniversary.getField(Anniversary.CALENDAR_CATEGORY_ID).moveFieldToThis(this.getField(AnnivMaster.CALENDAR_CATEGORY_ID)); recAnniversary.getField(Anniversary.HIDDEN).moveFieldToThis(this.getField(AnnivMaster.HIDDEN)); // Don't move properties (you will have to read the AnnivMaster to get the properties) recAnniversary.add(); } calendar.add(iRepeatCode, sRepeatCount); } } catch (DBException ex) { ex.printStackTrace(); } }
[ "public", "void", "addAppointments", "(", "Anniversary", "recAnniversary", ",", "Calendar", "calStart", ",", "Calendar", "calEnd", ")", "{", "try", "{", "Converter", ".", "initGlobals", "(", ")", ";", "Calendar", "calendar", "=", "Converter", ".", "gCalendar", ";", "Record", "recRepeat", "=", "(", "(", "ReferenceField", ")", "this", ".", "getField", "(", "AnnivMaster", ".", "REPEAT_INTERVAL_ID", ")", ")", ".", "getReference", "(", ")", ";", "String", "strRepeat", "=", "null", ";", "if", "(", "recRepeat", "!=", "null", ")", "strRepeat", "=", "recRepeat", ".", "getField", "(", "RepeatInterval", ".", "DESCRIPTION", ")", ".", "toString", "(", ")", ";", "char", "chRepeat", ";", "if", "(", "(", "strRepeat", "==", "null", ")", "||", "(", "strRepeat", ".", "length", "(", ")", "==", "0", ")", ")", "chRepeat", "=", "'", "'", ";", "else", "chRepeat", "=", "strRepeat", ".", "toUpperCase", "(", ")", ".", "charAt", "(", "0", ")", ";", "int", "iRepeatCode", ";", "if", "(", "chRepeat", "==", "'", "'", ")", "iRepeatCode", "=", "Calendar", ".", "DATE", ";", "else", "if", "(", "chRepeat", "==", "'", "'", ")", "iRepeatCode", "=", "Calendar", ".", "WEEK_OF_YEAR", ";", "else", "if", "(", "chRepeat", "==", "'", "'", ")", "iRepeatCode", "=", "Calendar", ".", "MONTH", ";", "else", "iRepeatCode", "=", "Calendar", ".", "YEAR", ";", "short", "sRepeatCount", "=", "(", "short", ")", "this", ".", "getField", "(", "AnnivMaster", ".", "REPEAT_COUNT", ")", ".", "getValue", "(", ")", ";", "if", "(", "sRepeatCount", "==", "0", ")", "sRepeatCount", "=", "1", ";", "Date", "timeStart", "=", "(", "(", "DateTimeField", ")", "this", ".", "getField", "(", "AnnivMaster", ".", "START_DATE_TIME", ")", ")", ".", "getDateTime", "(", ")", ";", "Date", "timeEnd", "=", "(", "(", "DateTimeField", ")", "this", ".", "getField", "(", "AnnivMaster", ".", "END_DATE_TIME", ")", ")", ".", "getDateTime", "(", ")", ";", "long", "lTimeLength", "=", "-", "1", ";", "if", "(", "timeEnd", "!=", "null", ")", "lTimeLength", "=", "timeEnd", ".", "getTime", "(", ")", "-", "timeStart", ".", "getTime", "(", ")", ";", "calendar", ".", "setTime", "(", "timeStart", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "100", ";", "i", "++", ")", "{", "if", "(", "(", "calendar", ".", "after", "(", "calStart", ")", ")", "&&", "(", "calendar", ".", "before", "(", "calEnd", ")", ")", ")", "{", "timeStart", "=", "calendar", ".", "getTime", "(", ")", ";", "timeEnd", "=", "null", ";", "if", "(", "lTimeLength", "!=", "-", "1", ")", "timeEnd", "=", "new", "Date", "(", "timeStart", ".", "getTime", "(", ")", "+", "lTimeLength", ")", ";", "recAnniversary", ".", "addNew", "(", ")", ";", "(", "(", "DateTimeField", ")", "recAnniversary", ".", "getField", "(", "Anniversary", ".", "START_DATE_TIME", ")", ")", ".", "setDateTime", "(", "timeStart", ",", "false", ",", "DBConstants", ".", "SCREEN_MOVE", ")", ";", "if", "(", "timeEnd", "!=", "null", ")", "(", "(", "DateTimeField", ")", "recAnniversary", ".", "getField", "(", "Anniversary", ".", "END_DATE_TIME", ")", ")", ".", "setDateTime", "(", "timeEnd", ",", "false", ",", "DBConstants", ".", "SCREEN_MOVE", ")", ";", "recAnniversary", ".", "getField", "(", "Anniversary", ".", "DESCRIPTION", ")", ".", "moveFieldToThis", "(", "this", ".", "getField", "(", "AnnivMaster", ".", "DESCRIPTION", ")", ")", ";", "(", "(", "ReferenceField", ")", "recAnniversary", ".", "getField", "(", "Anniversary", ".", "ANNIV_MASTER_ID", ")", ")", ".", "setReference", "(", "this", ")", ";", "recAnniversary", ".", "getField", "(", "Anniversary", ".", "CALENDAR_CATEGORY_ID", ")", ".", "moveFieldToThis", "(", "this", ".", "getField", "(", "AnnivMaster", ".", "CALENDAR_CATEGORY_ID", ")", ")", ";", "recAnniversary", ".", "getField", "(", "Anniversary", ".", "HIDDEN", ")", ".", "moveFieldToThis", "(", "this", ".", "getField", "(", "AnnivMaster", ".", "HIDDEN", ")", ")", ";", "// Don't move properties (you will have to read the AnnivMaster to get the properties)", "recAnniversary", ".", "add", "(", ")", ";", "}", "calendar", ".", "add", "(", "iRepeatCode", ",", "sRepeatCount", ")", ";", "}", "}", "catch", "(", "DBException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
AddAppointments Method.
[ "AddAppointments", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/calendar/src/main/java/org/jbundle/main/calendar/db/AnnivMaster.java#L216-L276
153,410
jbundle/jbundle
base/screen/model/src/main/java/org/jbundle/base/screen/model/html/DataAccessScreen.java
DataAccessScreen.openMainRecord
public Record openMainRecord() { Record record = null; if (this.getProperty(DBParams.APPLET) != null) return null; // Ignore params if I want the applet html displayed String strParamRecord = this.getProperty(DBParams.RECORD); // Display record if ((strParamRecord != null) && (strParamRecord.length() > 0)) record = Record.makeRecordFromClassName(strParamRecord, this); return record; }
java
public Record openMainRecord() { Record record = null; if (this.getProperty(DBParams.APPLET) != null) return null; // Ignore params if I want the applet html displayed String strParamRecord = this.getProperty(DBParams.RECORD); // Display record if ((strParamRecord != null) && (strParamRecord.length() > 0)) record = Record.makeRecordFromClassName(strParamRecord, this); return record; }
[ "public", "Record", "openMainRecord", "(", ")", "{", "Record", "record", "=", "null", ";", "if", "(", "this", ".", "getProperty", "(", "DBParams", ".", "APPLET", ")", "!=", "null", ")", "return", "null", ";", "// Ignore params if I want the applet html displayed", "String", "strParamRecord", "=", "this", ".", "getProperty", "(", "DBParams", ".", "RECORD", ")", ";", "// Display record", "if", "(", "(", "strParamRecord", "!=", "null", ")", "&&", "(", "strParamRecord", ".", "length", "(", ")", ">", "0", ")", ")", "record", "=", "Record", ".", "makeRecordFromClassName", "(", "strParamRecord", ",", "this", ")", ";", "return", "record", ";", "}" ]
Open the main file. DataAccessScreens check for a record param. @return The new main file.
[ "Open", "the", "main", "file", ".", "DataAccessScreens", "check", "for", "a", "record", "param", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/html/DataAccessScreen.java#L74-L83
153,411
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/field/PasswordPropertiesField.java
PasswordPropertiesField.addPasswordProperty
public void addPasswordProperty(String strProperty) { if (m_setPropertiesDescriptions == null) m_setPropertiesDescriptions = new HashSet<String>(); if (strProperty != null) m_setPropertiesDescriptions.add(strProperty); else m_setPropertiesDescriptions.remove(strProperty); }
java
public void addPasswordProperty(String strProperty) { if (m_setPropertiesDescriptions == null) m_setPropertiesDescriptions = new HashSet<String>(); if (strProperty != null) m_setPropertiesDescriptions.add(strProperty); else m_setPropertiesDescriptions.remove(strProperty); }
[ "public", "void", "addPasswordProperty", "(", "String", "strProperty", ")", "{", "if", "(", "m_setPropertiesDescriptions", "==", "null", ")", "m_setPropertiesDescriptions", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "if", "(", "strProperty", "!=", "null", ")", "m_setPropertiesDescriptions", ".", "add", "(", "strProperty", ")", ";", "else", "m_setPropertiesDescriptions", ".", "remove", "(", "strProperty", ")", ";", "}" ]
Add this to the list of properties that must be encrypted. @param strProperty
[ "Add", "this", "to", "the", "list", "of", "properties", "that", "must", "be", "encrypted", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/PasswordPropertiesField.java#L89-L97
153,412
jbundle/jbundle
main/msg/src/main/java/org/jbundle/main/msg/screen/MessageScreen.java
MessageScreen.processThisMessage
public void processThisMessage() { Utility.getLogger().info("On message called in receiving process"); try { BaseMessage messageIn = this.getMessage(); if (messageIn != null) { BaseMessage messageReply = this.createReplyMessage(messageIn); this.moveScreenParamsToMessage(messageReply); // Step 2 - Get the body part of the message this.getTransport().setupReplyMessage(messageReply, messageIn, MessageInfoTypeModel.REPLY, MessageTypeModel.MESSAGE_IN); this.getTransport().processIncomingMessage(messageReply, null); } } catch(Exception ex) { ex.printStackTrace(); Debug.print(ex, "Error in processing or replying to a message"); } }
java
public void processThisMessage() { Utility.getLogger().info("On message called in receiving process"); try { BaseMessage messageIn = this.getMessage(); if (messageIn != null) { BaseMessage messageReply = this.createReplyMessage(messageIn); this.moveScreenParamsToMessage(messageReply); // Step 2 - Get the body part of the message this.getTransport().setupReplyMessage(messageReply, messageIn, MessageInfoTypeModel.REPLY, MessageTypeModel.MESSAGE_IN); this.getTransport().processIncomingMessage(messageReply, null); } } catch(Exception ex) { ex.printStackTrace(); Debug.print(ex, "Error in processing or replying to a message"); } }
[ "public", "void", "processThisMessage", "(", ")", "{", "Utility", ".", "getLogger", "(", ")", ".", "info", "(", "\"On message called in receiving process\"", ")", ";", "try", "{", "BaseMessage", "messageIn", "=", "this", ".", "getMessage", "(", ")", ";", "if", "(", "messageIn", "!=", "null", ")", "{", "BaseMessage", "messageReply", "=", "this", ".", "createReplyMessage", "(", "messageIn", ")", ";", "this", ".", "moveScreenParamsToMessage", "(", "messageReply", ")", ";", "// Step 2 - Get the body part of the message", "this", ".", "getTransport", "(", ")", ".", "setupReplyMessage", "(", "messageReply", ",", "messageIn", ",", "MessageInfoTypeModel", ".", "REPLY", ",", "MessageTypeModel", ".", "MESSAGE_IN", ")", ";", "this", ".", "getTransport", "(", ")", ".", "processIncomingMessage", "(", "messageReply", ",", "null", ")", ";", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "Debug", ".", "print", "(", "ex", ",", "\"Error in processing or replying to a message\"", ")", ";", "}", "}" ]
This is the application code for handling the message. Once the message is received the application can retrieve the soap part, the attachment part if there are any, or any other information from the message.
[ "This", "is", "the", "application", "code", "for", "handling", "the", "message", ".", "Once", "the", "message", "is", "received", "the", "application", "can", "retrieve", "the", "soap", "part", "the", "attachment", "part", "if", "there", "are", "any", "or", "any", "other", "information", "from", "the", "message", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/msg/src/main/java/org/jbundle/main/msg/screen/MessageScreen.java#L133-L151
153,413
jbundle/jbundle
main/msg/src/main/java/org/jbundle/main/msg/screen/MessageScreen.java
MessageScreen.createReplyMessage
public BaseMessage createReplyMessage(BaseMessage messageIn) { //ProductRequest productRequest = (ProductRequest)messageIn.getMessageDataDesc(null); BaseMessage replyMessage = (BaseMessage)this.getMessageProcessInfo().createReplyMessage(messageIn); //BaseProductResponse responseMessage = (BaseProductResponse)replyMessage.getMessageDataDesc(null); //responseMessage.moveRequestInfoToReply(productRequest); if (replyMessage == null) replyMessage = new TreeMessage(null, null); if (replyMessage.getExternalMessage() == null) new ExternalMapTrxMessageIn(replyMessage, null); return replyMessage; // Override this! }
java
public BaseMessage createReplyMessage(BaseMessage messageIn) { //ProductRequest productRequest = (ProductRequest)messageIn.getMessageDataDesc(null); BaseMessage replyMessage = (BaseMessage)this.getMessageProcessInfo().createReplyMessage(messageIn); //BaseProductResponse responseMessage = (BaseProductResponse)replyMessage.getMessageDataDesc(null); //responseMessage.moveRequestInfoToReply(productRequest); if (replyMessage == null) replyMessage = new TreeMessage(null, null); if (replyMessage.getExternalMessage() == null) new ExternalMapTrxMessageIn(replyMessage, null); return replyMessage; // Override this! }
[ "public", "BaseMessage", "createReplyMessage", "(", "BaseMessage", "messageIn", ")", "{", "//ProductRequest productRequest = (ProductRequest)messageIn.getMessageDataDesc(null);", "BaseMessage", "replyMessage", "=", "(", "BaseMessage", ")", "this", ".", "getMessageProcessInfo", "(", ")", ".", "createReplyMessage", "(", "messageIn", ")", ";", "//BaseProductResponse responseMessage = (BaseProductResponse)replyMessage.getMessageDataDesc(null);", "//responseMessage.moveRequestInfoToReply(productRequest);", "if", "(", "replyMessage", "==", "null", ")", "replyMessage", "=", "new", "TreeMessage", "(", "null", ",", "null", ")", ";", "if", "(", "replyMessage", ".", "getExternalMessage", "(", ")", "==", "null", ")", "new", "ExternalMapTrxMessageIn", "(", "replyMessage", ",", "null", ")", ";", "return", "replyMessage", ";", "// Override this!", "}" ]
Given this message in, create the reply message. @param messageIn The incomming message @return the (empty) reply message.
[ "Given", "this", "message", "in", "create", "the", "reply", "message", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/msg/src/main/java/org/jbundle/main/msg/screen/MessageScreen.java#L157-L169
153,414
jbundle/jbundle
main/msg/src/main/java/org/jbundle/main/msg/screen/MessageScreen.java
MessageScreen.printData
public boolean printData(PrintWriter out, int iPrintOptions) { this.addHiddenParam(out, TrxMessageHeader.LOG_TRX_ID, this.getProperty(TrxMessageHeader.LOG_TRX_ID)); return super.printData(out, iPrintOptions); // Don't print }
java
public boolean printData(PrintWriter out, int iPrintOptions) { this.addHiddenParam(out, TrxMessageHeader.LOG_TRX_ID, this.getProperty(TrxMessageHeader.LOG_TRX_ID)); return super.printData(out, iPrintOptions); // Don't print }
[ "public", "boolean", "printData", "(", "PrintWriter", "out", ",", "int", "iPrintOptions", ")", "{", "this", ".", "addHiddenParam", "(", "out", ",", "TrxMessageHeader", ".", "LOG_TRX_ID", ",", "this", ".", "getProperty", "(", "TrxMessageHeader", ".", "LOG_TRX_ID", ")", ")", ";", "return", "super", ".", "printData", "(", "out", ",", "iPrintOptions", ")", ";", "// Don't print", "}" ]
PrintData Method.
[ "PrintData", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/msg/src/main/java/org/jbundle/main/msg/screen/MessageScreen.java#L189-L193
153,415
jbundle/jbundle
main/msg/src/main/java/org/jbundle/main/msg/db/MessageInfo.java
MessageInfo.addPropertiesFieldBehavior
public void addPropertiesFieldBehavior(BaseField fldDisplay, String strProperty) { BaseField fldProperties = this.getField(MessageInfo.MESSAGE_PROPERTIES); FieldListener listener = new CopyConvertersHandler(new PropertiesConverter(fldProperties, strProperty)); listener.setRespondsToMode(DBConstants.INIT_MOVE, false); listener.setRespondsToMode(DBConstants.READ_MOVE, false); fldDisplay.addListener(listener); listener = new CopyConvertersHandler(fldDisplay, new PropertiesConverter(fldProperties, strProperty)); listener.setRespondsToMode(DBConstants.SCREEN_MOVE, false); fldProperties.addListener(listener); }
java
public void addPropertiesFieldBehavior(BaseField fldDisplay, String strProperty) { BaseField fldProperties = this.getField(MessageInfo.MESSAGE_PROPERTIES); FieldListener listener = new CopyConvertersHandler(new PropertiesConverter(fldProperties, strProperty)); listener.setRespondsToMode(DBConstants.INIT_MOVE, false); listener.setRespondsToMode(DBConstants.READ_MOVE, false); fldDisplay.addListener(listener); listener = new CopyConvertersHandler(fldDisplay, new PropertiesConverter(fldProperties, strProperty)); listener.setRespondsToMode(DBConstants.SCREEN_MOVE, false); fldProperties.addListener(listener); }
[ "public", "void", "addPropertiesFieldBehavior", "(", "BaseField", "fldDisplay", ",", "String", "strProperty", ")", "{", "BaseField", "fldProperties", "=", "this", ".", "getField", "(", "MessageInfo", ".", "MESSAGE_PROPERTIES", ")", ";", "FieldListener", "listener", "=", "new", "CopyConvertersHandler", "(", "new", "PropertiesConverter", "(", "fldProperties", ",", "strProperty", ")", ")", ";", "listener", ".", "setRespondsToMode", "(", "DBConstants", ".", "INIT_MOVE", ",", "false", ")", ";", "listener", ".", "setRespondsToMode", "(", "DBConstants", ".", "READ_MOVE", ",", "false", ")", ";", "fldDisplay", ".", "addListener", "(", "listener", ")", ";", "listener", "=", "new", "CopyConvertersHandler", "(", "fldDisplay", ",", "new", "PropertiesConverter", "(", "fldProperties", ",", "strProperty", ")", ")", ";", "listener", ".", "setRespondsToMode", "(", "DBConstants", ".", "SCREEN_MOVE", ",", "false", ")", ";", "fldProperties", ".", "addListener", "(", "listener", ")", ";", "}" ]
AddPropertiesFieldBehavior Method.
[ "AddPropertiesFieldBehavior", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/msg/src/main/java/org/jbundle/main/msg/db/MessageInfo.java#L193-L203
153,416
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.forSite
public DB forSite(final long siteId) { return siteId == this.siteId ? this : new DB(this.connectionSupplier, siteId, this.taxonomyTermCaches.keySet(), this.taxonomyCacheTimeout, this.userCache, this.usernameCache, this.metrics); }
java
public DB forSite(final long siteId) { return siteId == this.siteId ? this : new DB(this.connectionSupplier, siteId, this.taxonomyTermCaches.keySet(), this.taxonomyCacheTimeout, this.userCache, this.usernameCache, this.metrics); }
[ "public", "DB", "forSite", "(", "final", "long", "siteId", ")", "{", "return", "siteId", "==", "this", ".", "siteId", "?", "this", ":", "new", "DB", "(", "this", ".", "connectionSupplier", ",", "siteId", ",", "this", ".", "taxonomyTermCaches", ".", "keySet", "(", ")", ",", "this", ".", "taxonomyCacheTimeout", ",", "this", ".", "userCache", ",", "this", ".", "usernameCache", ",", "this", ".", "metrics", ")", ";", "}" ]
Creates a database for another site with shared user caches, metrics and taxonomy terms. @param siteId The site id. @return The site-specific database.
[ "Creates", "a", "database", "for", "another", "site", "with", "shared", "user", "caches", "metrics", "and", "taxonomy", "terms", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L85-L88
153,417
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.userFromResultSet
private User userFromResultSet(final ResultSet rs) throws SQLException { String niceName = Strings.nullToEmpty(rs.getString(3)).trim(); String displayName = Strings.nullToEmpty(rs.getString(4)).trim(); String useDisplayName = displayName.isEmpty() ? niceName : displayName; return new User(rs.getLong(1), rs.getString(2), useDisplayName, niceName, rs.getString(5), rs.getTimestamp(6).getTime(), rs.getString(7), ImmutableList.of()); }
java
private User userFromResultSet(final ResultSet rs) throws SQLException { String niceName = Strings.nullToEmpty(rs.getString(3)).trim(); String displayName = Strings.nullToEmpty(rs.getString(4)).trim(); String useDisplayName = displayName.isEmpty() ? niceName : displayName; return new User(rs.getLong(1), rs.getString(2), useDisplayName, niceName, rs.getString(5), rs.getTimestamp(6).getTime(), rs.getString(7), ImmutableList.of()); }
[ "private", "User", "userFromResultSet", "(", "final", "ResultSet", "rs", ")", "throws", "SQLException", "{", "String", "niceName", "=", "Strings", ".", "nullToEmpty", "(", "rs", ".", "getString", "(", "3", ")", ")", ".", "trim", "(", ")", ";", "String", "displayName", "=", "Strings", ".", "nullToEmpty", "(", "rs", ".", "getString", "(", "4", ")", ")", ".", "trim", "(", ")", ";", "String", "useDisplayName", "=", "displayName", ".", "isEmpty", "(", ")", "?", "niceName", ":", "displayName", ";", "return", "new", "User", "(", "rs", ".", "getLong", "(", "1", ")", ",", "rs", ".", "getString", "(", "2", ")", ",", "useDisplayName", ",", "niceName", ",", "rs", ".", "getString", "(", "5", ")", ",", "rs", ".", "getTimestamp", "(", "6", ")", ".", "getTime", "(", ")", ",", "rs", ".", "getString", "(", "7", ")", ",", "ImmutableList", ".", "of", "(", ")", ")", ";", "}" ]
Creates a user from a result set. @param rs The result set. @return The user. @throws SQLException on database error.
[ "Creates", "a", "user", "from", "a", "result", "set", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L370-L375
153,418
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectUser
public User selectUser(final long userId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectUserTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectUserByIdSQL); stmt.setLong(1, userId); rs = stmt.executeQuery(); return rs.next() ? userFromResultSet(rs) : null; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } }
java
public User selectUser(final long userId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectUserTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectUserByIdSQL); stmt.setLong(1, userId); rs = stmt.executeQuery(); return rs.next() ? userFromResultSet(rs) : null; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } }
[ "public", "User", "selectUser", "(", "final", "long", "userId", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "selectUserTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "selectUserByIdSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "userId", ")", ";", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "return", "rs", ".", "next", "(", ")", "?", "userFromResultSet", "(", "rs", ")", ":", "null", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "}" ]
Selects a user from the database. @param userId The user id. @return The author or {@code null} if not found. @throws SQLException on database error.
[ "Selects", "a", "user", "from", "the", "database", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L445-L460
153,419
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.resolveUser
public User resolveUser(final long userId) throws SQLException { metrics.userCacheTries.mark(); User user = userCache.getIfPresent(userId); if(user != null) { metrics.userCacheHits.mark(); return user; } else { user = selectUser(userId); if(user != null) { userCache.put(userId, user); } return user; } }
java
public User resolveUser(final long userId) throws SQLException { metrics.userCacheTries.mark(); User user = userCache.getIfPresent(userId); if(user != null) { metrics.userCacheHits.mark(); return user; } else { user = selectUser(userId); if(user != null) { userCache.put(userId, user); } return user; } }
[ "public", "User", "resolveUser", "(", "final", "long", "userId", ")", "throws", "SQLException", "{", "metrics", ".", "userCacheTries", ".", "mark", "(", ")", ";", "User", "user", "=", "userCache", ".", "getIfPresent", "(", "userId", ")", ";", "if", "(", "user", "!=", "null", ")", "{", "metrics", ".", "userCacheHits", ".", "mark", "(", ")", ";", "return", "user", ";", "}", "else", "{", "user", "=", "selectUser", "(", "userId", ")", ";", "if", "(", "user", "!=", "null", ")", "{", "userCache", ".", "put", "(", "userId", ",", "user", ")", ";", "}", "return", "user", ";", "}", "}" ]
Resolves a user by id, possibly with the internal cache. @param userId The user id. @return The user or {@code null}, if not found. @throws SQLException on database error.
[ "Resolves", "a", "user", "by", "id", "possibly", "with", "the", "internal", "cache", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L468-L481
153,420
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.resolveUser
public User resolveUser(final String username) throws SQLException { metrics.usernameCacheTries.mark(); User user = usernameCache.getIfPresent(username); if(user != null) { metrics.usernameCacheHits.mark(); return user; } else { user = selectUser(username); if(user != null) { usernameCache.put(username, user); } return user; } }
java
public User resolveUser(final String username) throws SQLException { metrics.usernameCacheTries.mark(); User user = usernameCache.getIfPresent(username); if(user != null) { metrics.usernameCacheHits.mark(); return user; } else { user = selectUser(username); if(user != null) { usernameCache.put(username, user); } return user; } }
[ "public", "User", "resolveUser", "(", "final", "String", "username", ")", "throws", "SQLException", "{", "metrics", ".", "usernameCacheTries", ".", "mark", "(", ")", ";", "User", "user", "=", "usernameCache", ".", "getIfPresent", "(", "username", ")", ";", "if", "(", "user", "!=", "null", ")", "{", "metrics", ".", "usernameCacheHits", ".", "mark", "(", ")", ";", "return", "user", ";", "}", "else", "{", "user", "=", "selectUser", "(", "username", ")", ";", "if", "(", "user", "!=", "null", ")", "{", "usernameCache", ".", "put", "(", "username", ",", "user", ")", ";", "}", "return", "user", ";", "}", "}" ]
Resolves a user by username, possibly with the internal cache. @param username The username. @return The user or {@code null}, if not found. @throws SQLException on database error.
[ "Resolves", "a", "user", "by", "username", "possibly", "with", "the", "internal", "cache", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L489-L502
153,421
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.deleteUser
public boolean deleteUser(final long userId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(deleteUserSQL); stmt.setLong(1, userId); return stmt.executeUpdate() > 0; } finally { SQLUtil.closeQuietly(conn, stmt); } }
java
public boolean deleteUser(final long userId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(deleteUserSQL); stmt.setLong(1, userId); return stmt.executeUpdate() > 0; } finally { SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "boolean", "deleteUser", "(", "final", "long", "userId", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "deleteUserSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "userId", ")", ";", "return", "stmt", ".", "executeUpdate", "(", ")", ">", "0", ";", "}", "finally", "{", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Deletes a user by id. @param userId The user id. @return Was the user deleted? @throws SQLException on database error.
[ "Deletes", "a", "user", "by", "id", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L512-L524
153,422
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.userMetadata
public List<Meta> userMetadata(final long userId, final String key) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; List<Meta> meta = Lists.newArrayListWithExpectedSize(16); Timer.Context ctx = metrics.userMetadataTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectUserMetaKeySQL); stmt.setLong(1, userId); stmt.setString(2, key); rs = stmt.executeQuery(); while(rs.next()) { meta.add(new Meta(rs.getLong(1), rs.getString(2), rs.getString(3))); } return meta; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } }
java
public List<Meta> userMetadata(final long userId, final String key) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; List<Meta> meta = Lists.newArrayListWithExpectedSize(16); Timer.Context ctx = metrics.userMetadataTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectUserMetaKeySQL); stmt.setLong(1, userId); stmt.setString(2, key); rs = stmt.executeQuery(); while(rs.next()) { meta.add(new Meta(rs.getLong(1), rs.getString(2), rs.getString(3))); } return meta; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } }
[ "public", "List", "<", "Meta", ">", "userMetadata", "(", "final", "long", "userId", ",", "final", "String", "key", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "List", "<", "Meta", ">", "meta", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "16", ")", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "userMetadataTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "selectUserMetaKeySQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "userId", ")", ";", "stmt", ".", "setString", "(", "2", ",", "key", ")", ";", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "meta", ".", "add", "(", "new", "Meta", "(", "rs", ".", "getLong", "(", "1", ")", ",", "rs", ".", "getString", "(", "2", ")", ",", "rs", ".", "getString", "(", "3", ")", ")", ")", ";", "}", "return", "meta", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "}" ]
Selects user metadata with a specified key. @param userId The user id. @param key The metadata key. @return The list of values. @throws SQLException on database error.
[ "Selects", "user", "metadata", "with", "a", "specified", "key", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L565-L585
153,423
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.clearUserMeta
public void clearUserMeta(final long userId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.clearUserMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(deleteUserMetaSQL); stmt.setLong(1, userId); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
java
public void clearUserMeta(final long userId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.clearUserMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(deleteUserMetaSQL); stmt.setLong(1, userId); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "void", "clearUserMeta", "(", "final", "long", "userId", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "clearUserMetaTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "deleteUserMetaSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "userId", ")", ";", "stmt", ".", "executeUpdate", "(", ")", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Clears all metadata for a user. @param userId The user id. @throws SQLException on database error.
[ "Clears", "all", "metadata", "for", "a", "user", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L594-L607
153,424
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.deletePost
public void deletePost(final long postId) throws SQLException { clearPostMeta(postId); Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.deletePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(deletePostIdSQL); stmt.setLong(1, postId); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
java
public void deletePost(final long postId) throws SQLException { clearPostMeta(postId); Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.deletePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(deletePostIdSQL); stmt.setLong(1, postId); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "void", "deletePost", "(", "final", "long", "postId", ")", "throws", "SQLException", "{", "clearPostMeta", "(", "postId", ")", ";", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "deletePostTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "deletePostIdSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "postId", ")", ";", "stmt", ".", "executeUpdate", "(", ")", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Deletes a post with a specified id, including all associated metadata. @param postId The post id. @throws SQLException on database error.
[ "Deletes", "a", "post", "with", "a", "specified", "id", "including", "all", "associated", "metadata", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L668-L682
153,425
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.postFromResultSet
private Post.Builder postFromResultSet(final ResultSet rs) throws SQLException { Post.Builder post = Post.newBuilder(); post.setId(rs.getLong(1)); post.setAuthorId(rs.getLong(2)); Timestamp ts = rs.getTimestamp(3); post.setPublishTimestamp(ts != null ? ts.getTime() : 0L); post.setContent(Strings.emptyToNull(rs.getString(4))); post.setTitle(Strings.emptyToNull(rs.getString(5))); post.setExcerpt(Strings.emptyToNull(rs.getString(6))); post.setStatus(Post.Status.fromString(rs.getString(7))); post.setSlug(Strings.emptyToNull(rs.getString(8))); ts = rs.getTimestamp(9); post.setModifiedTimestamp(ts != null ? ts.getTime() : 0L); post.setParentId(rs.getLong(10)); post.setGUID(Strings.emptyToNull(rs.getString(11))); post.setType(Post.Type.fromString(rs.getString(12))); post.setMimeType(rs.getString(13)); return post; }
java
private Post.Builder postFromResultSet(final ResultSet rs) throws SQLException { Post.Builder post = Post.newBuilder(); post.setId(rs.getLong(1)); post.setAuthorId(rs.getLong(2)); Timestamp ts = rs.getTimestamp(3); post.setPublishTimestamp(ts != null ? ts.getTime() : 0L); post.setContent(Strings.emptyToNull(rs.getString(4))); post.setTitle(Strings.emptyToNull(rs.getString(5))); post.setExcerpt(Strings.emptyToNull(rs.getString(6))); post.setStatus(Post.Status.fromString(rs.getString(7))); post.setSlug(Strings.emptyToNull(rs.getString(8))); ts = rs.getTimestamp(9); post.setModifiedTimestamp(ts != null ? ts.getTime() : 0L); post.setParentId(rs.getLong(10)); post.setGUID(Strings.emptyToNull(rs.getString(11))); post.setType(Post.Type.fromString(rs.getString(12))); post.setMimeType(rs.getString(13)); return post; }
[ "private", "Post", ".", "Builder", "postFromResultSet", "(", "final", "ResultSet", "rs", ")", "throws", "SQLException", "{", "Post", ".", "Builder", "post", "=", "Post", ".", "newBuilder", "(", ")", ";", "post", ".", "setId", "(", "rs", ".", "getLong", "(", "1", ")", ")", ";", "post", ".", "setAuthorId", "(", "rs", ".", "getLong", "(", "2", ")", ")", ";", "Timestamp", "ts", "=", "rs", ".", "getTimestamp", "(", "3", ")", ";", "post", ".", "setPublishTimestamp", "(", "ts", "!=", "null", "?", "ts", ".", "getTime", "(", ")", ":", "0L", ")", ";", "post", ".", "setContent", "(", "Strings", ".", "emptyToNull", "(", "rs", ".", "getString", "(", "4", ")", ")", ")", ";", "post", ".", "setTitle", "(", "Strings", ".", "emptyToNull", "(", "rs", ".", "getString", "(", "5", ")", ")", ")", ";", "post", ".", "setExcerpt", "(", "Strings", ".", "emptyToNull", "(", "rs", ".", "getString", "(", "6", ")", ")", ")", ";", "post", ".", "setStatus", "(", "Post", ".", "Status", ".", "fromString", "(", "rs", ".", "getString", "(", "7", ")", ")", ")", ";", "post", ".", "setSlug", "(", "Strings", ".", "emptyToNull", "(", "rs", ".", "getString", "(", "8", ")", ")", ")", ";", "ts", "=", "rs", ".", "getTimestamp", "(", "9", ")", ";", "post", ".", "setModifiedTimestamp", "(", "ts", "!=", "null", "?", "ts", ".", "getTime", "(", ")", ":", "0L", ")", ";", "post", ".", "setParentId", "(", "rs", ".", "getLong", "(", "10", ")", ")", ";", "post", ".", "setGUID", "(", "Strings", ".", "emptyToNull", "(", "rs", ".", "getString", "(", "11", ")", ")", ")", ";", "post", ".", "setType", "(", "Post", ".", "Type", ".", "fromString", "(", "rs", ".", "getString", "(", "12", ")", ")", ")", ";", "post", ".", "setMimeType", "(", "rs", ".", "getString", "(", "13", ")", ")", ";", "return", "post", ";", "}" ]
Builds a post from a result set. @param rs The result set. @return The post (builder). @throws SQLException on database error.
[ "Builds", "a", "post", "from", "a", "result", "set", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L694-L716
153,426
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectAuthorPosts
public List<Post> selectAuthorPosts(final long userId, final Post.Sort sort, final Paging paging, final boolean withResolve) throws SQLException { if(paging.limit < 1 || paging.start < 0) { return ImmutableList.of(); } List<Post.Builder> builders = Lists.newArrayListWithExpectedSize(paging.limit < 1024 ? paging.limit : 1024); StringBuilder sql = new StringBuilder(selectPostSQL); sql.append(postsTableName); sql.append(" WHERE post_author=?"); appendPagingSortSQL(sql, sort, paging); Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectAuthorPostsTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(sql.toString()); stmt.setLong(1, userId); if(paging.interval != null) { stmt.setTimestamp(2, new Timestamp(paging.interval.getStartMillis())); stmt.setTimestamp(3, new Timestamp(paging.interval.getStartMillis())); stmt.setInt(4, paging.start); stmt.setInt(5, paging.limit); } else { stmt.setInt(2, paging.start); stmt.setInt(3, paging.limit); } rs = stmt.executeQuery(); while(rs.next()) { builders.add(postFromResultSet(rs)); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } List<Post> posts = Lists.newArrayListWithExpectedSize(builders.size()); for(Post.Builder builder : builders) { if(withResolve) { posts.add(resolve(builder).build()); } else { posts.add(builder.build()); } } return posts; }
java
public List<Post> selectAuthorPosts(final long userId, final Post.Sort sort, final Paging paging, final boolean withResolve) throws SQLException { if(paging.limit < 1 || paging.start < 0) { return ImmutableList.of(); } List<Post.Builder> builders = Lists.newArrayListWithExpectedSize(paging.limit < 1024 ? paging.limit : 1024); StringBuilder sql = new StringBuilder(selectPostSQL); sql.append(postsTableName); sql.append(" WHERE post_author=?"); appendPagingSortSQL(sql, sort, paging); Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectAuthorPostsTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(sql.toString()); stmt.setLong(1, userId); if(paging.interval != null) { stmt.setTimestamp(2, new Timestamp(paging.interval.getStartMillis())); stmt.setTimestamp(3, new Timestamp(paging.interval.getStartMillis())); stmt.setInt(4, paging.start); stmt.setInt(5, paging.limit); } else { stmt.setInt(2, paging.start); stmt.setInt(3, paging.limit); } rs = stmt.executeQuery(); while(rs.next()) { builders.add(postFromResultSet(rs)); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } List<Post> posts = Lists.newArrayListWithExpectedSize(builders.size()); for(Post.Builder builder : builders) { if(withResolve) { posts.add(resolve(builder).build()); } else { posts.add(builder.build()); } } return posts; }
[ "public", "List", "<", "Post", ">", "selectAuthorPosts", "(", "final", "long", "userId", ",", "final", "Post", ".", "Sort", "sort", ",", "final", "Paging", "paging", ",", "final", "boolean", "withResolve", ")", "throws", "SQLException", "{", "if", "(", "paging", ".", "limit", "<", "1", "||", "paging", ".", "start", "<", "0", ")", "{", "return", "ImmutableList", ".", "of", "(", ")", ";", "}", "List", "<", "Post", ".", "Builder", ">", "builders", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "paging", ".", "limit", "<", "1024", "?", "paging", ".", "limit", ":", "1024", ")", ";", "StringBuilder", "sql", "=", "new", "StringBuilder", "(", "selectPostSQL", ")", ";", "sql", ".", "append", "(", "postsTableName", ")", ";", "sql", ".", "append", "(", "\" WHERE post_author=?\"", ")", ";", "appendPagingSortSQL", "(", "sql", ",", "sort", ",", "paging", ")", ";", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "selectAuthorPostsTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "sql", ".", "toString", "(", ")", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "userId", ")", ";", "if", "(", "paging", ".", "interval", "!=", "null", ")", "{", "stmt", ".", "setTimestamp", "(", "2", ",", "new", "Timestamp", "(", "paging", ".", "interval", ".", "getStartMillis", "(", ")", ")", ")", ";", "stmt", ".", "setTimestamp", "(", "3", ",", "new", "Timestamp", "(", "paging", ".", "interval", ".", "getStartMillis", "(", ")", ")", ")", ";", "stmt", ".", "setInt", "(", "4", ",", "paging", ".", "start", ")", ";", "stmt", ".", "setInt", "(", "5", ",", "paging", ".", "limit", ")", ";", "}", "else", "{", "stmt", ".", "setInt", "(", "2", ",", "paging", ".", "start", ")", ";", "stmt", ".", "setInt", "(", "3", ",", "paging", ".", "limit", ")", ";", "}", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "builders", ".", "add", "(", "postFromResultSet", "(", "rs", ")", ")", ";", "}", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "List", "<", "Post", ">", "posts", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "builders", ".", "size", "(", ")", ")", ";", "for", "(", "Post", ".", "Builder", "builder", ":", "builders", ")", "{", "if", "(", "withResolve", ")", "{", "posts", ".", "add", "(", "resolve", "(", "builder", ")", ".", "build", "(", ")", ")", ";", "}", "else", "{", "posts", ".", "add", "(", "builder", ".", "build", "(", ")", ")", ";", "}", "}", "return", "posts", ";", "}" ]
Selects a page of posts for an author. @param userId The user id for the author. @param sort The sort direction. @param paging The paging. @param withResolve Should associated users, etc be resolved? @return The list of posts. @throws SQLException on database error.
[ "Selects", "a", "page", "of", "posts", "for", "an", "author", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L727-L779
153,427
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectMaxPostId
public long selectMaxPostId() throws SQLException { Connection conn = null; Statement stmt = null; ResultSet rs = null; try { conn = connectionSupplier.getConnection(); stmt = conn.createStatement(); rs = stmt.executeQuery(selectMaxPostIdSQL); return rs.next() ? rs.getLong(1) : 0L; } finally { closeQuietly(conn, stmt, rs); } }
java
public long selectMaxPostId() throws SQLException { Connection conn = null; Statement stmt = null; ResultSet rs = null; try { conn = connectionSupplier.getConnection(); stmt = conn.createStatement(); rs = stmt.executeQuery(selectMaxPostIdSQL); return rs.next() ? rs.getLong(1) : 0L; } finally { closeQuietly(conn, stmt, rs); } }
[ "public", "long", "selectMaxPostId", "(", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "Statement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "createStatement", "(", ")", ";", "rs", "=", "stmt", ".", "executeQuery", "(", "selectMaxPostIdSQL", ")", ";", "return", "rs", ".", "next", "(", ")", "?", "rs", ".", "getLong", "(", "1", ")", ":", "0L", ";", "}", "finally", "{", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "}" ]
Selects the current maximum post id. @return The post id. @throws SQLException on database error.
[ "Selects", "the", "current", "maximum", "post", "id", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L870-L882
153,428
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectPosts
public List<Post> selectPosts(final Post.Type type, final Post.Status status, final Post.Sort sort, final Paging paging, final boolean withResolve) throws SQLException { return selectPosts(type != null ? EnumSet.of(type) : null, status, sort, paging, withResolve); }
java
public List<Post> selectPosts(final Post.Type type, final Post.Status status, final Post.Sort sort, final Paging paging, final boolean withResolve) throws SQLException { return selectPosts(type != null ? EnumSet.of(type) : null, status, sort, paging, withResolve); }
[ "public", "List", "<", "Post", ">", "selectPosts", "(", "final", "Post", ".", "Type", "type", ",", "final", "Post", ".", "Status", "status", ",", "final", "Post", ".", "Sort", "sort", ",", "final", "Paging", "paging", ",", "final", "boolean", "withResolve", ")", "throws", "SQLException", "{", "return", "selectPosts", "(", "type", "!=", "null", "?", "EnumSet", ".", "of", "(", "type", ")", ":", "null", ",", "status", ",", "sort", ",", "paging", ",", "withResolve", ")", ";", "}" ]
Selects a page of posts with a specific type. @param type The post type. May be {@code null} for any type. @param status The required post status. @param sort The page sort. @param paging The page range and interval. @param withResolve Should associated users, etc be resolved? @return The list of posts. @throws SQLException on database error.
[ "Selects", "a", "page", "of", "posts", "with", "a", "specific", "type", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L963-L969
153,429
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectPosts
public List<Post> selectPosts(final EnumSet<Post.Type> types, final Post.Status status, final Post.Sort sort, final Paging paging, final boolean withResolve) throws SQLException { if(paging.limit < 1 || paging.start < 0) { return ImmutableList.of(); } List<Post.Builder> builders = Lists.newArrayListWithExpectedSize(paging.limit < 1024 ? paging.limit : 1024); StringBuilder sql = new StringBuilder(selectPostSQL); sql.append(postsTableName); sql.append(" WHERE post_status=?"); appendPostTypes(types, sql); appendPagingSortSQL(sql, sort, paging); Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectPostsTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(sql.toString()); stmt.setString(1, status.toString().toLowerCase()); if(paging.interval != null) { stmt.setTimestamp(2, new Timestamp(paging.interval.getStartMillis())); stmt.setTimestamp(3, new Timestamp(paging.interval.getEndMillis())); stmt.setInt(4, paging.start); stmt.setInt(5, paging.limit); } else { stmt.setInt(2, paging.start); stmt.setInt(3, paging.limit); } rs = stmt.executeQuery(); while(rs.next()) { builders.add(postFromResultSet(rs)); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } List<Post> posts = Lists.newArrayListWithExpectedSize(builders.size()); for(Post.Builder builder : builders) { if(withResolve) { posts.add(resolve(builder).build()); } else { posts.add(builder.build()); } } return posts; }
java
public List<Post> selectPosts(final EnumSet<Post.Type> types, final Post.Status status, final Post.Sort sort, final Paging paging, final boolean withResolve) throws SQLException { if(paging.limit < 1 || paging.start < 0) { return ImmutableList.of(); } List<Post.Builder> builders = Lists.newArrayListWithExpectedSize(paging.limit < 1024 ? paging.limit : 1024); StringBuilder sql = new StringBuilder(selectPostSQL); sql.append(postsTableName); sql.append(" WHERE post_status=?"); appendPostTypes(types, sql); appendPagingSortSQL(sql, sort, paging); Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectPostsTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(sql.toString()); stmt.setString(1, status.toString().toLowerCase()); if(paging.interval != null) { stmt.setTimestamp(2, new Timestamp(paging.interval.getStartMillis())); stmt.setTimestamp(3, new Timestamp(paging.interval.getEndMillis())); stmt.setInt(4, paging.start); stmt.setInt(5, paging.limit); } else { stmt.setInt(2, paging.start); stmt.setInt(3, paging.limit); } rs = stmt.executeQuery(); while(rs.next()) { builders.add(postFromResultSet(rs)); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } List<Post> posts = Lists.newArrayListWithExpectedSize(builders.size()); for(Post.Builder builder : builders) { if(withResolve) { posts.add(resolve(builder).build()); } else { posts.add(builder.build()); } } return posts; }
[ "public", "List", "<", "Post", ">", "selectPosts", "(", "final", "EnumSet", "<", "Post", ".", "Type", ">", "types", ",", "final", "Post", ".", "Status", "status", ",", "final", "Post", ".", "Sort", "sort", ",", "final", "Paging", "paging", ",", "final", "boolean", "withResolve", ")", "throws", "SQLException", "{", "if", "(", "paging", ".", "limit", "<", "1", "||", "paging", ".", "start", "<", "0", ")", "{", "return", "ImmutableList", ".", "of", "(", ")", ";", "}", "List", "<", "Post", ".", "Builder", ">", "builders", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "paging", ".", "limit", "<", "1024", "?", "paging", ".", "limit", ":", "1024", ")", ";", "StringBuilder", "sql", "=", "new", "StringBuilder", "(", "selectPostSQL", ")", ";", "sql", ".", "append", "(", "postsTableName", ")", ";", "sql", ".", "append", "(", "\" WHERE post_status=?\"", ")", ";", "appendPostTypes", "(", "types", ",", "sql", ")", ";", "appendPagingSortSQL", "(", "sql", ",", "sort", ",", "paging", ")", ";", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "selectPostsTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "sql", ".", "toString", "(", ")", ")", ";", "stmt", ".", "setString", "(", "1", ",", "status", ".", "toString", "(", ")", ".", "toLowerCase", "(", ")", ")", ";", "if", "(", "paging", ".", "interval", "!=", "null", ")", "{", "stmt", ".", "setTimestamp", "(", "2", ",", "new", "Timestamp", "(", "paging", ".", "interval", ".", "getStartMillis", "(", ")", ")", ")", ";", "stmt", ".", "setTimestamp", "(", "3", ",", "new", "Timestamp", "(", "paging", ".", "interval", ".", "getEndMillis", "(", ")", ")", ")", ";", "stmt", ".", "setInt", "(", "4", ",", "paging", ".", "start", ")", ";", "stmt", ".", "setInt", "(", "5", ",", "paging", ".", "limit", ")", ";", "}", "else", "{", "stmt", ".", "setInt", "(", "2", ",", "paging", ".", "start", ")", ";", "stmt", ".", "setInt", "(", "3", ",", "paging", ".", "limit", ")", ";", "}", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "builders", ".", "add", "(", "postFromResultSet", "(", "rs", ")", ")", ";", "}", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "List", "<", "Post", ">", "posts", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "builders", ".", "size", "(", ")", ")", ";", "for", "(", "Post", ".", "Builder", "builder", ":", "builders", ")", "{", "if", "(", "withResolve", ")", "{", "posts", ".", "add", "(", "resolve", "(", "builder", ")", ".", "build", "(", ")", ")", ";", "}", "else", "{", "posts", ".", "add", "(", "builder", ".", "build", "(", ")", ")", ";", "}", "}", "return", "posts", ";", "}" ]
Selects a page of posts with a set of specified types. @param types The set of post types to be included. If {@code null} or empty, all types will be included. @param status The required post status. @param sort The page sort. @param paging The page range and interval. @param withResolve Should associated users, etc be resolved? @return The list of posts. @throws SQLException on database error.
[ "Selects", "a", "page", "of", "posts", "with", "a", "set", "of", "specified", "types", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L981-L1035
153,430
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectPostIds
public List<Long> selectPostIds(final Post.Type type, final Post.Status status, final Collection<TaxonomyTerm> terms, final Post.Sort sort, final Paging paging) throws SQLException { return selectPostIds(type != null ? EnumSet.of(type) : null, status, terms, sort, paging); }
java
public List<Long> selectPostIds(final Post.Type type, final Post.Status status, final Collection<TaxonomyTerm> terms, final Post.Sort sort, final Paging paging) throws SQLException { return selectPostIds(type != null ? EnumSet.of(type) : null, status, terms, sort, paging); }
[ "public", "List", "<", "Long", ">", "selectPostIds", "(", "final", "Post", ".", "Type", "type", ",", "final", "Post", ".", "Status", "status", ",", "final", "Collection", "<", "TaxonomyTerm", ">", "terms", ",", "final", "Post", ".", "Sort", "sort", ",", "final", "Paging", "paging", ")", "throws", "SQLException", "{", "return", "selectPostIds", "(", "type", "!=", "null", "?", "EnumSet", ".", "of", "(", "type", ")", ":", "null", ",", "status", ",", "terms", ",", "sort", ",", "paging", ")", ";", "}" ]
Selects a page of posts with a specified type. @param type The post type. May be {@code null} for any type. @param status The required post status. @param terms A collection of terms attached to the posts. @param sort The page sort. @param paging The page range and interval. @return The list of posts. @throws SQLException on database error.
[ "Selects", "a", "page", "of", "posts", "with", "a", "specified", "type", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1047-L1053
153,431
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectPostIds
public List<Long> selectPostIds(final EnumSet<Post.Type> types, final Post.Status status, final Collection<TaxonomyTerm> terms, final Post.Sort sort, final Paging paging) throws SQLException { if(paging.limit < 1 || paging.start < 0) { return ImmutableList.of(); } List<Long> ids = Lists.newArrayListWithExpectedSize(paging.limit < 1024 ? paging.limit : 1024); StringBuilder sql = new StringBuilder("SELECT ID FROM "); sql.append(postsTableName); if(terms != null && terms.size() > 0) { sql.append(",").append(termRelationshipsTableName); sql.append(" WHERE post_status=? AND object_id=ID AND "); if(terms.size() == 1) { sql.append("term_taxonomy_id=").append(terms.iterator().next().id); } else { sql.append("term_taxonomy_id IN ("); Iterator<TaxonomyTerm> iter = terms.iterator(); sql.append(iter.next().id); while(iter.hasNext()) { sql.append(",").append(iter.next().id); } sql.append(")"); } } else { sql.append(" WHERE post_status=?"); } appendPostTypes(types, sql); appendPagingSortSQL(sql, sort, paging); Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectPostIdsTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(sql.toString()); stmt.setString(1, status.toString().toLowerCase()); if(paging.interval != null) { stmt.setTimestamp(2, new Timestamp(paging.interval.getStartMillis())); stmt.setTimestamp(3, new Timestamp(paging.interval.getEndMillis())); stmt.setInt(4, paging.start); stmt.setInt(5, paging.limit); } else { stmt.setInt(2, paging.start); stmt.setInt(3, paging.limit); } rs = stmt.executeQuery(); while(rs.next()) { ids.add(rs.getLong(1)); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } return ids; }
java
public List<Long> selectPostIds(final EnumSet<Post.Type> types, final Post.Status status, final Collection<TaxonomyTerm> terms, final Post.Sort sort, final Paging paging) throws SQLException { if(paging.limit < 1 || paging.start < 0) { return ImmutableList.of(); } List<Long> ids = Lists.newArrayListWithExpectedSize(paging.limit < 1024 ? paging.limit : 1024); StringBuilder sql = new StringBuilder("SELECT ID FROM "); sql.append(postsTableName); if(terms != null && terms.size() > 0) { sql.append(",").append(termRelationshipsTableName); sql.append(" WHERE post_status=? AND object_id=ID AND "); if(terms.size() == 1) { sql.append("term_taxonomy_id=").append(terms.iterator().next().id); } else { sql.append("term_taxonomy_id IN ("); Iterator<TaxonomyTerm> iter = terms.iterator(); sql.append(iter.next().id); while(iter.hasNext()) { sql.append(",").append(iter.next().id); } sql.append(")"); } } else { sql.append(" WHERE post_status=?"); } appendPostTypes(types, sql); appendPagingSortSQL(sql, sort, paging); Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectPostIdsTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(sql.toString()); stmt.setString(1, status.toString().toLowerCase()); if(paging.interval != null) { stmt.setTimestamp(2, new Timestamp(paging.interval.getStartMillis())); stmt.setTimestamp(3, new Timestamp(paging.interval.getEndMillis())); stmt.setInt(4, paging.start); stmt.setInt(5, paging.limit); } else { stmt.setInt(2, paging.start); stmt.setInt(3, paging.limit); } rs = stmt.executeQuery(); while(rs.next()) { ids.add(rs.getLong(1)); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } return ids; }
[ "public", "List", "<", "Long", ">", "selectPostIds", "(", "final", "EnumSet", "<", "Post", ".", "Type", ">", "types", ",", "final", "Post", ".", "Status", "status", ",", "final", "Collection", "<", "TaxonomyTerm", ">", "terms", ",", "final", "Post", ".", "Sort", "sort", ",", "final", "Paging", "paging", ")", "throws", "SQLException", "{", "if", "(", "paging", ".", "limit", "<", "1", "||", "paging", ".", "start", "<", "0", ")", "{", "return", "ImmutableList", ".", "of", "(", ")", ";", "}", "List", "<", "Long", ">", "ids", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "paging", ".", "limit", "<", "1024", "?", "paging", ".", "limit", ":", "1024", ")", ";", "StringBuilder", "sql", "=", "new", "StringBuilder", "(", "\"SELECT ID FROM \"", ")", ";", "sql", ".", "append", "(", "postsTableName", ")", ";", "if", "(", "terms", "!=", "null", "&&", "terms", ".", "size", "(", ")", ">", "0", ")", "{", "sql", ".", "append", "(", "\",\"", ")", ".", "append", "(", "termRelationshipsTableName", ")", ";", "sql", ".", "append", "(", "\" WHERE post_status=? AND object_id=ID AND \"", ")", ";", "if", "(", "terms", ".", "size", "(", ")", "==", "1", ")", "{", "sql", ".", "append", "(", "\"term_taxonomy_id=\"", ")", ".", "append", "(", "terms", ".", "iterator", "(", ")", ".", "next", "(", ")", ".", "id", ")", ";", "}", "else", "{", "sql", ".", "append", "(", "\"term_taxonomy_id IN (\"", ")", ";", "Iterator", "<", "TaxonomyTerm", ">", "iter", "=", "terms", ".", "iterator", "(", ")", ";", "sql", ".", "append", "(", "iter", ".", "next", "(", ")", ".", "id", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "sql", ".", "append", "(", "\",\"", ")", ".", "append", "(", "iter", ".", "next", "(", ")", ".", "id", ")", ";", "}", "sql", ".", "append", "(", "\")\"", ")", ";", "}", "}", "else", "{", "sql", ".", "append", "(", "\" WHERE post_status=?\"", ")", ";", "}", "appendPostTypes", "(", "types", ",", "sql", ")", ";", "appendPagingSortSQL", "(", "sql", ",", "sort", ",", "paging", ")", ";", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "selectPostIdsTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "sql", ".", "toString", "(", ")", ")", ";", "stmt", ".", "setString", "(", "1", ",", "status", ".", "toString", "(", ")", ".", "toLowerCase", "(", ")", ")", ";", "if", "(", "paging", ".", "interval", "!=", "null", ")", "{", "stmt", ".", "setTimestamp", "(", "2", ",", "new", "Timestamp", "(", "paging", ".", "interval", ".", "getStartMillis", "(", ")", ")", ")", ";", "stmt", ".", "setTimestamp", "(", "3", ",", "new", "Timestamp", "(", "paging", ".", "interval", ".", "getEndMillis", "(", ")", ")", ")", ";", "stmt", ".", "setInt", "(", "4", ",", "paging", ".", "start", ")", ";", "stmt", ".", "setInt", "(", "5", ",", "paging", ".", "limit", ")", ";", "}", "else", "{", "stmt", ".", "setInt", "(", "2", ",", "paging", ".", "start", ")", ";", "stmt", ".", "setInt", "(", "3", ",", "paging", ".", "limit", ")", ";", "}", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "ids", ".", "add", "(", "rs", ".", "getLong", "(", "1", ")", ")", ";", "}", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "return", "ids", ";", "}" ]
Selects a page of posts with associated terms and a set of types. @param types The post types. May be {@code null} or empty fo any type. @param status The required post status. @param terms A collection of terms attached to the posts. @param sort The page sort. @param paging The page range and interval. @return The list of posts. @throws SQLException on database error.
[ "Selects", "a", "page", "of", "posts", "with", "associated", "terms", "and", "a", "set", "of", "types", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1065-L1126
153,432
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.deleteChildren
public void deleteChildren(final long parentId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.deleteChildrenTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(deleteChildrenSQL); stmt.setLong(1, parentId); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
java
public void deleteChildren(final long parentId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.deleteChildrenTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(deleteChildrenSQL); stmt.setLong(1, parentId); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "void", "deleteChildren", "(", "final", "long", "parentId", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "deleteChildrenTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "deleteChildrenSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "parentId", ")", ";", "stmt", ".", "executeUpdate", "(", ")", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Deletes all children. @param parentId The parent post id. @throws SQLException on database error.
[ "Deletes", "all", "children", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1135-L1148
153,433
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectChildren
public List<Post> selectChildren(final long parentId, final boolean withResolve) throws SQLException { List<Post.Builder> builders = Lists.newArrayListWithExpectedSize(4); Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectChildrenTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectChildrenSQL); stmt.setLong(1, parentId); rs = stmt.executeQuery(); while(rs.next()) { builders.add(postFromResultSet(rs)); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } List<Post> posts = Lists.newArrayListWithExpectedSize(builders.size()); for(Post.Builder builder : builders) { if(withResolve) { posts.add(resolve(builder).build()); } else { posts.add(builder.build()); } } return posts; }
java
public List<Post> selectChildren(final long parentId, final boolean withResolve) throws SQLException { List<Post.Builder> builders = Lists.newArrayListWithExpectedSize(4); Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectChildrenTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectChildrenSQL); stmt.setLong(1, parentId); rs = stmt.executeQuery(); while(rs.next()) { builders.add(postFromResultSet(rs)); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } List<Post> posts = Lists.newArrayListWithExpectedSize(builders.size()); for(Post.Builder builder : builders) { if(withResolve) { posts.add(resolve(builder).build()); } else { posts.add(builder.build()); } } return posts; }
[ "public", "List", "<", "Post", ">", "selectChildren", "(", "final", "long", "parentId", ",", "final", "boolean", "withResolve", ")", "throws", "SQLException", "{", "List", "<", "Post", ".", "Builder", ">", "builders", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "4", ")", ";", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "selectChildrenTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "selectChildrenSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "parentId", ")", ";", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "builders", ".", "add", "(", "postFromResultSet", "(", "rs", ")", ")", ";", "}", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "List", "<", "Post", ">", "posts", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "builders", ".", "size", "(", ")", ")", ";", "for", "(", "Post", ".", "Builder", "builder", ":", "builders", ")", "{", "if", "(", "withResolve", ")", "{", "posts", ".", "add", "(", "resolve", "(", "builder", ")", ".", "build", "(", ")", ")", ";", "}", "else", "{", "posts", ".", "add", "(", "builder", ".", "build", "(", ")", ")", ";", "}", "}", "return", "posts", ";", "}" ]
Gets all children for a post. @param parentId The parent post id. @param withResolve Should associated users, etc be resolved? @return The list of children. @throws SQLException on database error.
[ "Gets", "all", "children", "for", "a", "post", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1159-L1190
153,434
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.appendPostTypes
private StringBuilder appendPostTypes(final EnumSet<Post.Type> types, final StringBuilder sql) { int typesCount = types != null ? types.size() : 0; switch(typesCount) { case 0: break; case 1: sql.append(" AND post_type=").append(String.format("'%s'", types.iterator().next().toString())); break; default: sql.append(" AND post_type IN ("); sql.append(inJoiner.join(types.stream().map(t -> String.format("'%s'", t.toString())).collect(Collectors.toSet()))); sql.append(")"); break; } return sql; }
java
private StringBuilder appendPostTypes(final EnumSet<Post.Type> types, final StringBuilder sql) { int typesCount = types != null ? types.size() : 0; switch(typesCount) { case 0: break; case 1: sql.append(" AND post_type=").append(String.format("'%s'", types.iterator().next().toString())); break; default: sql.append(" AND post_type IN ("); sql.append(inJoiner.join(types.stream().map(t -> String.format("'%s'", t.toString())).collect(Collectors.toSet()))); sql.append(")"); break; } return sql; }
[ "private", "StringBuilder", "appendPostTypes", "(", "final", "EnumSet", "<", "Post", ".", "Type", ">", "types", ",", "final", "StringBuilder", "sql", ")", "{", "int", "typesCount", "=", "types", "!=", "null", "?", "types", ".", "size", "(", ")", ":", "0", ";", "switch", "(", "typesCount", ")", "{", "case", "0", ":", "break", ";", "case", "1", ":", "sql", ".", "append", "(", "\" AND post_type=\"", ")", ".", "append", "(", "String", ".", "format", "(", "\"'%s'\"", ",", "types", ".", "iterator", "(", ")", ".", "next", "(", ")", ".", "toString", "(", ")", ")", ")", ";", "break", ";", "default", ":", "sql", ".", "append", "(", "\" AND post_type IN (\"", ")", ";", "sql", ".", "append", "(", "inJoiner", ".", "join", "(", "types", ".", "stream", "(", ")", ".", "map", "(", "t", "->", "String", ".", "format", "(", "\"'%s'\"", ",", "t", ".", "toString", "(", ")", ")", ")", ".", "collect", "(", "Collectors", ".", "toSet", "(", ")", ")", ")", ")", ";", "sql", ".", "append", "(", "\")\"", ")", ";", "break", ";", "}", "return", "sql", ";", "}" ]
Appends post type constraint. @param types The types. @param sql The buffer to append to. @return The input buffer.
[ "Appends", "post", "type", "constraint", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1198-L1214
153,435
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.appendPagingSortSQL
private StringBuilder appendPagingSortSQL(final StringBuilder sql, final Post.Sort sort,final Paging paging) { if(paging.interval != null) { sql.append(" AND post_date"); sql.append(paging.startIsOpen ? " >" : " >="); sql.append("?"); sql.append(" AND post_date"); sql.append(paging.endIsOpen ? " <" : " <="); sql.append("?"); } switch(sort) { case ASC: sql.append(" ORDER BY post_date ASC"); break; case DESC: sql.append(" ORDER BY post_date DESC"); break; case ASC_MOD: sql.append(" ORDER BY post_modified ASC"); break; case DESC_MOD: sql.append(" ORDER BY post_modified DESC"); break; case ID_ASC: sql.append(" ORDER BY ID ASC"); break; case ID_DESC: sql.append(" ORDER BY ID DESC"); break; default: sql.append(" ORDER BY post_date DESC"); break; } sql.append(" LIMIT ?,?"); return sql; }
java
private StringBuilder appendPagingSortSQL(final StringBuilder sql, final Post.Sort sort,final Paging paging) { if(paging.interval != null) { sql.append(" AND post_date"); sql.append(paging.startIsOpen ? " >" : " >="); sql.append("?"); sql.append(" AND post_date"); sql.append(paging.endIsOpen ? " <" : " <="); sql.append("?"); } switch(sort) { case ASC: sql.append(" ORDER BY post_date ASC"); break; case DESC: sql.append(" ORDER BY post_date DESC"); break; case ASC_MOD: sql.append(" ORDER BY post_modified ASC"); break; case DESC_MOD: sql.append(" ORDER BY post_modified DESC"); break; case ID_ASC: sql.append(" ORDER BY ID ASC"); break; case ID_DESC: sql.append(" ORDER BY ID DESC"); break; default: sql.append(" ORDER BY post_date DESC"); break; } sql.append(" LIMIT ?,?"); return sql; }
[ "private", "StringBuilder", "appendPagingSortSQL", "(", "final", "StringBuilder", "sql", ",", "final", "Post", ".", "Sort", "sort", ",", "final", "Paging", "paging", ")", "{", "if", "(", "paging", ".", "interval", "!=", "null", ")", "{", "sql", ".", "append", "(", "\" AND post_date\"", ")", ";", "sql", ".", "append", "(", "paging", ".", "startIsOpen", "?", "\" >\"", ":", "\" >=\"", ")", ";", "sql", ".", "append", "(", "\"?\"", ")", ";", "sql", ".", "append", "(", "\" AND post_date\"", ")", ";", "sql", ".", "append", "(", "paging", ".", "endIsOpen", "?", "\" <\"", ":", "\" <=\"", ")", ";", "sql", ".", "append", "(", "\"?\"", ")", ";", "}", "switch", "(", "sort", ")", "{", "case", "ASC", ":", "sql", ".", "append", "(", "\" ORDER BY post_date ASC\"", ")", ";", "break", ";", "case", "DESC", ":", "sql", ".", "append", "(", "\" ORDER BY post_date DESC\"", ")", ";", "break", ";", "case", "ASC_MOD", ":", "sql", ".", "append", "(", "\" ORDER BY post_modified ASC\"", ")", ";", "break", ";", "case", "DESC_MOD", ":", "sql", ".", "append", "(", "\" ORDER BY post_modified DESC\"", ")", ";", "break", ";", "case", "ID_ASC", ":", "sql", ".", "append", "(", "\" ORDER BY ID ASC\"", ")", ";", "break", ";", "case", "ID_DESC", ":", "sql", ".", "append", "(", "\" ORDER BY ID DESC\"", ")", ";", "break", ";", "default", ":", "sql", ".", "append", "(", "\" ORDER BY post_date DESC\"", ")", ";", "break", ";", "}", "sql", ".", "append", "(", "\" LIMIT ?,?\"", ")", ";", "return", "sql", ";", "}" ]
Appends paging interval constraint, if required, paging and sort. @param sql The buffer to append to. @param sort The sort. @param paging The paging. @return The input buffer.
[ "Appends", "paging", "interval", "constraint", "if", "required", "paging", "and", "sort", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1223-L1260
153,436
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.resolve
public Post.Builder resolve(final Post.Builder post) throws SQLException { Timer.Context ctx = metrics.resolvePostTimer.time(); try { User author = resolveUser(post.getAuthorId()); if(author != null) { List<Meta> meta = userMetadata(post.getAuthorId()); if(meta.size() > 0) { author = author.withMetadata(meta); } post.setAuthor(author); } List<Meta> meta = selectPostMeta(post.getId()); if(meta.size() > 0) { post.setMetadata(meta); } List<TaxonomyTerm> terms = selectPostTerms(post.getId()); if(terms.size() > 0) { post.setTaxonomyTerms(terms); } List<Post> children = selectChildren(post.getId(), false); if(children.size() > 0) { post.setChildren(children); } return post; } finally { ctx.stop(); } }
java
public Post.Builder resolve(final Post.Builder post) throws SQLException { Timer.Context ctx = metrics.resolvePostTimer.time(); try { User author = resolveUser(post.getAuthorId()); if(author != null) { List<Meta> meta = userMetadata(post.getAuthorId()); if(meta.size() > 0) { author = author.withMetadata(meta); } post.setAuthor(author); } List<Meta> meta = selectPostMeta(post.getId()); if(meta.size() > 0) { post.setMetadata(meta); } List<TaxonomyTerm> terms = selectPostTerms(post.getId()); if(terms.size() > 0) { post.setTaxonomyTerms(terms); } List<Post> children = selectChildren(post.getId(), false); if(children.size() > 0) { post.setChildren(children); } return post; } finally { ctx.stop(); } }
[ "public", "Post", ".", "Builder", "resolve", "(", "final", "Post", ".", "Builder", "post", ")", "throws", "SQLException", "{", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "resolvePostTimer", ".", "time", "(", ")", ";", "try", "{", "User", "author", "=", "resolveUser", "(", "post", ".", "getAuthorId", "(", ")", ")", ";", "if", "(", "author", "!=", "null", ")", "{", "List", "<", "Meta", ">", "meta", "=", "userMetadata", "(", "post", ".", "getAuthorId", "(", ")", ")", ";", "if", "(", "meta", ".", "size", "(", ")", ">", "0", ")", "{", "author", "=", "author", ".", "withMetadata", "(", "meta", ")", ";", "}", "post", ".", "setAuthor", "(", "author", ")", ";", "}", "List", "<", "Meta", ">", "meta", "=", "selectPostMeta", "(", "post", ".", "getId", "(", ")", ")", ";", "if", "(", "meta", ".", "size", "(", ")", ">", "0", ")", "{", "post", ".", "setMetadata", "(", "meta", ")", ";", "}", "List", "<", "TaxonomyTerm", ">", "terms", "=", "selectPostTerms", "(", "post", ".", "getId", "(", ")", ")", ";", "if", "(", "terms", ".", "size", "(", ")", ">", "0", ")", "{", "post", ".", "setTaxonomyTerms", "(", "terms", ")", ";", "}", "List", "<", "Post", ">", "children", "=", "selectChildren", "(", "post", ".", "getId", "(", ")", ",", "false", ")", ";", "if", "(", "children", ".", "size", "(", ")", ">", "0", ")", "{", "post", ".", "setChildren", "(", "children", ")", ";", "}", "return", "post", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "}", "}" ]
Resolves user, author, terms and meta for a post. @param post The post builder. @return The builder with resolved items. @throws SQLException on database error.
[ "Resolves", "user", "author", "terms", "and", "meta", "for", "a", "post", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1374-L1404
153,437
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectPost
public Post.Builder selectPost(final long postId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectPostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectPostSQL + postsTableName + " WHERE ID=?"); stmt.setLong(1, postId); rs = stmt.executeQuery(); return rs.next() ? postFromResultSet(rs) : null; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } }
java
public Post.Builder selectPost(final long postId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectPostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectPostSQL + postsTableName + " WHERE ID=?"); stmt.setLong(1, postId); rs = stmt.executeQuery(); return rs.next() ? postFromResultSet(rs) : null; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } }
[ "public", "Post", ".", "Builder", "selectPost", "(", "final", "long", "postId", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "selectPostTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "selectPostSQL", "+", "postsTableName", "+", "\" WHERE ID=?\"", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "postId", ")", ";", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "return", "rs", ".", "next", "(", ")", "?", "postFromResultSet", "(", "rs", ")", ":", "null", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "}" ]
Selects a post by id. @param postId The post id. @return The post. @throws SQLException on database error.
[ "Selects", "a", "post", "by", "id", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1412-L1427
153,438
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectPostMap
public Map<Long, Post> selectPostMap(final Collection<Long> postIds, final boolean withResolve) throws SQLException { Map<Long, Post> postMap = Maps.newHashMapWithExpectedSize(postIds.size()); Connection conn = null; Statement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectPostMapTimer.time(); StringBuilder sql = new StringBuilder(selectPostSQL).append(postsTableName).append(" WHERE ID IN ("); sql.append(inJoiner.join(postIds)); sql.append(")"); try { conn = connectionSupplier.getConnection(); stmt = conn.createStatement(); rs = stmt.executeQuery(sql.toString()); while(rs.next()) { Post.Builder post = postFromResultSet(rs); postMap.put(post.getId(), withResolve ? resolve(post).build() : post.build()); } return postMap; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } }
java
public Map<Long, Post> selectPostMap(final Collection<Long> postIds, final boolean withResolve) throws SQLException { Map<Long, Post> postMap = Maps.newHashMapWithExpectedSize(postIds.size()); Connection conn = null; Statement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectPostMapTimer.time(); StringBuilder sql = new StringBuilder(selectPostSQL).append(postsTableName).append(" WHERE ID IN ("); sql.append(inJoiner.join(postIds)); sql.append(")"); try { conn = connectionSupplier.getConnection(); stmt = conn.createStatement(); rs = stmt.executeQuery(sql.toString()); while(rs.next()) { Post.Builder post = postFromResultSet(rs); postMap.put(post.getId(), withResolve ? resolve(post).build() : post.build()); } return postMap; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } }
[ "public", "Map", "<", "Long", ",", "Post", ">", "selectPostMap", "(", "final", "Collection", "<", "Long", ">", "postIds", ",", "final", "boolean", "withResolve", ")", "throws", "SQLException", "{", "Map", "<", "Long", ",", "Post", ">", "postMap", "=", "Maps", ".", "newHashMapWithExpectedSize", "(", "postIds", ".", "size", "(", ")", ")", ";", "Connection", "conn", "=", "null", ";", "Statement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "selectPostMapTimer", ".", "time", "(", ")", ";", "StringBuilder", "sql", "=", "new", "StringBuilder", "(", "selectPostSQL", ")", ".", "append", "(", "postsTableName", ")", ".", "append", "(", "\" WHERE ID IN (\"", ")", ";", "sql", ".", "append", "(", "inJoiner", ".", "join", "(", "postIds", ")", ")", ";", "sql", ".", "append", "(", "\")\"", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "createStatement", "(", ")", ";", "rs", "=", "stmt", ".", "executeQuery", "(", "sql", ".", "toString", "(", ")", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "Post", ".", "Builder", "post", "=", "postFromResultSet", "(", "rs", ")", ";", "postMap", ".", "put", "(", "post", ".", "getId", "(", ")", ",", "withResolve", "?", "resolve", "(", "post", ")", ".", "build", "(", ")", ":", "post", ".", "build", "(", ")", ")", ";", "}", "return", "postMap", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "}" ]
Selects posts from a collection of ids into a map. @param postIds The collection of ids. @param withResolve Should associated users, etc be resolved? @return A map of post vs id. @throws SQLException on database error.
[ "Selects", "posts", "from", "a", "collection", "of", "ids", "into", "a", "map", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1437-L1461
153,439
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectPosts
public List<Post> selectPosts(final Collection<Long> postIds, final boolean withResolve) throws SQLException { if(postIds == null || postIds.size() == 0) { return ImmutableList.of(); } Map<Long, Post> postMap = selectPostMap(postIds, withResolve); List<Post> posts = Lists.newArrayListWithExpectedSize(postMap.size()); for(long id : postIds) { Post post = postMap.get(id); if(post != null) { posts.add(post); } } return posts; }
java
public List<Post> selectPosts(final Collection<Long> postIds, final boolean withResolve) throws SQLException { if(postIds == null || postIds.size() == 0) { return ImmutableList.of(); } Map<Long, Post> postMap = selectPostMap(postIds, withResolve); List<Post> posts = Lists.newArrayListWithExpectedSize(postMap.size()); for(long id : postIds) { Post post = postMap.get(id); if(post != null) { posts.add(post); } } return posts; }
[ "public", "List", "<", "Post", ">", "selectPosts", "(", "final", "Collection", "<", "Long", ">", "postIds", ",", "final", "boolean", "withResolve", ")", "throws", "SQLException", "{", "if", "(", "postIds", "==", "null", "||", "postIds", ".", "size", "(", ")", "==", "0", ")", "{", "return", "ImmutableList", ".", "of", "(", ")", ";", "}", "Map", "<", "Long", ",", "Post", ">", "postMap", "=", "selectPostMap", "(", "postIds", ",", "withResolve", ")", ";", "List", "<", "Post", ">", "posts", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "postMap", ".", "size", "(", ")", ")", ";", "for", "(", "long", "id", ":", "postIds", ")", "{", "Post", "post", "=", "postMap", ".", "get", "(", "id", ")", ";", "if", "(", "post", "!=", "null", ")", "{", "posts", ".", "add", "(", "post", ")", ";", "}", "}", "return", "posts", ";", "}" ]
Selects posts from a collection of ids into a list in input order. @param postIds The collection of post ids. @param withResolve Should associated users, etc be resolved? @return The list of posts. @throws SQLException on database error.
[ "Selects", "posts", "from", "a", "collection", "of", "ids", "into", "a", "list", "in", "input", "order", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1470-L1483
153,440
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.updatePostTimestamps
public boolean updatePostTimestamps(long postId, final long publishTimestamp, final long modifiedTimestamp, final TimeZone tz) throws SQLException { int offset = tz.getOffset(publishTimestamp); Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updatePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostTimestampsSQL); stmt.setTimestamp(1, new Timestamp(publishTimestamp)); stmt.setTimestamp(2, new Timestamp(publishTimestamp - offset)); stmt.setTimestamp(3, new Timestamp(modifiedTimestamp)); stmt.setTimestamp(4, new Timestamp(modifiedTimestamp - offset)); stmt.setLong(5, postId); return stmt.executeUpdate() > 0; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
java
public boolean updatePostTimestamps(long postId, final long publishTimestamp, final long modifiedTimestamp, final TimeZone tz) throws SQLException { int offset = tz.getOffset(publishTimestamp); Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updatePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostTimestampsSQL); stmt.setTimestamp(1, new Timestamp(publishTimestamp)); stmt.setTimestamp(2, new Timestamp(publishTimestamp - offset)); stmt.setTimestamp(3, new Timestamp(modifiedTimestamp)); stmt.setTimestamp(4, new Timestamp(modifiedTimestamp - offset)); stmt.setLong(5, postId); return stmt.executeUpdate() > 0; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "boolean", "updatePostTimestamps", "(", "long", "postId", ",", "final", "long", "publishTimestamp", ",", "final", "long", "modifiedTimestamp", ",", "final", "TimeZone", "tz", ")", "throws", "SQLException", "{", "int", "offset", "=", "tz", ".", "getOffset", "(", "publishTimestamp", ")", ";", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "updatePostTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "updatePostTimestampsSQL", ")", ";", "stmt", ".", "setTimestamp", "(", "1", ",", "new", "Timestamp", "(", "publishTimestamp", ")", ")", ";", "stmt", ".", "setTimestamp", "(", "2", ",", "new", "Timestamp", "(", "publishTimestamp", "-", "offset", ")", ")", ";", "stmt", ".", "setTimestamp", "(", "3", ",", "new", "Timestamp", "(", "modifiedTimestamp", ")", ")", ";", "stmt", ".", "setTimestamp", "(", "4", ",", "new", "Timestamp", "(", "modifiedTimestamp", "-", "offset", ")", ")", ";", "stmt", ".", "setLong", "(", "5", ",", "postId", ")", ";", "return", "stmt", ".", "executeUpdate", "(", ")", ">", "0", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Updates only the timestamp fields for a post. @param postId The post to update. @param publishTimestamp The publish timestamp. @param modifiedTimestamp The modified timestamp. @param tz The local time zone. @return Were the timestamps modified? @throws SQLException on database error or missing post id.
[ "Updates", "only", "the", "timestamp", "fields", "for", "a", "post", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1496-L1514
153,441
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.updatePostContent
public boolean updatePostContent(long postId, final String content) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updatePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostContentSQL); stmt.setString(1, content); stmt.setLong(2, postId); return stmt.executeUpdate() > 0; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
java
public boolean updatePostContent(long postId, final String content) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updatePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostContentSQL); stmt.setString(1, content); stmt.setLong(2, postId); return stmt.executeUpdate() > 0; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "boolean", "updatePostContent", "(", "long", "postId", ",", "final", "String", "content", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "updatePostTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "updatePostContentSQL", ")", ";", "stmt", ".", "setString", "(", "1", ",", "content", ")", ";", "stmt", ".", "setLong", "(", "2", ",", "postId", ")", ";", "return", "stmt", ".", "executeUpdate", "(", ")", ">", "0", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Updates the content for a post. @param postId The post to update. @param content The new content. @return Was the post modified? @throws SQLException on database error or missing post id.
[ "Updates", "the", "content", "for", "a", "post", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1525-L1539
153,442
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.updatePostExcerpt
public boolean updatePostExcerpt(long postId, final String excerpt) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updatePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostExcerptSQL); stmt.setString(1, excerpt); stmt.setLong(2, postId); return stmt.executeUpdate() > 0; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
java
public boolean updatePostExcerpt(long postId, final String excerpt) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updatePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostExcerptSQL); stmt.setString(1, excerpt); stmt.setLong(2, postId); return stmt.executeUpdate() > 0; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "boolean", "updatePostExcerpt", "(", "long", "postId", ",", "final", "String", "excerpt", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "updatePostTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "updatePostExcerptSQL", ")", ";", "stmt", ".", "setString", "(", "1", ",", "excerpt", ")", ";", "stmt", ".", "setLong", "(", "2", ",", "postId", ")", ";", "return", "stmt", ".", "executeUpdate", "(", ")", ">", "0", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Updates the excerpt for a post. @param postId The post to update. @param excerpt The new excerpt. @return Was the post modified? @throws SQLException on database error or missing post id.
[ "Updates", "the", "excerpt", "for", "a", "post", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1550-L1564
153,443
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.updatePostTitle
public boolean updatePostTitle(long postId, final String title) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updatePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostTitleSQL); stmt.setString(1, title); stmt.setLong(2, postId); return stmt.executeUpdate() > 0; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
java
public boolean updatePostTitle(long postId, final String title) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updatePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostTitleSQL); stmt.setString(1, title); stmt.setLong(2, postId); return stmt.executeUpdate() > 0; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "boolean", "updatePostTitle", "(", "long", "postId", ",", "final", "String", "title", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "updatePostTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "updatePostTitleSQL", ")", ";", "stmt", ".", "setString", "(", "1", ",", "title", ")", ";", "stmt", ".", "setLong", "(", "2", ",", "postId", ")", ";", "return", "stmt", ".", "executeUpdate", "(", ")", ">", "0", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Updates the title for a post. @param postId The post to update. @param title The new title. @return Was the post modified? @throws SQLException on database error or missing post id.
[ "Updates", "the", "title", "for", "a", "post", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1575-L1589
153,444
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.updatePostGuid
public boolean updatePostGuid(long postId, final String guid) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updatePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostGuidSQL); stmt.setString(1, guid); stmt.setLong(2, postId); return stmt.executeUpdate() > 0; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
java
public boolean updatePostGuid(long postId, final String guid) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updatePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostGuidSQL); stmt.setString(1, guid); stmt.setLong(2, postId); return stmt.executeUpdate() > 0; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "boolean", "updatePostGuid", "(", "long", "postId", ",", "final", "String", "guid", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "updatePostTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "updatePostGuidSQL", ")", ";", "stmt", ".", "setString", "(", "1", ",", "guid", ")", ";", "stmt", ".", "setLong", "(", "2", ",", "postId", ")", ";", "return", "stmt", ".", "executeUpdate", "(", ")", ">", "0", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Updates the guid for a post. @param postId The post to update. @param guid The new guid. @return Was the post modified? @throws SQLException on database error or missing post id.
[ "Updates", "the", "guid", "for", "a", "post", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1600-L1614
153,445
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.updatePostStatus
public void updatePostStatus(final long postId, final Post.Status status) throws SQLException { Connection conn = null; PreparedStatement stmt = null; try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostStatusSQL); stmt.setString(1, status.toString().toLowerCase()); stmt.setLong(2, postId); stmt.executeUpdate(); } finally { SQLUtil.closeQuietly(conn, stmt); } }
java
public void updatePostStatus(final long postId, final Post.Status status) throws SQLException { Connection conn = null; PreparedStatement stmt = null; try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostStatusSQL); stmt.setString(1, status.toString().toLowerCase()); stmt.setLong(2, postId); stmt.executeUpdate(); } finally { SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "void", "updatePostStatus", "(", "final", "long", "postId", ",", "final", "Post", ".", "Status", "status", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "updatePostStatusSQL", ")", ";", "stmt", ".", "setString", "(", "1", ",", "status", ".", "toString", "(", ")", ".", "toLowerCase", "(", ")", ")", ";", "stmt", ".", "setLong", "(", "2", ",", "postId", ")", ";", "stmt", ".", "executeUpdate", "(", ")", ";", "}", "finally", "{", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Updates the status for a post. @param postId The post id. @param status The new status. @throws SQLException on database error.
[ "Updates", "the", "status", "for", "a", "post", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1624-L1637
153,446
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.updatePostAuthor
public boolean updatePostAuthor(final long postId, final long authorId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostAuthorSQL); stmt.setLong(1, authorId); stmt.setLong(2, postId); return stmt.executeUpdate() > 0; } finally { SQLUtil.closeQuietly(conn, stmt); } }
java
public boolean updatePostAuthor(final long postId, final long authorId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostAuthorSQL); stmt.setLong(1, authorId); stmt.setLong(2, postId); return stmt.executeUpdate() > 0; } finally { SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "boolean", "updatePostAuthor", "(", "final", "long", "postId", ",", "final", "long", "authorId", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "updatePostAuthorSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "authorId", ")", ";", "stmt", ".", "setLong", "(", "2", ",", "postId", ")", ";", "return", "stmt", ".", "executeUpdate", "(", ")", ">", "0", ";", "}", "finally", "{", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Updates the author of a post. @param postId The post id. @param authorId The new author id. @return Was the author changed? @throws SQLException on database error.
[ "Updates", "the", "author", "of", "a", "post", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1648-L1661
153,447
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.updateCommentStatus
public void updateCommentStatus(final long postId, final Post.CommentStatus commentStatus, final Post.CommentStatus pingStatus) throws SQLException { Connection conn = null; PreparedStatement stmt = null; try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostCommentStatusSQL); stmt.setString(1, commentStatus.toString().toLowerCase()); stmt.setString(2, pingStatus.toString().toLowerCase()); stmt.setLong(3, postId); stmt.executeUpdate(); } finally { SQLUtil.closeQuietly(conn, stmt); } }
java
public void updateCommentStatus(final long postId, final Post.CommentStatus commentStatus, final Post.CommentStatus pingStatus) throws SQLException { Connection conn = null; PreparedStatement stmt = null; try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostCommentStatusSQL); stmt.setString(1, commentStatus.toString().toLowerCase()); stmt.setString(2, pingStatus.toString().toLowerCase()); stmt.setLong(3, postId); stmt.executeUpdate(); } finally { SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "void", "updateCommentStatus", "(", "final", "long", "postId", ",", "final", "Post", ".", "CommentStatus", "commentStatus", ",", "final", "Post", ".", "CommentStatus", "pingStatus", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "updatePostCommentStatusSQL", ")", ";", "stmt", ".", "setString", "(", "1", ",", "commentStatus", ".", "toString", "(", ")", ".", "toLowerCase", "(", ")", ")", ";", "stmt", ".", "setString", "(", "2", ",", "pingStatus", ".", "toString", "(", ")", ".", "toLowerCase", "(", ")", ")", ";", "stmt", ".", "setLong", "(", "3", ",", "postId", ")", ";", "stmt", ".", "executeUpdate", "(", ")", ";", "}", "finally", "{", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Updates the comment status for a post. @param postId The post id. @param commentStatus The new comment status ('open', 'closed'). @param pingStatus The new ping status ('open', 'closed'). @throws SQLException on database error.
[ "Updates", "the", "comment", "status", "for", "a", "post", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1673-L1688
153,448
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.updatePost
public Post updatePost(Post post, final TimeZone tz) throws SQLException { if(post.id < 1L) { throw new SQLException("The post id must be specified for update"); } if(post.modifiedTimestamp < 1) { post = post.modifiedNow(); } int offset = tz.getOffset(post.publishTimestamp); Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updatePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostSQL); stmt.setLong(1, post.authorId); stmt.setTimestamp(2, new Timestamp(post.publishTimestamp)); stmt.setTimestamp(3, new Timestamp(post.publishTimestamp - offset)); stmt.setString(4, Strings.nullToEmpty(post.content)); stmt.setString(5, Strings.nullToEmpty(post.title)); stmt.setString(6, Strings.nullToEmpty(post.excerpt)); stmt.setString(7, post.status.toString().toLowerCase()); stmt.setString(8, Strings.nullToEmpty(post.slug)); stmt.setTimestamp(9, new Timestamp(post.modifiedTimestamp)); stmt.setTimestamp(10, new Timestamp(post.modifiedTimestamp - offset)); stmt.setLong(11, post.parentId); stmt.setString(12, Strings.nullToEmpty(post.guid)); stmt.setString(13, post.type.toString().toLowerCase()); stmt.setString(14, post.mimeType != null ? post.mimeType : ""); stmt.setLong(15, post.id); stmt.executeUpdate(); return post; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
java
public Post updatePost(Post post, final TimeZone tz) throws SQLException { if(post.id < 1L) { throw new SQLException("The post id must be specified for update"); } if(post.modifiedTimestamp < 1) { post = post.modifiedNow(); } int offset = tz.getOffset(post.publishTimestamp); Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updatePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostSQL); stmt.setLong(1, post.authorId); stmt.setTimestamp(2, new Timestamp(post.publishTimestamp)); stmt.setTimestamp(3, new Timestamp(post.publishTimestamp - offset)); stmt.setString(4, Strings.nullToEmpty(post.content)); stmt.setString(5, Strings.nullToEmpty(post.title)); stmt.setString(6, Strings.nullToEmpty(post.excerpt)); stmt.setString(7, post.status.toString().toLowerCase()); stmt.setString(8, Strings.nullToEmpty(post.slug)); stmt.setTimestamp(9, new Timestamp(post.modifiedTimestamp)); stmt.setTimestamp(10, new Timestamp(post.modifiedTimestamp - offset)); stmt.setLong(11, post.parentId); stmt.setString(12, Strings.nullToEmpty(post.guid)); stmt.setString(13, post.type.toString().toLowerCase()); stmt.setString(14, post.mimeType != null ? post.mimeType : ""); stmt.setLong(15, post.id); stmt.executeUpdate(); return post; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "Post", "updatePost", "(", "Post", "post", ",", "final", "TimeZone", "tz", ")", "throws", "SQLException", "{", "if", "(", "post", ".", "id", "<", "1L", ")", "{", "throw", "new", "SQLException", "(", "\"The post id must be specified for update\"", ")", ";", "}", "if", "(", "post", ".", "modifiedTimestamp", "<", "1", ")", "{", "post", "=", "post", ".", "modifiedNow", "(", ")", ";", "}", "int", "offset", "=", "tz", ".", "getOffset", "(", "post", ".", "publishTimestamp", ")", ";", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "updatePostTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "updatePostSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "post", ".", "authorId", ")", ";", "stmt", ".", "setTimestamp", "(", "2", ",", "new", "Timestamp", "(", "post", ".", "publishTimestamp", ")", ")", ";", "stmt", ".", "setTimestamp", "(", "3", ",", "new", "Timestamp", "(", "post", ".", "publishTimestamp", "-", "offset", ")", ")", ";", "stmt", ".", "setString", "(", "4", ",", "Strings", ".", "nullToEmpty", "(", "post", ".", "content", ")", ")", ";", "stmt", ".", "setString", "(", "5", ",", "Strings", ".", "nullToEmpty", "(", "post", ".", "title", ")", ")", ";", "stmt", ".", "setString", "(", "6", ",", "Strings", ".", "nullToEmpty", "(", "post", ".", "excerpt", ")", ")", ";", "stmt", ".", "setString", "(", "7", ",", "post", ".", "status", ".", "toString", "(", ")", ".", "toLowerCase", "(", ")", ")", ";", "stmt", ".", "setString", "(", "8", ",", "Strings", ".", "nullToEmpty", "(", "post", ".", "slug", ")", ")", ";", "stmt", ".", "setTimestamp", "(", "9", ",", "new", "Timestamp", "(", "post", ".", "modifiedTimestamp", ")", ")", ";", "stmt", ".", "setTimestamp", "(", "10", ",", "new", "Timestamp", "(", "post", ".", "modifiedTimestamp", "-", "offset", ")", ")", ";", "stmt", ".", "setLong", "(", "11", ",", "post", ".", "parentId", ")", ";", "stmt", ".", "setString", "(", "12", ",", "Strings", ".", "nullToEmpty", "(", "post", ".", "guid", ")", ")", ";", "stmt", ".", "setString", "(", "13", ",", "post", ".", "type", ".", "toString", "(", ")", ".", "toLowerCase", "(", ")", ")", ";", "stmt", ".", "setString", "(", "14", ",", "post", ".", "mimeType", "!=", "null", "?", "post", ".", "mimeType", ":", "\"\"", ")", ";", "stmt", ".", "setLong", "(", "15", ",", "post", ".", "id", ")", ";", "stmt", ".", "executeUpdate", "(", ")", ";", "return", "post", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Updates a post. @param post The post to update. The {@code id} must be set. @param tz The local time zone. @return The updated post. @throws SQLException on database error or missing post id.
[ "Updates", "a", "post", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1699-L1736
153,449
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.touchPost
public void touchPost(final long postId, final TimeZone tz) throws SQLException { if(postId < 1L) { throw new SQLException("The post id must be specified for update"); } long modifiedTimestamp = System.currentTimeMillis(); int offset = tz.getOffset(modifiedTimestamp); Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updatePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostModifiedSQL); stmt.setTimestamp(1, new Timestamp(modifiedTimestamp)); stmt.setTimestamp(2, new Timestamp(modifiedTimestamp - offset)); stmt.setLong(3, postId); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
java
public void touchPost(final long postId, final TimeZone tz) throws SQLException { if(postId < 1L) { throw new SQLException("The post id must be specified for update"); } long modifiedTimestamp = System.currentTimeMillis(); int offset = tz.getOffset(modifiedTimestamp); Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updatePostTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostModifiedSQL); stmt.setTimestamp(1, new Timestamp(modifiedTimestamp)); stmt.setTimestamp(2, new Timestamp(modifiedTimestamp - offset)); stmt.setLong(3, postId); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "void", "touchPost", "(", "final", "long", "postId", ",", "final", "TimeZone", "tz", ")", "throws", "SQLException", "{", "if", "(", "postId", "<", "1L", ")", "{", "throw", "new", "SQLException", "(", "\"The post id must be specified for update\"", ")", ";", "}", "long", "modifiedTimestamp", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "int", "offset", "=", "tz", ".", "getOffset", "(", "modifiedTimestamp", ")", ";", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "updatePostTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "updatePostModifiedSQL", ")", ";", "stmt", ".", "setTimestamp", "(", "1", ",", "new", "Timestamp", "(", "modifiedTimestamp", ")", ")", ";", "stmt", ".", "setTimestamp", "(", "2", ",", "new", "Timestamp", "(", "modifiedTimestamp", "-", "offset", ")", ")", ";", "stmt", ".", "setLong", "(", "3", ",", "postId", ")", ";", "stmt", ".", "executeUpdate", "(", ")", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
"Touches" the last modified time for a post. @param postId The post id. @param tz The local time zone. @throws SQLException on database error or invalid post id.
[ "Touches", "the", "last", "modified", "time", "for", "a", "post", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1746-L1768
153,450
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectPostMeta
public List<Meta> selectPostMeta(final long postId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; List<Meta> meta = Lists.newArrayListWithExpectedSize(8); Timer.Context ctx = metrics.selectPostMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectPostMetaSQL); stmt.setLong(1, postId); rs = stmt.executeQuery(); while(rs.next()) { meta.add(new Meta(rs.getLong(1), rs.getString(2), rs.getString(3))); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } return meta; }
java
public List<Meta> selectPostMeta(final long postId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; List<Meta> meta = Lists.newArrayListWithExpectedSize(8); Timer.Context ctx = metrics.selectPostMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectPostMetaSQL); stmt.setLong(1, postId); rs = stmt.executeQuery(); while(rs.next()) { meta.add(new Meta(rs.getLong(1), rs.getString(2), rs.getString(3))); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } return meta; }
[ "public", "List", "<", "Meta", ">", "selectPostMeta", "(", "final", "long", "postId", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "List", "<", "Meta", ">", "meta", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "8", ")", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "selectPostMetaTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "selectPostMetaSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "postId", ")", ";", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "meta", ".", "add", "(", "new", "Meta", "(", "rs", ".", "getLong", "(", "1", ")", ",", "rs", ".", "getString", "(", "2", ")", ",", "rs", ".", "getString", "(", "3", ")", ")", ")", ";", "}", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "return", "meta", ";", "}" ]
Selects metadata for a post. @param postId The post id. @return The metadata. @throws SQLException on database error.
[ "Selects", "metadata", "for", "a", "post", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1886-L1907
153,451
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectPostMetaValue
public Meta selectPostMetaValue(final long postId, final String metaKey) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectPostMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectPostMetaValueSQL); stmt.setLong(1, postId); stmt.setString(2, metaKey); rs = stmt.executeQuery(); return rs.next() ? new Meta(rs.getLong(1), rs.getString(2), rs.getString(3)) : null; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } }
java
public Meta selectPostMetaValue(final long postId, final String metaKey) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectPostMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectPostMetaValueSQL); stmt.setLong(1, postId); stmt.setString(2, metaKey); rs = stmt.executeQuery(); return rs.next() ? new Meta(rs.getLong(1), rs.getString(2), rs.getString(3)) : null; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } }
[ "public", "Meta", "selectPostMetaValue", "(", "final", "long", "postId", ",", "final", "String", "metaKey", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "selectPostMetaTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "selectPostMetaValueSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "postId", ")", ";", "stmt", ".", "setString", "(", "2", ",", "metaKey", ")", ";", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "return", "rs", ".", "next", "(", ")", "?", "new", "Meta", "(", "rs", ".", "getLong", "(", "1", ")", ",", "rs", ".", "getString", "(", "2", ")", ",", "rs", ".", "getString", "(", "3", ")", ")", ":", "null", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "}" ]
Selects a single post meta value. @param postId The post id. @param metaKey The key. @return The meta value or {@code null} if none. @throws SQLException on database error.
[ "Selects", "a", "single", "post", "meta", "value", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1918-L1935
153,452
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.updatePostMetaValue
public void updatePostMetaValue(final long postId, final String metaKey, final String metaValue) throws SQLException { Meta currMeta = selectPostMetaValue(postId, metaKey); if(currMeta == null) { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.setPostMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(insertPostMetaSQL); stmt.setLong(1, postId); stmt.setString(2, metaKey); stmt.setString(3, metaValue); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } } else { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.setPostMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostMetaValueSQL); stmt.setString(1, metaValue); stmt.setString(2, metaKey); stmt.setLong(3, postId); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } } }
java
public void updatePostMetaValue(final long postId, final String metaKey, final String metaValue) throws SQLException { Meta currMeta = selectPostMetaValue(postId, metaKey); if(currMeta == null) { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.setPostMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(insertPostMetaSQL); stmt.setLong(1, postId); stmt.setString(2, metaKey); stmt.setString(3, metaValue); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } } else { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.setPostMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updatePostMetaValueSQL); stmt.setString(1, metaValue); stmt.setString(2, metaKey); stmt.setLong(3, postId); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } } }
[ "public", "void", "updatePostMetaValue", "(", "final", "long", "postId", ",", "final", "String", "metaKey", ",", "final", "String", "metaValue", ")", "throws", "SQLException", "{", "Meta", "currMeta", "=", "selectPostMetaValue", "(", "postId", ",", "metaKey", ")", ";", "if", "(", "currMeta", "==", "null", ")", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "setPostMetaTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "insertPostMetaSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "postId", ")", ";", "stmt", ".", "setString", "(", "2", ",", "metaKey", ")", ";", "stmt", ".", "setString", "(", "3", ",", "metaValue", ")", ";", "stmt", ".", "executeUpdate", "(", ")", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}", "else", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "setPostMetaTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "updatePostMetaValueSQL", ")", ";", "stmt", ".", "setString", "(", "1", ",", "metaValue", ")", ";", "stmt", ".", "setString", "(", "2", ",", "metaKey", ")", ";", "stmt", ".", "setLong", "(", "3", ",", "postId", ")", ";", "stmt", ".", "executeUpdate", "(", ")", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}", "}" ]
Updates a post meta value if it exists or inserts if it does not. @param postId The post id. @param metaKey The key. @param metaValue The value. @throws SQLException on database error.
[ "Updates", "a", "post", "meta", "value", "if", "it", "exists", "or", "inserts", "if", "it", "does", "not", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L1947-L1981
153,453
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.clearTermMeta
public void clearTermMeta(final long termId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.clearTermMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(deleteTermMetaSQL); stmt.setLong(1, termId); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
java
public void clearTermMeta(final long termId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.clearTermMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(deleteTermMetaSQL); stmt.setLong(1, termId); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "void", "clearTermMeta", "(", "final", "long", "termId", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "clearTermMetaTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "deleteTermMetaSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "termId", ")", ";", "stmt", ".", "executeUpdate", "(", ")", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Clears all metadata for a term. @param termId The term id. @throws SQLException on database error.
[ "Clears", "all", "metadata", "for", "a", "term", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2027-L2040
153,454
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectTermMeta
public List<Meta> selectTermMeta(final long termId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; List<Meta> meta = Lists.newArrayListWithExpectedSize(8); Timer.Context ctx = metrics.selectTermMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectTermMetaSQL); stmt.setLong(1, termId); rs = stmt.executeQuery(); while(rs.next()) { meta.add(new Meta(rs.getLong(1), rs.getString(2), rs.getString(3))); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } return meta; }
java
public List<Meta> selectTermMeta(final long termId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; List<Meta> meta = Lists.newArrayListWithExpectedSize(8); Timer.Context ctx = metrics.selectTermMetaTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectTermMetaSQL); stmt.setLong(1, termId); rs = stmt.executeQuery(); while(rs.next()) { meta.add(new Meta(rs.getLong(1), rs.getString(2), rs.getString(3))); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } return meta; }
[ "public", "List", "<", "Meta", ">", "selectTermMeta", "(", "final", "long", "termId", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "List", "<", "Meta", ">", "meta", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "8", ")", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "selectTermMetaTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "selectTermMetaSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "termId", ")", ";", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "meta", ".", "add", "(", "new", "Meta", "(", "rs", ".", "getLong", "(", "1", ")", ",", "rs", ".", "getString", "(", "2", ")", ",", "rs", ".", "getString", "(", "3", ")", ")", ")", ";", "}", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "return", "meta", ";", "}" ]
Selects metadata for a term. @param termId The term id. @return The metadata. @throws SQLException on database error.
[ "Selects", "metadata", "for", "a", "term", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2051-L2072
153,455
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectTermIds
public Set<Long> selectTermIds(final String name) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Set<Long> ids = Sets.newHashSetWithExpectedSize(4); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectTermIdsSQL); stmt.setString(1, name); rs = stmt.executeQuery(); while(rs.next()) { ids.add(rs.getLong(1)); } return ids; } finally { SQLUtil.closeQuietly(conn, stmt, rs); } }
java
public Set<Long> selectTermIds(final String name) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Set<Long> ids = Sets.newHashSetWithExpectedSize(4); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectTermIdsSQL); stmt.setString(1, name); rs = stmt.executeQuery(); while(rs.next()) { ids.add(rs.getLong(1)); } return ids; } finally { SQLUtil.closeQuietly(conn, stmt, rs); } }
[ "public", "Set", "<", "Long", ">", "selectTermIds", "(", "final", "String", "name", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "Set", "<", "Long", ">", "ids", "=", "Sets", ".", "newHashSetWithExpectedSize", "(", "4", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "selectTermIdsSQL", ")", ";", "stmt", ".", "setString", "(", "1", ",", "name", ")", ";", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "ids", ".", "add", "(", "rs", ".", "getLong", "(", "1", ")", ")", ";", "}", "return", "ids", ";", "}", "finally", "{", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "}" ]
Selects the term ids for all with the specified name. @param name The term name. @return The list of ids. @throws SQLException on database error.
[ "Selects", "the", "term", "ids", "for", "all", "with", "the", "specified", "name", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2118-L2136
153,456
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.createTerm
public Term createTerm(final String name, final String slug) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.createTermTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(insertTermSQL, Statement.RETURN_GENERATED_KEYS); stmt.setString(1, name); stmt.setString(2, slug); stmt.executeUpdate(); rs = stmt.getGeneratedKeys(); if(rs.next()) { return new Term(rs.getLong(1), name, slug); } else { throw new SQLException("Problem creating term (no generated id)"); } } finally { ctx.stop(); closeQuietly(conn, stmt, rs); } }
java
public Term createTerm(final String name, final String slug) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.createTermTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(insertTermSQL, Statement.RETURN_GENERATED_KEYS); stmt.setString(1, name); stmt.setString(2, slug); stmt.executeUpdate(); rs = stmt.getGeneratedKeys(); if(rs.next()) { return new Term(rs.getLong(1), name, slug); } else { throw new SQLException("Problem creating term (no generated id)"); } } finally { ctx.stop(); closeQuietly(conn, stmt, rs); } }
[ "public", "Term", "createTerm", "(", "final", "String", "name", ",", "final", "String", "slug", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "createTermTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "insertTermSQL", ",", "Statement", ".", "RETURN_GENERATED_KEYS", ")", ";", "stmt", ".", "setString", "(", "1", ",", "name", ")", ";", "stmt", ".", "setString", "(", "2", ",", "slug", ")", ";", "stmt", ".", "executeUpdate", "(", ")", ";", "rs", "=", "stmt", ".", "getGeneratedKeys", "(", ")", ";", "if", "(", "rs", ".", "next", "(", ")", ")", "{", "return", "new", "Term", "(", "rs", ".", "getLong", "(", "1", ")", ",", "name", ",", "slug", ")", ";", "}", "else", "{", "throw", "new", "SQLException", "(", "\"Problem creating term (no generated id)\"", ")", ";", "}", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "}" ]
Creates a term. @param name The term name. @param slug The term slug. @return The created term. @throws SQLException on database error.
[ "Creates", "a", "term", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2147-L2169
153,457
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectTerm
public Term selectTerm(final long id) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectTermTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectTermIdSQL); stmt.setLong(1, id); rs = stmt.executeQuery(); return rs.next() ? new Term(id, rs.getString(1), rs.getString(2)) : null; } finally { ctx.stop(); closeQuietly(conn, stmt, rs); } }
java
public Term selectTerm(final long id) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.selectTermTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectTermIdSQL); stmt.setLong(1, id); rs = stmt.executeQuery(); return rs.next() ? new Term(id, rs.getString(1), rs.getString(2)) : null; } finally { ctx.stop(); closeQuietly(conn, stmt, rs); } }
[ "public", "Term", "selectTerm", "(", "final", "long", "id", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "selectTermTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "selectTermIdSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "id", ")", ";", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "return", "rs", ".", "next", "(", ")", "?", "new", "Term", "(", "id", ",", "rs", ".", "getString", "(", "1", ")", ",", "rs", ".", "getString", "(", "2", ")", ")", ":", "null", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "}" ]
Selects a term by id. @param id The id. @return The term or {@code null} if none. @throws SQLException on database error.
[ "Selects", "a", "term", "by", "id", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2179-L2194
153,458
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.deleteTerm
public boolean deleteTerm(final long id) throws SQLException { try(Connection conn = connectionSupplier.getConnection(); PreparedStatement stmt = conn.prepareStatement(deleteTermIdSQL)) { stmt.setLong(1, id); return stmt.executeUpdate() > 0; } }
java
public boolean deleteTerm(final long id) throws SQLException { try(Connection conn = connectionSupplier.getConnection(); PreparedStatement stmt = conn.prepareStatement(deleteTermIdSQL)) { stmt.setLong(1, id); return stmt.executeUpdate() > 0; } }
[ "public", "boolean", "deleteTerm", "(", "final", "long", "id", ")", "throws", "SQLException", "{", "try", "(", "Connection", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "PreparedStatement", "stmt", "=", "conn", ".", "prepareStatement", "(", "deleteTermIdSQL", ")", ")", "{", "stmt", ".", "setLong", "(", "1", ",", "id", ")", ";", "return", "stmt", ".", "executeUpdate", "(", ")", ">", "0", ";", "}", "}" ]
Deletes a term by id. @param id The id. @return Was the term deleted? @throws SQLException on database error.
[ "Deletes", "a", "term", "by", "id", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2204-L2210
153,459
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectSlugTerms
public List<Term> selectSlugTerms(final String slug) throws SQLException { try(Connection conn = connectionSupplier.getConnection(); PreparedStatement stmt = conn.prepareStatement(selectTermSlugSQL); Timer.Context ctx = metrics.selectTermTimer.time()) { stmt.setString(1, slug); try(ResultSet rs = stmt.executeQuery()) { List<Term> terms = Lists.newArrayListWithExpectedSize(2); while(rs.next()) { terms.add(new Term(rs.getLong(1), rs.getString(2), rs.getString(3))); } return terms; } } }
java
public List<Term> selectSlugTerms(final String slug) throws SQLException { try(Connection conn = connectionSupplier.getConnection(); PreparedStatement stmt = conn.prepareStatement(selectTermSlugSQL); Timer.Context ctx = metrics.selectTermTimer.time()) { stmt.setString(1, slug); try(ResultSet rs = stmt.executeQuery()) { List<Term> terms = Lists.newArrayListWithExpectedSize(2); while(rs.next()) { terms.add(new Term(rs.getLong(1), rs.getString(2), rs.getString(3))); } return terms; } } }
[ "public", "List", "<", "Term", ">", "selectSlugTerms", "(", "final", "String", "slug", ")", "throws", "SQLException", "{", "try", "(", "Connection", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "PreparedStatement", "stmt", "=", "conn", ".", "prepareStatement", "(", "selectTermSlugSQL", ")", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "selectTermTimer", ".", "time", "(", ")", ")", "{", "stmt", ".", "setString", "(", "1", ",", "slug", ")", ";", "try", "(", "ResultSet", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ")", "{", "List", "<", "Term", ">", "terms", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "2", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "terms", ".", "add", "(", "new", "Term", "(", "rs", ".", "getLong", "(", "1", ")", ",", "rs", ".", "getString", "(", "2", ")", ",", "rs", ".", "getString", "(", "3", ")", ")", ")", ";", "}", "return", "terms", ";", "}", "}", "}" ]
Selects terms with a matching slug. @param slug The slug. @return The terms or an empty list if none. @throws SQLException on database error.
[ "Selects", "terms", "with", "a", "matching", "slug", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2220-L2233
153,460
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectTaxonomyTerm
public TaxonomyTerm selectTaxonomyTerm(final String taxonomy, final String name) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; long taxonomyTermId = 0L; long termId = 0L; String description = ""; Timer.Context ctx = metrics.selectTaxonomyTermTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectTaxonomyTermSQL); stmt.setString(1, name); stmt.setString(2, taxonomy); rs = stmt.executeQuery(); if(rs.next()) { taxonomyTermId = rs.getLong(1); termId = rs.getLong(2); description = rs.getString(3); } else { return null; } } finally { ctx.stop(); closeQuietly(conn, stmt, rs); } return new TaxonomyTerm(taxonomyTermId, taxonomy, selectTerm(termId), description); }
java
public TaxonomyTerm selectTaxonomyTerm(final String taxonomy, final String name) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; long taxonomyTermId = 0L; long termId = 0L; String description = ""; Timer.Context ctx = metrics.selectTaxonomyTermTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectTaxonomyTermSQL); stmt.setString(1, name); stmt.setString(2, taxonomy); rs = stmt.executeQuery(); if(rs.next()) { taxonomyTermId = rs.getLong(1); termId = rs.getLong(2); description = rs.getString(3); } else { return null; } } finally { ctx.stop(); closeQuietly(conn, stmt, rs); } return new TaxonomyTerm(taxonomyTermId, taxonomy, selectTerm(termId), description); }
[ "public", "TaxonomyTerm", "selectTaxonomyTerm", "(", "final", "String", "taxonomy", ",", "final", "String", "name", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "long", "taxonomyTermId", "=", "0L", ";", "long", "termId", "=", "0L", ";", "String", "description", "=", "\"\"", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "selectTaxonomyTermTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "selectTaxonomyTermSQL", ")", ";", "stmt", ".", "setString", "(", "1", ",", "name", ")", ";", "stmt", ".", "setString", "(", "2", ",", "taxonomy", ")", ";", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "if", "(", "rs", ".", "next", "(", ")", ")", "{", "taxonomyTermId", "=", "rs", ".", "getLong", "(", "1", ")", ";", "termId", "=", "rs", ".", "getLong", "(", "2", ")", ";", "description", "=", "rs", ".", "getString", "(", "3", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "return", "new", "TaxonomyTerm", "(", "taxonomyTermId", ",", "taxonomy", ",", "selectTerm", "(", "termId", ")", ",", "description", ")", ";", "}" ]
Selects a taxonomy term. @param taxonomy The taxonomy name. @param name The term name. @return The taxonomy term or {@code null} if none. @throws SQLException on database error.
[ "Selects", "a", "taxonomy", "term", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2244-L2271
153,461
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.setTaxonomyTermDescription
public boolean setTaxonomyTermDescription(final String taxonomy, final String name, final String description) throws SQLException { TaxonomyTerm term = selectTaxonomyTerm(taxonomy, name); if(term == null || term.term == null) { return false; } Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updateTaxonomyTermTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updateTaxonomyTermDescriptionSQL); stmt.setString(1, Strings.nullToEmpty(description)); stmt.setLong(2, term.term.id); stmt.setString(3, taxonomy); return stmt.executeUpdate() > 0; } finally { ctx.stop(); closeQuietly(conn, stmt); } }
java
public boolean setTaxonomyTermDescription(final String taxonomy, final String name, final String description) throws SQLException { TaxonomyTerm term = selectTaxonomyTerm(taxonomy, name); if(term == null || term.term == null) { return false; } Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.updateTaxonomyTermTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(updateTaxonomyTermDescriptionSQL); stmt.setString(1, Strings.nullToEmpty(description)); stmt.setLong(2, term.term.id); stmt.setString(3, taxonomy); return stmt.executeUpdate() > 0; } finally { ctx.stop(); closeQuietly(conn, stmt); } }
[ "public", "boolean", "setTaxonomyTermDescription", "(", "final", "String", "taxonomy", ",", "final", "String", "name", ",", "final", "String", "description", ")", "throws", "SQLException", "{", "TaxonomyTerm", "term", "=", "selectTaxonomyTerm", "(", "taxonomy", ",", "name", ")", ";", "if", "(", "term", "==", "null", "||", "term", ".", "term", "==", "null", ")", "{", "return", "false", ";", "}", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "updateTaxonomyTermTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "updateTaxonomyTermDescriptionSQL", ")", ";", "stmt", ".", "setString", "(", "1", ",", "Strings", ".", "nullToEmpty", "(", "description", ")", ")", ";", "stmt", ".", "setLong", "(", "2", ",", "term", ".", "term", ".", "id", ")", ";", "stmt", ".", "setString", "(", "3", ",", "taxonomy", ")", ";", "return", "stmt", ".", "executeUpdate", "(", ")", ">", "0", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Sets the description for a taxonomy term. @param taxonomy The taxonomy. @param name The term name. @param description The description. @return Was the description set? @throws SQLException on database error.
[ "Sets", "the", "description", "for", "a", "taxonomy", "term", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2283-L2305
153,462
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.createTaxonomyTerm
public TaxonomyTerm createTaxonomyTerm(final String taxonomy, final String name, final String slug, final String description) throws SQLException { Term term = createTerm(name, slug); Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.createTaxonomyTermTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(insertTaxonomyTermSQL, Statement.RETURN_GENERATED_KEYS); stmt.setLong(1, term.id); stmt.setString(2, taxonomy); stmt.setString(3, Strings.nullToEmpty(description)); stmt.executeUpdate(); rs = stmt.getGeneratedKeys(); if(rs.next()) { return new TaxonomyTerm(rs.getLong(1), taxonomy, term, description); } else { throw new SQLException("Problem creating taxonomy term (no generated id)"); } } finally { ctx.stop(); closeQuietly(conn, stmt, rs); } }
java
public TaxonomyTerm createTaxonomyTerm(final String taxonomy, final String name, final String slug, final String description) throws SQLException { Term term = createTerm(name, slug); Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.createTaxonomyTermTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(insertTaxonomyTermSQL, Statement.RETURN_GENERATED_KEYS); stmt.setLong(1, term.id); stmt.setString(2, taxonomy); stmt.setString(3, Strings.nullToEmpty(description)); stmt.executeUpdate(); rs = stmt.getGeneratedKeys(); if(rs.next()) { return new TaxonomyTerm(rs.getLong(1), taxonomy, term, description); } else { throw new SQLException("Problem creating taxonomy term (no generated id)"); } } finally { ctx.stop(); closeQuietly(conn, stmt, rs); } }
[ "public", "TaxonomyTerm", "createTaxonomyTerm", "(", "final", "String", "taxonomy", ",", "final", "String", "name", ",", "final", "String", "slug", ",", "final", "String", "description", ")", "throws", "SQLException", "{", "Term", "term", "=", "createTerm", "(", "name", ",", "slug", ")", ";", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "createTaxonomyTermTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "insertTaxonomyTermSQL", ",", "Statement", ".", "RETURN_GENERATED_KEYS", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "term", ".", "id", ")", ";", "stmt", ".", "setString", "(", "2", ",", "taxonomy", ")", ";", "stmt", ".", "setString", "(", "3", ",", "Strings", ".", "nullToEmpty", "(", "description", ")", ")", ";", "stmt", ".", "executeUpdate", "(", ")", ";", "rs", "=", "stmt", ".", "getGeneratedKeys", "(", ")", ";", "if", "(", "rs", ".", "next", "(", ")", ")", "{", "return", "new", "TaxonomyTerm", "(", "rs", ".", "getLong", "(", "1", ")", ",", "taxonomy", ",", "term", ",", "description", ")", ";", "}", "else", "{", "throw", "new", "SQLException", "(", "\"Problem creating taxonomy term (no generated id)\"", ")", ";", "}", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "}" ]
Creates a taxonomy term. @param taxonomy The taxonomy. @param name The term name. @param slug The term slug. @param description The taxonomy term description. @return The created term. @throws SQLException on database error.
[ "Creates", "a", "taxonomy", "term", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2319-L2344
153,463
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.resolveTaxonomyTerm
public TaxonomyTerm resolveTaxonomyTerm(final String taxonomy, final String name) throws SQLException { TaxonomyTerm term; Cache<String, TaxonomyTerm> taxonomyTermCache = taxonomyTermCaches.get(taxonomy); if(taxonomyTermCache != null) { metrics.taxonomyTermCacheTries.mark(); term = taxonomyTermCache.getIfPresent(name); if(term != null) { metrics.taxonomyTermCacheHits.mark(); return term; } } term = selectTaxonomyTerm(taxonomy, name); if(term != null && taxonomyTermCache != null) { taxonomyTermCache.put(name, term); } return term; }
java
public TaxonomyTerm resolveTaxonomyTerm(final String taxonomy, final String name) throws SQLException { TaxonomyTerm term; Cache<String, TaxonomyTerm> taxonomyTermCache = taxonomyTermCaches.get(taxonomy); if(taxonomyTermCache != null) { metrics.taxonomyTermCacheTries.mark(); term = taxonomyTermCache.getIfPresent(name); if(term != null) { metrics.taxonomyTermCacheHits.mark(); return term; } } term = selectTaxonomyTerm(taxonomy, name); if(term != null && taxonomyTermCache != null) { taxonomyTermCache.put(name, term); } return term; }
[ "public", "TaxonomyTerm", "resolveTaxonomyTerm", "(", "final", "String", "taxonomy", ",", "final", "String", "name", ")", "throws", "SQLException", "{", "TaxonomyTerm", "term", ";", "Cache", "<", "String", ",", "TaxonomyTerm", ">", "taxonomyTermCache", "=", "taxonomyTermCaches", ".", "get", "(", "taxonomy", ")", ";", "if", "(", "taxonomyTermCache", "!=", "null", ")", "{", "metrics", ".", "taxonomyTermCacheTries", ".", "mark", "(", ")", ";", "term", "=", "taxonomyTermCache", ".", "getIfPresent", "(", "name", ")", ";", "if", "(", "term", "!=", "null", ")", "{", "metrics", ".", "taxonomyTermCacheHits", ".", "mark", "(", ")", ";", "return", "term", ";", "}", "}", "term", "=", "selectTaxonomyTerm", "(", "taxonomy", ",", "name", ")", ";", "if", "(", "term", "!=", "null", "&&", "taxonomyTermCache", "!=", "null", ")", "{", "taxonomyTermCache", ".", "put", "(", "name", ",", "term", ")", ";", "}", "return", "term", ";", "}" ]
Resolves a taxonomy term. @param taxonomy The taxonomy. @param name The term name. @return The taxonomy term or {@code null} if not found. @throws SQLException on database error.
[ "Resolves", "a", "taxonomy", "term", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2353-L2371
153,464
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.clearPostTerm
public void clearPostTerm(final long postId, final long taxonomyTermId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.postTermsClearTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(clearPostTermSQL); stmt.setLong(1, postId); stmt.setLong(2, taxonomyTermId); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
java
public void clearPostTerm(final long postId, final long taxonomyTermId) throws SQLException { Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.postTermsClearTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(clearPostTermSQL); stmt.setLong(1, postId); stmt.setLong(2, taxonomyTermId); stmt.executeUpdate(); } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "void", "clearPostTerm", "(", "final", "long", "postId", ",", "final", "long", "taxonomyTermId", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "postTermsClearTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "clearPostTermSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "postId", ")", ";", "stmt", ".", "setLong", "(", "2", ",", "taxonomyTermId", ")", ";", "stmt", ".", "executeUpdate", "(", ")", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Clears a single taxonomy term associated with a post. @param postId The post id. @param taxonomyTermId The taxonomy term id. @throws SQLException on database error.
[ "Clears", "a", "single", "taxonomy", "term", "associated", "with", "a", "post", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2468-L2482
153,465
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.clearPostTerms
public void clearPostTerms(final long postId, final String taxonomy) throws SQLException { List<TaxonomyTerm> terms = selectPostTerms(postId, taxonomy); for(TaxonomyTerm term : terms) { clearPostTerm(postId, term.id); } }
java
public void clearPostTerms(final long postId, final String taxonomy) throws SQLException { List<TaxonomyTerm> terms = selectPostTerms(postId, taxonomy); for(TaxonomyTerm term : terms) { clearPostTerm(postId, term.id); } }
[ "public", "void", "clearPostTerms", "(", "final", "long", "postId", ",", "final", "String", "taxonomy", ")", "throws", "SQLException", "{", "List", "<", "TaxonomyTerm", ">", "terms", "=", "selectPostTerms", "(", "postId", ",", "taxonomy", ")", ";", "for", "(", "TaxonomyTerm", "term", ":", "terms", ")", "{", "clearPostTerm", "(", "postId", ",", "term", ".", "id", ")", ";", "}", "}" ]
Clears all terms associated with a post with a specified taxonomy. @param postId The post id. @param taxonomy The taxonomy. @throws SQLException on database error.
[ "Clears", "all", "terms", "associated", "with", "a", "post", "with", "a", "specified", "taxonomy", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2512-L2517
153,466
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.addPostTerm
public boolean addPostTerm(final long postId, final TaxonomyTerm taxonomyTerm) throws SQLException { List<TaxonomyTerm> currTerms = selectPostTerms(postId, taxonomyTerm.taxonomy); for(TaxonomyTerm currTerm : currTerms) { if(currTerm.term.name.equals(taxonomyTerm.term.name)) { return false; } } Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.postTermsSetTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(insertPostTermSQL); stmt.setLong(1, postId); stmt.setLong(2, taxonomyTerm.id); stmt.setInt(3, currTerms.size()); //Add at the last position... return stmt.executeUpdate() > 0; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
java
public boolean addPostTerm(final long postId, final TaxonomyTerm taxonomyTerm) throws SQLException { List<TaxonomyTerm> currTerms = selectPostTerms(postId, taxonomyTerm.taxonomy); for(TaxonomyTerm currTerm : currTerms) { if(currTerm.term.name.equals(taxonomyTerm.term.name)) { return false; } } Connection conn = null; PreparedStatement stmt = null; Timer.Context ctx = metrics.postTermsSetTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(insertPostTermSQL); stmt.setLong(1, postId); stmt.setLong(2, taxonomyTerm.id); stmt.setInt(3, currTerms.size()); //Add at the last position... return stmt.executeUpdate() > 0; } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt); } }
[ "public", "boolean", "addPostTerm", "(", "final", "long", "postId", ",", "final", "TaxonomyTerm", "taxonomyTerm", ")", "throws", "SQLException", "{", "List", "<", "TaxonomyTerm", ">", "currTerms", "=", "selectPostTerms", "(", "postId", ",", "taxonomyTerm", ".", "taxonomy", ")", ";", "for", "(", "TaxonomyTerm", "currTerm", ":", "currTerms", ")", "{", "if", "(", "currTerm", ".", "term", ".", "name", ".", "equals", "(", "taxonomyTerm", ".", "term", ".", "name", ")", ")", "{", "return", "false", ";", "}", "}", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "postTermsSetTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "insertPostTermSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "postId", ")", ";", "stmt", ".", "setLong", "(", "2", ",", "taxonomyTerm", ".", "id", ")", ";", "stmt", ".", "setInt", "(", "3", ",", "currTerms", ".", "size", "(", ")", ")", ";", "//Add at the last position...", "return", "stmt", ".", "executeUpdate", "(", ")", ">", "0", ";", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ")", ";", "}", "}" ]
Adds a term at the end of the current terms if it does not already exist. @param postId The post id. @param taxonomyTerm The taxonomy term to add. @return Was the term added? @throws SQLException on database error.
[ "Adds", "a", "term", "at", "the", "end", "of", "the", "current", "terms", "if", "it", "does", "not", "already", "exist", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2529-L2552
153,467
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectPostTerms
public List<TaxonomyTerm> selectPostTerms(final long postId, final String taxonomy) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; List<Long> termIds = Lists.newArrayListWithExpectedSize(8); Timer.Context ctx = metrics.postTermsSelectTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectPostTermsSQL); stmt.setLong(1, postId); rs = stmt.executeQuery(); while(rs.next()) { termIds.add(rs.getLong(1)); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } if(termIds.size() == 0) { return ImmutableList.of(); } List<TaxonomyTerm> terms = Lists.newArrayListWithExpectedSize(termIds.size()); for(long termId : termIds) { TaxonomyTerm term = resolveTaxonomyTerm(termId); if(term != null && (taxonomy == null || term.taxonomy.equals(taxonomy))) { terms.add(term); } } return terms; }
java
public List<TaxonomyTerm> selectPostTerms(final long postId, final String taxonomy) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; List<Long> termIds = Lists.newArrayListWithExpectedSize(8); Timer.Context ctx = metrics.postTermsSelectTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectPostTermsSQL); stmt.setLong(1, postId); rs = stmt.executeQuery(); while(rs.next()) { termIds.add(rs.getLong(1)); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } if(termIds.size() == 0) { return ImmutableList.of(); } List<TaxonomyTerm> terms = Lists.newArrayListWithExpectedSize(termIds.size()); for(long termId : termIds) { TaxonomyTerm term = resolveTaxonomyTerm(termId); if(term != null && (taxonomy == null || term.taxonomy.equals(taxonomy))) { terms.add(term); } } return terms; }
[ "public", "List", "<", "TaxonomyTerm", ">", "selectPostTerms", "(", "final", "long", "postId", ",", "final", "String", "taxonomy", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "List", "<", "Long", ">", "termIds", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "8", ")", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "postTermsSelectTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "selectPostTermsSQL", ")", ";", "stmt", ".", "setLong", "(", "1", ",", "postId", ")", ";", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "termIds", ".", "add", "(", "rs", ".", "getLong", "(", "1", ")", ")", ";", "}", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "if", "(", "termIds", ".", "size", "(", ")", "==", "0", ")", "{", "return", "ImmutableList", ".", "of", "(", ")", ";", "}", "List", "<", "TaxonomyTerm", ">", "terms", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "termIds", ".", "size", "(", ")", ")", ";", "for", "(", "long", "termId", ":", "termIds", ")", "{", "TaxonomyTerm", "term", "=", "resolveTaxonomyTerm", "(", "termId", ")", ";", "if", "(", "term", "!=", "null", "&&", "(", "taxonomy", "==", "null", "||", "term", ".", "taxonomy", ".", "equals", "(", "taxonomy", ")", ")", ")", "{", "terms", ".", "add", "(", "term", ")", ";", "}", "}", "return", "terms", ";", "}" ]
Selects all terms associated with a post. @param postId The post id. @param taxonomy The taxonomy. If {@code null}, any taxonomy is accepted. @return The list of terms. @throws SQLException on database error.
[ "Selects", "all", "terms", "associated", "with", "a", "post", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2618-L2649
153,468
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectOption
public String selectOption(final String optionName, final String defaultValue) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.optionSelectTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectOptionSQL); stmt.setString(1, optionName); rs = stmt.executeQuery(); if(rs.next()) { String val = rs.getString(1); return val != null ? val.trim() : defaultValue; } else { return defaultValue; } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } }
java
public String selectOption(final String optionName, final String defaultValue) throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Timer.Context ctx = metrics.optionSelectTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectOptionSQL); stmt.setString(1, optionName); rs = stmt.executeQuery(); if(rs.next()) { String val = rs.getString(1); return val != null ? val.trim() : defaultValue; } else { return defaultValue; } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } }
[ "public", "String", "selectOption", "(", "final", "String", "optionName", ",", "final", "String", "defaultValue", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "optionSelectTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "selectOptionSQL", ")", ";", "stmt", ".", "setString", "(", "1", ",", "optionName", ")", ";", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "if", "(", "rs", ".", "next", "(", ")", ")", "{", "String", "val", "=", "rs", ".", "getString", "(", "1", ")", ";", "return", "val", "!=", "null", "?", "val", ".", "trim", "(", ")", ":", "defaultValue", ";", "}", "else", "{", "return", "defaultValue", ";", "}", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "}" ]
Gets a configuration option with a default value. @param optionName The option name. @param defaultValue A default value if no option is set. @return The option value or the default value if not found. @throws SQLException on database error.
[ "Gets", "a", "configuration", "option", "with", "a", "default", "value", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2671-L2691
153,469
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectSite
public Site selectSite() throws SQLException { String baseURL = selectOption("home"); String title = selectOption("blogname"); String description = selectOption("blogdescription"); String permalinkStructure = selectOption("permalink_structure", "/?p=%postid%"); long defaultCategoryId = Long.parseLong(selectOption("default_category", "0")); TaxonomyTerm defaultCategoryTerm = resolveTaxonomyTerm(defaultCategoryId); if(defaultCategoryTerm == null) { defaultCategoryTerm = new TaxonomyTerm(0L, CATEGORY_TAXONOMY, new Term(0L, "Uncategorized", "uncategorized"), ""); } return new Site(siteId, baseURL, title, description, permalinkStructure, defaultCategoryTerm.term); }
java
public Site selectSite() throws SQLException { String baseURL = selectOption("home"); String title = selectOption("blogname"); String description = selectOption("blogdescription"); String permalinkStructure = selectOption("permalink_structure", "/?p=%postid%"); long defaultCategoryId = Long.parseLong(selectOption("default_category", "0")); TaxonomyTerm defaultCategoryTerm = resolveTaxonomyTerm(defaultCategoryId); if(defaultCategoryTerm == null) { defaultCategoryTerm = new TaxonomyTerm(0L, CATEGORY_TAXONOMY, new Term(0L, "Uncategorized", "uncategorized"), ""); } return new Site(siteId, baseURL, title, description, permalinkStructure, defaultCategoryTerm.term); }
[ "public", "Site", "selectSite", "(", ")", "throws", "SQLException", "{", "String", "baseURL", "=", "selectOption", "(", "\"home\"", ")", ";", "String", "title", "=", "selectOption", "(", "\"blogname\"", ")", ";", "String", "description", "=", "selectOption", "(", "\"blogdescription\"", ")", ";", "String", "permalinkStructure", "=", "selectOption", "(", "\"permalink_structure\"", ",", "\"/?p=%postid%\"", ")", ";", "long", "defaultCategoryId", "=", "Long", ".", "parseLong", "(", "selectOption", "(", "\"default_category\"", ",", "\"0\"", ")", ")", ";", "TaxonomyTerm", "defaultCategoryTerm", "=", "resolveTaxonomyTerm", "(", "defaultCategoryId", ")", ";", "if", "(", "defaultCategoryTerm", "==", "null", ")", "{", "defaultCategoryTerm", "=", "new", "TaxonomyTerm", "(", "0L", ",", "CATEGORY_TAXONOMY", ",", "new", "Term", "(", "0L", ",", "\"Uncategorized\"", ",", "\"uncategorized\"", ")", ",", "\"\"", ")", ";", "}", "return", "new", "Site", "(", "siteId", ",", "baseURL", ",", "title", ",", "description", ",", "permalinkStructure", ",", "defaultCategoryTerm", ".", "term", ")", ";", "}" ]
Selects the site metadata from the options table. @return The site metadata. @throws SQLException on database error.
[ "Selects", "the", "site", "metadata", "from", "the", "options", "table", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2698-L2709
153,470
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.blogFromResultSet
private Blog blogFromResultSet(final ResultSet rs) throws SQLException { long registeredTimestamp = 0L; long lastUpdatedTimestamp = 0L; try { registeredTimestamp = rs.getTimestamp(5).getTime(); } catch(SQLException se) { //Deal with possible java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp registeredTimestamp = 0L; } try { lastUpdatedTimestamp = rs.getTimestamp(6).getTime(); } catch(SQLException se) { //Deal with possible java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp lastUpdatedTimestamp = 0L; } return new Blog(rs.getLong(1), rs.getLong(2), rs.getString(3), rs.getString(4), registeredTimestamp, lastUpdatedTimestamp); }
java
private Blog blogFromResultSet(final ResultSet rs) throws SQLException { long registeredTimestamp = 0L; long lastUpdatedTimestamp = 0L; try { registeredTimestamp = rs.getTimestamp(5).getTime(); } catch(SQLException se) { //Deal with possible java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp registeredTimestamp = 0L; } try { lastUpdatedTimestamp = rs.getTimestamp(6).getTime(); } catch(SQLException se) { //Deal with possible java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp lastUpdatedTimestamp = 0L; } return new Blog(rs.getLong(1), rs.getLong(2), rs.getString(3), rs.getString(4), registeredTimestamp, lastUpdatedTimestamp); }
[ "private", "Blog", "blogFromResultSet", "(", "final", "ResultSet", "rs", ")", "throws", "SQLException", "{", "long", "registeredTimestamp", "=", "0L", ";", "long", "lastUpdatedTimestamp", "=", "0L", ";", "try", "{", "registeredTimestamp", "=", "rs", ".", "getTimestamp", "(", "5", ")", ".", "getTime", "(", ")", ";", "}", "catch", "(", "SQLException", "se", ")", "{", "//Deal with possible java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp", "registeredTimestamp", "=", "0L", ";", "}", "try", "{", "lastUpdatedTimestamp", "=", "rs", ".", "getTimestamp", "(", "6", ")", ".", "getTime", "(", ")", ";", "}", "catch", "(", "SQLException", "se", ")", "{", "//Deal with possible java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp", "lastUpdatedTimestamp", "=", "0L", ";", "}", "return", "new", "Blog", "(", "rs", ".", "getLong", "(", "1", ")", ",", "rs", ".", "getLong", "(", "2", ")", ",", "rs", ".", "getString", "(", "3", ")", ",", "rs", ".", "getString", "(", "4", ")", ",", "registeredTimestamp", ",", "lastUpdatedTimestamp", ")", ";", "}" ]
Creates a blog from a result set. @param rs The result set. @return The blog. @throws SQLException on database error.
[ "Creates", "a", "blog", "from", "a", "result", "set", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2719-L2739
153,471
attribyte/wpdb
src/main/java/org/attribyte/wp/db/DB.java
DB.selectPublicBlogs
public List<Blog> selectPublicBlogs() throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; List<Blog> blogs = Lists.newArrayListWithExpectedSize(4); Timer.Context ctx = metrics.selectBlogsTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectPublicBlogsSQL); rs = stmt.executeQuery(); while(rs.next()) { blogs.add(blogFromResultSet(rs)); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } return blogs; }
java
public List<Blog> selectPublicBlogs() throws SQLException { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; List<Blog> blogs = Lists.newArrayListWithExpectedSize(4); Timer.Context ctx = metrics.selectBlogsTimer.time(); try { conn = connectionSupplier.getConnection(); stmt = conn.prepareStatement(selectPublicBlogsSQL); rs = stmt.executeQuery(); while(rs.next()) { blogs.add(blogFromResultSet(rs)); } } finally { ctx.stop(); SQLUtil.closeQuietly(conn, stmt, rs); } return blogs; }
[ "public", "List", "<", "Blog", ">", "selectPublicBlogs", "(", ")", "throws", "SQLException", "{", "Connection", "conn", "=", "null", ";", "PreparedStatement", "stmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "List", "<", "Blog", ">", "blogs", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "4", ")", ";", "Timer", ".", "Context", "ctx", "=", "metrics", ".", "selectBlogsTimer", ".", "time", "(", ")", ";", "try", "{", "conn", "=", "connectionSupplier", ".", "getConnection", "(", ")", ";", "stmt", "=", "conn", ".", "prepareStatement", "(", "selectPublicBlogsSQL", ")", ";", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "blogs", ".", "add", "(", "blogFromResultSet", "(", "rs", ")", ")", ";", "}", "}", "finally", "{", "ctx", ".", "stop", "(", ")", ";", "SQLUtil", ".", "closeQuietly", "(", "conn", ",", "stmt", ",", "rs", ")", ";", "}", "return", "blogs", ";", "}" ]
Selects all public, enabled blogs. @return The list of blogs. @throws SQLException on database error.
[ "Selects", "all", "public", "enabled", "blogs", "." ]
b9adf6131dfb67899ebff770c9bfeb001cc42f30
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2748-L2768
153,472
jbundle/jbundle
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/PaperPrint.java
PaperPrint.surveyPage
public void surveyPage(PageFormat pageFormat, Graphics2D g2d, boolean bPrintHeader) { pageRect = new Rectangle((int)pageFormat.getImageableX(), (int)pageFormat.getImageableY(), (int)pageFormat.getImageableWidth(), (int)pageFormat.getImageableHeight()); FontMetrics fm = g2d.getFontMetrics(); int textHeight = fm.getHeight(); if (bPrintHeader) { headerHeight = textHeight + HEADER_MARGIN + BORDER; footerHeight = textHeight + HEADER_MARGIN + BORDER; } }
java
public void surveyPage(PageFormat pageFormat, Graphics2D g2d, boolean bPrintHeader) { pageRect = new Rectangle((int)pageFormat.getImageableX(), (int)pageFormat.getImageableY(), (int)pageFormat.getImageableWidth(), (int)pageFormat.getImageableHeight()); FontMetrics fm = g2d.getFontMetrics(); int textHeight = fm.getHeight(); if (bPrintHeader) { headerHeight = textHeight + HEADER_MARGIN + BORDER; footerHeight = textHeight + HEADER_MARGIN + BORDER; } }
[ "public", "void", "surveyPage", "(", "PageFormat", "pageFormat", ",", "Graphics2D", "g2d", ",", "boolean", "bPrintHeader", ")", "{", "pageRect", "=", "new", "Rectangle", "(", "(", "int", ")", "pageFormat", ".", "getImageableX", "(", ")", ",", "(", "int", ")", "pageFormat", ".", "getImageableY", "(", ")", ",", "(", "int", ")", "pageFormat", ".", "getImageableWidth", "(", ")", ",", "(", "int", ")", "pageFormat", ".", "getImageableHeight", "(", ")", ")", ";", "FontMetrics", "fm", "=", "g2d", ".", "getFontMetrics", "(", ")", ";", "int", "textHeight", "=", "fm", ".", "getHeight", "(", ")", ";", "if", "(", "bPrintHeader", ")", "{", "headerHeight", "=", "textHeight", "+", "HEADER_MARGIN", "+", "BORDER", ";", "footerHeight", "=", "textHeight", "+", "HEADER_MARGIN", "+", "BORDER", ";", "}", "}" ]
Save basic page information. @param pageFormat The pageformat from the print call. @param g2d The graphics environment from the print call.
[ "Save", "basic", "page", "information", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/PaperPrint.java#L57-L68
153,473
jbundle/jbundle
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/PaperPrint.java
PaperPrint.printHeader
protected void printHeader(Graphics2D g2d, String headerText) { FontMetrics fm = g2d.getFontMetrics(); int textHeight = fm.getHeight(); int stringWidth = fm.stringWidth(headerText); int textX = (pageRect.width - stringWidth) / 2 + pageRect.x; int textY = pageRect.y + textHeight + BORDER; g2d.drawString(headerText , textX, textY); }
java
protected void printHeader(Graphics2D g2d, String headerText) { FontMetrics fm = g2d.getFontMetrics(); int textHeight = fm.getHeight(); int stringWidth = fm.stringWidth(headerText); int textX = (pageRect.width - stringWidth) / 2 + pageRect.x; int textY = pageRect.y + textHeight + BORDER; g2d.drawString(headerText , textX, textY); }
[ "protected", "void", "printHeader", "(", "Graphics2D", "g2d", ",", "String", "headerText", ")", "{", "FontMetrics", "fm", "=", "g2d", ".", "getFontMetrics", "(", ")", ";", "int", "textHeight", "=", "fm", ".", "getHeight", "(", ")", ";", "int", "stringWidth", "=", "fm", ".", "stringWidth", "(", "headerText", ")", ";", "int", "textX", "=", "(", "pageRect", ".", "width", "-", "stringWidth", ")", "/", "2", "+", "pageRect", ".", "x", ";", "int", "textY", "=", "pageRect", ".", "y", "+", "textHeight", "+", "BORDER", ";", "g2d", ".", "drawString", "(", "headerText", ",", "textX", ",", "textY", ")", ";", "}" ]
Print the page header. @param g2d The graphics environment. @param headerText The text to print for the header.
[ "Print", "the", "page", "header", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/PaperPrint.java#L132-L140
153,474
jbundle/jbundle
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/PaperPrint.java
PaperPrint.printFooter
protected void printFooter(Graphics2D g2d, String footerText) { FontMetrics fm = g2d.getFontMetrics(); int stringWidth = fm.stringWidth(footerText); int textX = (pageRect.width - stringWidth) / 2 + pageRect.x; int textY = pageRect.y + pageRect.height - BORDER; g2d.drawString(footerText , textX, textY); }
java
protected void printFooter(Graphics2D g2d, String footerText) { FontMetrics fm = g2d.getFontMetrics(); int stringWidth = fm.stringWidth(footerText); int textX = (pageRect.width - stringWidth) / 2 + pageRect.x; int textY = pageRect.y + pageRect.height - BORDER; g2d.drawString(footerText , textX, textY); }
[ "protected", "void", "printFooter", "(", "Graphics2D", "g2d", ",", "String", "footerText", ")", "{", "FontMetrics", "fm", "=", "g2d", ".", "getFontMetrics", "(", ")", ";", "int", "stringWidth", "=", "fm", ".", "stringWidth", "(", "footerText", ")", ";", "int", "textX", "=", "(", "pageRect", ".", "width", "-", "stringWidth", ")", "/", "2", "+", "pageRect", ".", "x", ";", "int", "textY", "=", "pageRect", ".", "y", "+", "pageRect", ".", "height", "-", "BORDER", ";", "g2d", ".", "drawString", "(", "footerText", ",", "textX", ",", "textY", ")", ";", "}" ]
Print the page footer. @param g2d The graphics environment. @param footerText The text to print in the footer.
[ "Print", "the", "page", "footer", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/PaperPrint.java#L146-L153
153,475
tvesalainen/util
rpm/src/main/java/org/vesalainen/pm/deb/DEBBuilder.java
DEBBuilder.build
@Override public Path build(Path base) throws IOException { this.dir = base.resolve(name+"-"+version); this.debian = dir.resolve("debian"); control.setStandardsVersion(STANDARDS_VERSION); changeLog.set(name, version, release, maintainer); control.setSource(name); for (FileBuilder fb : fileBuilders) { fb.build(); } copyright.save(debian); control.save(debian); changeLog.save(debian); // compat Path compat = debian.resolve("compat"); try (BufferedWriter bf = Files.newBufferedWriter(compat, UTF_8)) { bf.append(String.format("%d\n", compatibility)); } for (MaintainerScript ms : maintainerScripts) { ms.save(); } // rules Path rules = debian.resolve("rules"); FileUtil.copyResource("/rules", rules, DEBBuilder.class); PosixHelp.setPermission(rules, "-rwxr-xr-x"); // source/format Path source = debian.resolve("source"); Files.createDirectories(source); Path format = source.resolve("format"); try (BufferedWriter bf = Files.newBufferedWriter(format, UTF_8)) { bf.append(SOURCE_FORMAT); } conffiles.save(debian); docs.save(debian); try { OSProcess.call(dir, null, "dpkg-buildpackage -us -uc"); } catch (InterruptedException ex) { throw new IOException(ex); } return dir; }
java
@Override public Path build(Path base) throws IOException { this.dir = base.resolve(name+"-"+version); this.debian = dir.resolve("debian"); control.setStandardsVersion(STANDARDS_VERSION); changeLog.set(name, version, release, maintainer); control.setSource(name); for (FileBuilder fb : fileBuilders) { fb.build(); } copyright.save(debian); control.save(debian); changeLog.save(debian); // compat Path compat = debian.resolve("compat"); try (BufferedWriter bf = Files.newBufferedWriter(compat, UTF_8)) { bf.append(String.format("%d\n", compatibility)); } for (MaintainerScript ms : maintainerScripts) { ms.save(); } // rules Path rules = debian.resolve("rules"); FileUtil.copyResource("/rules", rules, DEBBuilder.class); PosixHelp.setPermission(rules, "-rwxr-xr-x"); // source/format Path source = debian.resolve("source"); Files.createDirectories(source); Path format = source.resolve("format"); try (BufferedWriter bf = Files.newBufferedWriter(format, UTF_8)) { bf.append(SOURCE_FORMAT); } conffiles.save(debian); docs.save(debian); try { OSProcess.call(dir, null, "dpkg-buildpackage -us -uc"); } catch (InterruptedException ex) { throw new IOException(ex); } return dir; }
[ "@", "Override", "public", "Path", "build", "(", "Path", "base", ")", "throws", "IOException", "{", "this", ".", "dir", "=", "base", ".", "resolve", "(", "name", "+", "\"-\"", "+", "version", ")", ";", "this", ".", "debian", "=", "dir", ".", "resolve", "(", "\"debian\"", ")", ";", "control", ".", "setStandardsVersion", "(", "STANDARDS_VERSION", ")", ";", "changeLog", ".", "set", "(", "name", ",", "version", ",", "release", ",", "maintainer", ")", ";", "control", ".", "setSource", "(", "name", ")", ";", "for", "(", "FileBuilder", "fb", ":", "fileBuilders", ")", "{", "fb", ".", "build", "(", ")", ";", "}", "copyright", ".", "save", "(", "debian", ")", ";", "control", ".", "save", "(", "debian", ")", ";", "changeLog", ".", "save", "(", "debian", ")", ";", "// compat\r", "Path", "compat", "=", "debian", ".", "resolve", "(", "\"compat\"", ")", ";", "try", "(", "BufferedWriter", "bf", "=", "Files", ".", "newBufferedWriter", "(", "compat", ",", "UTF_8", ")", ")", "{", "bf", ".", "append", "(", "String", ".", "format", "(", "\"%d\\n\"", ",", "compatibility", ")", ")", ";", "}", "for", "(", "MaintainerScript", "ms", ":", "maintainerScripts", ")", "{", "ms", ".", "save", "(", ")", ";", "}", "// rules\r", "Path", "rules", "=", "debian", ".", "resolve", "(", "\"rules\"", ")", ";", "FileUtil", ".", "copyResource", "(", "\"/rules\"", ",", "rules", ",", "DEBBuilder", ".", "class", ")", ";", "PosixHelp", ".", "setPermission", "(", "rules", ",", "\"-rwxr-xr-x\"", ")", ";", "// source/format\r", "Path", "source", "=", "debian", ".", "resolve", "(", "\"source\"", ")", ";", "Files", ".", "createDirectories", "(", "source", ")", ";", "Path", "format", "=", "source", ".", "resolve", "(", "\"format\"", ")", ";", "try", "(", "BufferedWriter", "bf", "=", "Files", ".", "newBufferedWriter", "(", "format", ",", "UTF_8", ")", ")", "{", "bf", ".", "append", "(", "SOURCE_FORMAT", ")", ";", "}", "conffiles", ".", "save", "(", "debian", ")", ";", "docs", ".", "save", "(", "debian", ")", ";", "try", "{", "OSProcess", ".", "call", "(", "dir", ",", "null", ",", "\"dpkg-buildpackage -us -uc\"", ")", ";", "}", "catch", "(", "InterruptedException", "ex", ")", "{", "throw", "new", "IOException", "(", "ex", ")", ";", "}", "return", "dir", ";", "}" ]
Creates name-version directory creates debian source files and runs dpkg-buildpackage -us -uc @param base @return @throws IOException
[ "Creates", "name", "-", "version", "directory", "creates", "debian", "source", "files", "and", "runs", "dpkg", "-", "buildpackage", "-", "us", "-", "uc" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/rpm/src/main/java/org/vesalainen/pm/deb/DEBBuilder.java#L392-L441
153,476
jbundle/jbundle
app/program/plugin/src/main/java/org/jbundle/app/program/plugin/RunScriptMojo.java
RunScriptMojo.execute
public void execute() throws MojoExecutionException { if (properties == null) { getLog().warn("run-script failed: No properties supplied"); return; } boolean bSuccess = false; Environment env = null; RunScriptProcess process = null; try { env = new Environment(properties); Application app = new ThinApplication(env, properties, null); Task task = new AutoTask(app, null, null); process = new RunScriptProcess(task, null, null); bSuccess = (process.doRunCommand(null, properties) == DBConstants.NORMAL_RETURN); } catch (Exception e) { e.printStackTrace(); } finally { if (process != null) process.free(); if (env != null) env.free(); } if (bSuccess) getLog().info("run-script ran successfully: " + properties.get(DBParams.PROCESS)); else getLog().warn("run-script failed: " + properties.get(DBParams.PROCESS)); }
java
public void execute() throws MojoExecutionException { if (properties == null) { getLog().warn("run-script failed: No properties supplied"); return; } boolean bSuccess = false; Environment env = null; RunScriptProcess process = null; try { env = new Environment(properties); Application app = new ThinApplication(env, properties, null); Task task = new AutoTask(app, null, null); process = new RunScriptProcess(task, null, null); bSuccess = (process.doRunCommand(null, properties) == DBConstants.NORMAL_RETURN); } catch (Exception e) { e.printStackTrace(); } finally { if (process != null) process.free(); if (env != null) env.free(); } if (bSuccess) getLog().info("run-script ran successfully: " + properties.get(DBParams.PROCESS)); else getLog().warn("run-script failed: " + properties.get(DBParams.PROCESS)); }
[ "public", "void", "execute", "(", ")", "throws", "MojoExecutionException", "{", "if", "(", "properties", "==", "null", ")", "{", "getLog", "(", ")", ".", "warn", "(", "\"run-script failed: No properties supplied\"", ")", ";", "return", ";", "}", "boolean", "bSuccess", "=", "false", ";", "Environment", "env", "=", "null", ";", "RunScriptProcess", "process", "=", "null", ";", "try", "{", "env", "=", "new", "Environment", "(", "properties", ")", ";", "Application", "app", "=", "new", "ThinApplication", "(", "env", ",", "properties", ",", "null", ")", ";", "Task", "task", "=", "new", "AutoTask", "(", "app", ",", "null", ",", "null", ")", ";", "process", "=", "new", "RunScriptProcess", "(", "task", ",", "null", ",", "null", ")", ";", "bSuccess", "=", "(", "process", ".", "doRunCommand", "(", "null", ",", "properties", ")", "==", "DBConstants", ".", "NORMAL_RETURN", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "finally", "{", "if", "(", "process", "!=", "null", ")", "process", ".", "free", "(", ")", ";", "if", "(", "env", "!=", "null", ")", "env", ".", "free", "(", ")", ";", "}", "if", "(", "bSuccess", ")", "getLog", "(", ")", ".", "info", "(", "\"run-script ran successfully: \"", "+", "properties", ".", "get", "(", "DBParams", ".", "PROCESS", ")", ")", ";", "else", "getLog", "(", ")", ".", "warn", "(", "\"run-script failed: \"", "+", "properties", ".", "get", "(", "DBParams", ".", "PROCESS", ")", ")", ";", "}" ]
Execute the script mojo.
[ "Execute", "the", "script", "mojo", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/plugin/src/main/java/org/jbundle/app/program/plugin/RunScriptMojo.java#L40-L68
153,477
TealCube/hilt
src/main/java/com/tealcube/minecraft/bukkit/hilt/HiltItemStack.java
HiltItemStack.setName
public HiltItemStack setName(String name) { createItemMeta(); ItemMeta itemMeta = getItemMeta(); itemMeta.setDisplayName(name != null ? name.replace("\\s+", " ") : null); setItemMeta(itemMeta); return this; }
java
public HiltItemStack setName(String name) { createItemMeta(); ItemMeta itemMeta = getItemMeta(); itemMeta.setDisplayName(name != null ? name.replace("\\s+", " ") : null); setItemMeta(itemMeta); return this; }
[ "public", "HiltItemStack", "setName", "(", "String", "name", ")", "{", "createItemMeta", "(", ")", ";", "ItemMeta", "itemMeta", "=", "getItemMeta", "(", ")", ";", "itemMeta", ".", "setDisplayName", "(", "name", "!=", "null", "?", "name", ".", "replace", "(", "\"\\\\s+\"", ",", "\" \"", ")", ":", "null", ")", ";", "setItemMeta", "(", "itemMeta", ")", ";", "return", "this", ";", "}" ]
Sets the name of this ItemStack. Use null to remove name. @param name name to give the item @return this HiltItemStack with new name
[ "Sets", "the", "name", "of", "this", "ItemStack", ".", "Use", "null", "to", "remove", "name", "." ]
c3349b569e28a6f9e904f8417ba083bc913c8422
https://github.com/TealCube/hilt/blob/c3349b569e28a6f9e904f8417ba083bc913c8422/src/main/java/com/tealcube/minecraft/bukkit/hilt/HiltItemStack.java#L112-L118
153,478
TealCube/hilt
src/main/java/com/tealcube/minecraft/bukkit/hilt/HiltItemStack.java
HiltItemStack.getLore
public List<String> getLore() { createItemMeta(); if (getItemMeta().hasLore()) { return new ArrayList<>(getItemMeta().getLore()); } return new ArrayList<>(); }
java
public List<String> getLore() { createItemMeta(); if (getItemMeta().hasLore()) { return new ArrayList<>(getItemMeta().getLore()); } return new ArrayList<>(); }
[ "public", "List", "<", "String", ">", "getLore", "(", ")", "{", "createItemMeta", "(", ")", ";", "if", "(", "getItemMeta", "(", ")", ".", "hasLore", "(", ")", ")", "{", "return", "new", "ArrayList", "<>", "(", "getItemMeta", "(", ")", ".", "getLore", "(", ")", ")", ";", "}", "return", "new", "ArrayList", "<>", "(", ")", ";", "}" ]
Gets and returns the lore of this HiltItemStack. Grabs the lore from the ItemMeta if it has lore, otherwise returns an empty {@code List<String>}. @return lore of this item
[ "Gets", "and", "returns", "the", "lore", "of", "this", "HiltItemStack", "." ]
c3349b569e28a6f9e904f8417ba083bc913c8422
https://github.com/TealCube/hilt/blob/c3349b569e28a6f9e904f8417ba083bc913c8422/src/main/java/com/tealcube/minecraft/bukkit/hilt/HiltItemStack.java#L128-L134
153,479
TealCube/hilt
src/main/java/com/tealcube/minecraft/bukkit/hilt/HiltItemStack.java
HiltItemStack.setLore
public HiltItemStack setLore(List<String> lore) { createItemMeta(); ItemMeta itemMeta = getItemMeta(); itemMeta.setLore(lore); setItemMeta(itemMeta); return this; }
java
public HiltItemStack setLore(List<String> lore) { createItemMeta(); ItemMeta itemMeta = getItemMeta(); itemMeta.setLore(lore); setItemMeta(itemMeta); return this; }
[ "public", "HiltItemStack", "setLore", "(", "List", "<", "String", ">", "lore", ")", "{", "createItemMeta", "(", ")", ";", "ItemMeta", "itemMeta", "=", "getItemMeta", "(", ")", ";", "itemMeta", ".", "setLore", "(", "lore", ")", ";", "setItemMeta", "(", "itemMeta", ")", ";", "return", "this", ";", "}" ]
Sets the lore of this ItemStack. Use null to remove lore. @param lore lore to give the item @return this HiltItemStack with new lore
[ "Sets", "the", "lore", "of", "this", "ItemStack", ".", "Use", "null", "to", "remove", "lore", "." ]
c3349b569e28a6f9e904f8417ba083bc913c8422
https://github.com/TealCube/hilt/blob/c3349b569e28a6f9e904f8417ba083bc913c8422/src/main/java/com/tealcube/minecraft/bukkit/hilt/HiltItemStack.java#L142-L148
153,480
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/db/event/SoftDeleteDetailHandler.java
SoftDeleteDetailHandler.isSoftDeleteThisRecord
public boolean isSoftDeleteThisRecord() { Record recDetailOld = m_recDetail; Record recDetail = this.getDetailRecord(Record.findRecordOwner(this.getOwner())); if (m_recDetail != null) if (recDetailOld != m_recDetail) { recDetail.getRecordOwner().removeRecord(recDetail); this.getOwner().addListener(new FreeOnFreeHandler(recDetail)); } if (recDetail != null) { if (recDetail.getListener(SubFileFilter.class) == null) { recDetail.addListener(new SubFileFilter(this.getOwner())); } try { recDetail.close(); if (!recDetail.hasNext()) return false; // No detail records = hard delete the record. } catch (DBException ex) { ex.printStackTrace(); } } return super.isSoftDeleteThisRecord(); }
java
public boolean isSoftDeleteThisRecord() { Record recDetailOld = m_recDetail; Record recDetail = this.getDetailRecord(Record.findRecordOwner(this.getOwner())); if (m_recDetail != null) if (recDetailOld != m_recDetail) { recDetail.getRecordOwner().removeRecord(recDetail); this.getOwner().addListener(new FreeOnFreeHandler(recDetail)); } if (recDetail != null) { if (recDetail.getListener(SubFileFilter.class) == null) { recDetail.addListener(new SubFileFilter(this.getOwner())); } try { recDetail.close(); if (!recDetail.hasNext()) return false; // No detail records = hard delete the record. } catch (DBException ex) { ex.printStackTrace(); } } return super.isSoftDeleteThisRecord(); }
[ "public", "boolean", "isSoftDeleteThisRecord", "(", ")", "{", "Record", "recDetailOld", "=", "m_recDetail", ";", "Record", "recDetail", "=", "this", ".", "getDetailRecord", "(", "Record", ".", "findRecordOwner", "(", "this", ".", "getOwner", "(", ")", ")", ")", ";", "if", "(", "m_recDetail", "!=", "null", ")", "if", "(", "recDetailOld", "!=", "m_recDetail", ")", "{", "recDetail", ".", "getRecordOwner", "(", ")", ".", "removeRecord", "(", "recDetail", ")", ";", "this", ".", "getOwner", "(", ")", ".", "addListener", "(", "new", "FreeOnFreeHandler", "(", "recDetail", ")", ")", ";", "}", "if", "(", "recDetail", "!=", "null", ")", "{", "if", "(", "recDetail", ".", "getListener", "(", "SubFileFilter", ".", "class", ")", "==", "null", ")", "{", "recDetail", ".", "addListener", "(", "new", "SubFileFilter", "(", "this", ".", "getOwner", "(", ")", ")", ")", ";", "}", "try", "{", "recDetail", ".", "close", "(", ")", ";", "if", "(", "!", "recDetail", ".", "hasNext", "(", ")", ")", "return", "false", ";", "// No detail records = hard delete the record.", "}", "catch", "(", "DBException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "}", "return", "super", ".", "isSoftDeleteThisRecord", "(", ")", ";", "}" ]
Soft delete this record? Override this to decide whether to soft delete or physically delete the record. Soft delete if there are any detail record, otherwise hard delete this record.
[ "Soft", "delete", "this", "record?", "Override", "this", "to", "decide", "whether", "to", "soft", "delete", "or", "physically", "delete", "the", "record", ".", "Soft", "delete", "if", "there", "are", "any", "detail", "record", "otherwise", "hard", "delete", "this", "record", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/event/SoftDeleteDetailHandler.java#L95-L120
153,481
pressgang-ccms/PressGangCCMSRESTv1Common
src/main/java/org/jboss/pressgang/ccms/rest/v1/entities/base/RESTLogDetailsV1.java
RESTLogDetailsV1.setParameterToConfigured
protected void setParameterToConfigured(final String parameter) { if (configuredParameters == null) configuredParameters = new ArrayList<String>(); if (!configuredParameters.contains(parameter)) configuredParameters.add(parameter); }
java
protected void setParameterToConfigured(final String parameter) { if (configuredParameters == null) configuredParameters = new ArrayList<String>(); if (!configuredParameters.contains(parameter)) configuredParameters.add(parameter); }
[ "protected", "void", "setParameterToConfigured", "(", "final", "String", "parameter", ")", "{", "if", "(", "configuredParameters", "==", "null", ")", "configuredParameters", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "if", "(", "!", "configuredParameters", ".", "contains", "(", "parameter", ")", ")", "configuredParameters", ".", "add", "(", "parameter", ")", ";", "}" ]
This is a convenience method that adds a value to the configuredParameters collection @param parameter The parameter to specify as configured
[ "This", "is", "a", "convenience", "method", "that", "adds", "a", "value", "to", "the", "configuredParameters", "collection" ]
0641d21b127297b47035f3b8e55fba81251b419c
https://github.com/pressgang-ccms/PressGangCCMSRESTv1Common/blob/0641d21b127297b47035f3b8e55fba81251b419c/src/main/java/org/jboss/pressgang/ccms/rest/v1/entities/base/RESTLogDetailsV1.java#L123-L126
153,482
tvesalainen/util
util/src/main/java/org/vesalainen/math/Rect.java
Rect.reset
public void reset() { xMin = Double.NaN; xMax = Double.NaN; yMin = Double.NaN; yMax = Double.NaN; }
java
public void reset() { xMin = Double.NaN; xMax = Double.NaN; yMin = Double.NaN; yMax = Double.NaN; }
[ "public", "void", "reset", "(", ")", "{", "xMin", "=", "Double", ".", "NaN", ";", "xMax", "=", "Double", ".", "NaN", ";", "yMin", "=", "Double", ".", "NaN", ";", "yMax", "=", "Double", ".", "NaN", ";", "}" ]
Resets the limits.
[ "Resets", "the", "limits", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/math/Rect.java#L58-L64
153,483
tvesalainen/util
util/src/main/java/org/vesalainen/math/Rect.java
Rect.update
public void update(double x, double y, double radius) { update(x, y); update(x-radius, y-radius); update(x+radius, y-radius); update(x-radius, y+radius); update(x+radius, y+radius); }
java
public void update(double x, double y, double radius) { update(x, y); update(x-radius, y-radius); update(x+radius, y-radius); update(x-radius, y+radius); update(x+radius, y+radius); }
[ "public", "void", "update", "(", "double", "x", ",", "double", "y", ",", "double", "radius", ")", "{", "update", "(", "x", ",", "y", ")", ";", "update", "(", "x", "-", "radius", ",", "y", "-", "radius", ")", ";", "update", "(", "x", "+", "radius", ",", "y", "-", "radius", ")", ";", "update", "(", "x", "-", "radius", ",", "y", "+", "radius", ")", ";", "update", "(", "x", "+", "radius", ",", "y", "+", "radius", ")", ";", "}" ]
Updates limits so that circle is visible. @param x @param y @param radius
[ "Updates", "limits", "so", "that", "circle", "is", "visible", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/math/Rect.java#L71-L78
153,484
jmeetsma/Iglu-Util
src/main/java/org/ijsberg/iglu/util/collection/CollectionPart.java
CollectionPart.calculateCollectionPartDescriptions
private void calculateCollectionPartDescriptions() { collectionPartIds = new CollectionPartDescription[this.getNrofParts()]; int displayOffset = 0; int count = 0; for (count = 0; count < getNrofParts() - 1; count++) { displayOffset = count * maxPartSize; if (displayOffset != offset) { collectionPartIds[count] = new CollectionPartDescription(displayOffset, maxPartSize, false); } else { collectionPartIds[count] = new CollectionPartDescription(displayOffset, maxPartSize, true); currentCollectionPartIdIndex = count; } } displayOffset = count * maxPartSize; if (displayOffset != offset) { collectionPartIds[count] = new CollectionPartDescription(displayOffset, getLastPartSize(), false); } else { collectionPartIds[count] = new CollectionPartDescription(displayOffset, getLastPartSize(), true); currentCollectionPartIdIndex = count; } }
java
private void calculateCollectionPartDescriptions() { collectionPartIds = new CollectionPartDescription[this.getNrofParts()]; int displayOffset = 0; int count = 0; for (count = 0; count < getNrofParts() - 1; count++) { displayOffset = count * maxPartSize; if (displayOffset != offset) { collectionPartIds[count] = new CollectionPartDescription(displayOffset, maxPartSize, false); } else { collectionPartIds[count] = new CollectionPartDescription(displayOffset, maxPartSize, true); currentCollectionPartIdIndex = count; } } displayOffset = count * maxPartSize; if (displayOffset != offset) { collectionPartIds[count] = new CollectionPartDescription(displayOffset, getLastPartSize(), false); } else { collectionPartIds[count] = new CollectionPartDescription(displayOffset, getLastPartSize(), true); currentCollectionPartIdIndex = count; } }
[ "private", "void", "calculateCollectionPartDescriptions", "(", ")", "{", "collectionPartIds", "=", "new", "CollectionPartDescription", "[", "this", ".", "getNrofParts", "(", ")", "]", ";", "int", "displayOffset", "=", "0", ";", "int", "count", "=", "0", ";", "for", "(", "count", "=", "0", ";", "count", "<", "getNrofParts", "(", ")", "-", "1", ";", "count", "++", ")", "{", "displayOffset", "=", "count", "*", "maxPartSize", ";", "if", "(", "displayOffset", "!=", "offset", ")", "{", "collectionPartIds", "[", "count", "]", "=", "new", "CollectionPartDescription", "(", "displayOffset", ",", "maxPartSize", ",", "false", ")", ";", "}", "else", "{", "collectionPartIds", "[", "count", "]", "=", "new", "CollectionPartDescription", "(", "displayOffset", ",", "maxPartSize", ",", "true", ")", ";", "currentCollectionPartIdIndex", "=", "count", ";", "}", "}", "displayOffset", "=", "count", "*", "maxPartSize", ";", "if", "(", "displayOffset", "!=", "offset", ")", "{", "collectionPartIds", "[", "count", "]", "=", "new", "CollectionPartDescription", "(", "displayOffset", ",", "getLastPartSize", "(", ")", ",", "false", ")", ";", "}", "else", "{", "collectionPartIds", "[", "count", "]", "=", "new", "CollectionPartDescription", "(", "displayOffset", ",", "getLastPartSize", "(", ")", ",", "true", ")", ";", "currentCollectionPartIdIndex", "=", "count", ";", "}", "}" ]
Calculates offsets and sizes of all collection parts the complete collection is divided in.
[ "Calculates", "offsets", "and", "sizes", "of", "all", "collection", "parts", "the", "complete", "collection", "is", "divided", "in", "." ]
971eb022115247b1e34dc26dd02e7e621e29e910
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/collection/CollectionPart.java#L251-L274
153,485
yestech/yesepisodic
src/main/java/org/yestech/episodic/DefaultEpisodicService.java
DefaultEpisodicService.buildEpisodeMap
@SuppressWarnings({"ConstantConditions"}) private Map<String, String> buildEpisodeMap(String[] showIds, String[] episodeIds, String searchTerm, SearchType searchType, TagMode tagMode, Episode.EpisodeStatus status, SortBy sortBy, SortDir sortDir, Boolean includeViews, Integer page, Integer perPage, Integer embedWidth, Integer embedHeight) { Map<String, String> map = new HashMap<String, String>(); map.put("expires", expires()); if (showIds != null) map.put("show_id", join(showIds)); if (episodeIds != null) map.put("id", join(episodeIds)); if (searchTerm != null) map.put("search_type", searchType.name()); if (tagMode != null) map.put("tag_mode", tagMode.name()); if (status != null) map.put("status", status.name()); if (sortBy != null) map.put("sort_by", sortBy.name()); if (sortDir != null) map.put("sort_dir", sortDir.name()); if (includeViews != null) map.put("include_views", includeViews.toString()); if (page != null) map.put("page", page.toString()); if (perPage != null) map.put("per_page", perPage.toString()); if (embedWidth != null) map.put("embed_width", embedWidth.toString()); if (embedHeight != null) map.put("embed_height", embedHeight.toString()); return map; }
java
@SuppressWarnings({"ConstantConditions"}) private Map<String, String> buildEpisodeMap(String[] showIds, String[] episodeIds, String searchTerm, SearchType searchType, TagMode tagMode, Episode.EpisodeStatus status, SortBy sortBy, SortDir sortDir, Boolean includeViews, Integer page, Integer perPage, Integer embedWidth, Integer embedHeight) { Map<String, String> map = new HashMap<String, String>(); map.put("expires", expires()); if (showIds != null) map.put("show_id", join(showIds)); if (episodeIds != null) map.put("id", join(episodeIds)); if (searchTerm != null) map.put("search_type", searchType.name()); if (tagMode != null) map.put("tag_mode", tagMode.name()); if (status != null) map.put("status", status.name()); if (sortBy != null) map.put("sort_by", sortBy.name()); if (sortDir != null) map.put("sort_dir", sortDir.name()); if (includeViews != null) map.put("include_views", includeViews.toString()); if (page != null) map.put("page", page.toString()); if (perPage != null) map.put("per_page", perPage.toString()); if (embedWidth != null) map.put("embed_width", embedWidth.toString()); if (embedHeight != null) map.put("embed_height", embedHeight.toString()); return map; }
[ "@", "SuppressWarnings", "(", "{", "\"ConstantConditions\"", "}", ")", "private", "Map", "<", "String", ",", "String", ">", "buildEpisodeMap", "(", "String", "[", "]", "showIds", ",", "String", "[", "]", "episodeIds", ",", "String", "searchTerm", ",", "SearchType", "searchType", ",", "TagMode", "tagMode", ",", "Episode", ".", "EpisodeStatus", "status", ",", "SortBy", "sortBy", ",", "SortDir", "sortDir", ",", "Boolean", "includeViews", ",", "Integer", "page", ",", "Integer", "perPage", ",", "Integer", "embedWidth", ",", "Integer", "embedHeight", ")", "{", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "map", ".", "put", "(", "\"expires\"", ",", "expires", "(", ")", ")", ";", "if", "(", "showIds", "!=", "null", ")", "map", ".", "put", "(", "\"show_id\"", ",", "join", "(", "showIds", ")", ")", ";", "if", "(", "episodeIds", "!=", "null", ")", "map", ".", "put", "(", "\"id\"", ",", "join", "(", "episodeIds", ")", ")", ";", "if", "(", "searchTerm", "!=", "null", ")", "map", ".", "put", "(", "\"search_type\"", ",", "searchType", ".", "name", "(", ")", ")", ";", "if", "(", "tagMode", "!=", "null", ")", "map", ".", "put", "(", "\"tag_mode\"", ",", "tagMode", ".", "name", "(", ")", ")", ";", "if", "(", "status", "!=", "null", ")", "map", ".", "put", "(", "\"status\"", ",", "status", ".", "name", "(", ")", ")", ";", "if", "(", "sortBy", "!=", "null", ")", "map", ".", "put", "(", "\"sort_by\"", ",", "sortBy", ".", "name", "(", ")", ")", ";", "if", "(", "sortDir", "!=", "null", ")", "map", ".", "put", "(", "\"sort_dir\"", ",", "sortDir", ".", "name", "(", ")", ")", ";", "if", "(", "includeViews", "!=", "null", ")", "map", ".", "put", "(", "\"include_views\"", ",", "includeViews", ".", "toString", "(", ")", ")", ";", "if", "(", "page", "!=", "null", ")", "map", ".", "put", "(", "\"page\"", ",", "page", ".", "toString", "(", ")", ")", ";", "if", "(", "perPage", "!=", "null", ")", "map", ".", "put", "(", "\"per_page\"", ",", "perPage", ".", "toString", "(", ")", ")", ";", "if", "(", "embedWidth", "!=", "null", ")", "map", ".", "put", "(", "\"embed_width\"", ",", "embedWidth", ".", "toString", "(", ")", ")", ";", "if", "(", "embedHeight", "!=", "null", ")", "map", ".", "put", "(", "\"embed_height\"", ",", "embedHeight", ".", "toString", "(", ")", ")", ";", "return", "map", ";", "}" ]
split out because episode map method was too complex for intellij
[ "split", "out", "because", "episode", "map", "method", "was", "too", "complex", "for", "intellij" ]
ed9699443871a44d51e149f32769b4d84cded63d
https://github.com/yestech/yesepisodic/blob/ed9699443871a44d51e149f32769b4d84cded63d/src/main/java/org/yestech/episodic/DefaultEpisodicService.java#L293-L313
153,486
lightblueseas/vintage-time
src/main/java/de/alpharogroup/date/ConvertDateExtensions.java
ConvertDateExtensions.toCalendar
public static Calendar toCalendar(final long millis) { final Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(millis); return calendar; }
java
public static Calendar toCalendar(final long millis) { final Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(millis); return calendar; }
[ "public", "static", "Calendar", "toCalendar", "(", "final", "long", "millis", ")", "{", "final", "Calendar", "calendar", "=", "Calendar", ".", "getInstance", "(", ")", ";", "calendar", ".", "setTimeInMillis", "(", "millis", ")", ";", "return", "calendar", ";", "}" ]
Converts the given long value to a calendar object. @param millis the millis @return the calendar
[ "Converts", "the", "given", "long", "value", "to", "a", "calendar", "object", "." ]
fbf201e679d9f9b92e7b5771f3eea1413cc2e113
https://github.com/lightblueseas/vintage-time/blob/fbf201e679d9f9b92e7b5771f3eea1413cc2e113/src/main/java/de/alpharogroup/date/ConvertDateExtensions.java#L65-L70
153,487
lightblueseas/vintage-time
src/main/java/de/alpharogroup/date/ConvertDateExtensions.java
ConvertDateExtensions.toTimestamp
public static Timestamp toTimestamp(final Date date) { final Calendar cal = new GregorianCalendar(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return new Timestamp(cal.getTime().getTime()); }
java
public static Timestamp toTimestamp(final Date date) { final Calendar cal = new GregorianCalendar(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return new Timestamp(cal.getTime().getTime()); }
[ "public", "static", "Timestamp", "toTimestamp", "(", "final", "Date", "date", ")", "{", "final", "Calendar", "cal", "=", "new", "GregorianCalendar", "(", ")", ";", "cal", ".", "setTime", "(", "date", ")", ";", "cal", ".", "set", "(", "Calendar", ".", "HOUR_OF_DAY", ",", "0", ")", ";", "cal", ".", "set", "(", "Calendar", ".", "MINUTE", ",", "0", ")", ";", "cal", ".", "set", "(", "Calendar", ".", "SECOND", ",", "0", ")", ";", "cal", ".", "set", "(", "Calendar", ".", "MILLISECOND", ",", "0", ")", ";", "return", "new", "Timestamp", "(", "cal", ".", "getTime", "(", ")", ".", "getTime", "(", ")", ")", ";", "}" ]
Converts a Date to a Timestamp-object. @param date The date to convert. @return The Timestamp from the date.
[ "Converts", "a", "Date", "to", "a", "Timestamp", "-", "object", "." ]
fbf201e679d9f9b92e7b5771f3eea1413cc2e113
https://github.com/lightblueseas/vintage-time/blob/fbf201e679d9f9b92e7b5771f3eea1413cc2e113/src/main/java/de/alpharogroup/date/ConvertDateExtensions.java#L103-L113
153,488
PuyallupFoursquare/ccb-api-client-java
src/main/java/com/p4square/ccbapi/serializer/AbstractFormSerializer.java
AbstractFormSerializer.appendField
protected void appendField(final StringBuilder builder, final String key, final int value) { if (builder.length() > 0) { builder.append("&"); } builder.append(key).append("=").append(value); }
java
protected void appendField(final StringBuilder builder, final String key, final int value) { if (builder.length() > 0) { builder.append("&"); } builder.append(key).append("=").append(value); }
[ "protected", "void", "appendField", "(", "final", "StringBuilder", "builder", ",", "final", "String", "key", ",", "final", "int", "value", ")", "{", "if", "(", "builder", ".", "length", "(", ")", ">", "0", ")", "{", "builder", ".", "append", "(", "\"&\"", ")", ";", "}", "builder", ".", "append", "(", "key", ")", ".", "append", "(", "\"=\"", ")", ".", "append", "(", "value", ")", ";", "}" ]
Append an integer field to the form. @param builder The StringBuilder to use. @param key The form key, which must be URLEncoded before calling this method. @param value The value associated with the key.
[ "Append", "an", "integer", "field", "to", "the", "form", "." ]
54a7a3184dc565fe513aa520e1344b2303ea6834
https://github.com/PuyallupFoursquare/ccb-api-client-java/blob/54a7a3184dc565fe513aa520e1344b2303ea6834/src/main/java/com/p4square/ccbapi/serializer/AbstractFormSerializer.java#L67-L72
153,489
PuyallupFoursquare/ccb-api-client-java
src/main/java/com/p4square/ccbapi/serializer/AbstractFormSerializer.java
AbstractFormSerializer.appendField
protected void appendField(final StringBuilder builder, final String key, final LocalDate value) { appendField(builder, key, value.toString()); }
java
protected void appendField(final StringBuilder builder, final String key, final LocalDate value) { appendField(builder, key, value.toString()); }
[ "protected", "void", "appendField", "(", "final", "StringBuilder", "builder", ",", "final", "String", "key", ",", "final", "LocalDate", "value", ")", "{", "appendField", "(", "builder", ",", "key", ",", "value", ".", "toString", "(", ")", ")", ";", "}" ]
Append a LocalDate field to the form. @param builder The StringBuilder to use. @param key The form key, which must be URLEncoded before calling this method. @param value The value associated with the key.
[ "Append", "a", "LocalDate", "field", "to", "the", "form", "." ]
54a7a3184dc565fe513aa520e1344b2303ea6834
https://github.com/PuyallupFoursquare/ccb-api-client-java/blob/54a7a3184dc565fe513aa520e1344b2303ea6834/src/main/java/com/p4square/ccbapi/serializer/AbstractFormSerializer.java#L95-L98
153,490
nwillc/almost-functional
src/main/java/almost/functional/utils/Iterators.java
Iterators.collect
public static <T> List<T> collect(Iterator<T> iterator) { List<T> list = new ArrayList<T>(); while (iterator.hasNext()) { list.add(iterator.next()); } return list; }
java
public static <T> List<T> collect(Iterator<T> iterator) { List<T> list = new ArrayList<T>(); while (iterator.hasNext()) { list.add(iterator.next()); } return list; }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "collect", "(", "Iterator", "<", "T", ">", "iterator", ")", "{", "List", "<", "T", ">", "list", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "list", ".", "add", "(", "iterator", ".", "next", "(", ")", ")", ";", "}", "return", "list", ";", "}" ]
Collect an iterator's elements into a List. @param iterator the iterator @param <T> the element type @return a List containing the elements @since 1.9.3
[ "Collect", "an", "iterator", "s", "elements", "into", "a", "List", "." ]
a6cc7c73b2be475ed1bce5128c24b2eb9c27d666
https://github.com/nwillc/almost-functional/blob/a6cc7c73b2be475ed1bce5128c24b2eb9c27d666/src/main/java/almost/functional/utils/Iterators.java#L76-L82
153,491
nwillc/almost-functional
src/main/java/almost/functional/utils/Iterators.java
Iterators.parallelBatch
public static <T> void parallelBatch(Iterator<? extends T> iterator, final Consumer<Iterator<? extends T>> consumer, int batchSize) throws InterruptedException, ExecutionException { List<Callable<Boolean>> callables = new ArrayList<Callable<Boolean>>(); while (iterator.hasNext()) { Iterator<T> i = next(iterator, batchSize); final List<T> list = collect(i); callables.add(new Callable<Boolean>() { @Override public Boolean call() throws Exception { consumer.accept(list.iterator()); return true; } }); } List<Future<Boolean>> futures = EXECUTOR_SERVICE.invokeAll(callables); for (Future<Boolean> future : futures) { future.get(); } }
java
public static <T> void parallelBatch(Iterator<? extends T> iterator, final Consumer<Iterator<? extends T>> consumer, int batchSize) throws InterruptedException, ExecutionException { List<Callable<Boolean>> callables = new ArrayList<Callable<Boolean>>(); while (iterator.hasNext()) { Iterator<T> i = next(iterator, batchSize); final List<T> list = collect(i); callables.add(new Callable<Boolean>() { @Override public Boolean call() throws Exception { consumer.accept(list.iterator()); return true; } }); } List<Future<Boolean>> futures = EXECUTOR_SERVICE.invokeAll(callables); for (Future<Boolean> future : futures) { future.get(); } }
[ "public", "static", "<", "T", ">", "void", "parallelBatch", "(", "Iterator", "<", "?", "extends", "T", ">", "iterator", ",", "final", "Consumer", "<", "Iterator", "<", "?", "extends", "T", ">", ">", "consumer", ",", "int", "batchSize", ")", "throws", "InterruptedException", ",", "ExecutionException", "{", "List", "<", "Callable", "<", "Boolean", ">>", "callables", "=", "new", "ArrayList", "<", "Callable", "<", "Boolean", ">", ">", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "Iterator", "<", "T", ">", "i", "=", "next", "(", "iterator", ",", "batchSize", ")", ";", "final", "List", "<", "T", ">", "list", "=", "collect", "(", "i", ")", ";", "callables", ".", "add", "(", "new", "Callable", "<", "Boolean", ">", "(", ")", "{", "@", "Override", "public", "Boolean", "call", "(", ")", "throws", "Exception", "{", "consumer", ".", "accept", "(", "list", ".", "iterator", "(", ")", ")", ";", "return", "true", ";", "}", "}", ")", ";", "}", "List", "<", "Future", "<", "Boolean", ">", ">", "futures", "=", "EXECUTOR_SERVICE", ".", "invokeAll", "(", "callables", ")", ";", "for", "(", "Future", "<", "Boolean", ">", "future", ":", "futures", ")", "{", "future", ".", "get", "(", ")", ";", "}", "}" ]
Break an iterator's elements into batches, and invoke the consumer on these batches in a thread pool. @param iterator the iterator to draw elements from @param consumer the Consumer to use the batches @param batchSize the maximum number of elements per batch @param <T> the element type @throws InterruptedException @throws ExecutionException @since 1.9.3
[ "Break", "an", "iterator", "s", "elements", "into", "batches", "and", "invoke", "the", "consumer", "on", "these", "batches", "in", "a", "thread", "pool", "." ]
a6cc7c73b2be475ed1bce5128c24b2eb9c27d666
https://github.com/nwillc/almost-functional/blob/a6cc7c73b2be475ed1bce5128c24b2eb9c27d666/src/main/java/almost/functional/utils/Iterators.java#L95-L114
153,492
nwillc/almost-functional
src/main/java/almost/functional/utils/Iterators.java
Iterators.concat
public static <T> Iterator<T> concat(final Iterator<? extends T>... iterators) { return new ImmutableIterator<T>() { int current = 0; @Override public boolean hasNext() { advance(); return current < iterators.length; } @Override public T next() { advance(); try { return iterators[current].next(); } catch (ArrayIndexOutOfBoundsException e) { throw new NoSuchElementException(); } } private void advance() { while (current < iterators.length && !iterators[current].hasNext()) { current++; } } }; }
java
public static <T> Iterator<T> concat(final Iterator<? extends T>... iterators) { return new ImmutableIterator<T>() { int current = 0; @Override public boolean hasNext() { advance(); return current < iterators.length; } @Override public T next() { advance(); try { return iterators[current].next(); } catch (ArrayIndexOutOfBoundsException e) { throw new NoSuchElementException(); } } private void advance() { while (current < iterators.length && !iterators[current].hasNext()) { current++; } } }; }
[ "public", "static", "<", "T", ">", "Iterator", "<", "T", ">", "concat", "(", "final", "Iterator", "<", "?", "extends", "T", ">", "...", "iterators", ")", "{", "return", "new", "ImmutableIterator", "<", "T", ">", "(", ")", "{", "int", "current", "=", "0", ";", "@", "Override", "public", "boolean", "hasNext", "(", ")", "{", "advance", "(", ")", ";", "return", "current", "<", "iterators", ".", "length", ";", "}", "@", "Override", "public", "T", "next", "(", ")", "{", "advance", "(", ")", ";", "try", "{", "return", "iterators", "[", "current", "]", ".", "next", "(", ")", ";", "}", "catch", "(", "ArrayIndexOutOfBoundsException", "e", ")", "{", "throw", "new", "NoSuchElementException", "(", ")", ";", "}", "}", "private", "void", "advance", "(", ")", "{", "while", "(", "current", "<", "iterators", ".", "length", "&&", "!", "iterators", "[", "current", "]", ".", "hasNext", "(", ")", ")", "{", "current", "++", ";", "}", "}", "}", ";", "}" ]
Create an iterator which sequentially iterates over a collection of iterators. @param iterators the iterators to iterate @param <T> the element type @return the new iterator
[ "Create", "an", "iterator", "which", "sequentially", "iterates", "over", "a", "collection", "of", "iterators", "." ]
a6cc7c73b2be475ed1bce5128c24b2eb9c27d666
https://github.com/nwillc/almost-functional/blob/a6cc7c73b2be475ed1bce5128c24b2eb9c27d666/src/main/java/almost/functional/utils/Iterators.java#L123-L149
153,493
tvesalainen/util
util/src/main/java/org/vesalainen/math/sliding/AbstractSlidingBound.java
AbstractSlidingBound.grow
@Override protected void grow() { int newSize = newSize(); ring = (double[]) newArray(ring, size, new double[newSize]); size = newSize; }
java
@Override protected void grow() { int newSize = newSize(); ring = (double[]) newArray(ring, size, new double[newSize]); size = newSize; }
[ "@", "Override", "protected", "void", "grow", "(", ")", "{", "int", "newSize", "=", "newSize", "(", ")", ";", "ring", "=", "(", "double", "[", "]", ")", "newArray", "(", "ring", ",", "size", ",", "new", "double", "[", "newSize", "]", ")", ";", "size", "=", "newSize", ";", "}" ]
Grows ring buffer
[ "Grows", "ring", "buffer" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/math/sliding/AbstractSlidingBound.java#L122-L128
153,494
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/field/event/MultDepHandler.java
MultDepHandler.setDependentListener
public void setDependentListener(BaseListener dependentListener) { // Add this to the multi-dependecy if (dependentListener == null) return; boolean bAddToList = true; for (BaseListener listener : m_BehaviorList) { if (listener == dependentListener); bAddToList = false;; // Already co-dependent } if (bAddToList) m_BehaviorList.addElement(dependentListener); if (dependentListener != null) if (dependentListener.getDependentListener() == null) dependentListener.setDependentListener(this); // Dependent on each other! }
java
public void setDependentListener(BaseListener dependentListener) { // Add this to the multi-dependecy if (dependentListener == null) return; boolean bAddToList = true; for (BaseListener listener : m_BehaviorList) { if (listener == dependentListener); bAddToList = false;; // Already co-dependent } if (bAddToList) m_BehaviorList.addElement(dependentListener); if (dependentListener != null) if (dependentListener.getDependentListener() == null) dependentListener.setDependentListener(this); // Dependent on each other! }
[ "public", "void", "setDependentListener", "(", "BaseListener", "dependentListener", ")", "{", "// Add this to the multi-dependecy", "if", "(", "dependentListener", "==", "null", ")", "return", ";", "boolean", "bAddToList", "=", "true", ";", "for", "(", "BaseListener", "listener", ":", "m_BehaviorList", ")", "{", "if", "(", "listener", "==", "dependentListener", ")", ";", "bAddToList", "=", "false", ";", ";", "// Already co-dependent", "}", "if", "(", "bAddToList", ")", "m_BehaviorList", ".", "addElement", "(", "dependentListener", ")", ";", "if", "(", "dependentListener", "!=", "null", ")", "if", "(", "dependentListener", ".", "getDependentListener", "(", ")", "==", "null", ")", "dependentListener", ".", "setDependentListener", "(", "this", ")", ";", "// Dependent on each other!", "}" ]
Set this listener to be dependent on this. @param dependentListener A dependent listener to add to the list.
[ "Set", "this", "listener", "to", "be", "dependent", "on", "this", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/event/MultDepHandler.java#L91-L106
153,495
tvesalainen/util
util/src/main/java/org/vesalainen/nio/Splitter.java
Splitter.split
public int split(T obj, int start, int length) throws IOException { int count = 0; if (length > 0) { int end = (start + length) % size; if (start < end) { count = op(obj, start, end); } else { if (end > 0) { count = op(obj, start, size, 0, end); } else { count = op(obj, start, size); } } } assert count <= length; return count; }
java
public int split(T obj, int start, int length) throws IOException { int count = 0; if (length > 0) { int end = (start + length) % size; if (start < end) { count = op(obj, start, end); } else { if (end > 0) { count = op(obj, start, size, 0, end); } else { count = op(obj, start, size); } } } assert count <= length; return count; }
[ "public", "int", "split", "(", "T", "obj", ",", "int", "start", ",", "int", "length", ")", "throws", "IOException", "{", "int", "count", "=", "0", ";", "if", "(", "length", ">", "0", ")", "{", "int", "end", "=", "(", "start", "+", "length", ")", "%", "size", ";", "if", "(", "start", "<", "end", ")", "{", "count", "=", "op", "(", "obj", ",", "start", ",", "end", ")", ";", "}", "else", "{", "if", "(", "end", ">", "0", ")", "{", "count", "=", "op", "(", "obj", ",", "start", ",", "size", ",", "0", ",", "end", ")", ";", "}", "else", "{", "count", "=", "op", "(", "obj", ",", "start", ",", "size", ")", ";", "}", "}", "}", "assert", "count", "<=", "length", ";", "return", "count", ";", "}" ]
Calls either of two op methods depending on start + length > size. If so calls op with 5 parameters, otherwise op with 3 parameters. @param obj @param start @param length @return @throws IOException
[ "Calls", "either", "of", "two", "op", "methods", "depending", "on", "start", "+", "length", ">", "size", ".", "If", "so", "calls", "op", "with", "5", "parameters", "otherwise", "op", "with", "3", "parameters", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/Splitter.java#L47-L71
153,496
etnetera/seb
src/main/java/cz/etnetera/seb/event/SebEvent.java
SebEvent.init
public void init() { sebLabel = context.getSeb().getLabel(); label = generateLabel(); filePrefix = context.getUtils().join(Seb.LABEL_DELIMITER, time.format(Seb.FILE_DATE_FORMATTER), sebLabel, context.getClass().getSimpleName(), label); }
java
public void init() { sebLabel = context.getSeb().getLabel(); label = generateLabel(); filePrefix = context.getUtils().join(Seb.LABEL_DELIMITER, time.format(Seb.FILE_DATE_FORMATTER), sebLabel, context.getClass().getSimpleName(), label); }
[ "public", "void", "init", "(", ")", "{", "sebLabel", "=", "context", ".", "getSeb", "(", ")", ".", "getLabel", "(", ")", ";", "label", "=", "generateLabel", "(", ")", ";", "filePrefix", "=", "context", ".", "getUtils", "(", ")", ".", "join", "(", "Seb", ".", "LABEL_DELIMITER", ",", "time", ".", "format", "(", "Seb", ".", "FILE_DATE_FORMATTER", ")", ",", "sebLabel", ",", "context", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ",", "label", ")", ";", "}" ]
Is called before event is triggered.
[ "Is", "called", "before", "event", "is", "triggered", "." ]
6aed29c7726db12f440c60cfd253de229064ed04
https://github.com/etnetera/seb/blob/6aed29c7726db12f440c60cfd253de229064ed04/src/main/java/cz/etnetera/seb/event/SebEvent.java#L75-L79
153,497
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/structures/TopicErrorData.java
TopicErrorData.hasTranslationErrors
public boolean hasTranslationErrors() { for (final TopicErrorDatabase.ErrorType type : errorTypes) { if (TopicErrorDatabase.TRANSLATION_ERROR_TYPES.contains(type)) { return true; } } return false; }
java
public boolean hasTranslationErrors() { for (final TopicErrorDatabase.ErrorType type : errorTypes) { if (TopicErrorDatabase.TRANSLATION_ERROR_TYPES.contains(type)) { return true; } } return false; }
[ "public", "boolean", "hasTranslationErrors", "(", ")", "{", "for", "(", "final", "TopicErrorDatabase", ".", "ErrorType", "type", ":", "errorTypes", ")", "{", "if", "(", "TopicErrorDatabase", ".", "TRANSLATION_ERROR_TYPES", ".", "contains", "(", "type", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks to see if the Topic has any translation based errors set against it. @return True if there are any errors for the Topic, that are of a translation type.
[ "Checks", "to", "see", "if", "the", "Topic", "has", "any", "translation", "based", "errors", "set", "against", "it", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/structures/TopicErrorData.java#L82-L90
153,498
pressgang-ccms/PressGangCCMSBuilder
src/main/java/org/jboss/pressgang/ccms/contentspec/builder/structures/TopicErrorData.java
TopicErrorData.hasFatalErrors
public boolean hasFatalErrors() { for (final TopicErrorDatabase.ErrorType type : errorTypes) { if (TopicErrorDatabase.FATAL_ERROR_TYPES.contains(type)) { return true; } } return false; }
java
public boolean hasFatalErrors() { for (final TopicErrorDatabase.ErrorType type : errorTypes) { if (TopicErrorDatabase.FATAL_ERROR_TYPES.contains(type)) { return true; } } return false; }
[ "public", "boolean", "hasFatalErrors", "(", ")", "{", "for", "(", "final", "TopicErrorDatabase", ".", "ErrorType", "type", ":", "errorTypes", ")", "{", "if", "(", "TopicErrorDatabase", ".", "FATAL_ERROR_TYPES", ".", "contains", "(", "type", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks to see if the Topic has any regular errors set against it. @return True if there are any errors for the Topic, that are of a basic/normal type.
[ "Checks", "to", "see", "if", "the", "Topic", "has", "any", "regular", "errors", "set", "against", "it", "." ]
5436d36ba1b3c5baa246b270e5fc350e6778bce8
https://github.com/pressgang-ccms/PressGangCCMSBuilder/blob/5436d36ba1b3c5baa246b270e5fc350e6778bce8/src/main/java/org/jboss/pressgang/ccms/contentspec/builder/structures/TopicErrorData.java#L97-L105
153,499
jbundle/jbundle
main/calendar/src/main/java/org/jbundle/main/calendar/db/CalendarControl.java
CalendarControl.updateDatesAndCalendar
public void updateDatesAndCalendar() { if ((this.getEditMode() == DBConstants.EDIT_NONE) || (this.getEditMode() == DBConstants.EDIT_ADD)) return; // Only on initial setup boolean bUpdateDates = false; int iUpdateDays = (int)this.getField(CalendarControl.UPDATE_DAYS).getValue(); Calendar calNow = new GregorianCalendar(); if ((this.getField(CalendarControl.START_ANNIV_DATE).isNull()) || (this.getField(CalendarControl.END_ANNIV_DATE).isNull())) bUpdateDates = true; else { Calendar calCutoff = ((DateTimeField)this.getField(CalendarControl.LAST_UPDATE_DATE)).getCalendar(); calCutoff.add(Calendar.DAY_OF_YEAR, iUpdateDays); if (calNow.after(calCutoff)) bUpdateDates = true; } if (bUpdateDates) { int iBackDays = (int)this.getField(CalendarControl.ANNIV_BACK_DAYS).getValue(); int iRangeDays = (int)this.getField(CalendarControl.ANNIVERSARY_DAYS).getValue(); Calendar calStart = (Calendar)calNow.clone(); calStart.add(Calendar.DAY_OF_YEAR, -iBackDays); Calendar calEnd = (Calendar)calStart.clone(); calEnd.add(Calendar.DAY_OF_YEAR, iRangeDays - iBackDays); Calendar calOldEnd = ((DateTimeField)this.getField(CalendarControl.END_ANNIV_DATE)).getCalendar(); if (calOldEnd == null) calOldEnd = calNow; ((DateTimeField)this.getField(CalendarControl.START_ANNIV_DATE)).setCalendar(calStart, true, DBConstants.SCREEN_MOVE); ((DateTimeField)this.getField(CalendarControl.END_ANNIV_DATE)).setCalendar(calEnd, true, DBConstants.SCREEN_MOVE); ((DateTimeField)this.getField(CalendarControl.LAST_UPDATE_DATE)).setCalendar(calNow, true, DBConstants.SCREEN_MOVE); this.updateCalendar(calOldEnd, calEnd); // Update the calendar try { this.writeAndRefresh(); } catch (DBException ex) { ex.printStackTrace(); } } }
java
public void updateDatesAndCalendar() { if ((this.getEditMode() == DBConstants.EDIT_NONE) || (this.getEditMode() == DBConstants.EDIT_ADD)) return; // Only on initial setup boolean bUpdateDates = false; int iUpdateDays = (int)this.getField(CalendarControl.UPDATE_DAYS).getValue(); Calendar calNow = new GregorianCalendar(); if ((this.getField(CalendarControl.START_ANNIV_DATE).isNull()) || (this.getField(CalendarControl.END_ANNIV_DATE).isNull())) bUpdateDates = true; else { Calendar calCutoff = ((DateTimeField)this.getField(CalendarControl.LAST_UPDATE_DATE)).getCalendar(); calCutoff.add(Calendar.DAY_OF_YEAR, iUpdateDays); if (calNow.after(calCutoff)) bUpdateDates = true; } if (bUpdateDates) { int iBackDays = (int)this.getField(CalendarControl.ANNIV_BACK_DAYS).getValue(); int iRangeDays = (int)this.getField(CalendarControl.ANNIVERSARY_DAYS).getValue(); Calendar calStart = (Calendar)calNow.clone(); calStart.add(Calendar.DAY_OF_YEAR, -iBackDays); Calendar calEnd = (Calendar)calStart.clone(); calEnd.add(Calendar.DAY_OF_YEAR, iRangeDays - iBackDays); Calendar calOldEnd = ((DateTimeField)this.getField(CalendarControl.END_ANNIV_DATE)).getCalendar(); if (calOldEnd == null) calOldEnd = calNow; ((DateTimeField)this.getField(CalendarControl.START_ANNIV_DATE)).setCalendar(calStart, true, DBConstants.SCREEN_MOVE); ((DateTimeField)this.getField(CalendarControl.END_ANNIV_DATE)).setCalendar(calEnd, true, DBConstants.SCREEN_MOVE); ((DateTimeField)this.getField(CalendarControl.LAST_UPDATE_DATE)).setCalendar(calNow, true, DBConstants.SCREEN_MOVE); this.updateCalendar(calOldEnd, calEnd); // Update the calendar try { this.writeAndRefresh(); } catch (DBException ex) { ex.printStackTrace(); } } }
[ "public", "void", "updateDatesAndCalendar", "(", ")", "{", "if", "(", "(", "this", ".", "getEditMode", "(", ")", "==", "DBConstants", ".", "EDIT_NONE", ")", "||", "(", "this", ".", "getEditMode", "(", ")", "==", "DBConstants", ".", "EDIT_ADD", ")", ")", "return", ";", "// Only on initial setup", "boolean", "bUpdateDates", "=", "false", ";", "int", "iUpdateDays", "=", "(", "int", ")", "this", ".", "getField", "(", "CalendarControl", ".", "UPDATE_DAYS", ")", ".", "getValue", "(", ")", ";", "Calendar", "calNow", "=", "new", "GregorianCalendar", "(", ")", ";", "if", "(", "(", "this", ".", "getField", "(", "CalendarControl", ".", "START_ANNIV_DATE", ")", ".", "isNull", "(", ")", ")", "||", "(", "this", ".", "getField", "(", "CalendarControl", ".", "END_ANNIV_DATE", ")", ".", "isNull", "(", ")", ")", ")", "bUpdateDates", "=", "true", ";", "else", "{", "Calendar", "calCutoff", "=", "(", "(", "DateTimeField", ")", "this", ".", "getField", "(", "CalendarControl", ".", "LAST_UPDATE_DATE", ")", ")", ".", "getCalendar", "(", ")", ";", "calCutoff", ".", "add", "(", "Calendar", ".", "DAY_OF_YEAR", ",", "iUpdateDays", ")", ";", "if", "(", "calNow", ".", "after", "(", "calCutoff", ")", ")", "bUpdateDates", "=", "true", ";", "}", "if", "(", "bUpdateDates", ")", "{", "int", "iBackDays", "=", "(", "int", ")", "this", ".", "getField", "(", "CalendarControl", ".", "ANNIV_BACK_DAYS", ")", ".", "getValue", "(", ")", ";", "int", "iRangeDays", "=", "(", "int", ")", "this", ".", "getField", "(", "CalendarControl", ".", "ANNIVERSARY_DAYS", ")", ".", "getValue", "(", ")", ";", "Calendar", "calStart", "=", "(", "Calendar", ")", "calNow", ".", "clone", "(", ")", ";", "calStart", ".", "add", "(", "Calendar", ".", "DAY_OF_YEAR", ",", "-", "iBackDays", ")", ";", "Calendar", "calEnd", "=", "(", "Calendar", ")", "calStart", ".", "clone", "(", ")", ";", "calEnd", ".", "add", "(", "Calendar", ".", "DAY_OF_YEAR", ",", "iRangeDays", "-", "iBackDays", ")", ";", "Calendar", "calOldEnd", "=", "(", "(", "DateTimeField", ")", "this", ".", "getField", "(", "CalendarControl", ".", "END_ANNIV_DATE", ")", ")", ".", "getCalendar", "(", ")", ";", "if", "(", "calOldEnd", "==", "null", ")", "calOldEnd", "=", "calNow", ";", "(", "(", "DateTimeField", ")", "this", ".", "getField", "(", "CalendarControl", ".", "START_ANNIV_DATE", ")", ")", ".", "setCalendar", "(", "calStart", ",", "true", ",", "DBConstants", ".", "SCREEN_MOVE", ")", ";", "(", "(", "DateTimeField", ")", "this", ".", "getField", "(", "CalendarControl", ".", "END_ANNIV_DATE", ")", ")", ".", "setCalendar", "(", "calEnd", ",", "true", ",", "DBConstants", ".", "SCREEN_MOVE", ")", ";", "(", "(", "DateTimeField", ")", "this", ".", "getField", "(", "CalendarControl", ".", "LAST_UPDATE_DATE", ")", ")", ".", "setCalendar", "(", "calNow", ",", "true", ",", "DBConstants", ".", "SCREEN_MOVE", ")", ";", "this", ".", "updateCalendar", "(", "calOldEnd", ",", "calEnd", ")", ";", "// Update the calendar", "try", "{", "this", ".", "writeAndRefresh", "(", ")", ";", "}", "catch", "(", "DBException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "}", "}" ]
UpdateDatesAndCalendar Method.
[ "UpdateDatesAndCalendar", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/calendar/src/main/java/org/jbundle/main/calendar/db/CalendarControl.java#L153-L195