Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
d2army committed Jul 24, 2012
0 parents commit 56d320c
Show file tree
Hide file tree
Showing 99 changed files with 1,655 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This project was built using the Play Framework version 2.0.2 and using JDK 1.7.
It is a work in progress and is an experiment with machine learning using Play, Java and the LinkedIn-J API library

Do note that to run this project properly, make sure your system's JRE and JDK are both the same versions(i.e. either both 1.6 or 1.7).

15 changes: 15 additions & 0 deletions app/analyzer/group/CategoryAnalyzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package analyzer.group;

import analyzer.single.Analyzer;

abstract public class CategoryAnalyzer extends Analyzer {
protected String categoryName_ = "";

public CategoryAnalyzer(){

}

public void process(){

}
}
29 changes: 29 additions & 0 deletions app/analyzer/group/ConnectionsAnalyzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package analyzer.group;

import java.util.EnumSet;

import analyzer.single.Analyzer;
import analyzer.single.PersonAnalyzer;

import com.google.code.linkedinapi.client.enumeration.ProfileField;
import com.google.code.linkedinapi.schema.Connections;
import com.google.code.linkedinapi.schema.Person;
import com.google.code.linkedinapi.schema.Position;
import com.google.code.linkedinapi.schema.Positions;


public class ConnectionsAnalyzer extends Analyzer{
private Connections connections_;

public ConnectionsAnalyzer(Connections connections, String keyword){
this.connections_ = connections;
this.keyword_ = keyword;
}

public void process(){
for (Person person : this.connections_.getPersonList()) {
PersonAnalyzer pa = new PersonAnalyzer(person,this.keyword_);
pa.process();
}
}
}
14 changes: 14 additions & 0 deletions app/analyzer/group/EducationsAnalyzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package analyzer.group;

import com.google.code.linkedinapi.schema.Educations;

public class EducationsAnalyzer extends CategoryAnalyzer {

public EducationsAnalyzer(Educations educations){
this.categoryName_ = "Education";
}

public void process(){

}
}
15 changes: 15 additions & 0 deletions app/analyzer/group/HonorsAnalyzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package analyzer.group;

import analyzer.single.Analyzer;


public class HonorsAnalyzer extends CategoryAnalyzer {

public HonorsAnalyzer(String honors){
this.categoryName_ = "Honors";
}

public void process(){

}
}
15 changes: 15 additions & 0 deletions app/analyzer/group/InterestsAnalyzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package analyzer.group;

import analyzer.single.Analyzer;


public class InterestsAnalyzer extends CategoryAnalyzer {

public InterestsAnalyzer(String interests){
this.categoryName_ = "Interests";
}

public void process(){

}
}
40 changes: 40 additions & 0 deletions app/analyzer/group/MasterAnalyzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package analyzer.group;

import java.util.EnumSet;

import analyzer.single.Analyzer;

import com.google.code.linkedinapi.client.LinkedInApiClient;
import com.google.code.linkedinapi.client.enumeration.ProfileField;
import com.google.code.linkedinapi.schema.Connections;

public class MasterAnalyzer extends Analyzer {
final private static EnumSet<ProfileField> FIELDS_TO_GRAB = EnumSet.of(
ProfileField.FIRST_NAME,
ProfileField.LAST_NAME,
ProfileField.SPECIALTIES,
ProfileField.POSITIONS,
ProfileField.EDUCATIONS,
ProfileField.SKILLS,
ProfileField.INTERESTS,
ProfileField.HONORS,
ProfileField.RECOMMENDATIONS_RECEIVED
);
private LinkedInApiClient client_;

public MasterAnalyzer(LinkedInApiClient client, String keyword){
this.client_ = client;
this.keyword_ = keyword;
}

public void setKeyword(String keyword){
this.keyword_ = keyword;
}

public void process() {
Connections connections = this.client_.getConnectionsForCurrentUser(MasterAnalyzer.FIELDS_TO_GRAB);
ConnectionsAnalyzer ca = new ConnectionsAnalyzer(connections, this.keyword_);
ca.process();
}

}
26 changes: 26 additions & 0 deletions app/analyzer/group/PositionsAnalyzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package analyzer.group;

import analyzer.single.PositionAnalyzer;

import com.google.code.linkedinapi.schema.Position;
import com.google.code.linkedinapi.schema.Positions;

public class PositionsAnalyzer extends CategoryAnalyzer {
private Positions positions_;

public PositionsAnalyzer(Positions positions, String keyword){
this.positions_ = positions;
this.categoryName_ = "Positions";
this.keyword_ = keyword;
}

public void process(){
if (this.positions_ != null){
for(Position position : this.positions_.getPositionList()){
PositionAnalyzer pa = new PositionAnalyzer(position,this.keyword_);
pa.process();
}
}
}
}

17 changes: 17 additions & 0 deletions app/analyzer/group/RecommendationsReceivedAnalyzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package analyzer.group;

import analyzer.single.Analyzer;

import com.google.code.linkedinapi.schema.RecommendationsReceived;


public class RecommendationsReceivedAnalyzer extends CategoryAnalyzer {

public RecommendationsReceivedAnalyzer(RecommendationsReceived rr){
this.categoryName_ = "RecommendationsReceived";
}

public void process(){

}
}
16 changes: 16 additions & 0 deletions app/analyzer/group/SkillsAnalyzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package analyzer.group;

import analyzer.single.Analyzer;

import com.google.code.linkedinapi.schema.Skills;

public class SkillsAnalyzer extends CategoryAnalyzer {

public SkillsAnalyzer(Skills skills){
this.categoryName_ = "Skills";
}

public void process(){

}
}
27 changes: 27 additions & 0 deletions app/analyzer/single/Analyzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package analyzer.single;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import utility.StringManip;

abstract public class Analyzer {
protected static String finalResults_ = "";



//keyword to search for
protected String keyword_ = "";
abstract public void process();

public String getFinalResults(){
return Analyzer.finalResults_;
}

protected static void addData(String value){
Analyzer.finalResults_ = Analyzer.finalResults_.concat(value);
}



}
73 changes: 73 additions & 0 deletions app/analyzer/single/PersonAnalyzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package analyzer.single;

import java.util.List;

import models.PersonModel;
import analyzer.group.EducationsAnalyzer;
import analyzer.group.HonorsAnalyzer;
import analyzer.group.InterestsAnalyzer;
import analyzer.group.PositionsAnalyzer;
import analyzer.group.RecommendationsReceivedAnalyzer;
import analyzer.group.SkillsAnalyzer;

import com.google.code.linkedinapi.schema.Educations;
import com.google.code.linkedinapi.schema.Person;
import com.google.code.linkedinapi.schema.Positions;
import com.google.code.linkedinapi.schema.RecommendationsReceived;
import com.google.code.linkedinapi.schema.Skills;

public class PersonAnalyzer extends Analyzer {
private Person person_;

public PersonAnalyzer(Person person, String keyword){
this.person_ = person;
this.keyword_ = keyword;
}

/**
* init
*
* Is this Person already in the database
*/
private void init(){
String fullName = this.person_.getFirstName()+" "+this.person_.getLastName();
boolean alreadyExists = PersonModel.exists(fullName);

if(alreadyExists == true){

} else {
//need to create person
PersonModel pm = new PersonModel(fullName);
pm.save();
}

}


public void process(){
this.init();

Positions positionList = this.person_.getPositions();
PositionsAnalyzer pa = new PositionsAnalyzer(positionList, this.keyword_);
pa.process();

Educations educationList = this.person_.getEducations();
EducationsAnalyzer ea = new EducationsAnalyzer(educationList);

Skills skillsList = this.person_.getSkills();
SkillsAnalyzer sa = new SkillsAnalyzer(skillsList);

String specialties = this.person_.getSpecialties();
SpecialtiesAnalyzer spa = new SpecialtiesAnalyzer(specialties);

String interestList = this.person_.getInterests();
InterestsAnalyzer ia = new InterestsAnalyzer(interestList);

String honorsList = this.person_.getHonors();
HonorsAnalyzer ha = new HonorsAnalyzer(honorsList);

RecommendationsReceived recommendationsList = this.person_.getRecommendationsReceived();
RecommendationsReceivedAnalyzer rra = new RecommendationsReceivedAnalyzer(recommendationsList);

}
}
23 changes: 23 additions & 0 deletions app/analyzer/single/PositionAnalyzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package analyzer.single;

import com.google.code.linkedinapi.schema.Position;


public class PositionAnalyzer extends Analyzer {
private Position position_;

public PositionAnalyzer(Position position,String keyword){
this.position_ = position;
this.keyword_ = keyword;
}

/**
* Do the counting of the frequency items
*/
public void process(){
//how many times does the word actually show up in this position

//look at the titkle
//this.position_.getTitle();
}
}
14 changes: 14 additions & 0 deletions app/analyzer/single/SpecialtiesAnalyzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package analyzer.single;




public class SpecialtiesAnalyzer extends Analyzer {

public SpecialtiesAnalyzer(String specialties){

}
public void process(){

}
}
45 changes: 45 additions & 0 deletions app/api/LinkedInConnection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package api;

import java.util.EnumSet;

import play.cache.Cache;

import com.google.code.linkedinapi.client.LinkedInApiClient;
import com.google.code.linkedinapi.client.LinkedInApiClientFactory;
import com.google.code.linkedinapi.client.enumeration.ProfileField;
import com.google.code.linkedinapi.client.oauth.LinkedInAccessToken;
import com.google.code.linkedinapi.client.oauth.LinkedInOAuthService;
import com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceFactory;
import com.google.code.linkedinapi.client.oauth.LinkedInRequestToken;

public class LinkedInConnection {
private static String API_KEY = "j4lvn0lsmybt";
private static String API_SECRET = "AEhrcvtdFeaNNXz0";

final private static String REDIRECT_URL = "http://localhost:9000/complete";

private String authUrl_;
private LinkedInRequestToken requestToken_;
private LinkedInOAuthService oauthService_;


public LinkedInConnection() {
this.oauthService_ = LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(API_KEY,API_SECRET);
this.requestToken_ = oauthService_.getOAuthRequestToken(LinkedInConnection.REDIRECT_URL);

this.authUrl_ = this.requestToken_.getAuthorizationUrl();
}

public String getAuthUrl(){
return this.authUrl_;
}

public LinkedInApiClient completeAuthentication(String oauthVerifier) {

LinkedInAccessToken accessToken = this.oauthService_.getOAuthAccessToken(this.requestToken_, oauthVerifier);
LinkedInApiClientFactory factory = LinkedInApiClientFactory.newInstance(API_KEY, API_SECRET);
LinkedInApiClient client = factory.createLinkedInApiClient(accessToken);

return client;
}
}
Loading

0 comments on commit 56d320c

Please sign in to comment.