java.lang.IllegalArgumentException: column '`kitType`' does not exist. Available columns: [..., dependencies, ൔ, DMLoader, ...] - android-room

I get an expcetion when I try query some data from db.(RoomDb Version used:2.2.5)
It never reproduced in DEV. It only happened in PRD sometime on API 27 28 29 30.
Crash scenes:
1. Some time columnName of my database was changed to garbled.
java.lang.IllegalArgumentException: column 'kitType' does not exist. Available columns: [kitName, apiLevel, pkgVersionCode, packageName, kitCodePath, moduleCodePath, soLibraryPath, dependencies, ൔ, DMLoader, archType, forceUpgrade, ignoreForceUpgradeTime, mainEntry, kitState, moduleState, usesLibraryPath, appClass, reservedString1, reservedString2, reservedInt1, reservedInt2, reservedInt3]
as show above:kitType was changed to ൔ.
2. Some time columnName of my database was changed to other columnName.
java.lang.IllegalArgumentException: column 'reservedInt2' does not exist. Available columns: [id, packageName, pkgVersionCode, classname, actions, categories, intentFilter, reservedString1, reservedString2, reservedInt1, reservedInp2, reservedInt3, packageState]
as show above: reservedInt2 was changed to reservedInp2.
This is my Entity code:
#Entity(tableName = PackageInfoEntity.PACKAGE_INFO_TABLE_NAME,
primaryKeys = {PackageInfoEntity.PACKAGE_NAME, PackageInfoEntity.PKG_VERSION_CODE})
public class PackageInfoEntity {
#Ignore
public static final String PACKAGE_INFO_TABLE_NAME = "PackageInfoTable";
#Ignore
public static final String PACKAGE_NAME = "packageName";
#Ignore
public static final String PKG_VERSION_CODE = "pkgVersionCode";
#Ignore
public static final String APPLICATION_INFO = "applicationInfo";
#Ignore
public static final String PACKAGE_INFO = "packageInfo";
#Ignore
public static final String REF_COUNT = "refCount";
#Ignore
public static final String LAST_MODIFY = "lastModify";
#Ignore
public static final String PACKAGE_STATE = "packageState";
#Ignore
public static final String MODULE_PKG_STATE = "modulePkgState";
#Ignore
public static final String INVALID_TIME = "invalidTime";
#Ignore
public static final String PRE_PKG_NAME = "prePkgNames";
#Ignore
public static final String FUTURE_PKG_NAME = "futurePkgName";
#Ignore
private static final String TAG = "PackageInfoEntity";
#Ignore
public static final String RESERVEDSTRING_01 = "reservedString1";
#Ignore
public static final String RESERVEDSTRING_02 = "reservedString2";
#Ignore
public static final String RESERVEDINT_01 = "reservedInt1";
#Ignore
public static final String RESERVEDINT_02 = "reservedInt2";
#Ignore
public static final String RESERVEDINT_03 = "reservedInt3";
#NonNull
public String packageName;
#NonNull
public int pkgVersionCode;
#NonNull
#ColumnInfo(typeAffinity = ColumnInfo.BLOB)
public ApplicationInfo applicationInfo;
#NonNull
#ColumnInfo(typeAffinity = ColumnInfo.BLOB)
public PackageInfo packageInfo;
public int packageState;
public int modulePkgState;
public long invalidTime;
public String prePkgNames;
public String futurePkgName;
public String reservedString1;
public String reservedString2;
public Integer reservedInt1;
public Integer reservedInt2;
public Integer reservedInt3;
}
What I have tried:
This error never happened on my In-progress version with same app version.
I want to try add a try/catch block,but this database query is located on so many functions.
So is any advice can I figure this out.

Related

Hapi Fhir Constants for "Common Parameters defined for all resources"

http://www.hl7.org/implement/standards/fhir/search.html#advanced
Common Parameters defined for all resources:
Name Type Description Paths
_id token Resource id (not a full URL) Resource.id
_lastUpdated date Date last updated. Server has discretion on the boundary precision Resource.meta.lastUpdated
_tag token Search by a resource tag Resource.meta.tag
_profile uri Search for all resources tagged with a profile Resource.meta.profile
_security token Search by a security label Resource.meta.security
_text string Text search against the narrative
_content string Text search against the entire resource
_list string All resources in nominated list (by id, not a full URL)
_query string Custom named query
Is there a Hapi Fhir "constant" somewhere for these?
Today I happen to be looking for "_profile".
I've check the SP_ values for
org.hl7.fhir.r4.model.DomainResource;
org.hl7.fhir.r4.model.ListResource;
org.hl7.fhir.r4.model.Resource
but no luck.
I found org.hl7.fhir.r4.model.Resource.SP_RES_ID (as "_id")
String SP_RES_ID = "_id";
But not for the other "standard" ones.
Thanks.
Gradle package reference:
implementation group: 'ca.uhn.hapi.fhir', name: 'hapi-fhir-structures-r4', version: hapiFhirVersion
hapiFhirVersion = '5.1.0'
I found some
https://hapifhir.io/hapi-fhir/apidocs/hapi-fhir-base/ca/uhn/fhir/rest/api/Constants.html#PARAM_PROFILE
Package ca.uhn.fhir.rest.api
Constants.PARAM_PROFILE
public static final String PARAM_PROFILE = "_profile";
and some others since you found this question!
/**
* Used in paging links
*/
public static final String PARAM_BUNDLETYPE = "_bundletype";
public static final String PARAM_FILTER = "_filter";
public static final String PARAM_CONTAINED = "_contained";
public static final String PARAM_CONTAINED_TYPE = "_containedType";
public static final String PARAM_CONTENT = "_content";
public static final String PARAM_COUNT = "_count";
public static final String PARAM_DELETE = "_delete";
public static final String PARAM_ELEMENTS = "_elements";
public static final String PARAM_ELEMENTS_EXCLUDE_MODIFIER = ":exclude";
public static final String PARAM_FORMAT = "_format";
public static final String PARAM_HAS = "_has";
public static final String PARAM_HISTORY = "_history";
public static final String PARAM_INCLUDE = "_include";
public static final String PARAM_INCLUDE_QUALIFIER_RECURSE = ":recurse";
public static final String PARAM_INCLUDE_RECURSE = "_include" + PARAM_INCLUDE_QUALIFIER_RECURSE;
public static final String PARAM_INCLUDE_QUALIFIER_ITERATE = ":iterate";
public static final String PARAM_INCLUDE_ITERATE = "_include" + PARAM_INCLUDE_QUALIFIER_ITERATE;
public static final String PARAM_LASTUPDATED = "_lastUpdated";
public static final String PARAM_NARRATIVE = "_narrative";
public static final String PARAM_PAGINGACTION = "_getpages";
public static final String PARAM_PAGINGOFFSET = "_getpagesoffset";
public static final String PARAM_PRETTY = "_pretty";
public static final String PARAM_PRETTY_VALUE_FALSE = "false";
public static final String PARAM_PRETTY_VALUE_TRUE = "true";
public static final String PARAM_PROFILE = "_profile";
public static final String PARAM_QUERY = "_query";
public static final String PARAM_RESPONSE_URL = "response-url"; //Used in messaging
public static final String PARAM_REVINCLUDE = "_revinclude";
public static final String PARAM_REVINCLUDE_RECURSE = PARAM_REVINCLUDE + PARAM_INCLUDE_QUALIFIER_RECURSE;
public static final String PARAM_REVINCLUDE_ITERATE = PARAM_REVINCLUDE + PARAM_INCLUDE_QUALIFIER_ITERATE;
public static final String PARAM_SEARCH = "_search";
public static final String PARAM_SECURITY = "_security";
public static final String PARAM_SINCE = "_since";
public static final String PARAM_SORT = "_sort";
public static final String PARAM_SORT_ASC = "_sort:asc";
public static final String PARAM_SORT_DESC = "_sort:desc";
public static final String PARAM_SOURCE = "_source";
public static final String PARAM_SUMMARY = "_summary";
public static final String PARAM_TAG = "_tag";
public static final String PARAM_TAGS = "_tags";
public static final String PARAM_TEXT = "_text";
public static final String PARAM_VALIDATE = "_validate";
public static final String PARAMQUALIFIER_MISSING = ":missing";
public static final String PARAMQUALIFIER_MISSING_FALSE = "false";
public static final String PARAMQUALIFIER_MISSING_TRUE = "true";
public static final String PARAMQUALIFIER_STRING_CONTAINS = ":contains";
public static final String PARAMQUALIFIER_STRING_EXACT = ":exact";
public static final String PARAMQUALIFIER_TOKEN_TEXT = ":text";

Why methods doesn't see values set in constructor? (Spring Boot)

I have a class AuthorizationService like this:
#Service
public class AuthorizationService {
private final String code;
private final String client_id;
private final String redirect_uri;
private final String scope;
private final String show_dialog;
#Autowired
public AuthorizationService(
#Value("${spotify-property.response_type}") String code,
#Value("${spotify-property.client_id}") String client_id,
#Value("${spotify-property.redirect_uri}") String redirect_uri,
#Value("${spotify-property.scope}") String scope,
#Value("${spotify-property.redirect_uri}") String show_dialog) {
this.code = code;
this.client_id = client_id;
this.redirect_uri = redirect_uri;
this.scope = scope;
this.show_dialog = show_dialog;
System.out.println(code); //works
}
public ResponseEntity<HttpHeaders> getSpotifyRedirectionCode() {
HttpHeaders headers = new HttpHeaders();
System.out.println(client_id); //doesn't work
System.out.println(this.code); //does not work either
System.out.println(redirect_uri);
System.out.println(scope);
System.out.println(show_dialog);
//more code doesn't matter
return new ResponseEntity<>(headers, HttpStatus.TEMPORARY_REDIRECT);
}
Why these variables are ok in constructor but in methods are null, how to set them in correct way? Also
#Value("${spotify-property.response_type}")
private final String code;
does not work either.
Your class fields are final so get instantiated without your configuration values.
You can either use the constructor as you have before, or remove the final from your fields.
I'm not sure if my answer is 100% correct. But I believe that you cannot change final variables. The right way would be to remove the final keyword and keep the #Value annotations on the fields and the you don't have to use it in the constructor.
#Service
#RequiredArgsConstructor
public class AuthorizationService {
#Value("${spotify-property.response_type}")
private String code;
#Value("${spotify-property.client_id}")
private String client_id;
#Value("${spotify-property.redirect_uri}")
private String redirect_uri;
#Value("${spotify-property.scope}")
private String scope;
#Value("${spotify-property.redirect_uri}")
private String show_dialog;
public ResponseEntity<HttpHeaders> getSpotifyRedirectionCode() {
HttpHeaders headers = new HttpHeaders();
System.out.println(client_id); //works
System.out.println(this.code); //works too
System.out.println(this.redirect_uri);
System.out.println(this.scope);
System.out.println(this.show_dialog);
//more code doesn't matter
return new ResponseEntity<>(headers, HttpStatus.TEMPORARY_REDIRECT);
} }

RestDocs does double documentation on request parameters

Using RestDocs version 1.1.1.RELEASE and SpringBoot 1.4.0.RELEASE, parameters when using "httpRequest" is documented double.
The following code:
#RunWith(SpringRunner.class)
#WebMvcTest(ProductResource.class)
#AutoConfigureRestDocs("target/generated-snippets")
public class ProductResourceDocumentation {
private static final String PROPERTY_ID_VALUE = "d7612";
private static final String SALES_MARKET_VALUE = "999";
private static final String SEASON_VALUE = "2016";
private static final String SECTIONS_VALUE = "buildings";
private static final String SHOW_DESCRIPTIONS_VALUE = "false";
private static final String STRING = "string";
private static final Integer NUMBER = 1;
private static final String NOT_FOUND = "404 Not Found";
private static final String BAD_REQUEST = "400 Bad Request";
private RestDocumentationResultHandler documentationResultHandler;
#MockBean
private ProductHandler productHandler;
#Autowired
private MockMvc mockMvc;
#Before
public void setup() {
this.documentationResultHandler = document("{class-name}/{method-name}", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()));
}
#Test
public void listProducts() throws Exception {
Product product = getBasicProductsRepresentation();
when(productHandler.getProduct(PROPERTY_ID_VALUE, SALES_MARKET_VALUE, SEASON_VALUE, null, null)).thenReturn(product);
mockMvc.perform(RestDocumentationRequestBuilders.get("/products/{propertyId}", PROPERTY_ID_VALUE)
.param("salesMarket", SALES_MARKET_VALUE)
.param("season", SEASON_VALUE))
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.propertyID", is(PROPERTY_ID_VALUE)))
.andExpect(jsonPath("$.season", is(SEASON_VALUE)))
.andDo(documentationResultHandler.document(
pathParameters(
parameterWithName("propertyId").description(PATH_PARAM__PROPERTY_ID)
),
requestParameters(
parameterWithName("salesMarket").description(REQUEST_PARAM__SALES_MARKET),
parameterWithName("season").description(REQUEST_PARAM__SEASON)
),
httpRequest(), httpResponse()
));
}
Produces the following documentation ("salesMarket=999&season=2016" is documented twice):
GET /products/d7612? salesMarket=999&season=2016&salesMarket=999&season=2016 HTTP/1.1
Have anybody experienced anything similar or know what the problem is?
It's a bug that's been fixed in 1.1.2.RELEASE. Upgrading will resolve the problem. When upgrading make sure that you get 1.1.2 of both spring-restdocs-mockmvc and spring-restdocs-core. The latter module is where the fix is.
We get "double documentation" when we set a query param (see block below) to an empty string (""):
GET /Thing/OtherThing/Foo/?thinger=FOO&block=&bla=5&block= HTTP/1.1
We use Spring Boot 1.5.2 and Spring REST Docs 1.1.2.RELEASE.

How to filter source file using gradle?

Is there any plugin or solution to filter source file. When i am using maven there is plugin https://github.com/wavesoftware/templating-maven-plugin
That plugin work like a charm is there any solution for gradle, to achieve the same result.
For example i am crate interface that holds all information about build:
public interface BuildConfig {
public static final String PROFILE_FAST = "fast";
public static final String PROFILE_DEV = "dev";
public static final String PROFILE_TEST = "test";
public static final String PROFILE_UAT = "uat";
public static final String PROFILE_PROD = "prod";
public static final String APP_CODE = "${app-code}";
public static final String PROFILE_ID = "${profile-id}";
public static final String APP_VERSION = "${project.version}";
public static final boolean DEBUG = !("${profile-id}").equals(PROFILE_PROD);
}
thanks

MVC4 WebApplication - global variables available in views (cshtml files) using Razor engine

I wonder how it is now possible, using MVC4, to get such functionality which was possible in MVC3, to declare some variables (and/or constraints) which are then available in all cshtml files. I used this to make language files.
Earlier (in MVC3) I had App_Code folder in my Solution, where I put the file Lang.cshtml. In this file (valid resource for me) I had e.g.
#functions{
public static readonly string G_ADD = "Dodaj";
public static readonly string G_CREATE = "Utwórz";
public static readonly string G_SAVE = "Zapisz";
public static readonly string G_EDIT = "Edytuj";
public static readonly string G_DETAILS = "Szczegóły";
public static readonly string G_DELETE = "Usuń";
public static readonly string G_SEARCH = "Szukaj";
public static readonly string G_FIRST = "<< Pierwsza";
public static readonly string G_LAST = "Ostatnia >>";
public static readonly string G_PREV = "< Poprzednia";
public static readonly string G_NEXT = "Następna >";
public static readonly string G_ACTION = "Akcja";
public static readonly string G_ID = "ID";
public static readonly string G_PAGE = "STRONA";
public static readonly string G_OF = "z";
public static readonly string G_FROM = "z";
public static readonly string G_TO = "do";
public static readonly string G_ALL = "-- Wszystkie";
public static readonly string G_RECORDS = "Rekordów:";
public static readonly string G_CHOOSE = "Wybierz:";
public static readonly string G_BACK = "Wróć";
public static readonly string G_VIEW_CHART = "Wyświetl wykres";
}
so I could use the strings in any .cshtml (View) e.g.
#Lang.G_ADD
or even
#Html.ActionLink(#Lang.G_ADD, "AddContract", new { id = item.CONTRACT_ID });
Especially it makes my app more user-friendly for all those people working on i18n of it.
Now this solution doesn't work in MVC4 :/
The available resources solution is not much-effective. Imagine, that everytime you need to write AppName.Properties.Resources.G_ADD.
Also the XML in the Resources.resx looks baaaaaaadly. Very.
Writting any method to enumerate the Resources still do the job partially only as it is bloating the code and I am following "less the code the better" idea.
Please point me to the right direction. Also any ready solution is appreciated :)
Thank You all in advance!

Resources