Friday, 17 February 2017

i18N report xls

i18N report.. obviously the name say the meaning.. but the task is simple, the header in the report will be in english, but that should come from database.

* Initially thought of hitting db and taking a query and have 3 classes, 1 with list<reportvalue>, reportHeaderObject putting this object into another object say ReportObj. This !dea suggested by my Tech Lead, thanks. very good suggestion. while implementing another !dea hit in mind.

* Instead of creating new classes, set the value directly into the model, when we creating a variable. Think, you didn't got my point. let me clarify..

we have a cron/scheduler which will run every 15/30 mins, hit the database and update the properties file, that file we are using for i18N translation. My !dea is, instead of hitting to the db again, take the value directly from this properties file. googled..




ResourceBundle rb = ResourceBundle.getBundle("test.bundletest.mybundle");
String value = rb.getString(key);
with this, half of my task was over.. 

the second half is, how to set this object in the UI ?

saw the code, implemented by my colleague(obviously, on leave, enjoying weekend). Njoy Ramesh :D

PURE JAVASCRIPT (O _ O), however understandble.. 

changed in some places, get my object, set that as column header, BiNgOoo



Wednesday, 8 February 2017

thanks BaLaJ!

Today, Unknowingly deleted a column values, by noon, a colleague send mail to all, not to delete any values, without his knowledge like that




issue, got serious.. 

luckily found a query in http://stackoverflow.com/questions/19853150/rollback-a-committed-transaction
and thinking of how to implement it..
Explained the scenario to Balaji, with in minutes he put the query. Thats why, we call him Geekbot :D

ill say what i understand..

i took this oracle query..

select * from table as of timestamp timestamp '2017-02-08 17:30:00' order by id

1. Balaji, looked at it..
2. He copied, all the data,
3. pasted it in excel
4. kept only necessary columns
5. in excel he wrote query
 =CONCATENATE("UPDATE table SET TYPE='",C1,"' WHERE ID=",A1,";")
6. he press enter, update query came for all the entries..

Done. Big issue resolved in minutes, Thanks Geekbot. :D



Monday, 9 January 2017

Code Hints

// USING THIS LOGIC IN KEY UP TRIGGING A FUNCTION

ref : http://stackoverflow.com/questions/20281546/how-to-prevent-calling-of-en-event-handler-twice-on-fast-clicks

// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.

function debounce(func, wait, immediate) {
    var timeout;
    return function() {
        var context = this, args = arguments;
        var later = function() {
            timeout = null;
            if (!immediate) func.apply(context, args);
        };
        var callNow = immediate && !timeout;
        clearTimeout(timeout);
        timeout = setTimeout(later, wait);
        if (callNow) func.apply(context, args);
    };
};

Saturday, 12 November 2016

Angular 2


Saturday, 12 November 2016

Finally, Started learning angular 2.. It is been  a while, i wanted to learn angular 2 but got busy with other works.. Then my company itself provided us angular training + FOOD :D... hooo..! Thank You..
Training ended good.. hope i can share my road block in the following post.. :)

as of now.. https://angular.io/ & my angular trainer gitub
https://github.com/MicroTamil-Haribabu/ 



Thursdau 09 Feb 2017


Yep, After a long gap, i thought of start working on Angular 2. Now only got bit free from  project works.
so, now my 1st task to myself is, guess.. the same login page, what else it would be.. the developers who start learning a language obviously first task would be LOGIN page. So folks, lets begin.

I'm gonna continue with the application which i have in hand, which Mr.Haribabu helped me to create in a 3 days angular training.




Hope, it looks not that bad, lets do the logic in the fore-coming days.. ;)

Thursday, 20 October 2016

Spring Security + ACL button level Authentication + URL Authentication


In my case, i have some ArrayList of String in httpsession. i need to show a button the user, only if the button function name is available in that list. i have implement it via Spring Security ACL.
For that add ACL + spring security core jar in the classpath.
<dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>${spring.security.version}</version>
    </dependency>       
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>${spring.security.version}</version>
    </dependency>       
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-acl</artifactId>
        <version>${spring.security.version}</version>
    </dependency>
then, i have added the bean in xml.
<global-method-security pre-post-annotations="enabled">
  <expression-handler ref="expressionHandler"/>
</global-method-security>    
<beans:bean id="expressionHandler" class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler">
    <beans:property name="permissionEvaluator" ref="permissionEvaluator"/>
</beans:bean> 
<beans:bean id="permissionEvaluator" class="com.config.BasePermissionEvaluator"/>
then the handler class BasePermissionEvaluator, this class will evaluate, if that button has permission,
public class BasePermissionEvaluator implements PermissionEvaluator{
 @Override
 public boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission) {

  boolean hasPermission = true;
  // targetDomainObject [101001, 102001, 103001, 201001, 202001, 203001, 204001, 205001, 206001, 301001, 302001, 303001]permission : 303001
    @SuppressWarnings("unchecked")
    List<String> functionList =(List<String>) targetDomainObject;       
    if(!functionList.contains(permission.toString())) {
        hasPermission = false;  
    }
  return hasPermission;
 }

 @Override
 public boolean hasPermission(Authentication authentication,
   Serializable targetId, String targetType, Object permission) {
    throw new RuntimeException("Id and Class permissions are not supperted by this application");
 }
}
Finally in the jsp,
    <%@taglib uri="http://www.springframework.org/security/tags"
 prefix="sec"%>

<sec:accesscontrollist hasPermission="101001"   domainObject="${USER_FUNCTIONS}"> 
                    <button type="reset" id ="clearMPId"><spring:message code="mp.clear"/></button>
  </sec:accesscontrollist>   

for URL authentication, please follow

https://stackoverflow.com/a/45354372/2573744

Hope it helps.

Friday, 14 October 2016

Thursday, 1 September 2016

multi file upload + ajax post + jQuery

mannnnNNNNNN... File uploading.. File handling.. File writing.. File reading.. 
All these file operations, i'm bit scared of.. on these, i can now do file reading and file writing also can handle file.. but, this file upload.. i'm always had a fear of.. this time i got a chance to face it.. and lets see.. im confident, ill come up with a solution as always.. background songs going on.. lets start..

so.. this time, i got a partner.. to give me an UI.. so he gave me.. 

https://blueimp.github.io/jQuery-File-Upload/index.html

started with this.. implemented it my project.. UI came.. surprisingly, the expected functionality came.. however, as always, it ll not go that smooth.. i clicked the start button.. i cant guess.. where the url linq going.. ???

getting  an error SyntaxError: Unexpected token < in JSON at position 0

spend hours.. cannot find.. ask him to find, when uploading where the file is uploading.. 

http://hmkcode.com/spring-mvc-jquery-file-upload-multiple-dragdrop-progress/