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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
22,400 | evernote/android-job | library/src/main/java/android/support/v4/app/SafeJobServiceEngineImpl.java | SafeJobServiceEngineImpl.dequeueWork | @Override
public JobIntentService.GenericWorkItem dequeueWork() {
JobWorkItem work = null;
synchronized (mLock) {
if (mParams == null) {
return null;
}
try {
work = mParams.dequeueWork();
} catch (SecurityException se) {
//ignore
se.printStackTrace();
}
}
if (work != null) {
work.getIntent().setExtrasClassLoader(mService.getClassLoader());
return new WrapperWorkItem(work);
} else {
return null;
}
} | java | @Override
public JobIntentService.GenericWorkItem dequeueWork() {
JobWorkItem work = null;
synchronized (mLock) {
if (mParams == null) {
return null;
}
try {
work = mParams.dequeueWork();
} catch (SecurityException se) {
//ignore
se.printStackTrace();
}
}
if (work != null) {
work.getIntent().setExtrasClassLoader(mService.getClassLoader());
return new WrapperWorkItem(work);
} else {
return null;
}
} | [
"@",
"Override",
"public",
"JobIntentService",
".",
"GenericWorkItem",
"dequeueWork",
"(",
")",
"{",
"JobWorkItem",
"work",
"=",
"null",
";",
"synchronized",
"(",
"mLock",
")",
"{",
"if",
"(",
"mParams",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"work",
"=",
"mParams",
".",
"dequeueWork",
"(",
")",
";",
"}",
"catch",
"(",
"SecurityException",
"se",
")",
"{",
"//ignore",
"se",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"if",
"(",
"work",
"!=",
"null",
")",
"{",
"work",
".",
"getIntent",
"(",
")",
".",
"setExtrasClassLoader",
"(",
"mService",
".",
"getClassLoader",
"(",
")",
")",
";",
"return",
"new",
"WrapperWorkItem",
"(",
"work",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Dequeue some work. | [
"Dequeue",
"some",
"work",
"."
] | 5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf | https://github.com/evernote/android-job/blob/5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf/library/src/main/java/android/support/v4/app/SafeJobServiceEngineImpl.java#L86-L106 |
22,401 | evernote/android-job | library/src/main/java/com/evernote/android/job/util/JobPreconditions.java | JobPreconditions.checkNotEmpty | public static <T extends CharSequence> T checkNotEmpty(final T reference) {
if (TextUtils.isEmpty(reference)) {
throw new IllegalArgumentException();
}
return reference;
} | java | public static <T extends CharSequence> T checkNotEmpty(final T reference) {
if (TextUtils.isEmpty(reference)) {
throw new IllegalArgumentException();
}
return reference;
} | [
"public",
"static",
"<",
"T",
"extends",
"CharSequence",
">",
"T",
"checkNotEmpty",
"(",
"final",
"T",
"reference",
")",
"{",
"if",
"(",
"TextUtils",
".",
"isEmpty",
"(",
"reference",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"return",
"reference",
";",
"}"
] | Ensures that a CharSequence passed as a parameter to the calling method is
not null and not empty.
@param reference an CharSequence reference
@return the non-empty reference that was validated
@throws IllegalArgumentException if {@code reference} was null or empty | [
"Ensures",
"that",
"a",
"CharSequence",
"passed",
"as",
"a",
"parameter",
"to",
"the",
"calling",
"method",
"is",
"not",
"null",
"and",
"not",
"empty",
"."
] | 5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf | https://github.com/evernote/android-job/blob/5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf/library/src/main/java/com/evernote/android/job/util/JobPreconditions.java#L77-L82 |
22,402 | evernote/android-job | library/src/main/java/com/evernote/android/job/util/JobPreconditions.java | JobPreconditions.checkFlagsArgument | public static void checkFlagsArgument(final int requestedFlags, final int allowedFlags) {
if ((requestedFlags & allowedFlags) != requestedFlags) {
throw new IllegalArgumentException("Requested flags 0x"
+ Integer.toHexString(requestedFlags) + ", but only 0x"
+ Integer.toHexString(allowedFlags) + " are allowed");
}
} | java | public static void checkFlagsArgument(final int requestedFlags, final int allowedFlags) {
if ((requestedFlags & allowedFlags) != requestedFlags) {
throw new IllegalArgumentException("Requested flags 0x"
+ Integer.toHexString(requestedFlags) + ", but only 0x"
+ Integer.toHexString(allowedFlags) + " are allowed");
}
} | [
"public",
"static",
"void",
"checkFlagsArgument",
"(",
"final",
"int",
"requestedFlags",
",",
"final",
"int",
"allowedFlags",
")",
"{",
"if",
"(",
"(",
"requestedFlags",
"&",
"allowedFlags",
")",
"!=",
"requestedFlags",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Requested flags 0x\"",
"+",
"Integer",
".",
"toHexString",
"(",
"requestedFlags",
")",
"+",
"\", but only 0x\"",
"+",
"Integer",
".",
"toHexString",
"(",
"allowedFlags",
")",
"+",
"\" are allowed\"",
")",
";",
"}",
"}"
] | Check the requested flags, throwing if any requested flags are outside
the allowed set. | [
"Check",
"the",
"requested",
"flags",
"throwing",
"if",
"any",
"requested",
"flags",
"are",
"outside",
"the",
"allowed",
"set",
"."
] | 5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf | https://github.com/evernote/android-job/blob/5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf/library/src/main/java/com/evernote/android/job/util/JobPreconditions.java#L101-L107 |
22,403 | evernote/android-job | library/src/main/java/com/evernote/android/job/util/JobPreconditions.java | JobPreconditions.checkArgumentFinite | public static float checkArgumentFinite(final float value, final String valueName) {
if (Float.isNaN(value)) {
throw new IllegalArgumentException(valueName + " must not be NaN");
} else if (Float.isInfinite(value)) {
throw new IllegalArgumentException(valueName + " must not be infinite");
}
return value;
} | java | public static float checkArgumentFinite(final float value, final String valueName) {
if (Float.isNaN(value)) {
throw new IllegalArgumentException(valueName + " must not be NaN");
} else if (Float.isInfinite(value)) {
throw new IllegalArgumentException(valueName + " must not be infinite");
}
return value;
} | [
"public",
"static",
"float",
"checkArgumentFinite",
"(",
"final",
"float",
"value",
",",
"final",
"String",
"valueName",
")",
"{",
"if",
"(",
"Float",
".",
"isNaN",
"(",
"value",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"valueName",
"+",
"\" must not be NaN\"",
")",
";",
"}",
"else",
"if",
"(",
"Float",
".",
"isInfinite",
"(",
"value",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"valueName",
"+",
"\" must not be infinite\"",
")",
";",
"}",
"return",
"value",
";",
"}"
] | Ensures that the argument floating point value is a finite number.
<p>A finite number is defined to be both representable (that is, not NaN) and
not infinite (that is neither positive or negative infinity).</p>
@param value a floating point value
@param valueName the name of the argument to use if the check fails
@return the validated floating point value
@throws IllegalArgumentException if {@code value} was not finite | [
"Ensures",
"that",
"the",
"argument",
"floating",
"point",
"value",
"is",
"a",
"finite",
"number",
"."
] | 5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf | https://github.com/evernote/android-job/blob/5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf/library/src/main/java/com/evernote/android/job/util/JobPreconditions.java#L186-L194 |
22,404 | evernote/android-job | library/src/main/java/com/evernote/android/job/util/JobPreconditions.java | JobPreconditions.checkArgumentInRange | public static float checkArgumentInRange(float value, float lower, float upper,
String valueName) {
if (Float.isNaN(value)) {
throw new IllegalArgumentException(valueName + " must not be NaN");
} else if (value < lower) {
throw new IllegalArgumentException(
String.format(Locale.US,
"%s is out of range of [%f, %f] (too low)", valueName, lower, upper));
} else if (value > upper) {
throw new IllegalArgumentException(
String.format(Locale.US,
"%s is out of range of [%f, %f] (too high)", valueName, lower, upper));
}
return value;
} | java | public static float checkArgumentInRange(float value, float lower, float upper,
String valueName) {
if (Float.isNaN(value)) {
throw new IllegalArgumentException(valueName + " must not be NaN");
} else if (value < lower) {
throw new IllegalArgumentException(
String.format(Locale.US,
"%s is out of range of [%f, %f] (too low)", valueName, lower, upper));
} else if (value > upper) {
throw new IllegalArgumentException(
String.format(Locale.US,
"%s is out of range of [%f, %f] (too high)", valueName, lower, upper));
}
return value;
} | [
"public",
"static",
"float",
"checkArgumentInRange",
"(",
"float",
"value",
",",
"float",
"lower",
",",
"float",
"upper",
",",
"String",
"valueName",
")",
"{",
"if",
"(",
"Float",
".",
"isNaN",
"(",
"value",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"valueName",
"+",
"\" must not be NaN\"",
")",
";",
"}",
"else",
"if",
"(",
"value",
"<",
"lower",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"Locale",
".",
"US",
",",
"\"%s is out of range of [%f, %f] (too low)\"",
",",
"valueName",
",",
"lower",
",",
"upper",
")",
")",
";",
"}",
"else",
"if",
"(",
"value",
">",
"upper",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"Locale",
".",
"US",
",",
"\"%s is out of range of [%f, %f] (too high)\"",
",",
"valueName",
",",
"lower",
",",
"upper",
")",
")",
";",
"}",
"return",
"value",
";",
"}"
] | Ensures that the argument floating point value is within the inclusive range.
<p>While this can be used to range check against +/- infinity, note that all NaN numbers
will always be out of range.</p>
@param value a floating point value
@param lower the lower endpoint of the inclusive range
@param upper the upper endpoint of the inclusive range
@param valueName the name of the argument to use if the check fails
@return the validated floating point value
@throws IllegalArgumentException if {@code value} was not within the range | [
"Ensures",
"that",
"the",
"argument",
"floating",
"point",
"value",
"is",
"within",
"the",
"inclusive",
"range",
"."
] | 5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf | https://github.com/evernote/android-job/blob/5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf/library/src/main/java/com/evernote/android/job/util/JobPreconditions.java#L211-L226 |
22,405 | evernote/android-job | library/src/main/java/com/evernote/android/job/JobRequest.java | JobRequest.scheduleAsync | public void scheduleAsync(@NonNull final JobScheduledCallback callback) {
JobPreconditions.checkNotNull(callback);
JobConfig.getExecutorService().execute(new Runnable() {
@Override
public void run() {
try {
int jobId = schedule();
callback.onJobScheduled(jobId, getTag(), null);
} catch (Exception e) {
callback.onJobScheduled(JobScheduledCallback.JOB_ID_ERROR, getTag(), e);
}
}
});
} | java | public void scheduleAsync(@NonNull final JobScheduledCallback callback) {
JobPreconditions.checkNotNull(callback);
JobConfig.getExecutorService().execute(new Runnable() {
@Override
public void run() {
try {
int jobId = schedule();
callback.onJobScheduled(jobId, getTag(), null);
} catch (Exception e) {
callback.onJobScheduled(JobScheduledCallback.JOB_ID_ERROR, getTag(), e);
}
}
});
} | [
"public",
"void",
"scheduleAsync",
"(",
"@",
"NonNull",
"final",
"JobScheduledCallback",
"callback",
")",
"{",
"JobPreconditions",
".",
"checkNotNull",
"(",
"callback",
")",
";",
"JobConfig",
".",
"getExecutorService",
"(",
")",
".",
"execute",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"int",
"jobId",
"=",
"schedule",
"(",
")",
";",
"callback",
".",
"onJobScheduled",
"(",
"jobId",
",",
"getTag",
"(",
")",
",",
"null",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"callback",
".",
"onJobScheduled",
"(",
"JobScheduledCallback",
".",
"JOB_ID_ERROR",
",",
"getTag",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Helper method to schedule a request on a background thread. This is helpful to avoid IO operations
on the main thread. The callback notifies you about the job ID or a possible failure.
@param callback The callback which is invoked after the request has been scheduled. | [
"Helper",
"method",
"to",
"schedule",
"a",
"request",
"on",
"a",
"background",
"thread",
".",
"This",
"is",
"helpful",
"to",
"avoid",
"IO",
"operations",
"on",
"the",
"main",
"thread",
".",
"The",
"callback",
"notifies",
"you",
"about",
"the",
"job",
"ID",
"or",
"a",
"possible",
"failure",
"."
] | 5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf | https://github.com/evernote/android-job/blob/5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf/library/src/main/java/com/evernote/android/job/JobRequest.java#L453-L466 |
22,406 | evernote/android-job | library/src/main/java/com/evernote/android/job/JobRequest.java | JobRequest.cancelAndEdit | public Builder cancelAndEdit() {
// create a temporary variable, because .cancel() will reset mScheduledAt
long scheduledAt = mScheduledAt;
JobManager.instance().cancel(getJobId());
Builder builder = new Builder(this.mBuilder);
mStarted = false;
if (!isPeriodic()) {
long offset = JobConfig.getClock().currentTimeMillis() - scheduledAt;
long minValue = 1L; // 1ms
builder.setExecutionWindow(Math.max(minValue, getStartMs() - offset), Math.max(minValue, getEndMs() - offset));
}
return builder;
} | java | public Builder cancelAndEdit() {
// create a temporary variable, because .cancel() will reset mScheduledAt
long scheduledAt = mScheduledAt;
JobManager.instance().cancel(getJobId());
Builder builder = new Builder(this.mBuilder);
mStarted = false;
if (!isPeriodic()) {
long offset = JobConfig.getClock().currentTimeMillis() - scheduledAt;
long minValue = 1L; // 1ms
builder.setExecutionWindow(Math.max(minValue, getStartMs() - offset), Math.max(minValue, getEndMs() - offset));
}
return builder;
} | [
"public",
"Builder",
"cancelAndEdit",
"(",
")",
"{",
"// create a temporary variable, because .cancel() will reset mScheduledAt",
"long",
"scheduledAt",
"=",
"mScheduledAt",
";",
"JobManager",
".",
"instance",
"(",
")",
".",
"cancel",
"(",
"getJobId",
"(",
")",
")",
";",
"Builder",
"builder",
"=",
"new",
"Builder",
"(",
"this",
".",
"mBuilder",
")",
";",
"mStarted",
"=",
"false",
";",
"if",
"(",
"!",
"isPeriodic",
"(",
")",
")",
"{",
"long",
"offset",
"=",
"JobConfig",
".",
"getClock",
"(",
")",
".",
"currentTimeMillis",
"(",
")",
"-",
"scheduledAt",
";",
"long",
"minValue",
"=",
"1L",
";",
"// 1ms",
"builder",
".",
"setExecutionWindow",
"(",
"Math",
".",
"max",
"(",
"minValue",
",",
"getStartMs",
"(",
")",
"-",
"offset",
")",
",",
"Math",
".",
"max",
"(",
"minValue",
",",
"getEndMs",
"(",
")",
"-",
"offset",
")",
")",
";",
"}",
"return",
"builder",
";",
"}"
] | Cancel this request if it has been scheduled. Note that if the job isn't periodic, then the
time passed since the job has been scheduled is subtracted from the time frame. For example
a job should run between 4 and 6 seconds from now. You cancel the scheduled job after 2
seconds, then the job will run between 2 and 4 seconds after it's been scheduled again.
@return A builder to modify the parameters. | [
"Cancel",
"this",
"request",
"if",
"it",
"has",
"been",
"scheduled",
".",
"Note",
"that",
"if",
"the",
"job",
"isn",
"t",
"periodic",
"then",
"the",
"time",
"passed",
"since",
"the",
"job",
"has",
"been",
"scheduled",
"is",
"subtracted",
"from",
"the",
"time",
"frame",
".",
"For",
"example",
"a",
"job",
"should",
"run",
"between",
"4",
"and",
"6",
"seconds",
"from",
"now",
".",
"You",
"cancel",
"the",
"scheduled",
"job",
"after",
"2",
"seconds",
"then",
"the",
"job",
"will",
"run",
"between",
"2",
"and",
"4",
"seconds",
"after",
"it",
"s",
"been",
"scheduled",
"again",
"."
] | 5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf | https://github.com/evernote/android-job/blob/5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf/library/src/main/java/com/evernote/android/job/JobRequest.java#L476-L491 |
22,407 | evernote/android-job | library/src/main/java/com/evernote/android/job/JobConfig.java | JobConfig.setAllowSmallerIntervalsForMarshmallow | public static void setAllowSmallerIntervalsForMarshmallow(boolean allowSmallerIntervals) {
if (allowSmallerIntervals && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
throw new IllegalStateException("This method is only allowed to call on Android M or earlier");
}
JobConfig.allowSmallerIntervals = allowSmallerIntervals;
} | java | public static void setAllowSmallerIntervalsForMarshmallow(boolean allowSmallerIntervals) {
if (allowSmallerIntervals && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
throw new IllegalStateException("This method is only allowed to call on Android M or earlier");
}
JobConfig.allowSmallerIntervals = allowSmallerIntervals;
} | [
"public",
"static",
"void",
"setAllowSmallerIntervalsForMarshmallow",
"(",
"boolean",
"allowSmallerIntervals",
")",
"{",
"if",
"(",
"allowSmallerIntervals",
"&&",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"N",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"This method is only allowed to call on Android M or earlier\"",
")",
";",
"}",
"JobConfig",
".",
"allowSmallerIntervals",
"=",
"allowSmallerIntervals",
";",
"}"
] | Option to override the minimum period and minimum flex for periodic jobs. This is useful for testing
purposes. This method only works for Android M and earlier. Later versions throw an exception.
@param allowSmallerIntervals Whether a smaller interval and flex than the minimum values are allowed
for periodic jobs are allowed. The default value is {@code false}. | [
"Option",
"to",
"override",
"the",
"minimum",
"period",
"and",
"minimum",
"flex",
"for",
"periodic",
"jobs",
".",
"This",
"is",
"useful",
"for",
"testing",
"purposes",
".",
"This",
"method",
"only",
"works",
"for",
"Android",
"M",
"and",
"earlier",
".",
"Later",
"versions",
"throw",
"an",
"exception",
"."
] | 5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf | https://github.com/evernote/android-job/blob/5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf/library/src/main/java/com/evernote/android/job/JobConfig.java#L146-L151 |
22,408 | evernote/android-job | library/src/main/java/com/evernote/android/job/JobConfig.java | JobConfig.setJobIdOffset | public static void setJobIdOffset(int jobIdOffset) {
JobPreconditions.checkArgumentNonnegative(jobIdOffset, "offset can't be negative");
if (jobIdOffset > JobIdsInternal.RESERVED_JOB_ID_RANGE_START - 500) {
throw new IllegalArgumentException("offset is too close to Integer.MAX_VALUE");
}
JobConfig.jobIdOffset = jobIdOffset;
} | java | public static void setJobIdOffset(int jobIdOffset) {
JobPreconditions.checkArgumentNonnegative(jobIdOffset, "offset can't be negative");
if (jobIdOffset > JobIdsInternal.RESERVED_JOB_ID_RANGE_START - 500) {
throw new IllegalArgumentException("offset is too close to Integer.MAX_VALUE");
}
JobConfig.jobIdOffset = jobIdOffset;
} | [
"public",
"static",
"void",
"setJobIdOffset",
"(",
"int",
"jobIdOffset",
")",
"{",
"JobPreconditions",
".",
"checkArgumentNonnegative",
"(",
"jobIdOffset",
",",
"\"offset can't be negative\"",
")",
";",
"if",
"(",
"jobIdOffset",
">",
"JobIdsInternal",
".",
"RESERVED_JOB_ID_RANGE_START",
"-",
"500",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"offset is too close to Integer.MAX_VALUE\"",
")",
";",
"}",
"JobConfig",
".",
"jobIdOffset",
"=",
"jobIdOffset",
";",
"}"
] | Adds an offset to the job IDs. Job IDs are generated and usually start with 1. This offset shifts the
very first job ID.
@param jobIdOffset The offset for the very first job ID. | [
"Adds",
"an",
"offset",
"to",
"the",
"job",
"IDs",
".",
"Job",
"IDs",
"are",
"generated",
"and",
"usually",
"start",
"with",
"1",
".",
"This",
"offset",
"shifts",
"the",
"very",
"first",
"job",
"ID",
"."
] | 5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf | https://github.com/evernote/android-job/blob/5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf/library/src/main/java/com/evernote/android/job/JobConfig.java#L253-L260 |
22,409 | evernote/android-job | library/src/main/java/com/evernote/android/job/JobConfig.java | JobConfig.reset | public static void reset() {
for (JobApi api : JobApi.values()) {
ENABLED_APIS.put(api, Boolean.TRUE);
}
allowSmallerIntervals = false;
forceAllowApi14 = false;
jobReschedulePause = DEFAULT_JOB_RESCHEDULE_PAUSE;
skipJobReschedule = false;
jobIdOffset = 0;
forceRtc = false;
clock = Clock.DEFAULT;
executorService = DEFAULT_EXECUTOR_SERVICE;
closeDatabase = false;
JobCat.setLogcatEnabled(true);
JobCat.clearLogger();
} | java | public static void reset() {
for (JobApi api : JobApi.values()) {
ENABLED_APIS.put(api, Boolean.TRUE);
}
allowSmallerIntervals = false;
forceAllowApi14 = false;
jobReschedulePause = DEFAULT_JOB_RESCHEDULE_PAUSE;
skipJobReschedule = false;
jobIdOffset = 0;
forceRtc = false;
clock = Clock.DEFAULT;
executorService = DEFAULT_EXECUTOR_SERVICE;
closeDatabase = false;
JobCat.setLogcatEnabled(true);
JobCat.clearLogger();
} | [
"public",
"static",
"void",
"reset",
"(",
")",
"{",
"for",
"(",
"JobApi",
"api",
":",
"JobApi",
".",
"values",
"(",
")",
")",
"{",
"ENABLED_APIS",
".",
"put",
"(",
"api",
",",
"Boolean",
".",
"TRUE",
")",
";",
"}",
"allowSmallerIntervals",
"=",
"false",
";",
"forceAllowApi14",
"=",
"false",
";",
"jobReschedulePause",
"=",
"DEFAULT_JOB_RESCHEDULE_PAUSE",
";",
"skipJobReschedule",
"=",
"false",
";",
"jobIdOffset",
"=",
"0",
";",
"forceRtc",
"=",
"false",
";",
"clock",
"=",
"Clock",
".",
"DEFAULT",
";",
"executorService",
"=",
"DEFAULT_EXECUTOR_SERVICE",
";",
"closeDatabase",
"=",
"false",
";",
"JobCat",
".",
"setLogcatEnabled",
"(",
"true",
")",
";",
"JobCat",
".",
"clearLogger",
"(",
")",
";",
"}"
] | Resets all adjustments in the config. | [
"Resets",
"all",
"adjustments",
"in",
"the",
"config",
"."
] | 5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf | https://github.com/evernote/android-job/blob/5ae3d776ad9d80b5b7f60ae3e382d44d0d193faf/library/src/main/java/com/evernote/android/job/JobConfig.java#L329-L344 |
22,410 | searchbox-io/Jest | jest-common/src/main/java/io/searchbox/action/AbstractMultiIndexActionBuilder.java | AbstractMultiIndexActionBuilder.ignoreUnavailable | public K ignoreUnavailable(boolean ignore) {
setParameter(Parameters.IGNORE_UNAVAILABLE, String.valueOf(ignore));
return (K) this;
} | java | public K ignoreUnavailable(boolean ignore) {
setParameter(Parameters.IGNORE_UNAVAILABLE, String.valueOf(ignore));
return (K) this;
} | [
"public",
"K",
"ignoreUnavailable",
"(",
"boolean",
"ignore",
")",
"{",
"setParameter",
"(",
"Parameters",
".",
"IGNORE_UNAVAILABLE",
",",
"String",
".",
"valueOf",
"(",
"ignore",
")",
")",
";",
"return",
"(",
"K",
")",
"this",
";",
"}"
] | Ignore unavailable indices, this includes indices that not exists or closed indices.
@param ignore whether to ignore unavailable indices | [
"Ignore",
"unavailable",
"indices",
"this",
"includes",
"indices",
"that",
"not",
"exists",
"or",
"closed",
"indices",
"."
] | 42f0a97acc45582baf5e8ecd7ccbbc5ac0c111fc | https://github.com/searchbox-io/Jest/blob/42f0a97acc45582baf5e8ecd7ccbbc5ac0c111fc/jest-common/src/main/java/io/searchbox/action/AbstractMultiIndexActionBuilder.java#L31-L34 |
22,411 | searchbox-io/Jest | jest-common/src/main/java/io/searchbox/action/AbstractMultiIndexActionBuilder.java | AbstractMultiIndexActionBuilder.allowNoIndices | public K allowNoIndices(boolean allow) {
setParameter(Parameters.ALLOW_NO_INDICES, String.valueOf(allow));
return (K) this;
} | java | public K allowNoIndices(boolean allow) {
setParameter(Parameters.ALLOW_NO_INDICES, String.valueOf(allow));
return (K) this;
} | [
"public",
"K",
"allowNoIndices",
"(",
"boolean",
"allow",
")",
"{",
"setParameter",
"(",
"Parameters",
".",
"ALLOW_NO_INDICES",
",",
"String",
".",
"valueOf",
"(",
"allow",
")",
")",
";",
"return",
"(",
"K",
")",
"this",
";",
"}"
] | Fail of wildcard indices expressions results into no concrete indices.
@param allow whether to allow no indices. | [
"Fail",
"of",
"wildcard",
"indices",
"expressions",
"results",
"into",
"no",
"concrete",
"indices",
"."
] | 42f0a97acc45582baf5e8ecd7ccbbc5ac0c111fc | https://github.com/searchbox-io/Jest/blob/42f0a97acc45582baf5e8ecd7ccbbc5ac0c111fc/jest-common/src/main/java/io/searchbox/action/AbstractMultiIndexActionBuilder.java#L40-L43 |
22,412 | searchbox-io/Jest | jest-common/src/main/java/io/searchbox/indices/aliases/AbstractAliasMappingBuilder.java | AbstractAliasMappingBuilder.addRouting | public K addRouting(String routing) {
this.indexRouting.add(routing);
this.searchRouting.add(routing);
return (K) this;
} | java | public K addRouting(String routing) {
this.indexRouting.add(routing);
this.searchRouting.add(routing);
return (K) this;
} | [
"public",
"K",
"addRouting",
"(",
"String",
"routing",
")",
"{",
"this",
".",
"indexRouting",
".",
"add",
"(",
"routing",
")",
";",
"this",
".",
"searchRouting",
".",
"add",
"(",
"routing",
")",
";",
"return",
"(",
"K",
")",
"this",
";",
"}"
] | This method will add the given routing as both search & index routing. | [
"This",
"method",
"will",
"add",
"the",
"given",
"routing",
"as",
"both",
"search",
"&",
"index",
"routing",
"."
] | 42f0a97acc45582baf5e8ecd7ccbbc5ac0c111fc | https://github.com/searchbox-io/Jest/blob/42f0a97acc45582baf5e8ecd7ccbbc5ac0c111fc/jest-common/src/main/java/io/searchbox/indices/aliases/AbstractAliasMappingBuilder.java#L51-L55 |
22,413 | searchbox-io/Jest | jest-common/src/main/java/io/searchbox/indices/aliases/AbstractAliasMappingBuilder.java | AbstractAliasMappingBuilder.addRouting | public K addRouting(List<String> routings) {
this.indexRouting.addAll(routings);
this.searchRouting.addAll(routings);
return (K) this;
} | java | public K addRouting(List<String> routings) {
this.indexRouting.addAll(routings);
this.searchRouting.addAll(routings);
return (K) this;
} | [
"public",
"K",
"addRouting",
"(",
"List",
"<",
"String",
">",
"routings",
")",
"{",
"this",
".",
"indexRouting",
".",
"addAll",
"(",
"routings",
")",
";",
"this",
".",
"searchRouting",
".",
"addAll",
"(",
"routings",
")",
";",
"return",
"(",
"K",
")",
"this",
";",
"}"
] | This method will add the given routings as both search & index routing. | [
"This",
"method",
"will",
"add",
"the",
"given",
"routings",
"as",
"both",
"search",
"&",
"index",
"routing",
"."
] | 42f0a97acc45582baf5e8ecd7ccbbc5ac0c111fc | https://github.com/searchbox-io/Jest/blob/42f0a97acc45582baf5e8ecd7ccbbc5ac0c111fc/jest-common/src/main/java/io/searchbox/indices/aliases/AbstractAliasMappingBuilder.java#L60-L64 |
22,414 | jamesagnew/hapi-fhir | hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Include.java | Include.getParamType | public String getParamType() {
int firstColon = myValue.indexOf(':');
if (firstColon == -1 || firstColon == myValue.length() - 1) {
return null;
}
return myValue.substring(0, firstColon);
} | java | public String getParamType() {
int firstColon = myValue.indexOf(':');
if (firstColon == -1 || firstColon == myValue.length() - 1) {
return null;
}
return myValue.substring(0, firstColon);
} | [
"public",
"String",
"getParamType",
"(",
")",
"{",
"int",
"firstColon",
"=",
"myValue",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"firstColon",
"==",
"-",
"1",
"||",
"firstColon",
"==",
"myValue",
".",
"length",
"(",
")",
"-",
"1",
")",
"{",
"return",
"null",
";",
"}",
"return",
"myValue",
".",
"substring",
"(",
"0",
",",
"firstColon",
")",
";",
"}"
] | Returns the portion of the value before the first colon | [
"Returns",
"the",
"portion",
"of",
"the",
"value",
"before",
"the",
"first",
"colon"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Include.java#L130-L136 |
22,415 | jamesagnew/hapi-fhir | hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Include.java | Include.getParamName | public String getParamName() {
int firstColon = myValue.indexOf(':');
if (firstColon == -1 || firstColon == myValue.length() - 1) {
return null;
}
int secondColon = myValue.indexOf(':', firstColon + 1);
if (secondColon != -1) {
return myValue.substring(firstColon + 1, secondColon);
}
return myValue.substring(firstColon + 1);
} | java | public String getParamName() {
int firstColon = myValue.indexOf(':');
if (firstColon == -1 || firstColon == myValue.length() - 1) {
return null;
}
int secondColon = myValue.indexOf(':', firstColon + 1);
if (secondColon != -1) {
return myValue.substring(firstColon + 1, secondColon);
}
return myValue.substring(firstColon + 1);
} | [
"public",
"String",
"getParamName",
"(",
")",
"{",
"int",
"firstColon",
"=",
"myValue",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"firstColon",
"==",
"-",
"1",
"||",
"firstColon",
"==",
"myValue",
".",
"length",
"(",
")",
"-",
"1",
")",
"{",
"return",
"null",
";",
"}",
"int",
"secondColon",
"=",
"myValue",
".",
"indexOf",
"(",
"'",
"'",
",",
"firstColon",
"+",
"1",
")",
";",
"if",
"(",
"secondColon",
"!=",
"-",
"1",
")",
"{",
"return",
"myValue",
".",
"substring",
"(",
"firstColon",
"+",
"1",
",",
"secondColon",
")",
";",
"}",
"return",
"myValue",
".",
"substring",
"(",
"firstColon",
"+",
"1",
")",
";",
"}"
] | Returns the portion of the value after the first colon but before the second colon | [
"Returns",
"the",
"portion",
"of",
"the",
"value",
"after",
"the",
"first",
"colon",
"but",
"before",
"the",
"second",
"colon"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Include.java#L141-L151 |
22,416 | jamesagnew/hapi-fhir | hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/impl/FhirServerManager.java | FhirServerManager.unregisterFhirServer | public void unregisterFhirServer (FhirServer server, Map<String,Object> props) throws FhirConfigurationException {
if (server != null) {
String serverName = (String)props.get(FhirServer.SVCPROP_SERVICE_NAME);
if (serverName != null) {
FhirServer service = registeredServers.get(serverName);
if (service != null) {
log.trace("Unregistering FHIR Server ["+serverName+"]");
service.unregisterOsgiProviders();
registeredServers.remove(serverName);
log.trace("Dequeue any FHIR providers waiting for this server");
pendingProviders.remove(serverName);
if (registeredServers.size() == 0) {
log.trace("Dequeue any FHIR providers waiting for the first/only server");
pendingProviders.remove(FIRST_SERVER);
}
Collection<Collection<Object>> providers = serverProviders.get(serverName);
if (providers != null) {
serverProviders.remove(serverName);
registeredProviders.removeAll(providers);
}
}
} else {
throw new FhirConfigurationException("FHIR Server registered in OSGi is missing the required ["+FhirServer.SVCPROP_SERVICE_NAME+"] service-property");
}
}
} | java | public void unregisterFhirServer (FhirServer server, Map<String,Object> props) throws FhirConfigurationException {
if (server != null) {
String serverName = (String)props.get(FhirServer.SVCPROP_SERVICE_NAME);
if (serverName != null) {
FhirServer service = registeredServers.get(serverName);
if (service != null) {
log.trace("Unregistering FHIR Server ["+serverName+"]");
service.unregisterOsgiProviders();
registeredServers.remove(serverName);
log.trace("Dequeue any FHIR providers waiting for this server");
pendingProviders.remove(serverName);
if (registeredServers.size() == 0) {
log.trace("Dequeue any FHIR providers waiting for the first/only server");
pendingProviders.remove(FIRST_SERVER);
}
Collection<Collection<Object>> providers = serverProviders.get(serverName);
if (providers != null) {
serverProviders.remove(serverName);
registeredProviders.removeAll(providers);
}
}
} else {
throw new FhirConfigurationException("FHIR Server registered in OSGi is missing the required ["+FhirServer.SVCPROP_SERVICE_NAME+"] service-property");
}
}
} | [
"public",
"void",
"unregisterFhirServer",
"(",
"FhirServer",
"server",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"props",
")",
"throws",
"FhirConfigurationException",
"{",
"if",
"(",
"server",
"!=",
"null",
")",
"{",
"String",
"serverName",
"=",
"(",
"String",
")",
"props",
".",
"get",
"(",
"FhirServer",
".",
"SVCPROP_SERVICE_NAME",
")",
";",
"if",
"(",
"serverName",
"!=",
"null",
")",
"{",
"FhirServer",
"service",
"=",
"registeredServers",
".",
"get",
"(",
"serverName",
")",
";",
"if",
"(",
"service",
"!=",
"null",
")",
"{",
"log",
".",
"trace",
"(",
"\"Unregistering FHIR Server [\"",
"+",
"serverName",
"+",
"\"]\"",
")",
";",
"service",
".",
"unregisterOsgiProviders",
"(",
")",
";",
"registeredServers",
".",
"remove",
"(",
"serverName",
")",
";",
"log",
".",
"trace",
"(",
"\"Dequeue any FHIR providers waiting for this server\"",
")",
";",
"pendingProviders",
".",
"remove",
"(",
"serverName",
")",
";",
"if",
"(",
"registeredServers",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"log",
".",
"trace",
"(",
"\"Dequeue any FHIR providers waiting for the first/only server\"",
")",
";",
"pendingProviders",
".",
"remove",
"(",
"FIRST_SERVER",
")",
";",
"}",
"Collection",
"<",
"Collection",
"<",
"Object",
">",
">",
"providers",
"=",
"serverProviders",
".",
"get",
"(",
"serverName",
")",
";",
"if",
"(",
"providers",
"!=",
"null",
")",
"{",
"serverProviders",
".",
"remove",
"(",
"serverName",
")",
";",
"registeredProviders",
".",
"removeAll",
"(",
"providers",
")",
";",
"}",
"}",
"}",
"else",
"{",
"throw",
"new",
"FhirConfigurationException",
"(",
"\"FHIR Server registered in OSGi is missing the required [\"",
"+",
"FhirServer",
".",
"SVCPROP_SERVICE_NAME",
"+",
"\"] service-property\"",
")",
";",
"}",
"}",
"}"
] | This method will be called when a FHIR Server OSGi service
is being removed from the container. This normally will only
occur when its bundle is stopped because it is being removed
or updated.
@param server OSGi service implementing the FhirService interface
@param props the <service-properties> for that service
@throws FhirConfigurationException | [
"This",
"method",
"will",
"be",
"called",
"when",
"a",
"FHIR",
"Server",
"OSGi",
"service",
"is",
"being",
"removed",
"from",
"the",
"container",
".",
"This",
"normally",
"will",
"only",
"occur",
"when",
"its",
"bundle",
"is",
"stopped",
"because",
"it",
"is",
"being",
"removed",
"or",
"updated",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/impl/FhirServerManager.java#L130-L155 |
22,417 | jamesagnew/hapi-fhir | hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/impl/FhirServerManager.java | FhirServerManager.registerFhirProviders | public void registerFhirProviders (FhirProviderBundle bundle, Map<String,Object> props) throws FhirConfigurationException {
if (bundle != null) {
Collection<Object> providers = bundle.getProviders();
if (providers != null && !providers.isEmpty()) {
try {
String serverName = (String)props.get(FhirServer.SVCPROP_SERVICE_NAME);
String ourServerName = getServerName(serverName);
String bundleName = (String)props.get("name");
if (null == bundleName) {
bundleName = "<default>";
}
log.trace("Register FHIR Provider Bundle ["+bundleName+"] on FHIR Server ["+ourServerName+"]");
FhirServer server = registeredServers.get(ourServerName);
if (server != null) {
registerProviders(providers, server, serverName);
} else {
log.trace("Queue the Provider Bundle waiting for FHIR Server to be registered");
Collection<Collection<Object>> pending;
synchronized(pendingProviders) {
pending = pendingProviders.get(serverName);
if (null == pending) {
pending = Collections.synchronizedCollection(new ArrayList<Collection<Object>>());
pendingProviders.put(serverName, pending);
}
}
pending.add(providers);
}
} catch (BadServerException e) {
throw new FhirConfigurationException("Unable to register the OSGi FHIR Provider. Multiple Restful Servers exist. Specify the ["+FhirServer.SVCPROP_SERVICE_NAME+"] service-property");
}
}
}
} | java | public void registerFhirProviders (FhirProviderBundle bundle, Map<String,Object> props) throws FhirConfigurationException {
if (bundle != null) {
Collection<Object> providers = bundle.getProviders();
if (providers != null && !providers.isEmpty()) {
try {
String serverName = (String)props.get(FhirServer.SVCPROP_SERVICE_NAME);
String ourServerName = getServerName(serverName);
String bundleName = (String)props.get("name");
if (null == bundleName) {
bundleName = "<default>";
}
log.trace("Register FHIR Provider Bundle ["+bundleName+"] on FHIR Server ["+ourServerName+"]");
FhirServer server = registeredServers.get(ourServerName);
if (server != null) {
registerProviders(providers, server, serverName);
} else {
log.trace("Queue the Provider Bundle waiting for FHIR Server to be registered");
Collection<Collection<Object>> pending;
synchronized(pendingProviders) {
pending = pendingProviders.get(serverName);
if (null == pending) {
pending = Collections.synchronizedCollection(new ArrayList<Collection<Object>>());
pendingProviders.put(serverName, pending);
}
}
pending.add(providers);
}
} catch (BadServerException e) {
throw new FhirConfigurationException("Unable to register the OSGi FHIR Provider. Multiple Restful Servers exist. Specify the ["+FhirServer.SVCPROP_SERVICE_NAME+"] service-property");
}
}
}
} | [
"public",
"void",
"registerFhirProviders",
"(",
"FhirProviderBundle",
"bundle",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"props",
")",
"throws",
"FhirConfigurationException",
"{",
"if",
"(",
"bundle",
"!=",
"null",
")",
"{",
"Collection",
"<",
"Object",
">",
"providers",
"=",
"bundle",
".",
"getProviders",
"(",
")",
";",
"if",
"(",
"providers",
"!=",
"null",
"&&",
"!",
"providers",
".",
"isEmpty",
"(",
")",
")",
"{",
"try",
"{",
"String",
"serverName",
"=",
"(",
"String",
")",
"props",
".",
"get",
"(",
"FhirServer",
".",
"SVCPROP_SERVICE_NAME",
")",
";",
"String",
"ourServerName",
"=",
"getServerName",
"(",
"serverName",
")",
";",
"String",
"bundleName",
"=",
"(",
"String",
")",
"props",
".",
"get",
"(",
"\"name\"",
")",
";",
"if",
"(",
"null",
"==",
"bundleName",
")",
"{",
"bundleName",
"=",
"\"<default>\"",
";",
"}",
"log",
".",
"trace",
"(",
"\"Register FHIR Provider Bundle [\"",
"+",
"bundleName",
"+",
"\"] on FHIR Server [\"",
"+",
"ourServerName",
"+",
"\"]\"",
")",
";",
"FhirServer",
"server",
"=",
"registeredServers",
".",
"get",
"(",
"ourServerName",
")",
";",
"if",
"(",
"server",
"!=",
"null",
")",
"{",
"registerProviders",
"(",
"providers",
",",
"server",
",",
"serverName",
")",
";",
"}",
"else",
"{",
"log",
".",
"trace",
"(",
"\"Queue the Provider Bundle waiting for FHIR Server to be registered\"",
")",
";",
"Collection",
"<",
"Collection",
"<",
"Object",
">",
">",
"pending",
";",
"synchronized",
"(",
"pendingProviders",
")",
"{",
"pending",
"=",
"pendingProviders",
".",
"get",
"(",
"serverName",
")",
";",
"if",
"(",
"null",
"==",
"pending",
")",
"{",
"pending",
"=",
"Collections",
".",
"synchronizedCollection",
"(",
"new",
"ArrayList",
"<",
"Collection",
"<",
"Object",
">",
">",
"(",
")",
")",
";",
"pendingProviders",
".",
"put",
"(",
"serverName",
",",
"pending",
")",
";",
"}",
"}",
"pending",
".",
"add",
"(",
"providers",
")",
";",
"}",
"}",
"catch",
"(",
"BadServerException",
"e",
")",
"{",
"throw",
"new",
"FhirConfigurationException",
"(",
"\"Unable to register the OSGi FHIR Provider. Multiple Restful Servers exist. Specify the [\"",
"+",
"FhirServer",
".",
"SVCPROP_SERVICE_NAME",
"+",
"\"] service-property\"",
")",
";",
"}",
"}",
"}",
"}"
] | Register a new FHIR Provider-Bundle OSGi service.
This could be a "plain" provider that is published with the
FhirProvider interface or it could be a resource provider that
is published with either that same interface or the IResourceProvider
interface.
(That check is not made here but is included as usage documentation)
<p>
The OSGi service definition of a FHIR Provider would look like:
<code><pre>
<osgi:service ref="<b><i>some.bean</i></b>" interface="ca.uhn.fhir.osgi.IResourceProvider">
<osgi:service-properties>
<entry key="name" value="<b><i>osgi-service-name</i></b>"/>
<entry key="fhir.server.name" value="<b><i>fhir-server-name</i></b>"/>
</osgi:service-properties>
</osgi:service>
</pre></code>
The <b><i>fhir-server-name</i></b> parameter is the value assigned to the
<code>fhir.server.name</code> service-property of one of the OSGi-published
FHIR Servers.
@param server OSGi service implementing a FHIR provider interface
@param props the <service-properties> for that service
@throws FhirConfigurationException | [
"Register",
"a",
"new",
"FHIR",
"Provider",
"-",
"Bundle",
"OSGi",
"service",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/impl/FhirServerManager.java#L186-L219 |
22,418 | jamesagnew/hapi-fhir | hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/impl/FhirServerManager.java | FhirServerManager.unregisterFhirProviders | public void unregisterFhirProviders (FhirProviderBundle bundle, Map<String,Object> props) throws FhirConfigurationException {
if (bundle != null) {
Collection<Object> providers = bundle.getProviders();
if (providers != null && !providers.isEmpty()) {
try {
registeredProviders.remove(providers);
String serverName = (String)props.get(FhirServer.SVCPROP_SERVICE_NAME);
String ourServerName = getServerName(serverName);
FhirServer server = registeredServers.get(ourServerName);
if (server != null) {
server.unregisterOsgiProviders(providers);
Collection<Collection<Object>> active = serverProviders.get(serverName);
if (active != null) {
active.remove(providers);
}
}
} catch (BadServerException e) {
throw new FhirConfigurationException("Unable to register the OSGi FHIR Provider. Multiple Restful Servers exist. Specify the ["+FhirServer.SVCPROP_SERVICE_NAME+"] service-property");
}
}
}
} | java | public void unregisterFhirProviders (FhirProviderBundle bundle, Map<String,Object> props) throws FhirConfigurationException {
if (bundle != null) {
Collection<Object> providers = bundle.getProviders();
if (providers != null && !providers.isEmpty()) {
try {
registeredProviders.remove(providers);
String serverName = (String)props.get(FhirServer.SVCPROP_SERVICE_NAME);
String ourServerName = getServerName(serverName);
FhirServer server = registeredServers.get(ourServerName);
if (server != null) {
server.unregisterOsgiProviders(providers);
Collection<Collection<Object>> active = serverProviders.get(serverName);
if (active != null) {
active.remove(providers);
}
}
} catch (BadServerException e) {
throw new FhirConfigurationException("Unable to register the OSGi FHIR Provider. Multiple Restful Servers exist. Specify the ["+FhirServer.SVCPROP_SERVICE_NAME+"] service-property");
}
}
}
} | [
"public",
"void",
"unregisterFhirProviders",
"(",
"FhirProviderBundle",
"bundle",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"props",
")",
"throws",
"FhirConfigurationException",
"{",
"if",
"(",
"bundle",
"!=",
"null",
")",
"{",
"Collection",
"<",
"Object",
">",
"providers",
"=",
"bundle",
".",
"getProviders",
"(",
")",
";",
"if",
"(",
"providers",
"!=",
"null",
"&&",
"!",
"providers",
".",
"isEmpty",
"(",
")",
")",
"{",
"try",
"{",
"registeredProviders",
".",
"remove",
"(",
"providers",
")",
";",
"String",
"serverName",
"=",
"(",
"String",
")",
"props",
".",
"get",
"(",
"FhirServer",
".",
"SVCPROP_SERVICE_NAME",
")",
";",
"String",
"ourServerName",
"=",
"getServerName",
"(",
"serverName",
")",
";",
"FhirServer",
"server",
"=",
"registeredServers",
".",
"get",
"(",
"ourServerName",
")",
";",
"if",
"(",
"server",
"!=",
"null",
")",
"{",
"server",
".",
"unregisterOsgiProviders",
"(",
"providers",
")",
";",
"Collection",
"<",
"Collection",
"<",
"Object",
">",
">",
"active",
"=",
"serverProviders",
".",
"get",
"(",
"serverName",
")",
";",
"if",
"(",
"active",
"!=",
"null",
")",
"{",
"active",
".",
"remove",
"(",
"providers",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"BadServerException",
"e",
")",
"{",
"throw",
"new",
"FhirConfigurationException",
"(",
"\"Unable to register the OSGi FHIR Provider. Multiple Restful Servers exist. Specify the [\"",
"+",
"FhirServer",
".",
"SVCPROP_SERVICE_NAME",
"+",
"\"] service-property\"",
")",
";",
"}",
"}",
"}",
"}"
] | This method will be called when a FHIR Provider OSGi service
is being removed from the container. This normally will only
occur when its bundle is stopped because it is being removed
or updated.
@param server OSGi service implementing one of the provider
interfaces
@param props the <service-properties> for that service
@throws FhirConfigurationException | [
"This",
"method",
"will",
"be",
"called",
"when",
"a",
"FHIR",
"Provider",
"OSGi",
"service",
"is",
"being",
"removed",
"from",
"the",
"container",
".",
"This",
"normally",
"will",
"only",
"occur",
"when",
"its",
"bundle",
"is",
"stopped",
"because",
"it",
"is",
"being",
"removed",
"or",
"updated",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/impl/FhirServerManager.java#L248-L271 |
22,419 | jamesagnew/hapi-fhir | hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/model/BaseDateTimeType.java | BaseDateTimeType.setPrecision | public void setPrecision(TemporalPrecisionEnum thePrecision) throws DataFormatException {
if (thePrecision == null) {
throw new NullPointerException("Precision may not be null");
}
myPrecision = thePrecision;
updateStringValue();
} | java | public void setPrecision(TemporalPrecisionEnum thePrecision) throws DataFormatException {
if (thePrecision == null) {
throw new NullPointerException("Precision may not be null");
}
myPrecision = thePrecision;
updateStringValue();
} | [
"public",
"void",
"setPrecision",
"(",
"TemporalPrecisionEnum",
"thePrecision",
")",
"throws",
"DataFormatException",
"{",
"if",
"(",
"thePrecision",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Precision may not be null\"",
")",
";",
"}",
"myPrecision",
"=",
"thePrecision",
";",
"updateStringValue",
"(",
")",
";",
"}"
] | Sets the precision for this datatype
@throws DataFormatException | [
"Sets",
"the",
"precision",
"for",
"this",
"datatype"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/model/BaseDateTimeType.java#L587-L593 |
22,420 | jamesagnew/hapi-fhir | hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/model/BaseDateTimeType.java | BaseDateTimeType.setValue | public void setValue(Date theValue, TemporalPrecisionEnum thePrecision) throws DataFormatException {
if (getTimeZone() == null) {
setTimeZone(TimeZone.getDefault());
}
myPrecision = thePrecision;
myFractionalSeconds = "";
if (theValue != null) {
long millis = theValue.getTime() % 1000;
if (millis < 0) {
// This is for times before 1970 (see bug #444)
millis = 1000 + millis;
}
String fractionalSeconds = Integer.toString((int) millis);
myFractionalSeconds = StringUtils.leftPad(fractionalSeconds, 3, '0');
}
super.setValue(theValue);
} | java | public void setValue(Date theValue, TemporalPrecisionEnum thePrecision) throws DataFormatException {
if (getTimeZone() == null) {
setTimeZone(TimeZone.getDefault());
}
myPrecision = thePrecision;
myFractionalSeconds = "";
if (theValue != null) {
long millis = theValue.getTime() % 1000;
if (millis < 0) {
// This is for times before 1970 (see bug #444)
millis = 1000 + millis;
}
String fractionalSeconds = Integer.toString((int) millis);
myFractionalSeconds = StringUtils.leftPad(fractionalSeconds, 3, '0');
}
super.setValue(theValue);
} | [
"public",
"void",
"setValue",
"(",
"Date",
"theValue",
",",
"TemporalPrecisionEnum",
"thePrecision",
")",
"throws",
"DataFormatException",
"{",
"if",
"(",
"getTimeZone",
"(",
")",
"==",
"null",
")",
"{",
"setTimeZone",
"(",
"TimeZone",
".",
"getDefault",
"(",
")",
")",
";",
"}",
"myPrecision",
"=",
"thePrecision",
";",
"myFractionalSeconds",
"=",
"\"\"",
";",
"if",
"(",
"theValue",
"!=",
"null",
")",
"{",
"long",
"millis",
"=",
"theValue",
".",
"getTime",
"(",
")",
"%",
"1000",
";",
"if",
"(",
"millis",
"<",
"0",
")",
"{",
"// This is for times before 1970 (see bug #444)",
"millis",
"=",
"1000",
"+",
"millis",
";",
"}",
"String",
"fractionalSeconds",
"=",
"Integer",
".",
"toString",
"(",
"(",
"int",
")",
"millis",
")",
";",
"myFractionalSeconds",
"=",
"StringUtils",
".",
"leftPad",
"(",
"fractionalSeconds",
",",
"3",
",",
"'",
"'",
")",
";",
"}",
"super",
".",
"setValue",
"(",
"theValue",
")",
";",
"}"
] | Sets the value for this type using the given Java Date object as the time, and using the specified precision, as
well as the local timezone as determined by the local operating system. Both of
these properties may be modified in subsequent calls if neccesary.
@param theValue
The date value
@param thePrecision
The precision
@throws DataFormatException | [
"Sets",
"the",
"value",
"for",
"this",
"type",
"using",
"the",
"given",
"Java",
"Date",
"object",
"as",
"the",
"time",
"and",
"using",
"the",
"specified",
"precision",
"as",
"well",
"as",
"the",
"local",
"timezone",
"as",
"determined",
"by",
"the",
"local",
"operating",
"system",
".",
"Both",
"of",
"these",
"properties",
"may",
"be",
"modified",
"in",
"subsequent",
"calls",
"if",
"neccesary",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/model/BaseDateTimeType.java#L660-L676 |
22,421 | jamesagnew/hapi-fhir | hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/util/JaxRsResponse.java | JaxRsResponse.getResponseWriter | @Override
public Writer getResponseWriter(int theStatusCode, String theStatusMessage, String theContentType, String theCharset, boolean theRespondGzip)
throws UnsupportedEncodingException, IOException {
return new StringWriter();
} | java | @Override
public Writer getResponseWriter(int theStatusCode, String theStatusMessage, String theContentType, String theCharset, boolean theRespondGzip)
throws UnsupportedEncodingException, IOException {
return new StringWriter();
} | [
"@",
"Override",
"public",
"Writer",
"getResponseWriter",
"(",
"int",
"theStatusCode",
",",
"String",
"theStatusMessage",
",",
"String",
"theContentType",
",",
"String",
"theCharset",
",",
"boolean",
"theRespondGzip",
")",
"throws",
"UnsupportedEncodingException",
",",
"IOException",
"{",
"return",
"new",
"StringWriter",
"(",
")",
";",
"}"
] | The response writer is a simple String Writer. All output is configured
by the server. | [
"The",
"response",
"writer",
"is",
"a",
"simple",
"String",
"Writer",
".",
"All",
"output",
"is",
"configured",
"by",
"the",
"server",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/util/JaxRsResponse.java#L62-L66 |
22,422 | jamesagnew/hapi-fhir | hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/elementmodel/Property.java | Property.isPrimitive | public boolean isPrimitive(String code) {
StructureDefinition sd = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+code);
return sd != null && sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE;
} | java | public boolean isPrimitive(String code) {
StructureDefinition sd = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+code);
return sd != null && sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE;
} | [
"public",
"boolean",
"isPrimitive",
"(",
"String",
"code",
")",
"{",
"StructureDefinition",
"sd",
"=",
"context",
".",
"fetchResource",
"(",
"StructureDefinition",
".",
"class",
",",
"\"http://hl7.org/fhir/StructureDefinition/\"",
"+",
"code",
")",
";",
"return",
"sd",
"!=",
"null",
"&&",
"sd",
".",
"getKind",
"(",
")",
"==",
"StructureDefinitionKind",
".",
"PRIMITIVETYPE",
";",
"}"
] | Is the given type a primitive
@param E.g. "integer" | [
"Is",
"the",
"given",
"type",
"a",
"primitive"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/elementmodel/Property.java#L135-L138 |
22,423 | jamesagnew/hapi-fhir | examples/src/main/java/example/ExampleRestfulServlet.java | ExampleRestfulServlet.initialize | @Override
protected void initialize() throws ServletException {
/*
* The servlet defines any number of resource providers, and
* configures itself to use them by calling
* setResourceProviders()
*/
List<IResourceProvider> resourceProviders = new ArrayList<IResourceProvider>();
resourceProviders.add(new RestfulPatientResourceProvider());
resourceProviders.add(new RestfulObservationResourceProvider());
setResourceProviders(resourceProviders);
} | java | @Override
protected void initialize() throws ServletException {
/*
* The servlet defines any number of resource providers, and
* configures itself to use them by calling
* setResourceProviders()
*/
List<IResourceProvider> resourceProviders = new ArrayList<IResourceProvider>();
resourceProviders.add(new RestfulPatientResourceProvider());
resourceProviders.add(new RestfulObservationResourceProvider());
setResourceProviders(resourceProviders);
} | [
"@",
"Override",
"protected",
"void",
"initialize",
"(",
")",
"throws",
"ServletException",
"{",
"/*\n * The servlet defines any number of resource providers, and\n * configures itself to use them by calling\n * setResourceProviders()\n */",
"List",
"<",
"IResourceProvider",
">",
"resourceProviders",
"=",
"new",
"ArrayList",
"<",
"IResourceProvider",
">",
"(",
")",
";",
"resourceProviders",
".",
"add",
"(",
"new",
"RestfulPatientResourceProvider",
"(",
")",
")",
";",
"resourceProviders",
".",
"add",
"(",
"new",
"RestfulObservationResourceProvider",
"(",
")",
")",
";",
"setResourceProviders",
"(",
"resourceProviders",
")",
";",
"}"
] | The initialize method is automatically called when the servlet is starting up, so it can
be used to configure the servlet to define resource providers, or set up
configuration, interceptors, etc. | [
"The",
"initialize",
"method",
"is",
"automatically",
"called",
"when",
"the",
"servlet",
"is",
"starting",
"up",
"so",
"it",
"can",
"be",
"used",
"to",
"configure",
"the",
"servlet",
"to",
"define",
"resource",
"providers",
"or",
"set",
"up",
"configuration",
"interceptors",
"etc",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/examples/src/main/java/example/ExampleRestfulServlet.java#L28-L39 |
22,424 | jamesagnew/hapi-fhir | hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/DecimalDt.java | DecimalDt.round | public void round(int thePrecision) {
if (getValue() != null) {
BigDecimal newValue = getValue().round(new MathContext(thePrecision));
setValue(newValue);
}
} | java | public void round(int thePrecision) {
if (getValue() != null) {
BigDecimal newValue = getValue().round(new MathContext(thePrecision));
setValue(newValue);
}
} | [
"public",
"void",
"round",
"(",
"int",
"thePrecision",
")",
"{",
"if",
"(",
"getValue",
"(",
")",
"!=",
"null",
")",
"{",
"BigDecimal",
"newValue",
"=",
"getValue",
"(",
")",
".",
"round",
"(",
"new",
"MathContext",
"(",
"thePrecision",
")",
")",
";",
"setValue",
"(",
"newValue",
")",
";",
"}",
"}"
] | Rounds the value to the given prevision
@see MathContext#getPrecision() | [
"Rounds",
"the",
"value",
"to",
"the",
"given",
"prevision"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/DecimalDt.java#L116-L121 |
22,425 | jamesagnew/hapi-fhir | hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/utils/ToolingExtensions.java | ToolingExtensions.makeIssueSource | public static Extension makeIssueSource(Source source) {
Extension ex = new Extension();
// todo: write this up and get it published with the pack (and handle the redirect?)
ex.setUrl(ToolingExtensions.EXT_ISSUE_SOURCE);
CodeType c = new CodeType();
c.setValue(source.toString());
ex.setValue(c);
return ex;
} | java | public static Extension makeIssueSource(Source source) {
Extension ex = new Extension();
// todo: write this up and get it published with the pack (and handle the redirect?)
ex.setUrl(ToolingExtensions.EXT_ISSUE_SOURCE);
CodeType c = new CodeType();
c.setValue(source.toString());
ex.setValue(c);
return ex;
} | [
"public",
"static",
"Extension",
"makeIssueSource",
"(",
"Source",
"source",
")",
"{",
"Extension",
"ex",
"=",
"new",
"Extension",
"(",
")",
";",
"// todo: write this up and get it published with the pack (and handle the redirect?)\r",
"ex",
".",
"setUrl",
"(",
"ToolingExtensions",
".",
"EXT_ISSUE_SOURCE",
")",
";",
"CodeType",
"c",
"=",
"new",
"CodeType",
"(",
")",
";",
"c",
".",
"setValue",
"(",
"source",
".",
"toString",
"(",
")",
")",
";",
"ex",
".",
"setValue",
"(",
"c",
")",
";",
"return",
"ex",
";",
"}"
] | specific extension helpers | [
"specific",
"extension",
"helpers"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/utils/ToolingExtensions.java#L102-L110 |
22,426 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/BaseResourceMessage.java | BaseResourceMessage.copyAdditionalPropertiesFrom | public void copyAdditionalPropertiesFrom(BaseResourceMessage theMsg) {
if (theMsg.myAttributes != null) {
if (myAttributes == null) {
myAttributes = new HashMap<>();
}
myAttributes.putAll(theMsg.myAttributes);
}
} | java | public void copyAdditionalPropertiesFrom(BaseResourceMessage theMsg) {
if (theMsg.myAttributes != null) {
if (myAttributes == null) {
myAttributes = new HashMap<>();
}
myAttributes.putAll(theMsg.myAttributes);
}
} | [
"public",
"void",
"copyAdditionalPropertiesFrom",
"(",
"BaseResourceMessage",
"theMsg",
")",
"{",
"if",
"(",
"theMsg",
".",
"myAttributes",
"!=",
"null",
")",
"{",
"if",
"(",
"myAttributes",
"==",
"null",
")",
"{",
"myAttributes",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"}",
"myAttributes",
".",
"putAll",
"(",
"theMsg",
".",
"myAttributes",
")",
";",
"}",
"}"
] | Copies any attributes from the given message into this messsage.
@see #setAttribute(String, String)
@see #getAttribute(String) | [
"Copies",
"any",
"attributes",
"from",
"the",
"given",
"message",
"into",
"this",
"messsage",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/BaseResourceMessage.java#L92-L99 |
22,427 | jamesagnew/hapi-fhir | hapi-fhir-base/src/main/java/ca/uhn/fhir/util/XmlUtil.java | XmlUtil.encode | public static String encode(List<XMLEvent> theEvents) {
try {
StringWriter w = new StringWriter();
XMLEventWriter ew = XmlUtil.createXmlFragmentWriter(w);
for (XMLEvent next : theEvents) {
if (next.isCharacters()) {
ew.add(next);
} else {
ew.add(next);
}
}
ew.close();
return w.toString();
} catch (XMLStreamException e) {
throw new DataFormatException("Problem with the contained XML events", e);
} catch (FactoryConfigurationError e) {
throw new ConfigurationException(e);
}
} | java | public static String encode(List<XMLEvent> theEvents) {
try {
StringWriter w = new StringWriter();
XMLEventWriter ew = XmlUtil.createXmlFragmentWriter(w);
for (XMLEvent next : theEvents) {
if (next.isCharacters()) {
ew.add(next);
} else {
ew.add(next);
}
}
ew.close();
return w.toString();
} catch (XMLStreamException e) {
throw new DataFormatException("Problem with the contained XML events", e);
} catch (FactoryConfigurationError e) {
throw new ConfigurationException(e);
}
} | [
"public",
"static",
"String",
"encode",
"(",
"List",
"<",
"XMLEvent",
">",
"theEvents",
")",
"{",
"try",
"{",
"StringWriter",
"w",
"=",
"new",
"StringWriter",
"(",
")",
";",
"XMLEventWriter",
"ew",
"=",
"XmlUtil",
".",
"createXmlFragmentWriter",
"(",
"w",
")",
";",
"for",
"(",
"XMLEvent",
"next",
":",
"theEvents",
")",
"{",
"if",
"(",
"next",
".",
"isCharacters",
"(",
")",
")",
"{",
"ew",
".",
"add",
"(",
"next",
")",
";",
"}",
"else",
"{",
"ew",
".",
"add",
"(",
"next",
")",
";",
"}",
"}",
"ew",
".",
"close",
"(",
")",
";",
"return",
"w",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"XMLStreamException",
"e",
")",
"{",
"throw",
"new",
"DataFormatException",
"(",
"\"Problem with the contained XML events\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"FactoryConfigurationError",
"e",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"e",
")",
";",
"}",
"}"
] | Encode a set of StAX events into a String | [
"Encode",
"a",
"set",
"of",
"StAX",
"events",
"into",
"a",
"String"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/XmlUtil.java#L1570-L1589 |
22,428 | jamesagnew/hapi-fhir | hapi-fhir-base/src/main/java/ca/uhn/fhir/util/XmlUtil.java | XmlUtil.parse | public static List<XMLEvent> parse(String theValue) {
if (isBlank(theValue)) {
return Collections.emptyList();
}
String val = theValue.trim();
if (!val.startsWith("<")) {
val = XhtmlDt.DIV_OPEN_FIRST + val + "</div>";
}
boolean hasProcessingInstruction = val.startsWith("<?");
if (hasProcessingInstruction && val.endsWith("?>")) {
return null;
}
try {
ArrayList<XMLEvent> value = new ArrayList<>();
StringReader reader = new StringReader(val);
XMLEventReader er = XmlUtil.createXmlReader(reader);
boolean first = true;
while (er.hasNext()) {
XMLEvent next = er.nextEvent();
if (first) {
first = false;
continue;
}
if (er.hasNext()) {
// don't add the last event
value.add(next);
}
}
return value;
} catch (XMLStreamException e) {
throw new DataFormatException("String does not appear to be valid XML/XHTML (error is \"" + e.getMessage() + "\"): " + theValue, e);
} catch (FactoryConfigurationError e) {
throw new ConfigurationException(e);
}
} | java | public static List<XMLEvent> parse(String theValue) {
if (isBlank(theValue)) {
return Collections.emptyList();
}
String val = theValue.trim();
if (!val.startsWith("<")) {
val = XhtmlDt.DIV_OPEN_FIRST + val + "</div>";
}
boolean hasProcessingInstruction = val.startsWith("<?");
if (hasProcessingInstruction && val.endsWith("?>")) {
return null;
}
try {
ArrayList<XMLEvent> value = new ArrayList<>();
StringReader reader = new StringReader(val);
XMLEventReader er = XmlUtil.createXmlReader(reader);
boolean first = true;
while (er.hasNext()) {
XMLEvent next = er.nextEvent();
if (first) {
first = false;
continue;
}
if (er.hasNext()) {
// don't add the last event
value.add(next);
}
}
return value;
} catch (XMLStreamException e) {
throw new DataFormatException("String does not appear to be valid XML/XHTML (error is \"" + e.getMessage() + "\"): " + theValue, e);
} catch (FactoryConfigurationError e) {
throw new ConfigurationException(e);
}
} | [
"public",
"static",
"List",
"<",
"XMLEvent",
">",
"parse",
"(",
"String",
"theValue",
")",
"{",
"if",
"(",
"isBlank",
"(",
"theValue",
")",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"String",
"val",
"=",
"theValue",
".",
"trim",
"(",
")",
";",
"if",
"(",
"!",
"val",
".",
"startsWith",
"(",
"\"<\"",
")",
")",
"{",
"val",
"=",
"XhtmlDt",
".",
"DIV_OPEN_FIRST",
"+",
"val",
"+",
"\"</div>\"",
";",
"}",
"boolean",
"hasProcessingInstruction",
"=",
"val",
".",
"startsWith",
"(",
"\"<?\"",
")",
";",
"if",
"(",
"hasProcessingInstruction",
"&&",
"val",
".",
"endsWith",
"(",
"\"?>\"",
")",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"ArrayList",
"<",
"XMLEvent",
">",
"value",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"StringReader",
"reader",
"=",
"new",
"StringReader",
"(",
"val",
")",
";",
"XMLEventReader",
"er",
"=",
"XmlUtil",
".",
"createXmlReader",
"(",
"reader",
")",
";",
"boolean",
"first",
"=",
"true",
";",
"while",
"(",
"er",
".",
"hasNext",
"(",
")",
")",
"{",
"XMLEvent",
"next",
"=",
"er",
".",
"nextEvent",
"(",
")",
";",
"if",
"(",
"first",
")",
"{",
"first",
"=",
"false",
";",
"continue",
";",
"}",
"if",
"(",
"er",
".",
"hasNext",
"(",
")",
")",
"{",
"// don't add the last event",
"value",
".",
"add",
"(",
"next",
")",
";",
"}",
"}",
"return",
"value",
";",
"}",
"catch",
"(",
"XMLStreamException",
"e",
")",
"{",
"throw",
"new",
"DataFormatException",
"(",
"\"String does not appear to be valid XML/XHTML (error is \\\"\"",
"+",
"e",
".",
"getMessage",
"(",
")",
"+",
"\"\\\"): \"",
"+",
"theValue",
",",
"e",
")",
";",
"}",
"catch",
"(",
"FactoryConfigurationError",
"e",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"e",
")",
";",
"}",
"}"
] | Parses an XML string into a set of StAX events | [
"Parses",
"an",
"XML",
"string",
"into",
"a",
"set",
"of",
"StAX",
"events"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/XmlUtil.java#L1714-L1752 |
22,429 | jamesagnew/hapi-fhir | hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/model/BaseDateTimeType.java | BaseDateTimeType.setOffsetMinutes | public void setOffsetMinutes(int theZoneOffsetMinutes) {
int offsetAbs = Math.abs(theZoneOffsetMinutes);
int mins = offsetAbs % 60;
int hours = offsetAbs / 60;
if (theZoneOffsetMinutes < 0) {
setTimeZone(TimeZone.getTimeZone("GMT-" + hours + ":" + mins));
} else {
setTimeZone(TimeZone.getTimeZone("GMT+" + hours + ":" + mins));
}
} | java | public void setOffsetMinutes(int theZoneOffsetMinutes) {
int offsetAbs = Math.abs(theZoneOffsetMinutes);
int mins = offsetAbs % 60;
int hours = offsetAbs / 60;
if (theZoneOffsetMinutes < 0) {
setTimeZone(TimeZone.getTimeZone("GMT-" + hours + ":" + mins));
} else {
setTimeZone(TimeZone.getTimeZone("GMT+" + hours + ":" + mins));
}
} | [
"public",
"void",
"setOffsetMinutes",
"(",
"int",
"theZoneOffsetMinutes",
")",
"{",
"int",
"offsetAbs",
"=",
"Math",
".",
"abs",
"(",
"theZoneOffsetMinutes",
")",
";",
"int",
"mins",
"=",
"offsetAbs",
"%",
"60",
";",
"int",
"hours",
"=",
"offsetAbs",
"/",
"60",
";",
"if",
"(",
"theZoneOffsetMinutes",
"<",
"0",
")",
"{",
"setTimeZone",
"(",
"TimeZone",
".",
"getTimeZone",
"(",
"\"GMT-\"",
"+",
"hours",
"+",
"\":\"",
"+",
"mins",
")",
")",
";",
"}",
"else",
"{",
"setTimeZone",
"(",
"TimeZone",
".",
"getTimeZone",
"(",
"\"GMT+\"",
"+",
"hours",
"+",
"\":\"",
"+",
"mins",
")",
")",
";",
"}",
"}"
] | Sets the TimeZone offset in minutes relative to GMT | [
"Sets",
"the",
"TimeZone",
"offset",
"in",
"minutes",
"relative",
"to",
"GMT"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/model/BaseDateTimeType.java#L516-L527 |
22,430 | jamesagnew/hapi-fhir | hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/model/BaseDateTimeType.java | BaseDateTimeType.add | public void add(int theField, int theValue) {
switch (theField) {
case Calendar.YEAR:
setValue(DateUtils.addYears(getValue(), theValue), getPrecision());
break;
case Calendar.MONTH:
setValue(DateUtils.addMonths(getValue(), theValue), getPrecision());
break;
case Calendar.DATE:
setValue(DateUtils.addDays(getValue(), theValue), getPrecision());
break;
case Calendar.HOUR:
setValue(DateUtils.addHours(getValue(), theValue), getPrecision());
break;
case Calendar.MINUTE:
setValue(DateUtils.addMinutes(getValue(), theValue), getPrecision());
break;
case Calendar.SECOND:
setValue(DateUtils.addSeconds(getValue(), theValue), getPrecision());
break;
case Calendar.MILLISECOND:
setValue(DateUtils.addMilliseconds(getValue(), theValue), getPrecision());
break;
default:
throw new IllegalArgumentException("Unknown field constant: " + theField);
}
} | java | public void add(int theField, int theValue) {
switch (theField) {
case Calendar.YEAR:
setValue(DateUtils.addYears(getValue(), theValue), getPrecision());
break;
case Calendar.MONTH:
setValue(DateUtils.addMonths(getValue(), theValue), getPrecision());
break;
case Calendar.DATE:
setValue(DateUtils.addDays(getValue(), theValue), getPrecision());
break;
case Calendar.HOUR:
setValue(DateUtils.addHours(getValue(), theValue), getPrecision());
break;
case Calendar.MINUTE:
setValue(DateUtils.addMinutes(getValue(), theValue), getPrecision());
break;
case Calendar.SECOND:
setValue(DateUtils.addSeconds(getValue(), theValue), getPrecision());
break;
case Calendar.MILLISECOND:
setValue(DateUtils.addMilliseconds(getValue(), theValue), getPrecision());
break;
default:
throw new IllegalArgumentException("Unknown field constant: " + theField);
}
} | [
"public",
"void",
"add",
"(",
"int",
"theField",
",",
"int",
"theValue",
")",
"{",
"switch",
"(",
"theField",
")",
"{",
"case",
"Calendar",
".",
"YEAR",
":",
"setValue",
"(",
"DateUtils",
".",
"addYears",
"(",
"getValue",
"(",
")",
",",
"theValue",
")",
",",
"getPrecision",
"(",
")",
")",
";",
"break",
";",
"case",
"Calendar",
".",
"MONTH",
":",
"setValue",
"(",
"DateUtils",
".",
"addMonths",
"(",
"getValue",
"(",
")",
",",
"theValue",
")",
",",
"getPrecision",
"(",
")",
")",
";",
"break",
";",
"case",
"Calendar",
".",
"DATE",
":",
"setValue",
"(",
"DateUtils",
".",
"addDays",
"(",
"getValue",
"(",
")",
",",
"theValue",
")",
",",
"getPrecision",
"(",
")",
")",
";",
"break",
";",
"case",
"Calendar",
".",
"HOUR",
":",
"setValue",
"(",
"DateUtils",
".",
"addHours",
"(",
"getValue",
"(",
")",
",",
"theValue",
")",
",",
"getPrecision",
"(",
")",
")",
";",
"break",
";",
"case",
"Calendar",
".",
"MINUTE",
":",
"setValue",
"(",
"DateUtils",
".",
"addMinutes",
"(",
"getValue",
"(",
")",
",",
"theValue",
")",
",",
"getPrecision",
"(",
")",
")",
";",
"break",
";",
"case",
"Calendar",
".",
"SECOND",
":",
"setValue",
"(",
"DateUtils",
".",
"addSeconds",
"(",
"getValue",
"(",
")",
",",
"theValue",
")",
",",
"getPrecision",
"(",
")",
")",
";",
"break",
";",
"case",
"Calendar",
".",
"MILLISECOND",
":",
"setValue",
"(",
"DateUtils",
".",
"addMilliseconds",
"(",
"getValue",
"(",
")",
",",
"theValue",
")",
",",
"getPrecision",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unknown field constant: \"",
"+",
"theField",
")",
";",
"}",
"}"
] | Adds the given amount to the field specified by theField
@param theField
The field, uses constants from {@link Calendar} such as {@link Calendar#YEAR}
@param theValue
The number to add (or subtract for a negative number) | [
"Adds",
"the",
"given",
"amount",
"to",
"the",
"field",
"specified",
"by",
"theField"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/model/BaseDateTimeType.java#L544-L570 |
22,431 | jamesagnew/hapi-fhir | examples/src/main/java/example/PagingPatientProvider.java | PagingPatientProvider.search | @Search
public IBundleProvider search(@RequiredParam(name = Patient.SP_FAMILY) StringParam theFamily) {
final InstantDt searchTime = InstantDt.withCurrentTime();
/**
* First, we'll search the database for a set of database row IDs that
* match the given search criteria. That way we can keep just the row IDs
* around, and load the actual resources on demand later as the client
* pages through them.
*/
final List<Long> matchingResourceIds = null; // <-- implement this
/**
* Return a bundle provider which can page through the IDs and return the
* resources that go with them.
*/
return new IBundleProvider() {
@Override
public Integer size() {
return matchingResourceIds.size();
}
@Override
public List<IBaseResource> getResources(int theFromIndex, int theToIndex) {
int end = Math.max(theToIndex, matchingResourceIds.size() - 1);
List<Long> idsToReturn = matchingResourceIds.subList(theFromIndex, end);
return loadResourcesByIds(idsToReturn);
}
@Override
public InstantDt getPublished() {
return searchTime;
}
@Override
public Integer preferredPageSize() {
// Typically this method just returns null
return null;
}
@Override
public String getUuid() {
return null;
}
};
} | java | @Search
public IBundleProvider search(@RequiredParam(name = Patient.SP_FAMILY) StringParam theFamily) {
final InstantDt searchTime = InstantDt.withCurrentTime();
/**
* First, we'll search the database for a set of database row IDs that
* match the given search criteria. That way we can keep just the row IDs
* around, and load the actual resources on demand later as the client
* pages through them.
*/
final List<Long> matchingResourceIds = null; // <-- implement this
/**
* Return a bundle provider which can page through the IDs and return the
* resources that go with them.
*/
return new IBundleProvider() {
@Override
public Integer size() {
return matchingResourceIds.size();
}
@Override
public List<IBaseResource> getResources(int theFromIndex, int theToIndex) {
int end = Math.max(theToIndex, matchingResourceIds.size() - 1);
List<Long> idsToReturn = matchingResourceIds.subList(theFromIndex, end);
return loadResourcesByIds(idsToReturn);
}
@Override
public InstantDt getPublished() {
return searchTime;
}
@Override
public Integer preferredPageSize() {
// Typically this method just returns null
return null;
}
@Override
public String getUuid() {
return null;
}
};
} | [
"@",
"Search",
"public",
"IBundleProvider",
"search",
"(",
"@",
"RequiredParam",
"(",
"name",
"=",
"Patient",
".",
"SP_FAMILY",
")",
"StringParam",
"theFamily",
")",
"{",
"final",
"InstantDt",
"searchTime",
"=",
"InstantDt",
".",
"withCurrentTime",
"(",
")",
";",
"/**\n * First, we'll search the database for a set of database row IDs that\n * match the given search criteria. That way we can keep just the row IDs\n * around, and load the actual resources on demand later as the client\n * pages through them.\n */",
"final",
"List",
"<",
"Long",
">",
"matchingResourceIds",
"=",
"null",
";",
"// <-- implement this",
"/**\n * Return a bundle provider which can page through the IDs and return the\n * resources that go with them.\n */",
"return",
"new",
"IBundleProvider",
"(",
")",
"{",
"@",
"Override",
"public",
"Integer",
"size",
"(",
")",
"{",
"return",
"matchingResourceIds",
".",
"size",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"List",
"<",
"IBaseResource",
">",
"getResources",
"(",
"int",
"theFromIndex",
",",
"int",
"theToIndex",
")",
"{",
"int",
"end",
"=",
"Math",
".",
"max",
"(",
"theToIndex",
",",
"matchingResourceIds",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"List",
"<",
"Long",
">",
"idsToReturn",
"=",
"matchingResourceIds",
".",
"subList",
"(",
"theFromIndex",
",",
"end",
")",
";",
"return",
"loadResourcesByIds",
"(",
"idsToReturn",
")",
";",
"}",
"@",
"Override",
"public",
"InstantDt",
"getPublished",
"(",
")",
"{",
"return",
"searchTime",
";",
"}",
"@",
"Override",
"public",
"Integer",
"preferredPageSize",
"(",
")",
"{",
"// Typically this method just returns null",
"return",
"null",
";",
"}",
"@",
"Override",
"public",
"String",
"getUuid",
"(",
")",
"{",
"return",
"null",
";",
"}",
"}",
";",
"}"
] | Search for Patient resources matching a given family name | [
"Search",
"for",
"Patient",
"resources",
"matching",
"a",
"given",
"family",
"name"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/examples/src/main/java/example/PagingPatientProvider.java#L23-L69 |
22,432 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java | BaseHapiFhirDao.createForcedIdIfNeeded | protected ForcedId createForcedIdIfNeeded(ResourceTable theEntity, IIdType theId, boolean theCreateForPureNumericIds) {
if (theId.isEmpty() == false && theId.hasIdPart() && theEntity.getForcedId() == null) {
if (!theCreateForPureNumericIds && IdHelperService.isValidPid(theId)) {
return null;
}
ForcedId fid = new ForcedId();
fid.setResourceType(theEntity.getResourceType());
fid.setForcedId(theId.getIdPart());
fid.setResource(theEntity);
theEntity.setForcedId(fid);
return fid;
}
return null;
} | java | protected ForcedId createForcedIdIfNeeded(ResourceTable theEntity, IIdType theId, boolean theCreateForPureNumericIds) {
if (theId.isEmpty() == false && theId.hasIdPart() && theEntity.getForcedId() == null) {
if (!theCreateForPureNumericIds && IdHelperService.isValidPid(theId)) {
return null;
}
ForcedId fid = new ForcedId();
fid.setResourceType(theEntity.getResourceType());
fid.setForcedId(theId.getIdPart());
fid.setResource(theEntity);
theEntity.setForcedId(fid);
return fid;
}
return null;
} | [
"protected",
"ForcedId",
"createForcedIdIfNeeded",
"(",
"ResourceTable",
"theEntity",
",",
"IIdType",
"theId",
",",
"boolean",
"theCreateForPureNumericIds",
")",
"{",
"if",
"(",
"theId",
".",
"isEmpty",
"(",
")",
"==",
"false",
"&&",
"theId",
".",
"hasIdPart",
"(",
")",
"&&",
"theEntity",
".",
"getForcedId",
"(",
")",
"==",
"null",
")",
"{",
"if",
"(",
"!",
"theCreateForPureNumericIds",
"&&",
"IdHelperService",
".",
"isValidPid",
"(",
"theId",
")",
")",
"{",
"return",
"null",
";",
"}",
"ForcedId",
"fid",
"=",
"new",
"ForcedId",
"(",
")",
";",
"fid",
".",
"setResourceType",
"(",
"theEntity",
".",
"getResourceType",
"(",
")",
")",
";",
"fid",
".",
"setForcedId",
"(",
"theId",
".",
"getIdPart",
"(",
")",
")",
";",
"fid",
".",
"setResource",
"(",
"theEntity",
")",
";",
"theEntity",
".",
"setForcedId",
"(",
"fid",
")",
";",
"return",
"fid",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the newly created forced ID. If the entity already had a forced ID, or if
none was created, returns null. | [
"Returns",
"the",
"newly",
"created",
"forced",
"ID",
".",
"If",
"the",
"entity",
"already",
"had",
"a",
"forced",
"ID",
"or",
"if",
"none",
"was",
"created",
"returns",
"null",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java#L193-L208 |
22,433 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java | BaseHapiFhirDao.validateResourceForStorage | protected void validateResourceForStorage(T theResource, ResourceTable theEntityToSave) {
Object tag = null;
int totalMetaCount = 0;
if (theResource instanceof IResource) {
IResource res = (IResource) theResource;
TagList tagList = ResourceMetadataKeyEnum.TAG_LIST.get(res);
if (tagList != null) {
tag = tagList.getTag(Constants.TAG_SUBSETTED_SYSTEM_DSTU3, Constants.TAG_SUBSETTED_CODE);
totalMetaCount += tagList.size();
}
List<IdDt> profileList = ResourceMetadataKeyEnum.PROFILES.get(res);
if (profileList != null) {
totalMetaCount += profileList.size();
}
} else {
IAnyResource res = (IAnyResource) theResource;
tag = res.getMeta().getTag(Constants.TAG_SUBSETTED_SYSTEM_DSTU3, Constants.TAG_SUBSETTED_CODE);
totalMetaCount += res.getMeta().getTag().size();
totalMetaCount += res.getMeta().getProfile().size();
totalMetaCount += res.getMeta().getSecurity().size();
}
if (tag != null) {
throw new UnprocessableEntityException("Resource contains the 'subsetted' tag, and must not be stored as it may contain a subset of available data");
}
String resName = getContext().getResourceDefinition(theResource).getName();
validateChildReferences(theResource, resName);
validateMetaCount(totalMetaCount);
} | java | protected void validateResourceForStorage(T theResource, ResourceTable theEntityToSave) {
Object tag = null;
int totalMetaCount = 0;
if (theResource instanceof IResource) {
IResource res = (IResource) theResource;
TagList tagList = ResourceMetadataKeyEnum.TAG_LIST.get(res);
if (tagList != null) {
tag = tagList.getTag(Constants.TAG_SUBSETTED_SYSTEM_DSTU3, Constants.TAG_SUBSETTED_CODE);
totalMetaCount += tagList.size();
}
List<IdDt> profileList = ResourceMetadataKeyEnum.PROFILES.get(res);
if (profileList != null) {
totalMetaCount += profileList.size();
}
} else {
IAnyResource res = (IAnyResource) theResource;
tag = res.getMeta().getTag(Constants.TAG_SUBSETTED_SYSTEM_DSTU3, Constants.TAG_SUBSETTED_CODE);
totalMetaCount += res.getMeta().getTag().size();
totalMetaCount += res.getMeta().getProfile().size();
totalMetaCount += res.getMeta().getSecurity().size();
}
if (tag != null) {
throw new UnprocessableEntityException("Resource contains the 'subsetted' tag, and must not be stored as it may contain a subset of available data");
}
String resName = getContext().getResourceDefinition(theResource).getName();
validateChildReferences(theResource, resName);
validateMetaCount(totalMetaCount);
} | [
"protected",
"void",
"validateResourceForStorage",
"(",
"T",
"theResource",
",",
"ResourceTable",
"theEntityToSave",
")",
"{",
"Object",
"tag",
"=",
"null",
";",
"int",
"totalMetaCount",
"=",
"0",
";",
"if",
"(",
"theResource",
"instanceof",
"IResource",
")",
"{",
"IResource",
"res",
"=",
"(",
"IResource",
")",
"theResource",
";",
"TagList",
"tagList",
"=",
"ResourceMetadataKeyEnum",
".",
"TAG_LIST",
".",
"get",
"(",
"res",
")",
";",
"if",
"(",
"tagList",
"!=",
"null",
")",
"{",
"tag",
"=",
"tagList",
".",
"getTag",
"(",
"Constants",
".",
"TAG_SUBSETTED_SYSTEM_DSTU3",
",",
"Constants",
".",
"TAG_SUBSETTED_CODE",
")",
";",
"totalMetaCount",
"+=",
"tagList",
".",
"size",
"(",
")",
";",
"}",
"List",
"<",
"IdDt",
">",
"profileList",
"=",
"ResourceMetadataKeyEnum",
".",
"PROFILES",
".",
"get",
"(",
"res",
")",
";",
"if",
"(",
"profileList",
"!=",
"null",
")",
"{",
"totalMetaCount",
"+=",
"profileList",
".",
"size",
"(",
")",
";",
"}",
"}",
"else",
"{",
"IAnyResource",
"res",
"=",
"(",
"IAnyResource",
")",
"theResource",
";",
"tag",
"=",
"res",
".",
"getMeta",
"(",
")",
".",
"getTag",
"(",
"Constants",
".",
"TAG_SUBSETTED_SYSTEM_DSTU3",
",",
"Constants",
".",
"TAG_SUBSETTED_CODE",
")",
";",
"totalMetaCount",
"+=",
"res",
".",
"getMeta",
"(",
")",
".",
"getTag",
"(",
")",
".",
"size",
"(",
")",
";",
"totalMetaCount",
"+=",
"res",
".",
"getMeta",
"(",
")",
".",
"getProfile",
"(",
")",
".",
"size",
"(",
")",
";",
"totalMetaCount",
"+=",
"res",
".",
"getMeta",
"(",
")",
".",
"getSecurity",
"(",
")",
".",
"size",
"(",
")",
";",
"}",
"if",
"(",
"tag",
"!=",
"null",
")",
"{",
"throw",
"new",
"UnprocessableEntityException",
"(",
"\"Resource contains the 'subsetted' tag, and must not be stored as it may contain a subset of available data\"",
")",
";",
"}",
"String",
"resName",
"=",
"getContext",
"(",
")",
".",
"getResourceDefinition",
"(",
"theResource",
")",
".",
"getName",
"(",
")",
";",
"validateChildReferences",
"(",
"theResource",
",",
"resName",
")",
";",
"validateMetaCount",
"(",
"totalMetaCount",
")",
";",
"}"
] | This method is invoked immediately before storing a new resource, or an update to an existing resource to allow the DAO to ensure that it is valid for persistence. By default, checks for the
"subsetted" tag and rejects resources which have it. Subclasses should call the superclass implementation to preserve this check.
@param theResource The resource that is about to be persisted
@param theEntityToSave TODO | [
"This",
"method",
"is",
"invoked",
"immediately",
"before",
"storing",
"a",
"new",
"resource",
"or",
"an",
"update",
"to",
"an",
"existing",
"resource",
"to",
"allow",
"the",
"DAO",
"to",
"ensure",
"that",
"it",
"is",
"valid",
"for",
"persistence",
".",
"By",
"default",
"checks",
"for",
"the",
"subsetted",
"tag",
"and",
"rejects",
"resources",
"which",
"have",
"it",
".",
"Subclasses",
"should",
"call",
"the",
"superclass",
"implementation",
"to",
"preserve",
"this",
"check",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java#L1325-L1358 |
22,434 | jamesagnew/hapi-fhir | hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/model/ExtensionHelper.java | ExtensionHelper.setExtension | public static void setExtension(Element element, boolean modifier, String uri, Type value) throws FHIRException {
if (value == null) {
// deleting the extension
if (element instanceof BackboneElement)
for (Extension e : ((BackboneElement) element).getModifierExtension()) {
if (uri.equals(e.getUrl()))
((BackboneElement) element).getModifierExtension().remove(e);
}
for (Extension e : element.getExtension()) {
if (uri.equals(e.getUrl()))
element.getExtension().remove(e);
}
} else {
// it would probably be easier to delete and then create, but this would re-order the extensions
// not that order matters, but we'll preserve it anyway
boolean found = false;
if (element instanceof BackboneElement)
for (Extension e : ((BackboneElement) element).getModifierExtension()) {
if (uri.equals(e.getUrl())) {
if (!modifier)
throw new FHIRException("Error adding extension \""+uri+"\": found an existing modifier extension, and the extension is not marked as a modifier");
e.setValue(value);
found = true;
}
}
for (Extension e : element.getExtension()) {
if (uri.equals(e.getUrl())) {
if (modifier)
throw new FHIRException("Error adding extension \""+uri+"\": found an existing extension, and the extension is marked as a modifier");
e.setValue(value);
found = true;
}
}
if (!found) {
Extension ex = new Extension().setUrl(uri).setValue(value);
if (modifier) {
if (!(element instanceof BackboneElement))
throw new FHIRException("Error adding extension \""+uri+"\": extension is marked as a modifier, but element is not a backbone element");
((BackboneElement) element).getModifierExtension().add(ex);
} else {
element.getExtension().add(ex);
}
}
}
} | java | public static void setExtension(Element element, boolean modifier, String uri, Type value) throws FHIRException {
if (value == null) {
// deleting the extension
if (element instanceof BackboneElement)
for (Extension e : ((BackboneElement) element).getModifierExtension()) {
if (uri.equals(e.getUrl()))
((BackboneElement) element).getModifierExtension().remove(e);
}
for (Extension e : element.getExtension()) {
if (uri.equals(e.getUrl()))
element.getExtension().remove(e);
}
} else {
// it would probably be easier to delete and then create, but this would re-order the extensions
// not that order matters, but we'll preserve it anyway
boolean found = false;
if (element instanceof BackboneElement)
for (Extension e : ((BackboneElement) element).getModifierExtension()) {
if (uri.equals(e.getUrl())) {
if (!modifier)
throw new FHIRException("Error adding extension \""+uri+"\": found an existing modifier extension, and the extension is not marked as a modifier");
e.setValue(value);
found = true;
}
}
for (Extension e : element.getExtension()) {
if (uri.equals(e.getUrl())) {
if (modifier)
throw new FHIRException("Error adding extension \""+uri+"\": found an existing extension, and the extension is marked as a modifier");
e.setValue(value);
found = true;
}
}
if (!found) {
Extension ex = new Extension().setUrl(uri).setValue(value);
if (modifier) {
if (!(element instanceof BackboneElement))
throw new FHIRException("Error adding extension \""+uri+"\": extension is marked as a modifier, but element is not a backbone element");
((BackboneElement) element).getModifierExtension().add(ex);
} else {
element.getExtension().add(ex);
}
}
}
} | [
"public",
"static",
"void",
"setExtension",
"(",
"Element",
"element",
",",
"boolean",
"modifier",
",",
"String",
"uri",
",",
"Type",
"value",
")",
"throws",
"FHIRException",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"// deleting the extension\r",
"if",
"(",
"element",
"instanceof",
"BackboneElement",
")",
"for",
"(",
"Extension",
"e",
":",
"(",
"(",
"BackboneElement",
")",
"element",
")",
".",
"getModifierExtension",
"(",
")",
")",
"{",
"if",
"(",
"uri",
".",
"equals",
"(",
"e",
".",
"getUrl",
"(",
")",
")",
")",
"(",
"(",
"BackboneElement",
")",
"element",
")",
".",
"getModifierExtension",
"(",
")",
".",
"remove",
"(",
"e",
")",
";",
"}",
"for",
"(",
"Extension",
"e",
":",
"element",
".",
"getExtension",
"(",
")",
")",
"{",
"if",
"(",
"uri",
".",
"equals",
"(",
"e",
".",
"getUrl",
"(",
")",
")",
")",
"element",
".",
"getExtension",
"(",
")",
".",
"remove",
"(",
"e",
")",
";",
"}",
"}",
"else",
"{",
"// it would probably be easier to delete and then create, but this would re-order the extensions\r",
"// not that order matters, but we'll preserve it anyway\r",
"boolean",
"found",
"=",
"false",
";",
"if",
"(",
"element",
"instanceof",
"BackboneElement",
")",
"for",
"(",
"Extension",
"e",
":",
"(",
"(",
"BackboneElement",
")",
"element",
")",
".",
"getModifierExtension",
"(",
")",
")",
"{",
"if",
"(",
"uri",
".",
"equals",
"(",
"e",
".",
"getUrl",
"(",
")",
")",
")",
"{",
"if",
"(",
"!",
"modifier",
")",
"throw",
"new",
"FHIRException",
"(",
"\"Error adding extension \\\"\"",
"+",
"uri",
"+",
"\"\\\": found an existing modifier extension, and the extension is not marked as a modifier\"",
")",
";",
"e",
".",
"setValue",
"(",
"value",
")",
";",
"found",
"=",
"true",
";",
"}",
"}",
"for",
"(",
"Extension",
"e",
":",
"element",
".",
"getExtension",
"(",
")",
")",
"{",
"if",
"(",
"uri",
".",
"equals",
"(",
"e",
".",
"getUrl",
"(",
")",
")",
")",
"{",
"if",
"(",
"modifier",
")",
"throw",
"new",
"FHIRException",
"(",
"\"Error adding extension \\\"\"",
"+",
"uri",
"+",
"\"\\\": found an existing extension, and the extension is marked as a modifier\"",
")",
";",
"e",
".",
"setValue",
"(",
"value",
")",
";",
"found",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"found",
")",
"{",
"Extension",
"ex",
"=",
"new",
"Extension",
"(",
")",
".",
"setUrl",
"(",
"uri",
")",
".",
"setValue",
"(",
"value",
")",
";",
"if",
"(",
"modifier",
")",
"{",
"if",
"(",
"!",
"(",
"element",
"instanceof",
"BackboneElement",
")",
")",
"throw",
"new",
"FHIRException",
"(",
"\"Error adding extension \\\"\"",
"+",
"uri",
"+",
"\"\\\": extension is marked as a modifier, but element is not a backbone element\"",
")",
";",
"(",
"(",
"BackboneElement",
")",
"element",
")",
".",
"getModifierExtension",
"(",
")",
".",
"add",
"(",
"ex",
")",
";",
"}",
"else",
"{",
"element",
".",
"getExtension",
"(",
")",
".",
"add",
"(",
"ex",
")",
";",
"}",
"}",
"}",
"}"
] | set the value of an extension on the element. if value == null, make sure it doesn't exist
@param element - the element to act on. Can also be a backbone element
@param modifier - whether this is a modifier. Note that this is a definitional property of the extension; don't alternate
@param uri - the identifier for the extension
@param value - the value of the extension. Delete if this is null
@- if the modifier logic is incorrect | [
"set",
"the",
"value",
"of",
"an",
"extension",
"on",
"the",
"element",
".",
"if",
"value",
"==",
"null",
"make",
"sure",
"it",
"doesn",
"t",
"exist"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/model/ExtensionHelper.java#L93-L138 |
22,435 | jamesagnew/hapi-fhir | hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsProvider.java | AbstractJaxRsProvider.getBaseForServer | public String getBaseForServer() {
final String url = getUriInfo().getBaseUri().toASCIIString();
return StringUtils.isNotBlank(url) && url.endsWith("/") ? url.substring(0, url.length() - 1) : url;
} | java | public String getBaseForServer() {
final String url = getUriInfo().getBaseUri().toASCIIString();
return StringUtils.isNotBlank(url) && url.endsWith("/") ? url.substring(0, url.length() - 1) : url;
} | [
"public",
"String",
"getBaseForServer",
"(",
")",
"{",
"final",
"String",
"url",
"=",
"getUriInfo",
"(",
")",
".",
"getBaseUri",
"(",
")",
".",
"toASCIIString",
"(",
")",
";",
"return",
"StringUtils",
".",
"isNotBlank",
"(",
"url",
")",
"&&",
"url",
".",
"endsWith",
"(",
"\"/\"",
")",
"?",
"url",
".",
"substring",
"(",
"0",
",",
"url",
".",
"length",
"(",
")",
"-",
"1",
")",
":",
"url",
";",
"}"
] | This method returns the server base, independent of the request or resource.
@see javax.ws.rs.core.UriInfo#getBaseUri()
@return the ascii string for the server base | [
"This",
"method",
"returns",
"the",
"server",
"base",
"independent",
"of",
"the",
"request",
"or",
"resource",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsProvider.java#L107-L110 |
22,436 | jamesagnew/hapi-fhir | hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsProvider.java | AbstractJaxRsProvider.getParameters | public Map<String, String[]> getParameters() {
final MultivaluedMap<String, String> queryParameters = getUriInfo().getQueryParameters();
final HashMap<String, String[]> params = new HashMap<String, String[]>();
for (final Entry<String, List<String>> paramEntry : queryParameters.entrySet()) {
params.put(paramEntry.getKey(), paramEntry.getValue().toArray(new String[paramEntry.getValue().size()]));
}
return params;
} | java | public Map<String, String[]> getParameters() {
final MultivaluedMap<String, String> queryParameters = getUriInfo().getQueryParameters();
final HashMap<String, String[]> params = new HashMap<String, String[]>();
for (final Entry<String, List<String>> paramEntry : queryParameters.entrySet()) {
params.put(paramEntry.getKey(), paramEntry.getValue().toArray(new String[paramEntry.getValue().size()]));
}
return params;
} | [
"public",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"getParameters",
"(",
")",
"{",
"final",
"MultivaluedMap",
"<",
"String",
",",
"String",
">",
"queryParameters",
"=",
"getUriInfo",
"(",
")",
".",
"getQueryParameters",
"(",
")",
";",
"final",
"HashMap",
"<",
"String",
",",
"String",
"[",
"]",
">",
"params",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
"[",
"]",
">",
"(",
")",
";",
"for",
"(",
"final",
"Entry",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"paramEntry",
":",
"queryParameters",
".",
"entrySet",
"(",
")",
")",
"{",
"params",
".",
"put",
"(",
"paramEntry",
".",
"getKey",
"(",
")",
",",
"paramEntry",
".",
"getValue",
"(",
")",
".",
"toArray",
"(",
"new",
"String",
"[",
"paramEntry",
".",
"getValue",
"(",
")",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}",
"return",
"params",
";",
"}"
] | This method returns the query parameters
@return the query parameters | [
"This",
"method",
"returns",
"the",
"query",
"parameters"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsProvider.java#L174-L181 |
22,437 | jamesagnew/hapi-fhir | hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsProvider.java | AbstractJaxRsProvider.handleException | public Response handleException(final JaxRsRequest theRequest, final Throwable theException)
throws IOException {
if (theException instanceof JaxRsResponseException) {
return new JaxRsExceptionInterceptor().convertExceptionIntoResponse(theRequest, (JaxRsResponseException) theException);
} else {
return new JaxRsExceptionInterceptor().convertExceptionIntoResponse(theRequest,
new JaxRsExceptionInterceptor().convertException(this, theException));
}
} | java | public Response handleException(final JaxRsRequest theRequest, final Throwable theException)
throws IOException {
if (theException instanceof JaxRsResponseException) {
return new JaxRsExceptionInterceptor().convertExceptionIntoResponse(theRequest, (JaxRsResponseException) theException);
} else {
return new JaxRsExceptionInterceptor().convertExceptionIntoResponse(theRequest,
new JaxRsExceptionInterceptor().convertException(this, theException));
}
} | [
"public",
"Response",
"handleException",
"(",
"final",
"JaxRsRequest",
"theRequest",
",",
"final",
"Throwable",
"theException",
")",
"throws",
"IOException",
"{",
"if",
"(",
"theException",
"instanceof",
"JaxRsResponseException",
")",
"{",
"return",
"new",
"JaxRsExceptionInterceptor",
"(",
")",
".",
"convertExceptionIntoResponse",
"(",
"theRequest",
",",
"(",
"JaxRsResponseException",
")",
"theException",
")",
";",
"}",
"else",
"{",
"return",
"new",
"JaxRsExceptionInterceptor",
"(",
")",
".",
"convertExceptionIntoResponse",
"(",
"theRequest",
",",
"new",
"JaxRsExceptionInterceptor",
"(",
")",
".",
"convertException",
"(",
"this",
",",
"theException",
")",
")",
";",
"}",
"}"
] | Convert an exception to a response
@param theRequest
the incoming request
@param theException
the exception to convert
@return response
@throws IOException | [
"Convert",
"an",
"exception",
"to",
"a",
"response"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsProvider.java#L242-L250 |
22,438 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionLoader.java | SubscriptionLoader.syncSubscriptions | @SuppressWarnings("unused")
@Scheduled(fixedDelay = DateUtils.MILLIS_PER_MINUTE)
public void syncSubscriptions() {
if (!mySyncSubscriptionsSemaphore.tryAcquire()) {
return;
}
try {
doSyncSubscriptionsWithRetry();
} finally {
mySyncSubscriptionsSemaphore.release();
}
} | java | @SuppressWarnings("unused")
@Scheduled(fixedDelay = DateUtils.MILLIS_PER_MINUTE)
public void syncSubscriptions() {
if (!mySyncSubscriptionsSemaphore.tryAcquire()) {
return;
}
try {
doSyncSubscriptionsWithRetry();
} finally {
mySyncSubscriptionsSemaphore.release();
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"@",
"Scheduled",
"(",
"fixedDelay",
"=",
"DateUtils",
".",
"MILLIS_PER_MINUTE",
")",
"public",
"void",
"syncSubscriptions",
"(",
")",
"{",
"if",
"(",
"!",
"mySyncSubscriptionsSemaphore",
".",
"tryAcquire",
"(",
")",
")",
"{",
"return",
";",
"}",
"try",
"{",
"doSyncSubscriptionsWithRetry",
"(",
")",
";",
"}",
"finally",
"{",
"mySyncSubscriptionsSemaphore",
".",
"release",
"(",
")",
";",
"}",
"}"
] | Read the existing subscriptions from the database | [
"Read",
"the",
"existing",
"subscriptions",
"from",
"the",
"database"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionLoader.java#L62-L73 |
22,439 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/CircularQueueCaptureQueriesListener.java | CircularQueueCaptureQueriesListener.getCapturedQueries | @SuppressWarnings("UseBulkOperation")
public List<Query> getCapturedQueries() {
// Make a copy so that we aren't affected by changes to the list outside of the
// synchronized block
ArrayList<Query> retVal = new ArrayList<>(CAPACITY);
myQueries.forEach(retVal::add);
return Collections.unmodifiableList(retVal);
} | java | @SuppressWarnings("UseBulkOperation")
public List<Query> getCapturedQueries() {
// Make a copy so that we aren't affected by changes to the list outside of the
// synchronized block
ArrayList<Query> retVal = new ArrayList<>(CAPACITY);
myQueries.forEach(retVal::add);
return Collections.unmodifiableList(retVal);
} | [
"@",
"SuppressWarnings",
"(",
"\"UseBulkOperation\"",
")",
"public",
"List",
"<",
"Query",
">",
"getCapturedQueries",
"(",
")",
"{",
"// Make a copy so that we aren't affected by changes to the list outside of the",
"// synchronized block",
"ArrayList",
"<",
"Query",
">",
"retVal",
"=",
"new",
"ArrayList",
"<>",
"(",
"CAPACITY",
")",
";",
"myQueries",
".",
"forEach",
"(",
"retVal",
"::",
"add",
")",
";",
"return",
"Collections",
".",
"unmodifiableList",
"(",
"retVal",
")",
";",
"}"
] | Index 0 is oldest | [
"Index",
"0",
"is",
"oldest"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/CircularQueueCaptureQueriesListener.java#L65-L72 |
22,440 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/CircularQueueCaptureQueriesListener.java | CircularQueueCaptureQueriesListener.logUpdateQueriesForCurrentThread | public void logUpdateQueriesForCurrentThread() {
List<String> queries = getUpdateQueriesForCurrentThread()
.stream()
.map(CircularQueueCaptureQueriesListener::formatQueryAsSql)
.collect(Collectors.toList());
ourLog.info("Select Queries:\n{}", String.join("\n", queries));
} | java | public void logUpdateQueriesForCurrentThread() {
List<String> queries = getUpdateQueriesForCurrentThread()
.stream()
.map(CircularQueueCaptureQueriesListener::formatQueryAsSql)
.collect(Collectors.toList());
ourLog.info("Select Queries:\n{}", String.join("\n", queries));
} | [
"public",
"void",
"logUpdateQueriesForCurrentThread",
"(",
")",
"{",
"List",
"<",
"String",
">",
"queries",
"=",
"getUpdateQueriesForCurrentThread",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"CircularQueueCaptureQueriesListener",
"::",
"formatQueryAsSql",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"ourLog",
".",
"info",
"(",
"\"Select Queries:\\n{}\"",
",",
"String",
".",
"join",
"(",
"\"\\n\"",
",",
"queries",
")",
")",
";",
"}"
] | Log all captured UPDATE queries | [
"Log",
"all",
"captured",
"UPDATE",
"queries"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/CircularQueueCaptureQueriesListener.java#L150-L156 |
22,441 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/CircularQueueCaptureQueriesListener.java | CircularQueueCaptureQueriesListener.logFirstSelectQueryForCurrentThread | public void logFirstSelectQueryForCurrentThread() {
String firstSelectQuery = getSelectQueriesForCurrentThread()
.stream()
.findFirst()
.map(CircularQueueCaptureQueriesListener::formatQueryAsSql)
.orElse("NONE FOUND");
ourLog.info("First select Query:\n{}", firstSelectQuery);
} | java | public void logFirstSelectQueryForCurrentThread() {
String firstSelectQuery = getSelectQueriesForCurrentThread()
.stream()
.findFirst()
.map(CircularQueueCaptureQueriesListener::formatQueryAsSql)
.orElse("NONE FOUND");
ourLog.info("First select Query:\n{}", firstSelectQuery);
} | [
"public",
"void",
"logFirstSelectQueryForCurrentThread",
"(",
")",
"{",
"String",
"firstSelectQuery",
"=",
"getSelectQueriesForCurrentThread",
"(",
")",
".",
"stream",
"(",
")",
".",
"findFirst",
"(",
")",
".",
"map",
"(",
"CircularQueueCaptureQueriesListener",
"::",
"formatQueryAsSql",
")",
".",
"orElse",
"(",
"\"NONE FOUND\"",
")",
";",
"ourLog",
".",
"info",
"(",
"\"First select Query:\\n{}\"",
",",
"firstSelectQuery",
")",
";",
"}"
] | Log first captured SELECT query | [
"Log",
"first",
"captured",
"SELECT",
"query"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/CircularQueueCaptureQueriesListener.java#L183-L190 |
22,442 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-example/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigDstu2.java | FhirServerConfigDstu2.loggingInterceptor | public IServerInterceptor loggingInterceptor() {
LoggingInterceptor retVal = new LoggingInterceptor();
retVal.setLoggerName("fhirtest.access");
retVal.setMessageFormat(
"Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${operationName} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] ResponseEncoding[${responseEncodingNoDefault}]");
retVal.setLogExceptions(true);
retVal.setErrorMessageFormat("ERROR - ${requestVerb} ${requestUrl}");
return retVal;
} | java | public IServerInterceptor loggingInterceptor() {
LoggingInterceptor retVal = new LoggingInterceptor();
retVal.setLoggerName("fhirtest.access");
retVal.setMessageFormat(
"Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${operationName} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] ResponseEncoding[${responseEncodingNoDefault}]");
retVal.setLogExceptions(true);
retVal.setErrorMessageFormat("ERROR - ${requestVerb} ${requestUrl}");
return retVal;
} | [
"public",
"IServerInterceptor",
"loggingInterceptor",
"(",
")",
"{",
"LoggingInterceptor",
"retVal",
"=",
"new",
"LoggingInterceptor",
"(",
")",
";",
"retVal",
".",
"setLoggerName",
"(",
"\"fhirtest.access\"",
")",
";",
"retVal",
".",
"setMessageFormat",
"(",
"\"Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${operationName} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] ResponseEncoding[${responseEncodingNoDefault}]\"",
")",
";",
"retVal",
".",
"setLogExceptions",
"(",
"true",
")",
";",
"retVal",
".",
"setErrorMessageFormat",
"(",
"\"ERROR - ${requestVerb} ${requestUrl}\"",
")",
";",
"return",
"retVal",
";",
"}"
] | Do some fancy logging to create a nice access log that has details about each incoming request. | [
"Do",
"some",
"fancy",
"logging",
"to",
"create",
"a",
"nice",
"access",
"log",
"that",
"has",
"details",
"about",
"each",
"incoming",
"request",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-example/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigDstu2.java#L93-L101 |
22,443 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-example/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigDstu2.java | FhirServerConfigDstu2.responseHighlighterInterceptor | @Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor responseHighlighterInterceptor() {
ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor();
return retVal;
} | java | @Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor responseHighlighterInterceptor() {
ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor();
return retVal;
} | [
"@",
"Bean",
"(",
"autowire",
"=",
"Autowire",
".",
"BY_TYPE",
")",
"public",
"IServerInterceptor",
"responseHighlighterInterceptor",
"(",
")",
"{",
"ResponseHighlighterInterceptor",
"retVal",
"=",
"new",
"ResponseHighlighterInterceptor",
"(",
")",
";",
"return",
"retVal",
";",
"}"
] | This interceptor adds some pretty syntax highlighting in responses when a browser is detected | [
"This",
"interceptor",
"adds",
"some",
"pretty",
"syntax",
"highlighting",
"in",
"responses",
"when",
"a",
"browser",
"is",
"detected"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-example/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigDstu2.java#L106-L110 |
22,444 | jamesagnew/hapi-fhir | hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/LValue.java | LValue.asBoolean | public boolean asBoolean(Object value) {
if (value == null) {
return false;
}
if (value instanceof Boolean) {
return (Boolean) value;
}
return true;
} | java | public boolean asBoolean(Object value) {
if (value == null) {
return false;
}
if (value instanceof Boolean) {
return (Boolean) value;
}
return true;
} | [
"public",
"boolean",
"asBoolean",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"value",
"instanceof",
"Boolean",
")",
"{",
"return",
"(",
"Boolean",
")",
"value",
";",
"}",
"return",
"true",
";",
"}"
] | Convert `value` to a boolean. Note that only `nil` and `false`
are `false`, all other values are `true`.
@param value
the value to convert.
@return `value` as a boolean. | [
"Convert",
"value",
"to",
"a",
"boolean",
".",
"Note",
"that",
"only",
"nil",
"and",
"false",
"are",
"false",
"all",
"other",
"values",
"are",
"true",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/LValue.java#L113-L124 |
22,445 | jamesagnew/hapi-fhir | hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/LValue.java | LValue.asNumber | public Number asNumber(Object value) throws NumberFormatException {
if(value instanceof Number) {
return (Number) value;
}
String str = String.valueOf(value);
return str.matches("\\d+") ? Long.valueOf(str) : Double.valueOf(str);
} | java | public Number asNumber(Object value) throws NumberFormatException {
if(value instanceof Number) {
return (Number) value;
}
String str = String.valueOf(value);
return str.matches("\\d+") ? Long.valueOf(str) : Double.valueOf(str);
} | [
"public",
"Number",
"asNumber",
"(",
"Object",
"value",
")",
"throws",
"NumberFormatException",
"{",
"if",
"(",
"value",
"instanceof",
"Number",
")",
"{",
"return",
"(",
"Number",
")",
"value",
";",
"}",
"String",
"str",
"=",
"String",
".",
"valueOf",
"(",
"value",
")",
";",
"return",
"str",
".",
"matches",
"(",
"\"\\\\d+\"",
")",
"?",
"Long",
".",
"valueOf",
"(",
"str",
")",
":",
"Double",
".",
"valueOf",
"(",
"str",
")",
";",
"}"
] | Returns `value` as a Number. Strings will be coerced into
either a Long or Double.
@param value
the value to cast to a Number.
@return `value` as a Number.
@throws NumberFormatException when `value` is a String which could
not be parsed as a Long or Double. | [
"Returns",
"value",
"as",
"a",
"Number",
".",
"Strings",
"will",
"be",
"coerced",
"into",
"either",
"a",
"Long",
"or",
"Double",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/LValue.java#L138-L147 |
22,446 | jamesagnew/hapi-fhir | hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/LValue.java | LValue.asString | public String asString(Object value) {
if (value == null) {
return "";
}
if (!this.isArray(value)) {
return String.valueOf(value);
}
Object[] array = this.asArray(value);
StringBuilder builder = new StringBuilder();
for (Object obj : array) {
builder.append(this.asString(obj));
}
return builder.toString();
} | java | public String asString(Object value) {
if (value == null) {
return "";
}
if (!this.isArray(value)) {
return String.valueOf(value);
}
Object[] array = this.asArray(value);
StringBuilder builder = new StringBuilder();
for (Object obj : array) {
builder.append(this.asString(obj));
}
return builder.toString();
} | [
"public",
"String",
"asString",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"if",
"(",
"!",
"this",
".",
"isArray",
"(",
"value",
")",
")",
"{",
"return",
"String",
".",
"valueOf",
"(",
"value",
")",
";",
"}",
"Object",
"[",
"]",
"array",
"=",
"this",
".",
"asArray",
"(",
"value",
")",
";",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Object",
"obj",
":",
"array",
")",
"{",
"builder",
".",
"append",
"(",
"this",
".",
"asString",
"(",
"obj",
")",
")",
";",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] | Returns `value` as a String.
@param value
the value to convert to a String.
@return `value` as a String. | [
"Returns",
"value",
"as",
"a",
"String",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/LValue.java#L157-L176 |
22,447 | jamesagnew/hapi-fhir | hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/LValue.java | LValue.isArray | public boolean isArray(Object value) {
return value != null && (value.getClass().isArray() || value instanceof List);
} | java | public boolean isArray(Object value) {
return value != null && (value.getClass().isArray() || value instanceof List);
} | [
"public",
"boolean",
"isArray",
"(",
"Object",
"value",
")",
"{",
"return",
"value",
"!=",
"null",
"&&",
"(",
"value",
".",
"getClass",
"(",
")",
".",
"isArray",
"(",
")",
"||",
"value",
"instanceof",
"List",
")",
";",
"}"
] | Returns true iff `value` is an array or a java.util.List.
@param value
the value to check.
@return true iff `value` is an array or a java.util.List. | [
"Returns",
"true",
"iff",
"value",
"is",
"an",
"array",
"or",
"a",
"java",
".",
"util",
".",
"List",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/LValue.java#L186-L189 |
22,448 | jamesagnew/hapi-fhir | hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/LValue.java | LValue.isNumber | public boolean isNumber(Object value) {
if(value == null) {
return false;
}
if(value instanceof Number) {
return true;
}
// valid Long?
if(String.valueOf(value).matches("\\d+")) {
return true;
}
try {
// valid Double?
Double.parseDouble(String.valueOf(value));
} catch(Exception e) {
return false;
}
return true;
} | java | public boolean isNumber(Object value) {
if(value == null) {
return false;
}
if(value instanceof Number) {
return true;
}
// valid Long?
if(String.valueOf(value).matches("\\d+")) {
return true;
}
try {
// valid Double?
Double.parseDouble(String.valueOf(value));
} catch(Exception e) {
return false;
}
return true;
} | [
"public",
"boolean",
"isNumber",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"value",
"instanceof",
"Number",
")",
"{",
"return",
"true",
";",
"}",
"// valid Long?",
"if",
"(",
"String",
".",
"valueOf",
"(",
"value",
")",
".",
"matches",
"(",
"\"\\\\d+\"",
")",
")",
"{",
"return",
"true",
";",
"}",
"try",
"{",
"// valid Double?",
"Double",
".",
"parseDouble",
"(",
"String",
".",
"valueOf",
"(",
"value",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Returns true iff `value` is a Number.
@param value
the value to check.
@return true iff `value` is a Number. | [
"Returns",
"true",
"iff",
"value",
"is",
"a",
"Number",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/LValue.java#L211-L234 |
22,449 | jamesagnew/hapi-fhir | example-projects/hapi-fhir-jaxrs-sse/src/main/java/embedded/example/JaxRsPatientProvider.java | JaxRsPatientProvider.storePatient | private void storePatient(final Patient patient) {
try {
patients.put(patient.getIdentifierFirstRep().getValue(), patient);
// if storing is successful the notify the listeners that listens on
// any patient => patient/*
final String bundleToString = currentPatientsAsJsonString();
broadcaster
.broadcast(new OutboundEvent.Builder().name("patients").data(String.class, bundleToString).build());
} catch (final Exception e) {
e.printStackTrace();
}
} | java | private void storePatient(final Patient patient) {
try {
patients.put(patient.getIdentifierFirstRep().getValue(), patient);
// if storing is successful the notify the listeners that listens on
// any patient => patient/*
final String bundleToString = currentPatientsAsJsonString();
broadcaster
.broadcast(new OutboundEvent.Builder().name("patients").data(String.class, bundleToString).build());
} catch (final Exception e) {
e.printStackTrace();
}
} | [
"private",
"void",
"storePatient",
"(",
"final",
"Patient",
"patient",
")",
"{",
"try",
"{",
"patients",
".",
"put",
"(",
"patient",
".",
"getIdentifierFirstRep",
"(",
")",
".",
"getValue",
"(",
")",
",",
"patient",
")",
";",
"// if storing is successful the notify the listeners that listens on",
"// any patient => patient/*",
"final",
"String",
"bundleToString",
"=",
"currentPatientsAsJsonString",
"(",
")",
";",
"broadcaster",
".",
"broadcast",
"(",
"new",
"OutboundEvent",
".",
"Builder",
"(",
")",
".",
"name",
"(",
"\"patients\"",
")",
".",
"data",
"(",
"String",
".",
"class",
",",
"bundleToString",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] | Conceptual wrapper for storing in a db | [
"Conceptual",
"wrapper",
"for",
"storing",
"in",
"a",
"db"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/example-projects/hapi-fhir-jaxrs-sse/src/main/java/embedded/example/JaxRsPatientProvider.java#L79-L95 |
22,450 | jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/Translations.java | Translations.load | public void load(String filename) throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
loadMessages(builder.parse(new CSFileInputStream(filename)));
} | java | public void load(String filename) throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
loadMessages(builder.parse(new CSFileInputStream(filename)));
} | [
"public",
"void",
"load",
"(",
"String",
"filename",
")",
"throws",
"FileNotFoundException",
",",
"SAXException",
",",
"IOException",
",",
"ParserConfigurationException",
"{",
"DocumentBuilderFactory",
"factory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"DocumentBuilder",
"builder",
"=",
"factory",
".",
"newDocumentBuilder",
"(",
")",
";",
"loadMessages",
"(",
"builder",
".",
"parse",
"(",
"new",
"CSFileInputStream",
"(",
"filename",
")",
")",
")",
";",
"}"
] | Load from the XML translations file maintained by the FHIR project
@param filename
@throws IOException
@throws SAXException
@throws FileNotFoundException
@throws ParserConfigurationException
@throws Exception | [
"Load",
"from",
"the",
"XML",
"translations",
"file",
"maintained",
"by",
"the",
"FHIR",
"project"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/Translations.java#L42-L46 |
22,451 | jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/Translations.java | Translations.getMessage | public String getMessage(String id, String defaultMsg) {
return getMessage(id, lang, defaultMsg);
} | java | public String getMessage(String id, String defaultMsg) {
return getMessage(id, lang, defaultMsg);
} | [
"public",
"String",
"getMessage",
"(",
"String",
"id",
",",
"String",
"defaultMsg",
")",
"{",
"return",
"getMessage",
"(",
"id",
",",
"lang",
",",
"defaultMsg",
")",
";",
"}"
] | use configured language
@param id - the id of the message to retrieve
@param defaultMsg - string to use if the message is not defined or a language match is not found (if null, then will default to english)
@return the message | [
"use",
"configured",
"language"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/Translations.java#L68-L70 |
22,452 | jamesagnew/hapi-fhir | hapi-fhir-base/src/main/java/ca/uhn/fhir/util/FhirTerser.java | FhirTerser.cloneInto | public IBase cloneInto(IBase theSource, IBase theTarget, boolean theIgnoreMissingFields) {
Validate.notNull(theSource, "theSource must not be null");
Validate.notNull(theTarget, "theTarget must not be null");
if (theSource instanceof IPrimitiveType<?>) {
if (theTarget instanceof IPrimitiveType<?>) {
((IPrimitiveType<?>) theTarget).setValueAsString(((IPrimitiveType<?>) theSource).getValueAsString());
return theSource;
}
if (theIgnoreMissingFields) {
return theSource;
}
throw new DataFormatException("Can not copy value from primitive of type " + theSource.getClass().getName() + " into type " + theTarget.getClass().getName());
}
BaseRuntimeElementCompositeDefinition<?> sourceDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition(theSource.getClass());
BaseRuntimeElementCompositeDefinition<?> targetDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition(theTarget.getClass());
List<BaseRuntimeChildDefinition> children = sourceDef.getChildren();
if (sourceDef instanceof RuntimeExtensionDtDefinition) {
children = ((RuntimeExtensionDtDefinition) sourceDef).getChildrenIncludingUrl();
}
for (BaseRuntimeChildDefinition nextChild : children)
for (IBase nextValue : nextChild.getAccessor().getValues(theSource)) {
String elementName = nextChild.getChildNameByDatatype(nextValue.getClass());
BaseRuntimeChildDefinition targetChild = targetDef.getChildByName(elementName);
if (targetChild == null) {
if (theIgnoreMissingFields) {
continue;
}
throw new DataFormatException("Type " + theTarget.getClass().getName() + " does not have a child with name " + elementName);
}
BaseRuntimeElementDefinition<?> element = myContext.getElementDefinition(nextValue.getClass());
IBase target = element.newInstance();
targetChild.getMutator().addValue(theTarget, target);
cloneInto(nextValue, target, theIgnoreMissingFields);
}
return theTarget;
} | java | public IBase cloneInto(IBase theSource, IBase theTarget, boolean theIgnoreMissingFields) {
Validate.notNull(theSource, "theSource must not be null");
Validate.notNull(theTarget, "theTarget must not be null");
if (theSource instanceof IPrimitiveType<?>) {
if (theTarget instanceof IPrimitiveType<?>) {
((IPrimitiveType<?>) theTarget).setValueAsString(((IPrimitiveType<?>) theSource).getValueAsString());
return theSource;
}
if (theIgnoreMissingFields) {
return theSource;
}
throw new DataFormatException("Can not copy value from primitive of type " + theSource.getClass().getName() + " into type " + theTarget.getClass().getName());
}
BaseRuntimeElementCompositeDefinition<?> sourceDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition(theSource.getClass());
BaseRuntimeElementCompositeDefinition<?> targetDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition(theTarget.getClass());
List<BaseRuntimeChildDefinition> children = sourceDef.getChildren();
if (sourceDef instanceof RuntimeExtensionDtDefinition) {
children = ((RuntimeExtensionDtDefinition) sourceDef).getChildrenIncludingUrl();
}
for (BaseRuntimeChildDefinition nextChild : children)
for (IBase nextValue : nextChild.getAccessor().getValues(theSource)) {
String elementName = nextChild.getChildNameByDatatype(nextValue.getClass());
BaseRuntimeChildDefinition targetChild = targetDef.getChildByName(elementName);
if (targetChild == null) {
if (theIgnoreMissingFields) {
continue;
}
throw new DataFormatException("Type " + theTarget.getClass().getName() + " does not have a child with name " + elementName);
}
BaseRuntimeElementDefinition<?> element = myContext.getElementDefinition(nextValue.getClass());
IBase target = element.newInstance();
targetChild.getMutator().addValue(theTarget, target);
cloneInto(nextValue, target, theIgnoreMissingFields);
}
return theTarget;
} | [
"public",
"IBase",
"cloneInto",
"(",
"IBase",
"theSource",
",",
"IBase",
"theTarget",
",",
"boolean",
"theIgnoreMissingFields",
")",
"{",
"Validate",
".",
"notNull",
"(",
"theSource",
",",
"\"theSource must not be null\"",
")",
";",
"Validate",
".",
"notNull",
"(",
"theTarget",
",",
"\"theTarget must not be null\"",
")",
";",
"if",
"(",
"theSource",
"instanceof",
"IPrimitiveType",
"<",
"?",
">",
")",
"{",
"if",
"(",
"theTarget",
"instanceof",
"IPrimitiveType",
"<",
"?",
">",
")",
"{",
"(",
"(",
"IPrimitiveType",
"<",
"?",
">",
")",
"theTarget",
")",
".",
"setValueAsString",
"(",
"(",
"(",
"IPrimitiveType",
"<",
"?",
">",
")",
"theSource",
")",
".",
"getValueAsString",
"(",
")",
")",
";",
"return",
"theSource",
";",
"}",
"if",
"(",
"theIgnoreMissingFields",
")",
"{",
"return",
"theSource",
";",
"}",
"throw",
"new",
"DataFormatException",
"(",
"\"Can not copy value from primitive of type \"",
"+",
"theSource",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" into type \"",
"+",
"theTarget",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"BaseRuntimeElementCompositeDefinition",
"<",
"?",
">",
"sourceDef",
"=",
"(",
"BaseRuntimeElementCompositeDefinition",
"<",
"?",
">",
")",
"myContext",
".",
"getElementDefinition",
"(",
"theSource",
".",
"getClass",
"(",
")",
")",
";",
"BaseRuntimeElementCompositeDefinition",
"<",
"?",
">",
"targetDef",
"=",
"(",
"BaseRuntimeElementCompositeDefinition",
"<",
"?",
">",
")",
"myContext",
".",
"getElementDefinition",
"(",
"theTarget",
".",
"getClass",
"(",
")",
")",
";",
"List",
"<",
"BaseRuntimeChildDefinition",
">",
"children",
"=",
"sourceDef",
".",
"getChildren",
"(",
")",
";",
"if",
"(",
"sourceDef",
"instanceof",
"RuntimeExtensionDtDefinition",
")",
"{",
"children",
"=",
"(",
"(",
"RuntimeExtensionDtDefinition",
")",
"sourceDef",
")",
".",
"getChildrenIncludingUrl",
"(",
")",
";",
"}",
"for",
"(",
"BaseRuntimeChildDefinition",
"nextChild",
":",
"children",
")",
"for",
"(",
"IBase",
"nextValue",
":",
"nextChild",
".",
"getAccessor",
"(",
")",
".",
"getValues",
"(",
"theSource",
")",
")",
"{",
"String",
"elementName",
"=",
"nextChild",
".",
"getChildNameByDatatype",
"(",
"nextValue",
".",
"getClass",
"(",
")",
")",
";",
"BaseRuntimeChildDefinition",
"targetChild",
"=",
"targetDef",
".",
"getChildByName",
"(",
"elementName",
")",
";",
"if",
"(",
"targetChild",
"==",
"null",
")",
"{",
"if",
"(",
"theIgnoreMissingFields",
")",
"{",
"continue",
";",
"}",
"throw",
"new",
"DataFormatException",
"(",
"\"Type \"",
"+",
"theTarget",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" does not have a child with name \"",
"+",
"elementName",
")",
";",
"}",
"BaseRuntimeElementDefinition",
"<",
"?",
">",
"element",
"=",
"myContext",
".",
"getElementDefinition",
"(",
"nextValue",
".",
"getClass",
"(",
")",
")",
";",
"IBase",
"target",
"=",
"element",
".",
"newInstance",
"(",
")",
";",
"targetChild",
".",
"getMutator",
"(",
")",
".",
"addValue",
"(",
"theTarget",
",",
"target",
")",
";",
"cloneInto",
"(",
"nextValue",
",",
"target",
",",
"theIgnoreMissingFields",
")",
";",
"}",
"return",
"theTarget",
";",
"}"
] | Clones all values from a source object into the equivalent fields in a target object
@param theSource The source object (must not be null)
@param theTarget The target object to copy values into (must not be null)
@param theIgnoreMissingFields The ignore fields in the target which do not exist (if false, an exception will be thrown if the target is unable to accept a value from the source)
@return Returns the target (which will be the same object that was passed into theTarget) for easy chaining | [
"Clones",
"all",
"values",
"from",
"a",
"source",
"object",
"into",
"the",
"equivalent",
"fields",
"in",
"a",
"target",
"object"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/FhirTerser.java#L105-L147 |
22,453 | jamesagnew/hapi-fhir | hapi-fhir-base/src/main/java/ca/uhn/fhir/util/FhirTerser.java | FhirTerser.visit | public void visit(IBaseResource theResource, IModelVisitor theVisitor) {
BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(theResource);
visit(new IdentityHashMap<Object, Object>(), theResource, theResource, null, null, def, theVisitor);
} | java | public void visit(IBaseResource theResource, IModelVisitor theVisitor) {
BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(theResource);
visit(new IdentityHashMap<Object, Object>(), theResource, theResource, null, null, def, theVisitor);
} | [
"public",
"void",
"visit",
"(",
"IBaseResource",
"theResource",
",",
"IModelVisitor",
"theVisitor",
")",
"{",
"BaseRuntimeElementCompositeDefinition",
"<",
"?",
">",
"def",
"=",
"myContext",
".",
"getResourceDefinition",
"(",
"theResource",
")",
";",
"visit",
"(",
"new",
"IdentityHashMap",
"<",
"Object",
",",
"Object",
">",
"(",
")",
",",
"theResource",
",",
"theResource",
",",
"null",
",",
"null",
",",
"def",
",",
"theVisitor",
")",
";",
"}"
] | Visit all elements in a given resource
<p>
Note on scope: This method will descend into any contained resources ({@link IResource#getContained()}) as well, but will not descend into linked resources (e.g.
{@link BaseResourceReferenceDt#getResource()}) or embedded resources (e.g. Bundle.entry.resource)
</p>
@param theResource The resource to visit
@param theVisitor The visitor | [
"Visit",
"all",
"elements",
"in",
"a",
"given",
"resource"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/FhirTerser.java#L813-L816 |
22,454 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/matcher/CriteriaResourceMatcher.java | CriteriaResourceMatcher.match | public SubscriptionMatchResult match(String theCriteria, IBaseResource theResource, ResourceIndexedSearchParams theSearchParams) {
RuntimeResourceDefinition resourceDefinition;
if (theResource == null) {
resourceDefinition = UrlUtil.parseUrlResourceType(myFhirContext, theCriteria);
} else {
resourceDefinition = myFhirContext.getResourceDefinition(theResource);
}
SearchParameterMap searchParameterMap;
try {
searchParameterMap = myMatchUrlService.translateMatchUrl(theCriteria, resourceDefinition);
} catch (UnsupportedOperationException e) {
return SubscriptionMatchResult.unsupportedFromReason(SubscriptionMatchResult.PARSE_FAIL);
}
searchParameterMap.clean();
if (searchParameterMap.getLastUpdated() != null) {
return SubscriptionMatchResult.unsupportedFromParameterAndReason(Constants.PARAM_LASTUPDATED, SubscriptionMatchResult.STANDARD_PARAMETER);
}
for (Map.Entry<String, List<List<IQueryParameterType>>> entry : searchParameterMap.entrySet()) {
String theParamName = entry.getKey();
List<List<IQueryParameterType>> theAndOrParams = entry.getValue();
SubscriptionMatchResult result = matchIdsWithAndOr(theParamName, theAndOrParams, resourceDefinition, theResource, theSearchParams);
if (!result.matched()){
return result;
}
}
return SubscriptionMatchResult.successfulMatch();
} | java | public SubscriptionMatchResult match(String theCriteria, IBaseResource theResource, ResourceIndexedSearchParams theSearchParams) {
RuntimeResourceDefinition resourceDefinition;
if (theResource == null) {
resourceDefinition = UrlUtil.parseUrlResourceType(myFhirContext, theCriteria);
} else {
resourceDefinition = myFhirContext.getResourceDefinition(theResource);
}
SearchParameterMap searchParameterMap;
try {
searchParameterMap = myMatchUrlService.translateMatchUrl(theCriteria, resourceDefinition);
} catch (UnsupportedOperationException e) {
return SubscriptionMatchResult.unsupportedFromReason(SubscriptionMatchResult.PARSE_FAIL);
}
searchParameterMap.clean();
if (searchParameterMap.getLastUpdated() != null) {
return SubscriptionMatchResult.unsupportedFromParameterAndReason(Constants.PARAM_LASTUPDATED, SubscriptionMatchResult.STANDARD_PARAMETER);
}
for (Map.Entry<String, List<List<IQueryParameterType>>> entry : searchParameterMap.entrySet()) {
String theParamName = entry.getKey();
List<List<IQueryParameterType>> theAndOrParams = entry.getValue();
SubscriptionMatchResult result = matchIdsWithAndOr(theParamName, theAndOrParams, resourceDefinition, theResource, theSearchParams);
if (!result.matched()){
return result;
}
}
return SubscriptionMatchResult.successfulMatch();
} | [
"public",
"SubscriptionMatchResult",
"match",
"(",
"String",
"theCriteria",
",",
"IBaseResource",
"theResource",
",",
"ResourceIndexedSearchParams",
"theSearchParams",
")",
"{",
"RuntimeResourceDefinition",
"resourceDefinition",
";",
"if",
"(",
"theResource",
"==",
"null",
")",
"{",
"resourceDefinition",
"=",
"UrlUtil",
".",
"parseUrlResourceType",
"(",
"myFhirContext",
",",
"theCriteria",
")",
";",
"}",
"else",
"{",
"resourceDefinition",
"=",
"myFhirContext",
".",
"getResourceDefinition",
"(",
"theResource",
")",
";",
"}",
"SearchParameterMap",
"searchParameterMap",
";",
"try",
"{",
"searchParameterMap",
"=",
"myMatchUrlService",
".",
"translateMatchUrl",
"(",
"theCriteria",
",",
"resourceDefinition",
")",
";",
"}",
"catch",
"(",
"UnsupportedOperationException",
"e",
")",
"{",
"return",
"SubscriptionMatchResult",
".",
"unsupportedFromReason",
"(",
"SubscriptionMatchResult",
".",
"PARSE_FAIL",
")",
";",
"}",
"searchParameterMap",
".",
"clean",
"(",
")",
";",
"if",
"(",
"searchParameterMap",
".",
"getLastUpdated",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"SubscriptionMatchResult",
".",
"unsupportedFromParameterAndReason",
"(",
"Constants",
".",
"PARAM_LASTUPDATED",
",",
"SubscriptionMatchResult",
".",
"STANDARD_PARAMETER",
")",
";",
"}",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"List",
"<",
"List",
"<",
"IQueryParameterType",
">",
">",
">",
"entry",
":",
"searchParameterMap",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"theParamName",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"List",
"<",
"List",
"<",
"IQueryParameterType",
">",
">",
"theAndOrParams",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"SubscriptionMatchResult",
"result",
"=",
"matchIdsWithAndOr",
"(",
"theParamName",
",",
"theAndOrParams",
",",
"resourceDefinition",
",",
"theResource",
",",
"theSearchParams",
")",
";",
"if",
"(",
"!",
"result",
".",
"matched",
"(",
")",
")",
"{",
"return",
"result",
";",
"}",
"}",
"return",
"SubscriptionMatchResult",
".",
"successfulMatch",
"(",
")",
";",
"}"
] | This method is called in two different scenarios. With a null theResource, it determines whether database matching might be required.
Otherwise, it tries to perform the match in-memory, returning UNSUPPORTED if it's not possible.
Note that there will be cases where it returns UNSUPPORTED with a null resource, but when a non-null resource it returns supported and no match.
This is because an earlier parameter may be matchable in-memory in which case processing stops and we never get to the parameter
that would have required a database call. | [
"This",
"method",
"is",
"called",
"in",
"two",
"different",
"scenarios",
".",
"With",
"a",
"null",
"theResource",
"it",
"determines",
"whether",
"database",
"matching",
"might",
"be",
"required",
".",
"Otherwise",
"it",
"tries",
"to",
"perform",
"the",
"match",
"in",
"-",
"memory",
"returning",
"UNSUPPORTED",
"if",
"it",
"s",
"not",
"possible",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/matcher/CriteriaResourceMatcher.java#L67-L94 |
22,455 | jamesagnew/hapi-fhir | hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/FhirServerImpl.java | FhirServerImpl.registerOsgiProvider | @Override
public void registerOsgiProvider (Object provider) throws FhirConfigurationException {
if (null == provider) {
throw new NullPointerException("FHIR Provider cannot be null");
}
try {
super.registerProvider(provider);
log.trace("registered provider. class ["+provider.getClass().getName()+"]");
this.serverProviders.add(provider);
} catch (Exception e) {
log.error("Error registering FHIR Provider", e);
throw new FhirConfigurationException("Error registering FHIR Provider", e);
}
} | java | @Override
public void registerOsgiProvider (Object provider) throws FhirConfigurationException {
if (null == provider) {
throw new NullPointerException("FHIR Provider cannot be null");
}
try {
super.registerProvider(provider);
log.trace("registered provider. class ["+provider.getClass().getName()+"]");
this.serverProviders.add(provider);
} catch (Exception e) {
log.error("Error registering FHIR Provider", e);
throw new FhirConfigurationException("Error registering FHIR Provider", e);
}
} | [
"@",
"Override",
"public",
"void",
"registerOsgiProvider",
"(",
"Object",
"provider",
")",
"throws",
"FhirConfigurationException",
"{",
"if",
"(",
"null",
"==",
"provider",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"FHIR Provider cannot be null\"",
")",
";",
"}",
"try",
"{",
"super",
".",
"registerProvider",
"(",
"provider",
")",
";",
"log",
".",
"trace",
"(",
"\"registered provider. class [\"",
"+",
"provider",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"]\"",
")",
";",
"this",
".",
"serverProviders",
".",
"add",
"(",
"provider",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Error registering FHIR Provider\"",
",",
"e",
")",
";",
"throw",
"new",
"FhirConfigurationException",
"(",
"\"Error registering FHIR Provider\"",
",",
"e",
")",
";",
"}",
"}"
] | Dynamically registers a single provider with the RestfulServer
@param provider the provider to be registered
@throws FhirConfigurationException | [
"Dynamically",
"registers",
"a",
"single",
"provider",
"with",
"the",
"RestfulServer"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/FhirServerImpl.java#L60-L73 |
22,456 | jamesagnew/hapi-fhir | hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/FhirServerImpl.java | FhirServerImpl.unregisterOsgiProvider | @Override
public void unregisterOsgiProvider (Object provider) throws FhirConfigurationException {
if (null == provider) {
throw new NullPointerException("FHIR Provider cannot be null");
}
try {
this.serverProviders.remove(provider);
log.trace("unregistered provider. class ["+provider.getClass().getName()+"]");
super.unregisterProvider(provider);
} catch (Exception e) {
log.error("Error unregistering FHIR Provider", e);
throw new FhirConfigurationException("Error unregistering FHIR Provider", e);
}
} | java | @Override
public void unregisterOsgiProvider (Object provider) throws FhirConfigurationException {
if (null == provider) {
throw new NullPointerException("FHIR Provider cannot be null");
}
try {
this.serverProviders.remove(provider);
log.trace("unregistered provider. class ["+provider.getClass().getName()+"]");
super.unregisterProvider(provider);
} catch (Exception e) {
log.error("Error unregistering FHIR Provider", e);
throw new FhirConfigurationException("Error unregistering FHIR Provider", e);
}
} | [
"@",
"Override",
"public",
"void",
"unregisterOsgiProvider",
"(",
"Object",
"provider",
")",
"throws",
"FhirConfigurationException",
"{",
"if",
"(",
"null",
"==",
"provider",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"FHIR Provider cannot be null\"",
")",
";",
"}",
"try",
"{",
"this",
".",
"serverProviders",
".",
"remove",
"(",
"provider",
")",
";",
"log",
".",
"trace",
"(",
"\"unregistered provider. class [\"",
"+",
"provider",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"]\"",
")",
";",
"super",
".",
"unregisterProvider",
"(",
"provider",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Error unregistering FHIR Provider\"",
",",
"e",
")",
";",
"throw",
"new",
"FhirConfigurationException",
"(",
"\"Error unregistering FHIR Provider\"",
",",
"e",
")",
";",
"}",
"}"
] | Dynamically unregisters a single provider with the RestfulServer
@param provider the provider to be unregistered
@throws FhirConfigurationException | [
"Dynamically",
"unregisters",
"a",
"single",
"provider",
"with",
"the",
"RestfulServer"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/FhirServerImpl.java#L81-L94 |
22,457 | jamesagnew/hapi-fhir | hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/FhirServerImpl.java | FhirServerImpl.registerOsgiProviders | @Override
public void registerOsgiProviders (Collection<Object> providers) throws FhirConfigurationException {
if (null == providers) {
throw new NullPointerException("FHIR Provider list cannot be null");
}
try {
super.registerProviders(providers);
for (Object provider : providers) {
log.trace("registered provider. class ["+provider.getClass().getName()+"]");
this.serverProviders.add(provider);
}
} catch (Exception e) {
log.error("Error registering FHIR Providers", e);
throw new FhirConfigurationException("Error registering FHIR Providers", e);
}
} | java | @Override
public void registerOsgiProviders (Collection<Object> providers) throws FhirConfigurationException {
if (null == providers) {
throw new NullPointerException("FHIR Provider list cannot be null");
}
try {
super.registerProviders(providers);
for (Object provider : providers) {
log.trace("registered provider. class ["+provider.getClass().getName()+"]");
this.serverProviders.add(provider);
}
} catch (Exception e) {
log.error("Error registering FHIR Providers", e);
throw new FhirConfigurationException("Error registering FHIR Providers", e);
}
} | [
"@",
"Override",
"public",
"void",
"registerOsgiProviders",
"(",
"Collection",
"<",
"Object",
">",
"providers",
")",
"throws",
"FhirConfigurationException",
"{",
"if",
"(",
"null",
"==",
"providers",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"FHIR Provider list cannot be null\"",
")",
";",
"}",
"try",
"{",
"super",
".",
"registerProviders",
"(",
"providers",
")",
";",
"for",
"(",
"Object",
"provider",
":",
"providers",
")",
"{",
"log",
".",
"trace",
"(",
"\"registered provider. class [\"",
"+",
"provider",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"]\"",
")",
";",
"this",
".",
"serverProviders",
".",
"add",
"(",
"provider",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Error registering FHIR Providers\"",
",",
"e",
")",
";",
"throw",
"new",
"FhirConfigurationException",
"(",
"\"Error registering FHIR Providers\"",
",",
"e",
")",
";",
"}",
"}"
] | Dynamically registers a list of providers with the RestfulServer
@param provider the providers to be registered
@throws FhirConfigurationException | [
"Dynamically",
"registers",
"a",
"list",
"of",
"providers",
"with",
"the",
"RestfulServer"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/FhirServerImpl.java#L102-L117 |
22,458 | jamesagnew/hapi-fhir | hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/FhirServerImpl.java | FhirServerImpl.unregisterOsgiProviders | @Override
public void unregisterOsgiProviders (Collection<Object> providers) throws FhirConfigurationException {
if (null == providers) {
throw new NullPointerException("FHIR Provider list cannot be null");
}
try {
for (Object provider : providers) {
log.trace("unregistered provider. class ["+provider.getClass().getName()+"]");
this.serverProviders.remove(provider);
}
super.unregisterProvider(providers);
} catch (Exception e) {
log.error("Error unregistering FHIR Providers", e);
throw new FhirConfigurationException("Error unregistering FHIR Providers", e);
}
} | java | @Override
public void unregisterOsgiProviders (Collection<Object> providers) throws FhirConfigurationException {
if (null == providers) {
throw new NullPointerException("FHIR Provider list cannot be null");
}
try {
for (Object provider : providers) {
log.trace("unregistered provider. class ["+provider.getClass().getName()+"]");
this.serverProviders.remove(provider);
}
super.unregisterProvider(providers);
} catch (Exception e) {
log.error("Error unregistering FHIR Providers", e);
throw new FhirConfigurationException("Error unregistering FHIR Providers", e);
}
} | [
"@",
"Override",
"public",
"void",
"unregisterOsgiProviders",
"(",
"Collection",
"<",
"Object",
">",
"providers",
")",
"throws",
"FhirConfigurationException",
"{",
"if",
"(",
"null",
"==",
"providers",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"FHIR Provider list cannot be null\"",
")",
";",
"}",
"try",
"{",
"for",
"(",
"Object",
"provider",
":",
"providers",
")",
"{",
"log",
".",
"trace",
"(",
"\"unregistered provider. class [\"",
"+",
"provider",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"]\"",
")",
";",
"this",
".",
"serverProviders",
".",
"remove",
"(",
"provider",
")",
";",
"}",
"super",
".",
"unregisterProvider",
"(",
"providers",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Error unregistering FHIR Providers\"",
",",
"e",
")",
";",
"throw",
"new",
"FhirConfigurationException",
"(",
"\"Error unregistering FHIR Providers\"",
",",
"e",
")",
";",
"}",
"}"
] | Dynamically unregisters a list of providers with the RestfulServer
@param provider the providers to be unregistered
@throws FhirConfigurationException | [
"Dynamically",
"unregisters",
"a",
"list",
"of",
"providers",
"with",
"the",
"RestfulServer"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/FhirServerImpl.java#L125-L140 |
22,459 | jamesagnew/hapi-fhir | hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/FhirServerImpl.java | FhirServerImpl.unregisterOsgiProviders | @Override
public void unregisterOsgiProviders () throws FhirConfigurationException {
// need to make a copy to be able to remove items
Collection<Object> providers = new ArrayList<Object>();
providers.addAll(this.serverProviders);
this.unregisterOsgiProviders(providers);
} | java | @Override
public void unregisterOsgiProviders () throws FhirConfigurationException {
// need to make a copy to be able to remove items
Collection<Object> providers = new ArrayList<Object>();
providers.addAll(this.serverProviders);
this.unregisterOsgiProviders(providers);
} | [
"@",
"Override",
"public",
"void",
"unregisterOsgiProviders",
"(",
")",
"throws",
"FhirConfigurationException",
"{",
"// need to make a copy to be able to remove items",
"Collection",
"<",
"Object",
">",
"providers",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
")",
";",
"providers",
".",
"addAll",
"(",
"this",
".",
"serverProviders",
")",
";",
"this",
".",
"unregisterOsgiProviders",
"(",
"providers",
")",
";",
"}"
] | Dynamically unregisters all of providers currently registered
@throws FhirConfigurationException | [
"Dynamically",
"unregisters",
"all",
"of",
"providers",
"currently",
"registered"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-osgi-core/src/main/java/ca/uhn/fhir/osgi/FhirServerImpl.java#L147-L153 |
22,460 | jamesagnew/hapi-fhir | hapi-fhir-tutorial/simple-server/src/main/java/ca/uhn/fhir/example/ex3/Example03_PatientResourceProvider.java | Example03_PatientResourceProvider.search | @Search
public List<Patient> search(@RequiredParam(name="family") StringParam theParam) {
List<Patient> retVal = new ArrayList<Patient>();
// Loop through the patients looking for matches
for (Patient next : myPatients.values()) {
String familyName = next.getNameFirstRep().getFamilyAsSingleString().toLowerCase();
if (familyName.contains(theParam.getValue().toLowerCase()) == false) {
continue;
}
retVal.add(next);
}
return retVal;
} | java | @Search
public List<Patient> search(@RequiredParam(name="family") StringParam theParam) {
List<Patient> retVal = new ArrayList<Patient>();
// Loop through the patients looking for matches
for (Patient next : myPatients.values()) {
String familyName = next.getNameFirstRep().getFamilyAsSingleString().toLowerCase();
if (familyName.contains(theParam.getValue().toLowerCase()) == false) {
continue;
}
retVal.add(next);
}
return retVal;
} | [
"@",
"Search",
"public",
"List",
"<",
"Patient",
">",
"search",
"(",
"@",
"RequiredParam",
"(",
"name",
"=",
"\"family\"",
")",
"StringParam",
"theParam",
")",
"{",
"List",
"<",
"Patient",
">",
"retVal",
"=",
"new",
"ArrayList",
"<",
"Patient",
">",
"(",
")",
";",
"// Loop through the patients looking for matches",
"for",
"(",
"Patient",
"next",
":",
"myPatients",
".",
"values",
"(",
")",
")",
"{",
"String",
"familyName",
"=",
"next",
".",
"getNameFirstRep",
"(",
")",
".",
"getFamilyAsSingleString",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"familyName",
".",
"contains",
"(",
"theParam",
".",
"getValue",
"(",
")",
".",
"toLowerCase",
"(",
")",
")",
"==",
"false",
")",
"{",
"continue",
";",
"}",
"retVal",
".",
"add",
"(",
"next",
")",
";",
"}",
"return",
"retVal",
";",
"}"
] | A search with a parameter | [
"A",
"search",
"with",
"a",
"parameter"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-tutorial/simple-server/src/main/java/ca/uhn/fhir/example/ex3/Example03_PatientResourceProvider.java#L82-L96 |
22,461 | jamesagnew/hapi-fhir | hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/BaseParamWithPrefix.java | BaseParamWithPrefix.extractPrefixAndReturnRest | String extractPrefixAndReturnRest(String theString) {
int offset = 0;
while (true) {
if (theString.length() == offset) {
break;
} else {
char nextChar = theString.charAt(offset);
if (nextChar == '-' || Character.isDigit(nextChar)) {
break;
}
}
offset++;
}
String prefix = theString.substring(0, offset);
if (!isBlank(prefix)) {
myPrefix = ParamPrefixEnum.forValue(prefix);
if (myPrefix == null) {
switch (prefix) {
case ">=":
myPrefix = ParamPrefixEnum.GREATERTHAN_OR_EQUALS;
break;
case ">":
myPrefix = ParamPrefixEnum.GREATERTHAN;
break;
case "<=":
myPrefix = ParamPrefixEnum.LESSTHAN_OR_EQUALS;
break;
case "<":
myPrefix = ParamPrefixEnum.LESSTHAN;
break;
case "~":
myPrefix = ParamPrefixEnum.APPROXIMATE;
break;
default :
ourLog.warn("Invalid prefix being ignored: {}", prefix);
break;
}
if (myPrefix != null) {
ourLog.warn("Date parameter has legacy prefix '{}' which has been removed from FHIR. This should be replaced with '{}'", prefix, myPrefix);
}
}
}
return theString.substring(offset);
} | java | String extractPrefixAndReturnRest(String theString) {
int offset = 0;
while (true) {
if (theString.length() == offset) {
break;
} else {
char nextChar = theString.charAt(offset);
if (nextChar == '-' || Character.isDigit(nextChar)) {
break;
}
}
offset++;
}
String prefix = theString.substring(0, offset);
if (!isBlank(prefix)) {
myPrefix = ParamPrefixEnum.forValue(prefix);
if (myPrefix == null) {
switch (prefix) {
case ">=":
myPrefix = ParamPrefixEnum.GREATERTHAN_OR_EQUALS;
break;
case ">":
myPrefix = ParamPrefixEnum.GREATERTHAN;
break;
case "<=":
myPrefix = ParamPrefixEnum.LESSTHAN_OR_EQUALS;
break;
case "<":
myPrefix = ParamPrefixEnum.LESSTHAN;
break;
case "~":
myPrefix = ParamPrefixEnum.APPROXIMATE;
break;
default :
ourLog.warn("Invalid prefix being ignored: {}", prefix);
break;
}
if (myPrefix != null) {
ourLog.warn("Date parameter has legacy prefix '{}' which has been removed from FHIR. This should be replaced with '{}'", prefix, myPrefix);
}
}
}
return theString.substring(offset);
} | [
"String",
"extractPrefixAndReturnRest",
"(",
"String",
"theString",
")",
"{",
"int",
"offset",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"theString",
".",
"length",
"(",
")",
"==",
"offset",
")",
"{",
"break",
";",
"}",
"else",
"{",
"char",
"nextChar",
"=",
"theString",
".",
"charAt",
"(",
"offset",
")",
";",
"if",
"(",
"nextChar",
"==",
"'",
"'",
"||",
"Character",
".",
"isDigit",
"(",
"nextChar",
")",
")",
"{",
"break",
";",
"}",
"}",
"offset",
"++",
";",
"}",
"String",
"prefix",
"=",
"theString",
".",
"substring",
"(",
"0",
",",
"offset",
")",
";",
"if",
"(",
"!",
"isBlank",
"(",
"prefix",
")",
")",
"{",
"myPrefix",
"=",
"ParamPrefixEnum",
".",
"forValue",
"(",
"prefix",
")",
";",
"if",
"(",
"myPrefix",
"==",
"null",
")",
"{",
"switch",
"(",
"prefix",
")",
"{",
"case",
"\">=\"",
":",
"myPrefix",
"=",
"ParamPrefixEnum",
".",
"GREATERTHAN_OR_EQUALS",
";",
"break",
";",
"case",
"\">\"",
":",
"myPrefix",
"=",
"ParamPrefixEnum",
".",
"GREATERTHAN",
";",
"break",
";",
"case",
"\"<=\"",
":",
"myPrefix",
"=",
"ParamPrefixEnum",
".",
"LESSTHAN_OR_EQUALS",
";",
"break",
";",
"case",
"\"<\"",
":",
"myPrefix",
"=",
"ParamPrefixEnum",
".",
"LESSTHAN",
";",
"break",
";",
"case",
"\"~\"",
":",
"myPrefix",
"=",
"ParamPrefixEnum",
".",
"APPROXIMATE",
";",
"break",
";",
"default",
":",
"ourLog",
".",
"warn",
"(",
"\"Invalid prefix being ignored: {}\"",
",",
"prefix",
")",
";",
"break",
";",
"}",
"if",
"(",
"myPrefix",
"!=",
"null",
")",
"{",
"ourLog",
".",
"warn",
"(",
"\"Date parameter has legacy prefix '{}' which has been removed from FHIR. This should be replaced with '{}'\"",
",",
"prefix",
",",
"myPrefix",
")",
";",
"}",
"}",
"}",
"return",
"theString",
".",
"substring",
"(",
"offset",
")",
";",
"}"
] | Eg. if this is invoked with "gt2012-11-02", sets the prefix to GREATER_THAN and returns "2012-11-02" | [
"Eg",
".",
"if",
"this",
"is",
"invoked",
"with",
"gt2012",
"-",
"11",
"-",
"02",
"sets",
"the",
"prefix",
"to",
"GREATER_THAN",
"and",
"returns",
"2012",
"-",
"11",
"-",
"02"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/BaseParamWithPrefix.java#L43-L93 |
22,462 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java | BaseHapiFhirResourceDao.preProcessResourceForStorage | protected void preProcessResourceForStorage(T theResource) {
String type = getContext().getResourceDefinition(theResource).getName();
if (!getResourceName().equals(type)) {
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "incorrectResourceType", type, getResourceName()));
}
if (theResource.getIdElement().hasIdPart()) {
if (!theResource.getIdElement().isIdPartValid()) {
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithInvalidId", theResource.getIdElement().getIdPart()));
}
}
/*
* Replace absolute references with relative ones if configured to do so
*/
if (getConfig().getTreatBaseUrlsAsLocal().isEmpty() == false) {
FhirTerser t = getContext().newTerser();
List<ResourceReferenceInfo> refs = t.getAllResourceReferences(theResource);
for (ResourceReferenceInfo nextRef : refs) {
IIdType refId = nextRef.getResourceReference().getReferenceElement();
if (refId != null && refId.hasBaseUrl()) {
if (getConfig().getTreatBaseUrlsAsLocal().contains(refId.getBaseUrl())) {
IIdType newRefId = refId.toUnqualified();
nextRef.getResourceReference().setReference(newRefId.getValue());
}
}
}
}
} | java | protected void preProcessResourceForStorage(T theResource) {
String type = getContext().getResourceDefinition(theResource).getName();
if (!getResourceName().equals(type)) {
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "incorrectResourceType", type, getResourceName()));
}
if (theResource.getIdElement().hasIdPart()) {
if (!theResource.getIdElement().isIdPartValid()) {
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithInvalidId", theResource.getIdElement().getIdPart()));
}
}
/*
* Replace absolute references with relative ones if configured to do so
*/
if (getConfig().getTreatBaseUrlsAsLocal().isEmpty() == false) {
FhirTerser t = getContext().newTerser();
List<ResourceReferenceInfo> refs = t.getAllResourceReferences(theResource);
for (ResourceReferenceInfo nextRef : refs) {
IIdType refId = nextRef.getResourceReference().getReferenceElement();
if (refId != null && refId.hasBaseUrl()) {
if (getConfig().getTreatBaseUrlsAsLocal().contains(refId.getBaseUrl())) {
IIdType newRefId = refId.toUnqualified();
nextRef.getResourceReference().setReference(newRefId.getValue());
}
}
}
}
} | [
"protected",
"void",
"preProcessResourceForStorage",
"(",
"T",
"theResource",
")",
"{",
"String",
"type",
"=",
"getContext",
"(",
")",
".",
"getResourceDefinition",
"(",
"theResource",
")",
".",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"getResourceName",
"(",
")",
".",
"equals",
"(",
"type",
")",
")",
"{",
"throw",
"new",
"InvalidRequestException",
"(",
"getContext",
"(",
")",
".",
"getLocalizer",
"(",
")",
".",
"getMessage",
"(",
"BaseHapiFhirResourceDao",
".",
"class",
",",
"\"incorrectResourceType\"",
",",
"type",
",",
"getResourceName",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"theResource",
".",
"getIdElement",
"(",
")",
".",
"hasIdPart",
"(",
")",
")",
"{",
"if",
"(",
"!",
"theResource",
".",
"getIdElement",
"(",
")",
".",
"isIdPartValid",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidRequestException",
"(",
"getContext",
"(",
")",
".",
"getLocalizer",
"(",
")",
".",
"getMessage",
"(",
"BaseHapiFhirResourceDao",
".",
"class",
",",
"\"failedToCreateWithInvalidId\"",
",",
"theResource",
".",
"getIdElement",
"(",
")",
".",
"getIdPart",
"(",
")",
")",
")",
";",
"}",
"}",
"/*\n\t\t * Replace absolute references with relative ones if configured to do so\n\t\t */",
"if",
"(",
"getConfig",
"(",
")",
".",
"getTreatBaseUrlsAsLocal",
"(",
")",
".",
"isEmpty",
"(",
")",
"==",
"false",
")",
"{",
"FhirTerser",
"t",
"=",
"getContext",
"(",
")",
".",
"newTerser",
"(",
")",
";",
"List",
"<",
"ResourceReferenceInfo",
">",
"refs",
"=",
"t",
".",
"getAllResourceReferences",
"(",
"theResource",
")",
";",
"for",
"(",
"ResourceReferenceInfo",
"nextRef",
":",
"refs",
")",
"{",
"IIdType",
"refId",
"=",
"nextRef",
".",
"getResourceReference",
"(",
")",
".",
"getReferenceElement",
"(",
")",
";",
"if",
"(",
"refId",
"!=",
"null",
"&&",
"refId",
".",
"hasBaseUrl",
"(",
")",
")",
"{",
"if",
"(",
"getConfig",
"(",
")",
".",
"getTreatBaseUrlsAsLocal",
"(",
")",
".",
"contains",
"(",
"refId",
".",
"getBaseUrl",
"(",
")",
")",
")",
"{",
"IIdType",
"newRefId",
"=",
"refId",
".",
"toUnqualified",
"(",
")",
";",
"nextRef",
".",
"getResourceReference",
"(",
")",
".",
"setReference",
"(",
"newRefId",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | May be overridden by subclasses to validate resources prior to storage
@param theResource The resource that is about to be stored | [
"May",
"be",
"overridden",
"by",
"subclasses",
"to",
"validate",
"resources",
"prior",
"to",
"storage"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java#L831-L859 |
22,463 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java | BaseHapiFhirResourceDao.validateCriteriaAndReturnResourceDefinition | @Override
public RuntimeResourceDefinition validateCriteriaAndReturnResourceDefinition(String criteria) {
String resourceName;
if (criteria == null || criteria.trim().isEmpty()) {
throw new IllegalArgumentException("Criteria cannot be empty");
}
if (criteria.contains("?")) {
resourceName = criteria.substring(0, criteria.indexOf("?"));
} else {
resourceName = criteria;
}
return getContext().getResourceDefinition(resourceName);
} | java | @Override
public RuntimeResourceDefinition validateCriteriaAndReturnResourceDefinition(String criteria) {
String resourceName;
if (criteria == null || criteria.trim().isEmpty()) {
throw new IllegalArgumentException("Criteria cannot be empty");
}
if (criteria.contains("?")) {
resourceName = criteria.substring(0, criteria.indexOf("?"));
} else {
resourceName = criteria;
}
return getContext().getResourceDefinition(resourceName);
} | [
"@",
"Override",
"public",
"RuntimeResourceDefinition",
"validateCriteriaAndReturnResourceDefinition",
"(",
"String",
"criteria",
")",
"{",
"String",
"resourceName",
";",
"if",
"(",
"criteria",
"==",
"null",
"||",
"criteria",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Criteria cannot be empty\"",
")",
";",
"}",
"if",
"(",
"criteria",
".",
"contains",
"(",
"\"?\"",
")",
")",
"{",
"resourceName",
"=",
"criteria",
".",
"substring",
"(",
"0",
",",
"criteria",
".",
"indexOf",
"(",
"\"?\"",
")",
")",
";",
"}",
"else",
"{",
"resourceName",
"=",
"criteria",
";",
"}",
"return",
"getContext",
"(",
")",
".",
"getResourceDefinition",
"(",
"resourceName",
")",
";",
"}"
] | Get the resource definition from the criteria which specifies the resource type
@param criteria
@return | [
"Get",
"the",
"resource",
"definition",
"from",
"the",
"criteria",
"which",
"specifies",
"the",
"resource",
"type"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java#L1366-L1379 |
22,464 | jamesagnew/hapi-fhir | hapi-fhir-converter/src/main/java/org/hl7/fhir/convertors/Convert.java | Convert.makeDateTimeFromIVL | public DateTimeType makeDateTimeFromIVL(Element ivl) throws Exception {
if (ivl == null)
return null;
if (ivl.hasAttribute("value"))
return makeDateTimeFromTS(ivl);
Element high = cda.getChild(ivl, "high");
if (high != null)
return makeDateTimeFromTS(high);
Element low = cda.getChild(ivl, "low");
if (low != null)
return makeDateTimeFromTS(low);
return null;
} | java | public DateTimeType makeDateTimeFromIVL(Element ivl) throws Exception {
if (ivl == null)
return null;
if (ivl.hasAttribute("value"))
return makeDateTimeFromTS(ivl);
Element high = cda.getChild(ivl, "high");
if (high != null)
return makeDateTimeFromTS(high);
Element low = cda.getChild(ivl, "low");
if (low != null)
return makeDateTimeFromTS(low);
return null;
} | [
"public",
"DateTimeType",
"makeDateTimeFromIVL",
"(",
"Element",
"ivl",
")",
"throws",
"Exception",
"{",
"if",
"(",
"ivl",
"==",
"null",
")",
"return",
"null",
";",
"if",
"(",
"ivl",
".",
"hasAttribute",
"(",
"\"value\"",
")",
")",
"return",
"makeDateTimeFromTS",
"(",
"ivl",
")",
";",
"Element",
"high",
"=",
"cda",
".",
"getChild",
"(",
"ivl",
",",
"\"high\"",
")",
";",
"if",
"(",
"high",
"!=",
"null",
")",
"return",
"makeDateTimeFromTS",
"(",
"high",
")",
";",
"Element",
"low",
"=",
"cda",
".",
"getChild",
"(",
"ivl",
",",
"\"low\"",
")",
";",
"if",
"(",
"low",
"!=",
"null",
")",
"return",
"makeDateTimeFromTS",
"(",
"low",
")",
";",
"return",
"null",
";",
"}"
] | this is a weird one - where CDA has an IVL, and FHIR has a date | [
"this",
"is",
"a",
"weird",
"one",
"-",
"where",
"CDA",
"has",
"an",
"IVL",
"and",
"FHIR",
"has",
"a",
"date"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-converter/src/main/java/org/hl7/fhir/convertors/Convert.java#L418-L430 |
22,465 | jamesagnew/hapi-fhir | hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/ucum/UcumEssenceService.java | UcumEssenceService.analyse | @Override
public String analyse(String unit) throws UcumException {
if (Utilities.noString(unit))
return "(unity)";
assert checkStringParam(unit) : paramError("analyse", "unit", "must not be null or empty");
Term term = new ExpressionParser(model).parse(unit);
return new FormalStructureComposer().compose(term);
} | java | @Override
public String analyse(String unit) throws UcumException {
if (Utilities.noString(unit))
return "(unity)";
assert checkStringParam(unit) : paramError("analyse", "unit", "must not be null or empty");
Term term = new ExpressionParser(model).parse(unit);
return new FormalStructureComposer().compose(term);
} | [
"@",
"Override",
"public",
"String",
"analyse",
"(",
"String",
"unit",
")",
"throws",
"UcumException",
"{",
"if",
"(",
"Utilities",
".",
"noString",
"(",
"unit",
")",
")",
"return",
"\"(unity)\"",
";",
"assert",
"checkStringParam",
"(",
"unit",
")",
":",
"paramError",
"(",
"\"analyse\"",
",",
"\"unit\"",
",",
"\"must not be null or empty\"",
")",
";",
"Term",
"term",
"=",
"new",
"ExpressionParser",
"(",
"model",
")",
".",
"parse",
"(",
"unit",
")",
";",
"return",
"new",
"FormalStructureComposer",
"(",
")",
".",
"compose",
"(",
"term",
")",
";",
"}"
] | given a unit, return a formal description of what the units stand for using
full names
@param units the unit code
@return formal description
@throws UcumException
@ | [
"given",
"a",
"unit",
"return",
"a",
"formal",
"description",
"of",
"what",
"the",
"units",
"stand",
"for",
"using",
"full",
"names"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/ucum/UcumEssenceService.java#L198-L205 |
22,466 | jamesagnew/hapi-fhir | hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java | IncomingRequestAddressStrategy.determineServletContextPath | public static String determineServletContextPath(HttpServletRequest theRequest, RestfulServer server) {
String retVal;
if (server.getServletContext() != null) {
if (server.getServletContext().getMajorVersion() >= 3 || (server.getServletContext().getMajorVersion() > 2 && server.getServletContext().getMinorVersion() >= 5)) {
retVal = server.getServletContext().getContextPath();
} else {
retVal = theRequest.getContextPath();
}
} else {
retVal = theRequest.getContextPath();
}
retVal = StringUtils.defaultString(retVal);
return retVal;
} | java | public static String determineServletContextPath(HttpServletRequest theRequest, RestfulServer server) {
String retVal;
if (server.getServletContext() != null) {
if (server.getServletContext().getMajorVersion() >= 3 || (server.getServletContext().getMajorVersion() > 2 && server.getServletContext().getMinorVersion() >= 5)) {
retVal = server.getServletContext().getContextPath();
} else {
retVal = theRequest.getContextPath();
}
} else {
retVal = theRequest.getContextPath();
}
retVal = StringUtils.defaultString(retVal);
return retVal;
} | [
"public",
"static",
"String",
"determineServletContextPath",
"(",
"HttpServletRequest",
"theRequest",
",",
"RestfulServer",
"server",
")",
"{",
"String",
"retVal",
";",
"if",
"(",
"server",
".",
"getServletContext",
"(",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"server",
".",
"getServletContext",
"(",
")",
".",
"getMajorVersion",
"(",
")",
">=",
"3",
"||",
"(",
"server",
".",
"getServletContext",
"(",
")",
".",
"getMajorVersion",
"(",
")",
">",
"2",
"&&",
"server",
".",
"getServletContext",
"(",
")",
".",
"getMinorVersion",
"(",
")",
">=",
"5",
")",
")",
"{",
"retVal",
"=",
"server",
".",
"getServletContext",
"(",
")",
".",
"getContextPath",
"(",
")",
";",
"}",
"else",
"{",
"retVal",
"=",
"theRequest",
".",
"getContextPath",
"(",
")",
";",
"}",
"}",
"else",
"{",
"retVal",
"=",
"theRequest",
".",
"getContextPath",
"(",
")",
";",
"}",
"retVal",
"=",
"StringUtils",
".",
"defaultString",
"(",
"retVal",
")",
";",
"return",
"retVal",
";",
"}"
] | Determines the servlet's context path.
This is here to try and deal with the wide variation in servers and what they return.
getServletContext().getContextPath() is supposed to return the path to the specific servlet we are deployed as but it's not available everywhere. On some servers getServletContext() can return
null (old Jetty seems to suffer from this, see hapi-fhir-base-test-mindeps-server) and on other old servers (Servlet 2.4) getServletContext().getContextPath() doesn't even exist.
theRequest.getContextPath() returns the context for the specific incoming request. It should be available everywhere, but it's likely to be less predicable if there are multiple servlet mappings
pointing to the same servlet, so we don't favour it. This is possibly not the best strategy (maybe we should just always use theRequest.getContextPath()?) but so far people seem happy with this
behavour across a wide variety of platforms.
If you are having troubles on a given platform/configuration and want to suggest a change or even report incompatibility here, we'd love to hear about it. | [
"Determines",
"the",
"servlet",
"s",
"context",
"path",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java#L124-L137 |
22,467 | jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/terminologies/CodeSystemUtilities.java | CodeSystemUtilities.getOtherChildren | public static List<String> getOtherChildren(CodeSystem cs, ConceptDefinitionComponent c) {
List<String> res = new ArrayList<String>();
for (ConceptPropertyComponent p : c.getProperty()) {
if ("parent".equals(p.getCode())) {
res.add(p.getValue().primitiveValue());
}
}
return res;
} | java | public static List<String> getOtherChildren(CodeSystem cs, ConceptDefinitionComponent c) {
List<String> res = new ArrayList<String>();
for (ConceptPropertyComponent p : c.getProperty()) {
if ("parent".equals(p.getCode())) {
res.add(p.getValue().primitiveValue());
}
}
return res;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"getOtherChildren",
"(",
"CodeSystem",
"cs",
",",
"ConceptDefinitionComponent",
"c",
")",
"{",
"List",
"<",
"String",
">",
"res",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"ConceptPropertyComponent",
"p",
":",
"c",
".",
"getProperty",
"(",
")",
")",
"{",
"if",
"(",
"\"parent\"",
".",
"equals",
"(",
"p",
".",
"getCode",
"(",
")",
")",
")",
"{",
"res",
".",
"add",
"(",
"p",
".",
"getValue",
"(",
")",
".",
"primitiveValue",
"(",
")",
")",
";",
"}",
"}",
"return",
"res",
";",
"}"
] | returns additional parents not in the heirarchy | [
"returns",
"additional",
"parents",
"not",
"in",
"the",
"heirarchy"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/terminologies/CodeSystemUtilities.java#L243-L251 |
22,468 | jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/model/BaseDateTimeType.java | BaseDateTimeType.equalsUsingFhirPathRules | public Boolean equalsUsingFhirPathRules(BaseDateTimeType theOther) {
BaseDateTimeType me = this;
// Per FHIRPath rules, we compare equivalence at the lowest precision of the two values,
// so if we need to, we'll clone either side and reduce its precision
int lowestPrecision = Math.min(me.getPrecision().ordinal(), theOther.getPrecision().ordinal());
TemporalPrecisionEnum lowestPrecisionEnum = TemporalPrecisionEnum.values()[lowestPrecision];
if (me.getPrecision() != lowestPrecisionEnum) {
me = new DateTimeType(me.getValueAsString());
me.setPrecision(lowestPrecisionEnum);
}
if (theOther.getPrecision() != lowestPrecisionEnum) {
theOther = new DateTimeType(theOther.getValueAsString());
theOther.setPrecision(lowestPrecisionEnum);
}
if (me.hasTimezoneIfRequired() != theOther.hasTimezoneIfRequired()) {
if (me.getPrecision() == theOther.getPrecision()) {
if (me.getPrecision().ordinal() >= TemporalPrecisionEnum.MINUTE.ordinal() && theOther.getPrecision().ordinal() >= TemporalPrecisionEnum.MINUTE.ordinal()) {
boolean couldBeTheSameTime = couldBeTheSameTime(me, theOther) || couldBeTheSameTime(theOther, me);
if (!couldBeTheSameTime) {
return false;
}
}
}
return null;
}
// Same precision
if (me.getPrecision() == theOther.getPrecision()) {
if (me.getPrecision().ordinal() >= TemporalPrecisionEnum.MINUTE.ordinal()) {
long leftTime = me.getValue().getTime();
long rightTime = theOther.getValue().getTime();
return leftTime == rightTime;
} else {
String leftTime = me.getValueAsString();
String rightTime = theOther.getValueAsString();
return leftTime.equals(rightTime);
}
}
// Both represent 0 millis but the millis are optional
if (((Integer)0).equals(me.getMillis())) {
if (((Integer)0).equals(theOther.getMillis())) {
if (me.getPrecision().ordinal() >= TemporalPrecisionEnum.SECOND.ordinal()) {
if (theOther.getPrecision().ordinal() >= TemporalPrecisionEnum.SECOND.ordinal()) {
return me.getValue().getTime() == theOther.getValue().getTime();
}
}
}
}
return false;
} | java | public Boolean equalsUsingFhirPathRules(BaseDateTimeType theOther) {
BaseDateTimeType me = this;
// Per FHIRPath rules, we compare equivalence at the lowest precision of the two values,
// so if we need to, we'll clone either side and reduce its precision
int lowestPrecision = Math.min(me.getPrecision().ordinal(), theOther.getPrecision().ordinal());
TemporalPrecisionEnum lowestPrecisionEnum = TemporalPrecisionEnum.values()[lowestPrecision];
if (me.getPrecision() != lowestPrecisionEnum) {
me = new DateTimeType(me.getValueAsString());
me.setPrecision(lowestPrecisionEnum);
}
if (theOther.getPrecision() != lowestPrecisionEnum) {
theOther = new DateTimeType(theOther.getValueAsString());
theOther.setPrecision(lowestPrecisionEnum);
}
if (me.hasTimezoneIfRequired() != theOther.hasTimezoneIfRequired()) {
if (me.getPrecision() == theOther.getPrecision()) {
if (me.getPrecision().ordinal() >= TemporalPrecisionEnum.MINUTE.ordinal() && theOther.getPrecision().ordinal() >= TemporalPrecisionEnum.MINUTE.ordinal()) {
boolean couldBeTheSameTime = couldBeTheSameTime(me, theOther) || couldBeTheSameTime(theOther, me);
if (!couldBeTheSameTime) {
return false;
}
}
}
return null;
}
// Same precision
if (me.getPrecision() == theOther.getPrecision()) {
if (me.getPrecision().ordinal() >= TemporalPrecisionEnum.MINUTE.ordinal()) {
long leftTime = me.getValue().getTime();
long rightTime = theOther.getValue().getTime();
return leftTime == rightTime;
} else {
String leftTime = me.getValueAsString();
String rightTime = theOther.getValueAsString();
return leftTime.equals(rightTime);
}
}
// Both represent 0 millis but the millis are optional
if (((Integer)0).equals(me.getMillis())) {
if (((Integer)0).equals(theOther.getMillis())) {
if (me.getPrecision().ordinal() >= TemporalPrecisionEnum.SECOND.ordinal()) {
if (theOther.getPrecision().ordinal() >= TemporalPrecisionEnum.SECOND.ordinal()) {
return me.getValue().getTime() == theOther.getValue().getTime();
}
}
}
}
return false;
} | [
"public",
"Boolean",
"equalsUsingFhirPathRules",
"(",
"BaseDateTimeType",
"theOther",
")",
"{",
"BaseDateTimeType",
"me",
"=",
"this",
";",
"// Per FHIRPath rules, we compare equivalence at the lowest precision of the two values,",
"// so if we need to, we'll clone either side and reduce its precision",
"int",
"lowestPrecision",
"=",
"Math",
".",
"min",
"(",
"me",
".",
"getPrecision",
"(",
")",
".",
"ordinal",
"(",
")",
",",
"theOther",
".",
"getPrecision",
"(",
")",
".",
"ordinal",
"(",
")",
")",
";",
"TemporalPrecisionEnum",
"lowestPrecisionEnum",
"=",
"TemporalPrecisionEnum",
".",
"values",
"(",
")",
"[",
"lowestPrecision",
"]",
";",
"if",
"(",
"me",
".",
"getPrecision",
"(",
")",
"!=",
"lowestPrecisionEnum",
")",
"{",
"me",
"=",
"new",
"DateTimeType",
"(",
"me",
".",
"getValueAsString",
"(",
")",
")",
";",
"me",
".",
"setPrecision",
"(",
"lowestPrecisionEnum",
")",
";",
"}",
"if",
"(",
"theOther",
".",
"getPrecision",
"(",
")",
"!=",
"lowestPrecisionEnum",
")",
"{",
"theOther",
"=",
"new",
"DateTimeType",
"(",
"theOther",
".",
"getValueAsString",
"(",
")",
")",
";",
"theOther",
".",
"setPrecision",
"(",
"lowestPrecisionEnum",
")",
";",
"}",
"if",
"(",
"me",
".",
"hasTimezoneIfRequired",
"(",
")",
"!=",
"theOther",
".",
"hasTimezoneIfRequired",
"(",
")",
")",
"{",
"if",
"(",
"me",
".",
"getPrecision",
"(",
")",
"==",
"theOther",
".",
"getPrecision",
"(",
")",
")",
"{",
"if",
"(",
"me",
".",
"getPrecision",
"(",
")",
".",
"ordinal",
"(",
")",
">=",
"TemporalPrecisionEnum",
".",
"MINUTE",
".",
"ordinal",
"(",
")",
"&&",
"theOther",
".",
"getPrecision",
"(",
")",
".",
"ordinal",
"(",
")",
">=",
"TemporalPrecisionEnum",
".",
"MINUTE",
".",
"ordinal",
"(",
")",
")",
"{",
"boolean",
"couldBeTheSameTime",
"=",
"couldBeTheSameTime",
"(",
"me",
",",
"theOther",
")",
"||",
"couldBeTheSameTime",
"(",
"theOther",
",",
"me",
")",
";",
"if",
"(",
"!",
"couldBeTheSameTime",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}",
"// Same precision",
"if",
"(",
"me",
".",
"getPrecision",
"(",
")",
"==",
"theOther",
".",
"getPrecision",
"(",
")",
")",
"{",
"if",
"(",
"me",
".",
"getPrecision",
"(",
")",
".",
"ordinal",
"(",
")",
">=",
"TemporalPrecisionEnum",
".",
"MINUTE",
".",
"ordinal",
"(",
")",
")",
"{",
"long",
"leftTime",
"=",
"me",
".",
"getValue",
"(",
")",
".",
"getTime",
"(",
")",
";",
"long",
"rightTime",
"=",
"theOther",
".",
"getValue",
"(",
")",
".",
"getTime",
"(",
")",
";",
"return",
"leftTime",
"==",
"rightTime",
";",
"}",
"else",
"{",
"String",
"leftTime",
"=",
"me",
".",
"getValueAsString",
"(",
")",
";",
"String",
"rightTime",
"=",
"theOther",
".",
"getValueAsString",
"(",
")",
";",
"return",
"leftTime",
".",
"equals",
"(",
"rightTime",
")",
";",
"}",
"}",
"// Both represent 0 millis but the millis are optional",
"if",
"(",
"(",
"(",
"Integer",
")",
"0",
")",
".",
"equals",
"(",
"me",
".",
"getMillis",
"(",
")",
")",
")",
"{",
"if",
"(",
"(",
"(",
"Integer",
")",
"0",
")",
".",
"equals",
"(",
"theOther",
".",
"getMillis",
"(",
")",
")",
")",
"{",
"if",
"(",
"me",
".",
"getPrecision",
"(",
")",
".",
"ordinal",
"(",
")",
">=",
"TemporalPrecisionEnum",
".",
"SECOND",
".",
"ordinal",
"(",
")",
")",
"{",
"if",
"(",
"theOther",
".",
"getPrecision",
"(",
")",
".",
"ordinal",
"(",
")",
">=",
"TemporalPrecisionEnum",
".",
"SECOND",
".",
"ordinal",
"(",
")",
")",
"{",
"return",
"me",
".",
"getValue",
"(",
")",
".",
"getTime",
"(",
")",
"==",
"theOther",
".",
"getValue",
"(",
")",
".",
"getTime",
"(",
")",
";",
"}",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | This method implements a datetime equality check using the rules as defined by FHIRPath.
This method returns:
<ul>
<li>true if the given datetimes represent the exact same instant with the same precision (irrespective of the timezone)</li>
<li>true if the given datetimes represent the exact same instant but one includes milliseconds of <code>.[0]+</code> while the other includes only SECONDS precision (irrespecitve of the timezone)</li>
<li>true if the given datetimes represent the exact same year/year-month/year-month-date (if both operands have the same precision)</li>
<li>false if both datetimes have equal precision of MINUTE or greater, one has no timezone specified but the other does, and could not represent the same instant in any timezone</li>
<li>null if both datetimes have equal precision of MINUTE or greater, one has no timezone specified but the other does, and could potentially represent the same instant in any timezone</li>
<li>false if the given datetimes have the same precision but do not represent the same instant (irrespective of timezone)</li>
<li>null otherwise (since these datetimes are not comparable)</li>
</ul> | [
"This",
"method",
"implements",
"a",
"datetime",
"equality",
"check",
"using",
"the",
"rules",
"as",
"defined",
"by",
"FHIRPath",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/model/BaseDateTimeType.java#L878-L932 |
22,469 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/ResourceDeliveryMessage.java | ResourceDeliveryMessage.getSubscriptionId | public String getSubscriptionId(FhirContext theFhirContext) {
String retVal = null;
if (getSubscription() != null) {
retVal = getSubscription().getIdElement(theFhirContext).getValue();
}
return retVal;
} | java | public String getSubscriptionId(FhirContext theFhirContext) {
String retVal = null;
if (getSubscription() != null) {
retVal = getSubscription().getIdElement(theFhirContext).getValue();
}
return retVal;
} | [
"public",
"String",
"getSubscriptionId",
"(",
"FhirContext",
"theFhirContext",
")",
"{",
"String",
"retVal",
"=",
"null",
";",
"if",
"(",
"getSubscription",
"(",
")",
"!=",
"null",
")",
"{",
"retVal",
"=",
"getSubscription",
"(",
")",
".",
"getIdElement",
"(",
"theFhirContext",
")",
".",
"getValue",
"(",
")",
";",
"}",
"return",
"retVal",
";",
"}"
] | Helper method to fetch the subscription ID | [
"Helper",
"method",
"to",
"fetch",
"the",
"subscription",
"ID"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/ResourceDeliveryMessage.java#L125-L131 |
22,470 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaBundleProvider.java | PersistedJpaBundleProvider.ensureSearchEntityLoaded | public boolean ensureSearchEntityLoaded() {
if (mySearchEntity == null) {
ensureDependenciesInjected();
TransactionTemplate txTemplate = new TransactionTemplate(myPlatformTransactionManager);
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
txTemplate.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED);
return txTemplate.execute(s -> {
try {
setSearchEntity(mySearchDao.findByUuid(myUuid));
if (mySearchEntity == null) {
return false;
}
ourLog.trace("Retrieved search with version {} and total {}", mySearchEntity.getVersion(), mySearchEntity.getTotalCount());
// Load the includes now so that they are available outside of this transaction
mySearchEntity.getIncludes().size();
return true;
} catch (NoResultException e) {
return false;
}
});
}
return true;
} | java | public boolean ensureSearchEntityLoaded() {
if (mySearchEntity == null) {
ensureDependenciesInjected();
TransactionTemplate txTemplate = new TransactionTemplate(myPlatformTransactionManager);
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
txTemplate.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED);
return txTemplate.execute(s -> {
try {
setSearchEntity(mySearchDao.findByUuid(myUuid));
if (mySearchEntity == null) {
return false;
}
ourLog.trace("Retrieved search with version {} and total {}", mySearchEntity.getVersion(), mySearchEntity.getTotalCount());
// Load the includes now so that they are available outside of this transaction
mySearchEntity.getIncludes().size();
return true;
} catch (NoResultException e) {
return false;
}
});
}
return true;
} | [
"public",
"boolean",
"ensureSearchEntityLoaded",
"(",
")",
"{",
"if",
"(",
"mySearchEntity",
"==",
"null",
")",
"{",
"ensureDependenciesInjected",
"(",
")",
";",
"TransactionTemplate",
"txTemplate",
"=",
"new",
"TransactionTemplate",
"(",
"myPlatformTransactionManager",
")",
";",
"txTemplate",
".",
"setPropagationBehavior",
"(",
"TransactionDefinition",
".",
"PROPAGATION_REQUIRED",
")",
";",
"txTemplate",
".",
"setIsolationLevel",
"(",
"TransactionDefinition",
".",
"ISOLATION_READ_COMMITTED",
")",
";",
"return",
"txTemplate",
".",
"execute",
"(",
"s",
"->",
"{",
"try",
"{",
"setSearchEntity",
"(",
"mySearchDao",
".",
"findByUuid",
"(",
"myUuid",
")",
")",
";",
"if",
"(",
"mySearchEntity",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"ourLog",
".",
"trace",
"(",
"\"Retrieved search with version {} and total {}\"",
",",
"mySearchEntity",
".",
"getVersion",
"(",
")",
",",
"mySearchEntity",
".",
"getTotalCount",
"(",
")",
")",
";",
"// Load the includes now so that they are available outside of this transaction",
"mySearchEntity",
".",
"getIncludes",
"(",
")",
".",
"size",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"NoResultException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Returns false if the entity can't be found | [
"Returns",
"false",
"if",
"the",
"entity",
"can",
"t",
"be",
"found"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaBundleProvider.java#L154-L181 |
22,471 | jamesagnew/hapi-fhir | hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/IdDt.java | IdDt.equalsIgnoreBase | @SuppressWarnings("deprecation")
public boolean equalsIgnoreBase(IdDt theId) {
if (theId == null) {
return false;
}
if (theId.isEmpty()) {
return isEmpty();
}
return ObjectUtils.equals(getResourceType(), theId.getResourceType()) && ObjectUtils.equals(getIdPart(), theId.getIdPart()) && ObjectUtils.equals(getVersionIdPart(), theId.getVersionIdPart());
} | java | @SuppressWarnings("deprecation")
public boolean equalsIgnoreBase(IdDt theId) {
if (theId == null) {
return false;
}
if (theId.isEmpty()) {
return isEmpty();
}
return ObjectUtils.equals(getResourceType(), theId.getResourceType()) && ObjectUtils.equals(getIdPart(), theId.getIdPart()) && ObjectUtils.equals(getVersionIdPart(), theId.getVersionIdPart());
} | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"public",
"boolean",
"equalsIgnoreBase",
"(",
"IdDt",
"theId",
")",
"{",
"if",
"(",
"theId",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"theId",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"isEmpty",
"(",
")",
";",
"}",
"return",
"ObjectUtils",
".",
"equals",
"(",
"getResourceType",
"(",
")",
",",
"theId",
".",
"getResourceType",
"(",
")",
")",
"&&",
"ObjectUtils",
".",
"equals",
"(",
"getIdPart",
"(",
")",
",",
"theId",
".",
"getIdPart",
"(",
")",
")",
"&&",
"ObjectUtils",
".",
"equals",
"(",
"getVersionIdPart",
"(",
")",
",",
"theId",
".",
"getVersionIdPart",
"(",
")",
")",
";",
"}"
] | Returns true if this IdDt matches the given IdDt in terms of resource type and ID, but ignores the URL base | [
"Returns",
"true",
"if",
"this",
"IdDt",
"matches",
"the",
"given",
"IdDt",
"in",
"terms",
"of",
"resource",
"type",
"and",
"ID",
"but",
"ignores",
"the",
"URL",
"base"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/IdDt.java#L203-L212 |
22,472 | jamesagnew/hapi-fhir | hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/interceptor/JaxRsExceptionInterceptor.java | JaxRsExceptionInterceptor.intercept | @AroundInvoke
public Object intercept(final InvocationContext ctx)
throws JaxRsResponseException {
try {
return ctx.proceed();
}
catch (final Exception theException) {
final AbstractJaxRsProvider theServer = (AbstractJaxRsProvider) ctx.getTarget();
throw convertException(theServer, theException);
}
} | java | @AroundInvoke
public Object intercept(final InvocationContext ctx)
throws JaxRsResponseException {
try {
return ctx.proceed();
}
catch (final Exception theException) {
final AbstractJaxRsProvider theServer = (AbstractJaxRsProvider) ctx.getTarget();
throw convertException(theServer, theException);
}
} | [
"@",
"AroundInvoke",
"public",
"Object",
"intercept",
"(",
"final",
"InvocationContext",
"ctx",
")",
"throws",
"JaxRsResponseException",
"{",
"try",
"{",
"return",
"ctx",
".",
"proceed",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"theException",
")",
"{",
"final",
"AbstractJaxRsProvider",
"theServer",
"=",
"(",
"AbstractJaxRsProvider",
")",
"ctx",
".",
"getTarget",
"(",
")",
";",
"throw",
"convertException",
"(",
"theServer",
",",
"theException",
")",
";",
"}",
"}"
] | This interceptor will catch all exception and convert them using the exceptionhandler
@param ctx the invocation context
@return the result
@throws JaxRsResponseException an exception that can be handled by a jee container | [
"This",
"interceptor",
"will",
"catch",
"all",
"exception",
"and",
"convert",
"them",
"using",
"the",
"exceptionhandler"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/interceptor/JaxRsExceptionInterceptor.java#L67-L77 |
22,473 | jamesagnew/hapi-fhir | hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/interceptor/JaxRsExceptionInterceptor.java | JaxRsExceptionInterceptor.convertException | public JaxRsResponseException convertException(final AbstractJaxRsProvider theServer, final Throwable theException) {
if (theServer.withStackTrace()) {
exceptionHandler.setReturnStackTracesForExceptionTypes(Throwable.class);
}
final JaxRsRequest requestDetails = theServer.getRequest(null, null).build();
final BaseServerResponseException convertedException = preprocessException(theException, requestDetails);
return new JaxRsResponseException(convertedException);
} | java | public JaxRsResponseException convertException(final AbstractJaxRsProvider theServer, final Throwable theException) {
if (theServer.withStackTrace()) {
exceptionHandler.setReturnStackTracesForExceptionTypes(Throwable.class);
}
final JaxRsRequest requestDetails = theServer.getRequest(null, null).build();
final BaseServerResponseException convertedException = preprocessException(theException, requestDetails);
return new JaxRsResponseException(convertedException);
} | [
"public",
"JaxRsResponseException",
"convertException",
"(",
"final",
"AbstractJaxRsProvider",
"theServer",
",",
"final",
"Throwable",
"theException",
")",
"{",
"if",
"(",
"theServer",
".",
"withStackTrace",
"(",
")",
")",
"{",
"exceptionHandler",
".",
"setReturnStackTracesForExceptionTypes",
"(",
"Throwable",
".",
"class",
")",
";",
"}",
"final",
"JaxRsRequest",
"requestDetails",
"=",
"theServer",
".",
"getRequest",
"(",
"null",
",",
"null",
")",
".",
"build",
"(",
")",
";",
"final",
"BaseServerResponseException",
"convertedException",
"=",
"preprocessException",
"(",
"theException",
",",
"requestDetails",
")",
";",
"return",
"new",
"JaxRsResponseException",
"(",
"convertedException",
")",
";",
"}"
] | This method convert an exception to a JaxRsResponseException
@param theServer the provider
@param theException the exception to convert
@return JaxRsResponseException | [
"This",
"method",
"convert",
"an",
"exception",
"to",
"a",
"JaxRsResponseException"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/interceptor/JaxRsExceptionInterceptor.java#L85-L92 |
22,474 | jamesagnew/hapi-fhir | hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/interceptor/JaxRsExceptionInterceptor.java | JaxRsExceptionInterceptor.convertExceptionIntoResponse | public Response convertExceptionIntoResponse(final JaxRsRequest theRequest, final JaxRsResponseException theException)
throws IOException {
return handleExceptionWithoutServletError(theRequest, theException);
} | java | public Response convertExceptionIntoResponse(final JaxRsRequest theRequest, final JaxRsResponseException theException)
throws IOException {
return handleExceptionWithoutServletError(theRequest, theException);
} | [
"public",
"Response",
"convertExceptionIntoResponse",
"(",
"final",
"JaxRsRequest",
"theRequest",
",",
"final",
"JaxRsResponseException",
"theException",
")",
"throws",
"IOException",
"{",
"return",
"handleExceptionWithoutServletError",
"(",
"theRequest",
",",
"theException",
")",
";",
"}"
] | This method converts an exception into a response
@param theRequest the request
@param theException the thrown exception
@return the response describing the error
@throws IOException | [
"This",
"method",
"converts",
"an",
"exception",
"into",
"a",
"response"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/interceptor/JaxRsExceptionInterceptor.java#L101-L104 |
22,475 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/SpringObjectCaster.java | SpringObjectCaster.getTargetObject | public static <T> T getTargetObject(Object proxy, Class<T> clazz) throws Exception {
while( (AopUtils.isJdkDynamicProxy(proxy))) {
return clazz.cast(getTargetObject(((Advised)proxy).getTargetSource().getTarget(), clazz));
}
return clazz.cast(proxy);
} | java | public static <T> T getTargetObject(Object proxy, Class<T> clazz) throws Exception {
while( (AopUtils.isJdkDynamicProxy(proxy))) {
return clazz.cast(getTargetObject(((Advised)proxy).getTargetSource().getTarget(), clazz));
}
return clazz.cast(proxy);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"getTargetObject",
"(",
"Object",
"proxy",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"throws",
"Exception",
"{",
"while",
"(",
"(",
"AopUtils",
".",
"isJdkDynamicProxy",
"(",
"proxy",
")",
")",
")",
"{",
"return",
"clazz",
".",
"cast",
"(",
"getTargetObject",
"(",
"(",
"(",
"Advised",
")",
"proxy",
")",
".",
"getTargetSource",
"(",
")",
".",
"getTarget",
"(",
")",
",",
"clazz",
")",
")",
";",
"}",
"return",
"clazz",
".",
"cast",
"(",
"proxy",
")",
";",
"}"
] | Retrieve the Spring proxy object's target object
@param proxy
@param clazz
@param <T>
@return
@throws Exception | [
"Retrieve",
"the",
"Spring",
"proxy",
"object",
"s",
"target",
"object"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/SpringObjectCaster.java#L40-L46 |
22,476 | jamesagnew/hapi-fhir | hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/BundleProviders.java | BundleProviders.newEmptyList | public static IBundleProvider newEmptyList() {
final InstantDt published = InstantDt.withCurrentTime();
return new IBundleProvider() {
@Override
public List<IBaseResource> getResources(int theFromIndex, int theToIndex) {
return Collections.emptyList();
}
@Override
public Integer size() {
return 0;
}
@Override
public InstantDt getPublished() {
return published;
}
@Override
public Integer preferredPageSize() {
return null;
}
@Override
public String getUuid() {
return null;
}
};
} | java | public static IBundleProvider newEmptyList() {
final InstantDt published = InstantDt.withCurrentTime();
return new IBundleProvider() {
@Override
public List<IBaseResource> getResources(int theFromIndex, int theToIndex) {
return Collections.emptyList();
}
@Override
public Integer size() {
return 0;
}
@Override
public InstantDt getPublished() {
return published;
}
@Override
public Integer preferredPageSize() {
return null;
}
@Override
public String getUuid() {
return null;
}
};
} | [
"public",
"static",
"IBundleProvider",
"newEmptyList",
"(",
")",
"{",
"final",
"InstantDt",
"published",
"=",
"InstantDt",
".",
"withCurrentTime",
"(",
")",
";",
"return",
"new",
"IBundleProvider",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"IBaseResource",
">",
"getResources",
"(",
"int",
"theFromIndex",
",",
"int",
"theToIndex",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"Integer",
"size",
"(",
")",
"{",
"return",
"0",
";",
"}",
"@",
"Override",
"public",
"InstantDt",
"getPublished",
"(",
")",
"{",
"return",
"published",
";",
"}",
"@",
"Override",
"public",
"Integer",
"preferredPageSize",
"(",
")",
"{",
"return",
"null",
";",
"}",
"@",
"Override",
"public",
"String",
"getUuid",
"(",
")",
"{",
"return",
"null",
";",
"}",
"}",
";",
"}"
] | Create a new unmodifiable empty resource list with the current time as the publish date. | [
"Create",
"a",
"new",
"unmodifiable",
"empty",
"resource",
"list",
"with",
"the",
"current",
"time",
"as",
"the",
"publish",
"date",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/BundleProviders.java#L46-L74 |
22,477 | jamesagnew/hapi-fhir | hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/interceptor/AdditionalRequestHeadersInterceptor.java | AdditionalRequestHeadersInterceptor.getHeaderValues | private List<String> getHeaderValues(String headerName) {
if (additionalHttpHeaders.get(headerName) == null) {
additionalHttpHeaders.put(headerName, new ArrayList<String>());
}
return additionalHttpHeaders.get(headerName);
} | java | private List<String> getHeaderValues(String headerName) {
if (additionalHttpHeaders.get(headerName) == null) {
additionalHttpHeaders.put(headerName, new ArrayList<String>());
}
return additionalHttpHeaders.get(headerName);
} | [
"private",
"List",
"<",
"String",
">",
"getHeaderValues",
"(",
"String",
"headerName",
")",
"{",
"if",
"(",
"additionalHttpHeaders",
".",
"get",
"(",
"headerName",
")",
"==",
"null",
")",
"{",
"additionalHttpHeaders",
".",
"put",
"(",
"headerName",
",",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
")",
";",
"}",
"return",
"additionalHttpHeaders",
".",
"get",
"(",
"headerName",
")",
";",
"}"
] | Gets the header values list for a given header.
If the header doesn't have any values, an empty list will be returned.
@param headerName the name of the header
@return the list of values for the header | [
"Gets",
"the",
"header",
"values",
"list",
"for",
"a",
"given",
"header",
".",
"If",
"the",
"header",
"doesn",
"t",
"have",
"any",
"values",
"an",
"empty",
"list",
"will",
"be",
"returned",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/interceptor/AdditionalRequestHeadersInterceptor.java#L85-L90 |
22,478 | jamesagnew/hapi-fhir | hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/interceptor/AdditionalRequestHeadersInterceptor.java | AdditionalRequestHeadersInterceptor.interceptRequest | @Override
public void interceptRequest(IHttpRequest theRequest) {
for (Map.Entry<String, List<String>> header : additionalHttpHeaders.entrySet()) {
for (String headerValue : header.getValue()) {
if (headerValue != null) {
theRequest.addHeader(header.getKey(), headerValue);
}
}
}
} | java | @Override
public void interceptRequest(IHttpRequest theRequest) {
for (Map.Entry<String, List<String>> header : additionalHttpHeaders.entrySet()) {
for (String headerValue : header.getValue()) {
if (headerValue != null) {
theRequest.addHeader(header.getKey(), headerValue);
}
}
}
} | [
"@",
"Override",
"public",
"void",
"interceptRequest",
"(",
"IHttpRequest",
"theRequest",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"header",
":",
"additionalHttpHeaders",
".",
"entrySet",
"(",
")",
")",
"{",
"for",
"(",
"String",
"headerValue",
":",
"header",
".",
"getValue",
"(",
")",
")",
"{",
"if",
"(",
"headerValue",
"!=",
"null",
")",
"{",
"theRequest",
".",
"addHeader",
"(",
"header",
".",
"getKey",
"(",
")",
",",
"headerValue",
")",
";",
"}",
"}",
"}",
"}"
] | Adds the additional header values to the HTTP request.
@param theRequest the HTTP request | [
"Adds",
"the",
"additional",
"header",
"values",
"to",
"the",
"HTTP",
"request",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/interceptor/AdditionalRequestHeadersInterceptor.java#L96-L105 |
22,479 | jamesagnew/hapi-fhir | hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementDefinition.java | BaseRuntimeElementDefinition.sealAndInitialize | void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
for (BaseRuntimeChildDefinition next : myExtensions) {
next.sealAndInitialize(theContext, theClassToElementDefinitions);
}
for (RuntimeChildDeclaredExtensionDefinition next : myExtensions) {
String extUrl = next.getExtensionUrl();
if (myUrlToExtension.containsKey(extUrl)) {
throw new ConfigurationException("Duplicate extension URL[" + extUrl + "] in Element[" + getName() + "]");
}
myUrlToExtension.put(extUrl, next);
if (next.isModifier()) {
myExtensionsModifier.add(next);
} else {
myExtensionsNonModifier.add(next);
}
}
myExtensions = Collections.unmodifiableList(myExtensions);
} | java | void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
for (BaseRuntimeChildDefinition next : myExtensions) {
next.sealAndInitialize(theContext, theClassToElementDefinitions);
}
for (RuntimeChildDeclaredExtensionDefinition next : myExtensions) {
String extUrl = next.getExtensionUrl();
if (myUrlToExtension.containsKey(extUrl)) {
throw new ConfigurationException("Duplicate extension URL[" + extUrl + "] in Element[" + getName() + "]");
}
myUrlToExtension.put(extUrl, next);
if (next.isModifier()) {
myExtensionsModifier.add(next);
} else {
myExtensionsNonModifier.add(next);
}
}
myExtensions = Collections.unmodifiableList(myExtensions);
} | [
"void",
"sealAndInitialize",
"(",
"FhirContext",
"theContext",
",",
"Map",
"<",
"Class",
"<",
"?",
"extends",
"IBase",
">",
",",
"BaseRuntimeElementDefinition",
"<",
"?",
">",
">",
"theClassToElementDefinitions",
")",
"{",
"for",
"(",
"BaseRuntimeChildDefinition",
"next",
":",
"myExtensions",
")",
"{",
"next",
".",
"sealAndInitialize",
"(",
"theContext",
",",
"theClassToElementDefinitions",
")",
";",
"}",
"for",
"(",
"RuntimeChildDeclaredExtensionDefinition",
"next",
":",
"myExtensions",
")",
"{",
"String",
"extUrl",
"=",
"next",
".",
"getExtensionUrl",
"(",
")",
";",
"if",
"(",
"myUrlToExtension",
".",
"containsKey",
"(",
"extUrl",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"\"Duplicate extension URL[\"",
"+",
"extUrl",
"+",
"\"] in Element[\"",
"+",
"getName",
"(",
")",
"+",
"\"]\"",
")",
";",
"}",
"myUrlToExtension",
".",
"put",
"(",
"extUrl",
",",
"next",
")",
";",
"if",
"(",
"next",
".",
"isModifier",
"(",
")",
")",
"{",
"myExtensionsModifier",
".",
"add",
"(",
"next",
")",
";",
"}",
"else",
"{",
"myExtensionsNonModifier",
".",
"add",
"(",
"next",
")",
";",
"}",
"}",
"myExtensions",
"=",
"Collections",
".",
"unmodifiableList",
"(",
"myExtensions",
")",
";",
"}"
] | Invoked prior to use to perform any initialization and make object
mutable.
@param theContext TODO | [
"Invoked",
"prior",
"to",
"use",
"to",
"perform",
"any",
"initialization",
"and",
"make",
"object",
"mutable",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementDefinition.java#L176-L196 |
22,480 | jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java | ShExGenerator.emitInnerTypes | private String emitInnerTypes() {
StringBuilder itDefs = new StringBuilder();
while(emittedInnerTypes.size() < innerTypes.size()) {
for (Pair<StructureDefinition, ElementDefinition> it : new HashSet<Pair<StructureDefinition, ElementDefinition>>(innerTypes)) {
if (!emittedInnerTypes.contains(it)) {
itDefs.append("\n").append(genInnerTypeDef(it.getLeft(), it.getRight()));
emittedInnerTypes.add(it);
}
}
}
return itDefs.toString();
} | java | private String emitInnerTypes() {
StringBuilder itDefs = new StringBuilder();
while(emittedInnerTypes.size() < innerTypes.size()) {
for (Pair<StructureDefinition, ElementDefinition> it : new HashSet<Pair<StructureDefinition, ElementDefinition>>(innerTypes)) {
if (!emittedInnerTypes.contains(it)) {
itDefs.append("\n").append(genInnerTypeDef(it.getLeft(), it.getRight()));
emittedInnerTypes.add(it);
}
}
}
return itDefs.toString();
} | [
"private",
"String",
"emitInnerTypes",
"(",
")",
"{",
"StringBuilder",
"itDefs",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"while",
"(",
"emittedInnerTypes",
".",
"size",
"(",
")",
"<",
"innerTypes",
".",
"size",
"(",
")",
")",
"{",
"for",
"(",
"Pair",
"<",
"StructureDefinition",
",",
"ElementDefinition",
">",
"it",
":",
"new",
"HashSet",
"<",
"Pair",
"<",
"StructureDefinition",
",",
"ElementDefinition",
">",
">",
"(",
"innerTypes",
")",
")",
"{",
"if",
"(",
"!",
"emittedInnerTypes",
".",
"contains",
"(",
"it",
")",
")",
"{",
"itDefs",
".",
"append",
"(",
"\"\\n\"",
")",
".",
"append",
"(",
"genInnerTypeDef",
"(",
"it",
".",
"getLeft",
"(",
")",
",",
"it",
".",
"getRight",
"(",
")",
")",
")",
";",
"emittedInnerTypes",
".",
"add",
"(",
"it",
")",
";",
"}",
"}",
"}",
"return",
"itDefs",
".",
"toString",
"(",
")",
";",
"}"
] | Generate a flattened definition for the inner types
@return stringified inner type definitions | [
"Generate",
"a",
"flattened",
"definition",
"for",
"the",
"inner",
"types"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java#L368-L379 |
22,481 | jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java | ShExGenerator.emitDataTypes | private String emitDataTypes() {
StringBuilder dtDefs = new StringBuilder();
while (emittedDatatypes.size() < datatypes.size()) {
for (String dt : new HashSet<String>(datatypes)) {
if (!emittedDatatypes.contains(dt)) {
StructureDefinition sd = context.fetchResource(StructureDefinition.class,
ProfileUtilities.sdNs(dt, null));
// TODO: Figure out why the line below doesn't work
// if (sd != null && !uniq_structures.contains(sd))
if(sd != null && !uniq_structure_urls.contains(sd.getUrl()))
dtDefs.append("\n").append(genShapeDefinition(sd, false));
emittedDatatypes.add(dt);
}
}
}
return dtDefs.toString();
} | java | private String emitDataTypes() {
StringBuilder dtDefs = new StringBuilder();
while (emittedDatatypes.size() < datatypes.size()) {
for (String dt : new HashSet<String>(datatypes)) {
if (!emittedDatatypes.contains(dt)) {
StructureDefinition sd = context.fetchResource(StructureDefinition.class,
ProfileUtilities.sdNs(dt, null));
// TODO: Figure out why the line below doesn't work
// if (sd != null && !uniq_structures.contains(sd))
if(sd != null && !uniq_structure_urls.contains(sd.getUrl()))
dtDefs.append("\n").append(genShapeDefinition(sd, false));
emittedDatatypes.add(dt);
}
}
}
return dtDefs.toString();
} | [
"private",
"String",
"emitDataTypes",
"(",
")",
"{",
"StringBuilder",
"dtDefs",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"while",
"(",
"emittedDatatypes",
".",
"size",
"(",
")",
"<",
"datatypes",
".",
"size",
"(",
")",
")",
"{",
"for",
"(",
"String",
"dt",
":",
"new",
"HashSet",
"<",
"String",
">",
"(",
"datatypes",
")",
")",
"{",
"if",
"(",
"!",
"emittedDatatypes",
".",
"contains",
"(",
"dt",
")",
")",
"{",
"StructureDefinition",
"sd",
"=",
"context",
".",
"fetchResource",
"(",
"StructureDefinition",
".",
"class",
",",
"ProfileUtilities",
".",
"sdNs",
"(",
"dt",
",",
"null",
")",
")",
";",
"// TODO: Figure out why the line below doesn't work\r",
"// if (sd != null && !uniq_structures.contains(sd))\r",
"if",
"(",
"sd",
"!=",
"null",
"&&",
"!",
"uniq_structure_urls",
".",
"contains",
"(",
"sd",
".",
"getUrl",
"(",
")",
")",
")",
"dtDefs",
".",
"append",
"(",
"\"\\n\"",
")",
".",
"append",
"(",
"genShapeDefinition",
"(",
"sd",
",",
"false",
")",
")",
";",
"emittedDatatypes",
".",
"add",
"(",
"dt",
")",
";",
"}",
"}",
"}",
"return",
"dtDefs",
".",
"toString",
"(",
")",
";",
"}"
] | Generate a shape definition for the current set of datatypes
@return stringified data type definitions | [
"Generate",
"a",
"shape",
"definition",
"for",
"the",
"current",
"set",
"of",
"datatypes"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java#L385-L401 |
22,482 | jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java | ShExGenerator.simpleElement | private String simpleElement(StructureDefinition sd, ElementDefinition ed, String typ) {
String addldef = "";
ElementDefinition.ElementDefinitionBindingComponent binding = ed.getBinding();
if(binding.hasStrength() && binding.getStrength() == Enumerations.BindingStrength.REQUIRED && "code".equals(typ)) {
ValueSet vs = resolveBindingReference(sd, binding.getValueSet());
if (vs != null) {
addldef = tmplt(VALUESET_DEFN_TEMPLATE).add("vsn", vsprefix(vs.getUrl())).render();
required_value_sets.add(vs);
}
}
// TODO: check whether value sets and fixed are mutually exclusive
if(ed.hasFixed()) {
addldef = tmplt(FIXED_VALUE_TEMPLATE).add("val", ed.getFixed().primitiveValue()).render();
}
return tmplt(SIMPLE_ELEMENT_DEFN_TEMPLATE).add("typ", typ).add("vsdef", addldef).render();
} | java | private String simpleElement(StructureDefinition sd, ElementDefinition ed, String typ) {
String addldef = "";
ElementDefinition.ElementDefinitionBindingComponent binding = ed.getBinding();
if(binding.hasStrength() && binding.getStrength() == Enumerations.BindingStrength.REQUIRED && "code".equals(typ)) {
ValueSet vs = resolveBindingReference(sd, binding.getValueSet());
if (vs != null) {
addldef = tmplt(VALUESET_DEFN_TEMPLATE).add("vsn", vsprefix(vs.getUrl())).render();
required_value_sets.add(vs);
}
}
// TODO: check whether value sets and fixed are mutually exclusive
if(ed.hasFixed()) {
addldef = tmplt(FIXED_VALUE_TEMPLATE).add("val", ed.getFixed().primitiveValue()).render();
}
return tmplt(SIMPLE_ELEMENT_DEFN_TEMPLATE).add("typ", typ).add("vsdef", addldef).render();
} | [
"private",
"String",
"simpleElement",
"(",
"StructureDefinition",
"sd",
",",
"ElementDefinition",
"ed",
",",
"String",
"typ",
")",
"{",
"String",
"addldef",
"=",
"\"\"",
";",
"ElementDefinition",
".",
"ElementDefinitionBindingComponent",
"binding",
"=",
"ed",
".",
"getBinding",
"(",
")",
";",
"if",
"(",
"binding",
".",
"hasStrength",
"(",
")",
"&&",
"binding",
".",
"getStrength",
"(",
")",
"==",
"Enumerations",
".",
"BindingStrength",
".",
"REQUIRED",
"&&",
"\"code\"",
".",
"equals",
"(",
"typ",
")",
")",
"{",
"ValueSet",
"vs",
"=",
"resolveBindingReference",
"(",
"sd",
",",
"binding",
".",
"getValueSet",
"(",
")",
")",
";",
"if",
"(",
"vs",
"!=",
"null",
")",
"{",
"addldef",
"=",
"tmplt",
"(",
"VALUESET_DEFN_TEMPLATE",
")",
".",
"add",
"(",
"\"vsn\"",
",",
"vsprefix",
"(",
"vs",
".",
"getUrl",
"(",
")",
")",
")",
".",
"render",
"(",
")",
";",
"required_value_sets",
".",
"add",
"(",
"vs",
")",
";",
"}",
"}",
"// TODO: check whether value sets and fixed are mutually exclusive\r",
"if",
"(",
"ed",
".",
"hasFixed",
"(",
")",
")",
"{",
"addldef",
"=",
"tmplt",
"(",
"FIXED_VALUE_TEMPLATE",
")",
".",
"add",
"(",
"\"val\"",
",",
"ed",
".",
"getFixed",
"(",
")",
".",
"primitiveValue",
"(",
")",
")",
".",
"render",
"(",
")",
";",
"}",
"return",
"tmplt",
"(",
"SIMPLE_ELEMENT_DEFN_TEMPLATE",
")",
".",
"add",
"(",
"\"typ\"",
",",
"typ",
")",
".",
"add",
"(",
"\"vsdef\"",
",",
"addldef",
")",
".",
"render",
"(",
")",
";",
"}"
] | Generate a type reference and optional value set definition
@param sd Containing StructureDefinition
@param ed Element being defined
@param typ Element type
@return Type definition | [
"Generate",
"a",
"type",
"reference",
"and",
"optional",
"value",
"set",
"definition"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java#L520-L535 |
22,483 | jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java | ShExGenerator.genTypeRef | private String genTypeRef(StructureDefinition sd, ElementDefinition ed, String id, ElementDefinition.TypeRefComponent typ) {
if(typ.hasProfile()) {
if(typ.getCode().equals("Reference"))
return genReference("", typ);
else if(ProfileUtilities.getChildList(sd, ed).size() > 0) {
// inline anonymous type - give it a name and factor it out
innerTypes.add(new ImmutablePair<StructureDefinition, ElementDefinition>(sd, ed));
return simpleElement(sd, ed, id);
}
else {
String ref = getTypeName(typ);
datatypes.add(ref);
return simpleElement(sd, ed, ref);
}
} else if (typ.getCodeElement().getExtensionsByUrl(ToolingExtensions.EXT_RDF_TYPE).size() > 0) {
String xt = null;
try {
xt = typ.getCodeElement().getExtensionString(ToolingExtensions.EXT_RDF_TYPE);
} catch (FHIRException e) {
e.printStackTrace();
}
// TODO: Remove the next line when the type of token gets switched to string
// TODO: Add a rdf-type entry for valueInteger to xsd:integer (instead of int)
ST td_entry = tmplt(PRIMITIVE_ELEMENT_DEFN_TEMPLATE).add("typ",
xt.replace("xsd:token", "xsd:string").replace("xsd:int", "xsd:integer"));
StringBuilder facets = new StringBuilder();
if(ed.hasMinValue()) {
Type mv = ed.getMinValue();
facets.append(tmplt(MINVALUE_TEMPLATE).add("val", mv.primitiveValue()).render());
}
if(ed.hasMaxValue()) {
Type mv = ed.getMaxValue();
facets.append(tmplt(MAXVALUE_TEMPLATE).add("val", mv.primitiveValue()).render());
}
if(ed.hasMaxLength()) {
int ml = ed.getMaxLength();
facets.append(tmplt(MAXLENGTH_TEMPLATE).add("val", ml).render());
}
if(ed.hasPattern()) {
Type pat = ed.getPattern();
facets.append(tmplt(PATTERN_TEMPLATE).add("val",pat.primitiveValue()).render());
}
td_entry.add("facets", facets.toString());
return td_entry.render();
} else if (typ.getCode() == null) {
ST primitive_entry = tmplt(PRIMITIVE_ELEMENT_DEFN_TEMPLATE);
primitive_entry.add("typ", "xsd:string");
return primitive_entry.render();
} else if(typ.getCode().equals("xhtml")) {
return tmplt(XHTML_TYPE_TEMPLATE).render();
} else {
datatypes.add(typ.getCode());
return simpleElement(sd, ed, typ.getCode());
}
} | java | private String genTypeRef(StructureDefinition sd, ElementDefinition ed, String id, ElementDefinition.TypeRefComponent typ) {
if(typ.hasProfile()) {
if(typ.getCode().equals("Reference"))
return genReference("", typ);
else if(ProfileUtilities.getChildList(sd, ed).size() > 0) {
// inline anonymous type - give it a name and factor it out
innerTypes.add(new ImmutablePair<StructureDefinition, ElementDefinition>(sd, ed));
return simpleElement(sd, ed, id);
}
else {
String ref = getTypeName(typ);
datatypes.add(ref);
return simpleElement(sd, ed, ref);
}
} else if (typ.getCodeElement().getExtensionsByUrl(ToolingExtensions.EXT_RDF_TYPE).size() > 0) {
String xt = null;
try {
xt = typ.getCodeElement().getExtensionString(ToolingExtensions.EXT_RDF_TYPE);
} catch (FHIRException e) {
e.printStackTrace();
}
// TODO: Remove the next line when the type of token gets switched to string
// TODO: Add a rdf-type entry for valueInteger to xsd:integer (instead of int)
ST td_entry = tmplt(PRIMITIVE_ELEMENT_DEFN_TEMPLATE).add("typ",
xt.replace("xsd:token", "xsd:string").replace("xsd:int", "xsd:integer"));
StringBuilder facets = new StringBuilder();
if(ed.hasMinValue()) {
Type mv = ed.getMinValue();
facets.append(tmplt(MINVALUE_TEMPLATE).add("val", mv.primitiveValue()).render());
}
if(ed.hasMaxValue()) {
Type mv = ed.getMaxValue();
facets.append(tmplt(MAXVALUE_TEMPLATE).add("val", mv.primitiveValue()).render());
}
if(ed.hasMaxLength()) {
int ml = ed.getMaxLength();
facets.append(tmplt(MAXLENGTH_TEMPLATE).add("val", ml).render());
}
if(ed.hasPattern()) {
Type pat = ed.getPattern();
facets.append(tmplt(PATTERN_TEMPLATE).add("val",pat.primitiveValue()).render());
}
td_entry.add("facets", facets.toString());
return td_entry.render();
} else if (typ.getCode() == null) {
ST primitive_entry = tmplt(PRIMITIVE_ELEMENT_DEFN_TEMPLATE);
primitive_entry.add("typ", "xsd:string");
return primitive_entry.render();
} else if(typ.getCode().equals("xhtml")) {
return tmplt(XHTML_TYPE_TEMPLATE).render();
} else {
datatypes.add(typ.getCode());
return simpleElement(sd, ed, typ.getCode());
}
} | [
"private",
"String",
"genTypeRef",
"(",
"StructureDefinition",
"sd",
",",
"ElementDefinition",
"ed",
",",
"String",
"id",
",",
"ElementDefinition",
".",
"TypeRefComponent",
"typ",
")",
"{",
"if",
"(",
"typ",
".",
"hasProfile",
"(",
")",
")",
"{",
"if",
"(",
"typ",
".",
"getCode",
"(",
")",
".",
"equals",
"(",
"\"Reference\"",
")",
")",
"return",
"genReference",
"(",
"\"\"",
",",
"typ",
")",
";",
"else",
"if",
"(",
"ProfileUtilities",
".",
"getChildList",
"(",
"sd",
",",
"ed",
")",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"// inline anonymous type - give it a name and factor it out\r",
"innerTypes",
".",
"add",
"(",
"new",
"ImmutablePair",
"<",
"StructureDefinition",
",",
"ElementDefinition",
">",
"(",
"sd",
",",
"ed",
")",
")",
";",
"return",
"simpleElement",
"(",
"sd",
",",
"ed",
",",
"id",
")",
";",
"}",
"else",
"{",
"String",
"ref",
"=",
"getTypeName",
"(",
"typ",
")",
";",
"datatypes",
".",
"add",
"(",
"ref",
")",
";",
"return",
"simpleElement",
"(",
"sd",
",",
"ed",
",",
"ref",
")",
";",
"}",
"}",
"else",
"if",
"(",
"typ",
".",
"getCodeElement",
"(",
")",
".",
"getExtensionsByUrl",
"(",
"ToolingExtensions",
".",
"EXT_RDF_TYPE",
")",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"String",
"xt",
"=",
"null",
";",
"try",
"{",
"xt",
"=",
"typ",
".",
"getCodeElement",
"(",
")",
".",
"getExtensionString",
"(",
"ToolingExtensions",
".",
"EXT_RDF_TYPE",
")",
";",
"}",
"catch",
"(",
"FHIRException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"// TODO: Remove the next line when the type of token gets switched to string\r",
"// TODO: Add a rdf-type entry for valueInteger to xsd:integer (instead of int)\r",
"ST",
"td_entry",
"=",
"tmplt",
"(",
"PRIMITIVE_ELEMENT_DEFN_TEMPLATE",
")",
".",
"add",
"(",
"\"typ\"",
",",
"xt",
".",
"replace",
"(",
"\"xsd:token\"",
",",
"\"xsd:string\"",
")",
".",
"replace",
"(",
"\"xsd:int\"",
",",
"\"xsd:integer\"",
")",
")",
";",
"StringBuilder",
"facets",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"ed",
".",
"hasMinValue",
"(",
")",
")",
"{",
"Type",
"mv",
"=",
"ed",
".",
"getMinValue",
"(",
")",
";",
"facets",
".",
"append",
"(",
"tmplt",
"(",
"MINVALUE_TEMPLATE",
")",
".",
"add",
"(",
"\"val\"",
",",
"mv",
".",
"primitiveValue",
"(",
")",
")",
".",
"render",
"(",
")",
")",
";",
"}",
"if",
"(",
"ed",
".",
"hasMaxValue",
"(",
")",
")",
"{",
"Type",
"mv",
"=",
"ed",
".",
"getMaxValue",
"(",
")",
";",
"facets",
".",
"append",
"(",
"tmplt",
"(",
"MAXVALUE_TEMPLATE",
")",
".",
"add",
"(",
"\"val\"",
",",
"mv",
".",
"primitiveValue",
"(",
")",
")",
".",
"render",
"(",
")",
")",
";",
"}",
"if",
"(",
"ed",
".",
"hasMaxLength",
"(",
")",
")",
"{",
"int",
"ml",
"=",
"ed",
".",
"getMaxLength",
"(",
")",
";",
"facets",
".",
"append",
"(",
"tmplt",
"(",
"MAXLENGTH_TEMPLATE",
")",
".",
"add",
"(",
"\"val\"",
",",
"ml",
")",
".",
"render",
"(",
")",
")",
";",
"}",
"if",
"(",
"ed",
".",
"hasPattern",
"(",
")",
")",
"{",
"Type",
"pat",
"=",
"ed",
".",
"getPattern",
"(",
")",
";",
"facets",
".",
"append",
"(",
"tmplt",
"(",
"PATTERN_TEMPLATE",
")",
".",
"add",
"(",
"\"val\"",
",",
"pat",
".",
"primitiveValue",
"(",
")",
")",
".",
"render",
"(",
")",
")",
";",
"}",
"td_entry",
".",
"add",
"(",
"\"facets\"",
",",
"facets",
".",
"toString",
"(",
")",
")",
";",
"return",
"td_entry",
".",
"render",
"(",
")",
";",
"}",
"else",
"if",
"(",
"typ",
".",
"getCode",
"(",
")",
"==",
"null",
")",
"{",
"ST",
"primitive_entry",
"=",
"tmplt",
"(",
"PRIMITIVE_ELEMENT_DEFN_TEMPLATE",
")",
";",
"primitive_entry",
".",
"add",
"(",
"\"typ\"",
",",
"\"xsd:string\"",
")",
";",
"return",
"primitive_entry",
".",
"render",
"(",
")",
";",
"}",
"else",
"if",
"(",
"typ",
".",
"getCode",
"(",
")",
".",
"equals",
"(",
"\"xhtml\"",
")",
")",
"{",
"return",
"tmplt",
"(",
"XHTML_TYPE_TEMPLATE",
")",
".",
"render",
"(",
")",
";",
"}",
"else",
"{",
"datatypes",
".",
"add",
"(",
"typ",
".",
"getCode",
"(",
")",
")",
";",
"return",
"simpleElement",
"(",
"sd",
",",
"ed",
",",
"typ",
".",
"getCode",
"(",
")",
")",
";",
"}",
"}"
] | Generate a type reference
@param sd Containing structure definition
@param ed Containing element definition
@param id Element id
@param typ Element type
@return Type reference string | [
"Generate",
"a",
"type",
"reference"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java#L551-L609 |
22,484 | jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java | ShExGenerator.genAlternativeTypes | private ST genAlternativeTypes(ElementDefinition ed, String id, String shortId) {
ST shex_alt = tmplt(ALTERNATIVE_SHAPES_TEMPLATE);
List<String> altEntries = new ArrayList<String>();
for(ElementDefinition.TypeRefComponent typ : ed.getType()) {
altEntries.add(genAltEntry(id, typ));
}
shex_alt.add("altEntries", StringUtils.join(altEntries, " OR\n "));
return shex_alt;
} | java | private ST genAlternativeTypes(ElementDefinition ed, String id, String shortId) {
ST shex_alt = tmplt(ALTERNATIVE_SHAPES_TEMPLATE);
List<String> altEntries = new ArrayList<String>();
for(ElementDefinition.TypeRefComponent typ : ed.getType()) {
altEntries.add(genAltEntry(id, typ));
}
shex_alt.add("altEntries", StringUtils.join(altEntries, " OR\n "));
return shex_alt;
} | [
"private",
"ST",
"genAlternativeTypes",
"(",
"ElementDefinition",
"ed",
",",
"String",
"id",
",",
"String",
"shortId",
")",
"{",
"ST",
"shex_alt",
"=",
"tmplt",
"(",
"ALTERNATIVE_SHAPES_TEMPLATE",
")",
";",
"List",
"<",
"String",
">",
"altEntries",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"ElementDefinition",
".",
"TypeRefComponent",
"typ",
":",
"ed",
".",
"getType",
"(",
")",
")",
"{",
"altEntries",
".",
"add",
"(",
"genAltEntry",
"(",
"id",
",",
"typ",
")",
")",
";",
"}",
"shex_alt",
".",
"add",
"(",
"\"altEntries\"",
",",
"StringUtils",
".",
"join",
"(",
"altEntries",
",",
"\" OR\\n \"",
")",
")",
";",
"return",
"shex_alt",
";",
"}"
] | Generate a set of alternative shapes
@param ed Containing element definition
@param id Element definition identifier
@param shortId id to use in the actual definition
@return ShEx list of alternative anonymous shapes separated by "OR" | [
"Generate",
"a",
"set",
"of",
"alternative",
"shapes"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java#L618-L628 |
22,485 | jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java | ShExGenerator.genAltEntry | private String genAltEntry(String id, ElementDefinition.TypeRefComponent typ) {
if(!typ.getCode().equals("Reference"))
throw new AssertionError("We do not handle " + typ.getCode() + " alternatives");
return genReference(id, typ);
} | java | private String genAltEntry(String id, ElementDefinition.TypeRefComponent typ) {
if(!typ.getCode().equals("Reference"))
throw new AssertionError("We do not handle " + typ.getCode() + " alternatives");
return genReference(id, typ);
} | [
"private",
"String",
"genAltEntry",
"(",
"String",
"id",
",",
"ElementDefinition",
".",
"TypeRefComponent",
"typ",
")",
"{",
"if",
"(",
"!",
"typ",
".",
"getCode",
"(",
")",
".",
"equals",
"(",
"\"Reference\"",
")",
")",
"throw",
"new",
"AssertionError",
"(",
"\"We do not handle \"",
"+",
"typ",
".",
"getCode",
"(",
")",
"+",
"\" alternatives\"",
")",
";",
"return",
"genReference",
"(",
"id",
",",
"typ",
")",
";",
"}"
] | Generate an alternative shape for a reference
@param id reference name
@param typ shape type
@return ShEx equivalent | [
"Generate",
"an",
"alternative",
"shape",
"for",
"a",
"reference"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java#L638-L643 |
22,486 | jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java | ShExGenerator.genChoiceEntry | private String genChoiceEntry(StructureDefinition sd, ElementDefinition ed, String id, String base, ElementDefinition.TypeRefComponent typ) {
ST shex_choice_entry = tmplt(ELEMENT_TEMPLATE);
String ext = typ.getCode();
shex_choice_entry.add("id", "fhir:" + base+Character.toUpperCase(ext.charAt(0)) + ext.substring(1) + " ");
shex_choice_entry.add("card", "");
shex_choice_entry.add("defn", genTypeRef(sd, ed, id, typ));
shex_choice_entry.add("comment", " ");
return shex_choice_entry.render();
} | java | private String genChoiceEntry(StructureDefinition sd, ElementDefinition ed, String id, String base, ElementDefinition.TypeRefComponent typ) {
ST shex_choice_entry = tmplt(ELEMENT_TEMPLATE);
String ext = typ.getCode();
shex_choice_entry.add("id", "fhir:" + base+Character.toUpperCase(ext.charAt(0)) + ext.substring(1) + " ");
shex_choice_entry.add("card", "");
shex_choice_entry.add("defn", genTypeRef(sd, ed, id, typ));
shex_choice_entry.add("comment", " ");
return shex_choice_entry.render();
} | [
"private",
"String",
"genChoiceEntry",
"(",
"StructureDefinition",
"sd",
",",
"ElementDefinition",
"ed",
",",
"String",
"id",
",",
"String",
"base",
",",
"ElementDefinition",
".",
"TypeRefComponent",
"typ",
")",
"{",
"ST",
"shex_choice_entry",
"=",
"tmplt",
"(",
"ELEMENT_TEMPLATE",
")",
";",
"String",
"ext",
"=",
"typ",
".",
"getCode",
"(",
")",
";",
"shex_choice_entry",
".",
"add",
"(",
"\"id\"",
",",
"\"fhir:\"",
"+",
"base",
"+",
"Character",
".",
"toUpperCase",
"(",
"ext",
".",
"charAt",
"(",
"0",
")",
")",
"+",
"ext",
".",
"substring",
"(",
"1",
")",
"+",
"\" \"",
")",
";",
"shex_choice_entry",
".",
"add",
"(",
"\"card\"",
",",
"\"\"",
")",
";",
"shex_choice_entry",
".",
"add",
"(",
"\"defn\"",
",",
"genTypeRef",
"(",
"sd",
",",
"ed",
",",
"id",
",",
"typ",
")",
")",
";",
"shex_choice_entry",
".",
"add",
"(",
"\"comment\"",
",",
"\" \"",
")",
";",
"return",
"shex_choice_entry",
".",
"render",
"(",
")",
";",
"}"
] | Generate an entry in a choice list
@param base base identifier
@param typ type/discriminant
@return ShEx fragment for choice entry | [
"Generate",
"an",
"entry",
"in",
"a",
"choice",
"list"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java#L668-L677 |
22,487 | jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java | ShExGenerator.genInnerTypeDef | private String genInnerTypeDef(StructureDefinition sd, ElementDefinition ed) {
String path = ed.hasBase() ? ed.getBase().getPath() : ed.getPath();;
ST element_reference = tmplt(SHAPE_DEFINITION_TEMPLATE);
element_reference.add("resourceDecl", ""); // Not a resource
element_reference.add("id", path);
String comment = ed.getShort();
element_reference.add("comment", comment == null? " " : "# " + comment);
List<String> elements = new ArrayList<String>();
for (ElementDefinition child: ProfileUtilities.getChildList(sd, path, null))
elements.add(genElementDefinition(sd, child));
element_reference.add("elements", StringUtils.join(elements, "\n"));
return element_reference.render();
} | java | private String genInnerTypeDef(StructureDefinition sd, ElementDefinition ed) {
String path = ed.hasBase() ? ed.getBase().getPath() : ed.getPath();;
ST element_reference = tmplt(SHAPE_DEFINITION_TEMPLATE);
element_reference.add("resourceDecl", ""); // Not a resource
element_reference.add("id", path);
String comment = ed.getShort();
element_reference.add("comment", comment == null? " " : "# " + comment);
List<String> elements = new ArrayList<String>();
for (ElementDefinition child: ProfileUtilities.getChildList(sd, path, null))
elements.add(genElementDefinition(sd, child));
element_reference.add("elements", StringUtils.join(elements, "\n"));
return element_reference.render();
} | [
"private",
"String",
"genInnerTypeDef",
"(",
"StructureDefinition",
"sd",
",",
"ElementDefinition",
"ed",
")",
"{",
"String",
"path",
"=",
"ed",
".",
"hasBase",
"(",
")",
"?",
"ed",
".",
"getBase",
"(",
")",
".",
"getPath",
"(",
")",
":",
"ed",
".",
"getPath",
"(",
")",
";",
";",
"ST",
"element_reference",
"=",
"tmplt",
"(",
"SHAPE_DEFINITION_TEMPLATE",
")",
";",
"element_reference",
".",
"add",
"(",
"\"resourceDecl\"",
",",
"\"\"",
")",
";",
"// Not a resource\r",
"element_reference",
".",
"add",
"(",
"\"id\"",
",",
"path",
")",
";",
"String",
"comment",
"=",
"ed",
".",
"getShort",
"(",
")",
";",
"element_reference",
".",
"add",
"(",
"\"comment\"",
",",
"comment",
"==",
"null",
"?",
"\" \"",
":",
"\"# \"",
"+",
"comment",
")",
";",
"List",
"<",
"String",
">",
"elements",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"ElementDefinition",
"child",
":",
"ProfileUtilities",
".",
"getChildList",
"(",
"sd",
",",
"path",
",",
"null",
")",
")",
"elements",
".",
"(",
"genElementDefinition",
"(",
"sd",
",",
"child",
")",
")",
";",
"element_reference",
".",
"add",
"(",
"\"elements\"",
",",
"StringUtils",
".",
"join",
"(",
"elements",
",",
"\"\\n\"",
")",
")",
";",
"return",
"element_reference",
".",
"render",
"(",
")",
";",
"}"
] | Generate a definition for a referenced element
@param sd Containing structure definition
@param ed Inner element
@return ShEx representation of element reference | [
"Generate",
"a",
"definition",
"for",
"a",
"referenced",
"element"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java#L685-L699 |
22,488 | jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java | ShExGenerator.genReference | private String genReference(String id, ElementDefinition.TypeRefComponent typ) {
ST shex_ref = tmplt(REFERENCE_DEFN_TEMPLATE);
String ref = getTypeName(typ);
shex_ref.add("id", id);
shex_ref.add("ref", ref);
references.add(ref);
return shex_ref.render();
} | java | private String genReference(String id, ElementDefinition.TypeRefComponent typ) {
ST shex_ref = tmplt(REFERENCE_DEFN_TEMPLATE);
String ref = getTypeName(typ);
shex_ref.add("id", id);
shex_ref.add("ref", ref);
references.add(ref);
return shex_ref.render();
} | [
"private",
"String",
"genReference",
"(",
"String",
"id",
",",
"ElementDefinition",
".",
"TypeRefComponent",
"typ",
")",
"{",
"ST",
"shex_ref",
"=",
"tmplt",
"(",
"REFERENCE_DEFN_TEMPLATE",
")",
";",
"String",
"ref",
"=",
"getTypeName",
"(",
"typ",
")",
";",
"shex_ref",
".",
"add",
"(",
"\"id\"",
",",
"id",
")",
";",
"shex_ref",
".",
"add",
"(",
"\"ref\"",
",",
"ref",
")",
";",
"references",
".",
"add",
"(",
"ref",
")",
";",
"return",
"shex_ref",
".",
"render",
"(",
")",
";",
"}"
] | Generate a reference to a resource
@param id attribute identifier
@param typ possible reference types
@return string that represents the result | [
"Generate",
"a",
"reference",
"to",
"a",
"resource"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java#L707-L715 |
22,489 | jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java | ShExGenerator.getTypeName | private String getTypeName(ElementDefinition.TypeRefComponent typ) {
// TODO: This is brittle. There has to be a utility to do this...
if (typ.hasTargetProfile()) {
String[] els = typ.getTargetProfile().get(0).getValue().split("/");
return els[els.length - 1];
} else if (typ.hasProfile()) {
String[] els = typ.getProfile().get(0).getValue().split("/");
return els[els.length - 1];
} else {
return typ.getCode();
}
} | java | private String getTypeName(ElementDefinition.TypeRefComponent typ) {
// TODO: This is brittle. There has to be a utility to do this...
if (typ.hasTargetProfile()) {
String[] els = typ.getTargetProfile().get(0).getValue().split("/");
return els[els.length - 1];
} else if (typ.hasProfile()) {
String[] els = typ.getProfile().get(0).getValue().split("/");
return els[els.length - 1];
} else {
return typ.getCode();
}
} | [
"private",
"String",
"getTypeName",
"(",
"ElementDefinition",
".",
"TypeRefComponent",
"typ",
")",
"{",
"// TODO: This is brittle. There has to be a utility to do this...\r",
"if",
"(",
"typ",
".",
"hasTargetProfile",
"(",
")",
")",
"{",
"String",
"[",
"]",
"els",
"=",
"typ",
".",
"getTargetProfile",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getValue",
"(",
")",
".",
"split",
"(",
"\"/\"",
")",
";",
"return",
"els",
"[",
"els",
".",
"length",
"-",
"1",
"]",
";",
"}",
"else",
"if",
"(",
"typ",
".",
"hasProfile",
"(",
")",
")",
"{",
"String",
"[",
"]",
"els",
"=",
"typ",
".",
"getProfile",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getValue",
"(",
")",
".",
"split",
"(",
"\"/\"",
")",
";",
"return",
"els",
"[",
"els",
".",
"length",
"-",
"1",
"]",
";",
"}",
"else",
"{",
"return",
"typ",
".",
"getCode",
"(",
")",
";",
"}",
"}"
] | Return the type name for typ
@param typ type to get name for
@return name | [
"Return",
"the",
"type",
"name",
"for",
"typ"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java#L722-L733 |
22,490 | jamesagnew/hapi-fhir | hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/QuantityClientParam.java | QuantityClientParam.withPrefix | public IMatches<IAndUnits> withPrefix(final ParamPrefixEnum thePrefix) {
return new NumberClientParam.IMatches<IAndUnits>() {
@Override
public IAndUnits number(long theNumber) {
return new AndUnits(thePrefix, Long.toString(theNumber));
}
@Override
public IAndUnits number(String theNumber) {
return new AndUnits(thePrefix, theNumber);
}
};
} | java | public IMatches<IAndUnits> withPrefix(final ParamPrefixEnum thePrefix) {
return new NumberClientParam.IMatches<IAndUnits>() {
@Override
public IAndUnits number(long theNumber) {
return new AndUnits(thePrefix, Long.toString(theNumber));
}
@Override
public IAndUnits number(String theNumber) {
return new AndUnits(thePrefix, theNumber);
}
};
} | [
"public",
"IMatches",
"<",
"IAndUnits",
">",
"withPrefix",
"(",
"final",
"ParamPrefixEnum",
"thePrefix",
")",
"{",
"return",
"new",
"NumberClientParam",
".",
"IMatches",
"<",
"IAndUnits",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"IAndUnits",
"number",
"(",
"long",
"theNumber",
")",
"{",
"return",
"new",
"AndUnits",
"(",
"thePrefix",
",",
"Long",
".",
"toString",
"(",
"theNumber",
")",
")",
";",
"}",
"@",
"Override",
"public",
"IAndUnits",
"number",
"(",
"String",
"theNumber",
")",
"{",
"return",
"new",
"AndUnits",
"(",
"thePrefix",
",",
"theNumber",
")",
";",
"}",
"}",
";",
"}"
] | Use the given quantity prefix
@param thePrefix The prefix, or <code>null</code> for no prefix | [
"Use",
"the",
"given",
"quantity",
"prefix"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/QuantityClientParam.java#L133-L145 |
22,491 | jamesagnew/hapi-fhir | hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java | RestfulServer.determineResourceMethod | public BaseMethodBinding<?> determineResourceMethod(RequestDetails requestDetails, String requestPath) {
RequestTypeEnum requestType = requestDetails.getRequestType();
ResourceBinding resourceBinding = null;
BaseMethodBinding<?> resourceMethod = null;
String resourceName = requestDetails.getResourceName();
if (myServerConformanceMethod.incomingServerRequestMatchesMethod(requestDetails)) {
resourceMethod = myServerConformanceMethod;
} else if (resourceName == null) {
resourceBinding = myServerBinding;
} else {
resourceBinding = myResourceNameToBinding.get(resourceName);
if (resourceBinding == null) {
throwUnknownResourceTypeException(resourceName);
}
}
if (resourceMethod == null) {
if (resourceBinding != null) {
resourceMethod = resourceBinding.getMethod(requestDetails);
}
if (resourceMethod == null) {
resourceMethod = myGlobalBinding.getMethod(requestDetails);
}
}
if (resourceMethod == null) {
if (isBlank(requestPath)) {
throw new InvalidRequestException(myFhirContext.getLocalizer().getMessage(RestfulServer.class, "rootRequest"));
}
throwUnknownFhirOperationException(requestDetails, requestPath, requestType);
}
return resourceMethod;
} | java | public BaseMethodBinding<?> determineResourceMethod(RequestDetails requestDetails, String requestPath) {
RequestTypeEnum requestType = requestDetails.getRequestType();
ResourceBinding resourceBinding = null;
BaseMethodBinding<?> resourceMethod = null;
String resourceName = requestDetails.getResourceName();
if (myServerConformanceMethod.incomingServerRequestMatchesMethod(requestDetails)) {
resourceMethod = myServerConformanceMethod;
} else if (resourceName == null) {
resourceBinding = myServerBinding;
} else {
resourceBinding = myResourceNameToBinding.get(resourceName);
if (resourceBinding == null) {
throwUnknownResourceTypeException(resourceName);
}
}
if (resourceMethod == null) {
if (resourceBinding != null) {
resourceMethod = resourceBinding.getMethod(requestDetails);
}
if (resourceMethod == null) {
resourceMethod = myGlobalBinding.getMethod(requestDetails);
}
}
if (resourceMethod == null) {
if (isBlank(requestPath)) {
throw new InvalidRequestException(myFhirContext.getLocalizer().getMessage(RestfulServer.class, "rootRequest"));
}
throwUnknownFhirOperationException(requestDetails, requestPath, requestType);
}
return resourceMethod;
} | [
"public",
"BaseMethodBinding",
"<",
"?",
">",
"determineResourceMethod",
"(",
"RequestDetails",
"requestDetails",
",",
"String",
"requestPath",
")",
"{",
"RequestTypeEnum",
"requestType",
"=",
"requestDetails",
".",
"getRequestType",
"(",
")",
";",
"ResourceBinding",
"resourceBinding",
"=",
"null",
";",
"BaseMethodBinding",
"<",
"?",
">",
"resourceMethod",
"=",
"null",
";",
"String",
"resourceName",
"=",
"requestDetails",
".",
"getResourceName",
"(",
")",
";",
"if",
"(",
"myServerConformanceMethod",
".",
"incomingServerRequestMatchesMethod",
"(",
"requestDetails",
")",
")",
"{",
"resourceMethod",
"=",
"myServerConformanceMethod",
";",
"}",
"else",
"if",
"(",
"resourceName",
"==",
"null",
")",
"{",
"resourceBinding",
"=",
"myServerBinding",
";",
"}",
"else",
"{",
"resourceBinding",
"=",
"myResourceNameToBinding",
".",
"get",
"(",
"resourceName",
")",
";",
"if",
"(",
"resourceBinding",
"==",
"null",
")",
"{",
"throwUnknownResourceTypeException",
"(",
"resourceName",
")",
";",
"}",
"}",
"if",
"(",
"resourceMethod",
"==",
"null",
")",
"{",
"if",
"(",
"resourceBinding",
"!=",
"null",
")",
"{",
"resourceMethod",
"=",
"resourceBinding",
".",
"getMethod",
"(",
"requestDetails",
")",
";",
"}",
"if",
"(",
"resourceMethod",
"==",
"null",
")",
"{",
"resourceMethod",
"=",
"myGlobalBinding",
".",
"getMethod",
"(",
"requestDetails",
")",
";",
"}",
"}",
"if",
"(",
"resourceMethod",
"==",
"null",
")",
"{",
"if",
"(",
"isBlank",
"(",
"requestPath",
")",
")",
"{",
"throw",
"new",
"InvalidRequestException",
"(",
"myFhirContext",
".",
"getLocalizer",
"(",
")",
".",
"getMessage",
"(",
"RestfulServer",
".",
"class",
",",
"\"rootRequest\"",
")",
")",
";",
"}",
"throwUnknownFhirOperationException",
"(",
"requestDetails",
",",
"requestPath",
",",
"requestType",
")",
";",
"}",
"return",
"resourceMethod",
";",
"}"
] | Figure out and return whichever method binding is appropriate for
the given request | [
"Figure",
"out",
"and",
"return",
"whichever",
"method",
"binding",
"is",
"appropriate",
"for",
"the",
"given",
"request"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java#L292-L324 |
22,492 | jamesagnew/hapi-fhir | hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java | RestfulServer.getInterceptors_ | @Deprecated
@Override
public List<IServerInterceptor> getInterceptors_() {
List<IServerInterceptor> retVal = getInterceptorService()
.getAllRegisteredInterceptors()
.stream()
.filter(t -> t instanceof IServerInterceptor)
.map(t -> (IServerInterceptor) t)
.collect(Collectors.toList());
return Collections.unmodifiableList(retVal);
} | java | @Deprecated
@Override
public List<IServerInterceptor> getInterceptors_() {
List<IServerInterceptor> retVal = getInterceptorService()
.getAllRegisteredInterceptors()
.stream()
.filter(t -> t instanceof IServerInterceptor)
.map(t -> (IServerInterceptor) t)
.collect(Collectors.toList());
return Collections.unmodifiableList(retVal);
} | [
"@",
"Deprecated",
"@",
"Override",
"public",
"List",
"<",
"IServerInterceptor",
">",
"getInterceptors_",
"(",
")",
"{",
"List",
"<",
"IServerInterceptor",
">",
"retVal",
"=",
"getInterceptorService",
"(",
")",
".",
"getAllRegisteredInterceptors",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"t",
"->",
"t",
"instanceof",
"IServerInterceptor",
")",
".",
"map",
"(",
"t",
"->",
"(",
"IServerInterceptor",
")",
"t",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"return",
"Collections",
".",
"unmodifiableList",
"(",
"retVal",
")",
";",
"}"
] | Returns a list of all registered server interceptors
@deprecated As of HAPI FHIR 3.8.0, use {@link #getInterceptorService()} to access the interceptor service. You can register and unregister interceptors using this service. | [
"Returns",
"a",
"list",
"of",
"all",
"registered",
"server",
"interceptors"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java#L566-L576 |
22,493 | jamesagnew/hapi-fhir | hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java | RestfulServer.setPlainProviders | @Deprecated
public void setPlainProviders(Collection<Object> theProviders) {
Validate.noNullElements(theProviders, "theProviders must not contain any null elements");
myPlainProviders.clear();
if (theProviders != null) {
myPlainProviders.addAll(theProviders);
}
} | java | @Deprecated
public void setPlainProviders(Collection<Object> theProviders) {
Validate.noNullElements(theProviders, "theProviders must not contain any null elements");
myPlainProviders.clear();
if (theProviders != null) {
myPlainProviders.addAll(theProviders);
}
} | [
"@",
"Deprecated",
"public",
"void",
"setPlainProviders",
"(",
"Collection",
"<",
"Object",
">",
"theProviders",
")",
"{",
"Validate",
".",
"noNullElements",
"(",
"theProviders",
",",
"\"theProviders must not contain any null elements\"",
")",
";",
"myPlainProviders",
".",
"clear",
"(",
")",
";",
"if",
"(",
"theProviders",
"!=",
"null",
")",
"{",
"myPlainProviders",
".",
"addAll",
"(",
"theProviders",
")",
";",
"}",
"}"
] | Sets the non-resource specific providers which implement method calls on this server.
@see #setResourceProviders(Collection)
@deprecated This method causes inconsistent behaviour depending on the order it is called in. Use {@link #registerProviders(Object...)} instead. | [
"Sets",
"the",
"non",
"-",
"resource",
"specific",
"providers",
"which",
"implement",
"method",
"calls",
"on",
"this",
"server",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java#L659-L667 |
22,494 | jamesagnew/hapi-fhir | hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java | RestfulServer.registerProvider | public void registerProvider(Object provider) {
if (provider != null) {
Collection<Object> providerList = new ArrayList<>(1);
providerList.add(provider);
registerProviders(providerList);
}
} | java | public void registerProvider(Object provider) {
if (provider != null) {
Collection<Object> providerList = new ArrayList<>(1);
providerList.add(provider);
registerProviders(providerList);
}
} | [
"public",
"void",
"registerProvider",
"(",
"Object",
"provider",
")",
"{",
"if",
"(",
"provider",
"!=",
"null",
")",
"{",
"Collection",
"<",
"Object",
">",
"providerList",
"=",
"new",
"ArrayList",
"<>",
"(",
"1",
")",
";",
"providerList",
".",
"add",
"(",
"provider",
")",
";",
"registerProviders",
"(",
"providerList",
")",
";",
"}",
"}"
] | Register a single provider. This could be a Resource Provider or a "plain" provider not associated with any
resource. | [
"Register",
"a",
"single",
"provider",
".",
"This",
"could",
"be",
"a",
"Resource",
"Provider",
"or",
"a",
"plain",
"provider",
"not",
"associated",
"with",
"any",
"resource",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java#L1403-L1409 |
22,495 | jamesagnew/hapi-fhir | hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java | RestfulServer.registerProviders | public void registerProviders(Collection<?> theProviders) {
Validate.noNullElements(theProviders, "theProviders must not contain any null elements");
myProviderRegistrationMutex.lock();
try {
if (!myStarted) {
for (Object provider : theProviders) {
ourLog.info("Registration of provider [" + provider.getClass().getName() + "] will be delayed until FHIR server startup");
if (provider instanceof IResourceProvider) {
myResourceProviders.add((IResourceProvider) provider);
} else {
myPlainProviders.add(provider);
}
}
return;
}
} finally {
myProviderRegistrationMutex.unlock();
}
registerProviders(theProviders, false);
} | java | public void registerProviders(Collection<?> theProviders) {
Validate.noNullElements(theProviders, "theProviders must not contain any null elements");
myProviderRegistrationMutex.lock();
try {
if (!myStarted) {
for (Object provider : theProviders) {
ourLog.info("Registration of provider [" + provider.getClass().getName() + "] will be delayed until FHIR server startup");
if (provider instanceof IResourceProvider) {
myResourceProviders.add((IResourceProvider) provider);
} else {
myPlainProviders.add(provider);
}
}
return;
}
} finally {
myProviderRegistrationMutex.unlock();
}
registerProviders(theProviders, false);
} | [
"public",
"void",
"registerProviders",
"(",
"Collection",
"<",
"?",
">",
"theProviders",
")",
"{",
"Validate",
".",
"noNullElements",
"(",
"theProviders",
",",
"\"theProviders must not contain any null elements\"",
")",
";",
"myProviderRegistrationMutex",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"!",
"myStarted",
")",
"{",
"for",
"(",
"Object",
"provider",
":",
"theProviders",
")",
"{",
"ourLog",
".",
"info",
"(",
"\"Registration of provider [\"",
"+",
"provider",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"] will be delayed until FHIR server startup\"",
")",
";",
"if",
"(",
"provider",
"instanceof",
"IResourceProvider",
")",
"{",
"myResourceProviders",
".",
"add",
"(",
"(",
"IResourceProvider",
")",
"provider",
")",
";",
"}",
"else",
"{",
"myPlainProviders",
".",
"add",
"(",
"provider",
")",
";",
"}",
"}",
"return",
";",
"}",
"}",
"finally",
"{",
"myProviderRegistrationMutex",
".",
"unlock",
"(",
")",
";",
"}",
"registerProviders",
"(",
"theProviders",
",",
"false",
")",
";",
"}"
] | Register a group of theProviders. These could be Resource Providers, "plain" theProviders or a mixture of the two.
@param theProviders a {@code Collection} of theProviders. The parameter could be null or an empty {@code Collection} | [
"Register",
"a",
"group",
"of",
"theProviders",
".",
"These",
"could",
"be",
"Resource",
"Providers",
"plain",
"theProviders",
"or",
"a",
"mixture",
"of",
"the",
"two",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java#L1426-L1446 |
22,496 | jamesagnew/hapi-fhir | hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java | RestfulServer.setProviders | public void setProviders(Object... theProviders) {
Validate.noNullElements(theProviders, "theProviders must not contain any null elements");
myPlainProviders.clear();
if (theProviders != null) {
myPlainProviders.addAll(Arrays.asList(theProviders));
}
} | java | public void setProviders(Object... theProviders) {
Validate.noNullElements(theProviders, "theProviders must not contain any null elements");
myPlainProviders.clear();
if (theProviders != null) {
myPlainProviders.addAll(Arrays.asList(theProviders));
}
} | [
"public",
"void",
"setProviders",
"(",
"Object",
"...",
"theProviders",
")",
"{",
"Validate",
".",
"noNullElements",
"(",
"theProviders",
",",
"\"theProviders must not contain any null elements\"",
")",
";",
"myPlainProviders",
".",
"clear",
"(",
")",
";",
"if",
"(",
"theProviders",
"!=",
"null",
")",
"{",
"myPlainProviders",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"theProviders",
")",
")",
";",
"}",
"}"
] | Sets the non-resource specific providers which implement method calls on this server
@see #setResourceProviders(Collection) | [
"Sets",
"the",
"non",
"-",
"resource",
"specific",
"providers",
"which",
"implement",
"method",
"calls",
"on",
"this",
"server"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java#L1612-L1619 |
22,497 | jamesagnew/hapi-fhir | hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java | RestfulServer.unregisterInterceptor | @Deprecated
public void unregisterInterceptor(Object theInterceptor) {
Validate.notNull(theInterceptor, "Interceptor can not be null");
getInterceptorService().unregisterInterceptor(theInterceptor);
} | java | @Deprecated
public void unregisterInterceptor(Object theInterceptor) {
Validate.notNull(theInterceptor, "Interceptor can not be null");
getInterceptorService().unregisterInterceptor(theInterceptor);
} | [
"@",
"Deprecated",
"public",
"void",
"unregisterInterceptor",
"(",
"Object",
"theInterceptor",
")",
"{",
"Validate",
".",
"notNull",
"(",
"theInterceptor",
",",
"\"Interceptor can not be null\"",
")",
";",
"getInterceptorService",
"(",
")",
".",
"unregisterInterceptor",
"(",
"theInterceptor",
")",
";",
"}"
] | Unregisters an interceptor
@param theInterceptor The interceptor
@deprecated As of HAPI FHIR 3.8.0, use {@link #getInterceptorService()} to access the interceptor service. You can register and unregister interceptors using this service. | [
"Unregisters",
"an",
"interceptor"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java#L1645-L1649 |
22,498 | jamesagnew/hapi-fhir | hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionMatcherInterceptor.java | SubscriptionMatcherInterceptor.submitResourceModified | @Override
public void submitResourceModified(final ResourceModifiedMessage theMsg) {
/*
* We only want to submit the message to the processing queue once the
* transaction is committed. We do this in order to make sure that the
* data is actually in the DB, in case it's the database matcher.
*/
if (TransactionSynchronizationManager.isSynchronizationActive()) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public int getOrder() {
return 0;
}
@Override
public void afterCommit() {
sendToProcessingChannel(theMsg);
}
});
} else {
sendToProcessingChannel(theMsg);
}
} | java | @Override
public void submitResourceModified(final ResourceModifiedMessage theMsg) {
/*
* We only want to submit the message to the processing queue once the
* transaction is committed. We do this in order to make sure that the
* data is actually in the DB, in case it's the database matcher.
*/
if (TransactionSynchronizationManager.isSynchronizationActive()) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public int getOrder() {
return 0;
}
@Override
public void afterCommit() {
sendToProcessingChannel(theMsg);
}
});
} else {
sendToProcessingChannel(theMsg);
}
} | [
"@",
"Override",
"public",
"void",
"submitResourceModified",
"(",
"final",
"ResourceModifiedMessage",
"theMsg",
")",
"{",
"/*\n\t\t * We only want to submit the message to the processing queue once the\n\t\t * transaction is committed. We do this in order to make sure that the\n\t\t * data is actually in the DB, in case it's the database matcher.\n\t\t */",
"if",
"(",
"TransactionSynchronizationManager",
".",
"isSynchronizationActive",
"(",
")",
")",
"{",
"TransactionSynchronizationManager",
".",
"registerSynchronization",
"(",
"new",
"TransactionSynchronizationAdapter",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"getOrder",
"(",
")",
"{",
"return",
"0",
";",
"}",
"@",
"Override",
"public",
"void",
"afterCommit",
"(",
")",
"{",
"sendToProcessingChannel",
"(",
"theMsg",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"sendToProcessingChannel",
"(",
"theMsg",
")",
";",
"}",
"}"
] | This is an internal API - Use with caution! | [
"This",
"is",
"an",
"internal",
"API",
"-",
"Use",
"with",
"caution!"
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionMatcherInterceptor.java#L125-L147 |
22,499 | jamesagnew/hapi-fhir | hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/Template.java | Template.parse | public static Template parse(String input) {
return new Template(input, Tag.getTags(), Filter.getFilters());
} | java | public static Template parse(String input) {
return new Template(input, Tag.getTags(), Filter.getFilters());
} | [
"public",
"static",
"Template",
"parse",
"(",
"String",
"input",
")",
"{",
"return",
"new",
"Template",
"(",
"input",
",",
"Tag",
".",
"getTags",
"(",
")",
",",
"Filter",
".",
"getFilters",
"(",
")",
")",
";",
"}"
] | Returns a new Template instance from a given input string.
@param input
the input string holding the Liquid source.
@return a new Template instance from a given input string. | [
"Returns",
"a",
"new",
"Template",
"instance",
"from",
"a",
"given",
"input",
"string",
"."
] | 150a84d52fe691b7f48fcb28247c4bddb7aec352 | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/Template.java#L123-L125 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.