id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
6955389d-86cb-4c6e-b727-eee1fbc1706c | public AppTest( String testName )
{
super( testName );
} |
bc06ee0b-62fc-4ac9-8f34-ae9db376370a | public static Test suite()
{
return new TestSuite( AppTest.class );
} |
3267f9c9-d4a7-4484-a962-5518da26c12a | public void testApp()
{
assertTrue( true );
} |
da64764d-8ebe-49b3-a7a0-7526c29e2885 | public static void main(String[] args) {
int numOfPpl=0;
List<Integer> weights = new ArrayList<Integer>();
try{
FileInputStream fstream = new FileInputStream("input.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
Scanner s = new Scanner(br);
numOfPpl = s.nextInt();
for(int i=0; i<numOfPpl; i++){
weights.add(s.nextInt());
}
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
if(numOfPpl==1){
System.out.println("BFS "+weights.get(0)+" 0");
System.out.println("DFS "+weights.get(0)+" 0");
System.out.println("A* "+weights.get(0)+" 0");
}
else{
try{
// Create file
FileWriter fstream = new FileWriter("output.txt");
BufferedWriter out = new BufferedWriter(fstream);
ArrayList<Integer> dummy = new ArrayList<Integer>();
State init = new State(weights, dummy, true);
State goal = new State(dummy, weights, false);
BFS bfs = new BFS(init, goal);
out.write(bfs.toString());
out.write(DFS.search(init, goal));
out.write(AStar.search(init, goal));
//Close the output stream
out.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
} |
01aafe17-b224-4f0d-867d-2673e7798f47 | public State(List<Integer> start, List<Integer> goal, boolean atStart){
this.start = start;
this.goal = goal;
this.atStart = atStart;
} |
8c4e5798-aafe-433a-ac0e-693fe08d8478 | public int hashCode(){
Integer hash = 0;
int goalSum = 0;
int goalCount =0;
int startSum = 0;
int startCount = 0;
int boat = 0;
for(Integer Is: start){
startCount++;
startSum = Is + startSum;
}
for(Integer Ig: goal){
goalCount++;
goalSum = Ig + goalSum;
}
if(atStart){
boat = 1;
}
String prehash = Integer.toString(1).concat(Integer.toString(goalCount)).concat(Integer.toString(goalSum)).concat(Integer.toString(1)).concat(Integer.toString(startCount)).concat(Integer.toString(startSum)).concat(Integer.toString(1)).concat(Integer.toString(boat));
hash = Integer.parseInt(prehash);
return hash;
} |
f38e96a0-fe4b-4ee0-84d7-feefcdd9edda | public boolean equals(State state){
List<Integer> goal1 = new ArrayList<Integer>(this.goal);
List<Integer> goal2 = new ArrayList<Integer>(state.goal);
List<Integer> start1 = new ArrayList<Integer>(this.start);
List<Integer> start2 = new ArrayList<Integer>(state.start);
List<Integer> goalItr = new ArrayList<Integer>(this.goal);
List<Integer> startItr= new ArrayList<Integer>(this.start);
if(this.atStart==state.atStart){
for(Integer i: goalItr){
goal2.remove(i);
goal1.remove(i);
}
if(goal1.isEmpty()&&goal2.isEmpty()){
for(Integer k: startItr){
start2.remove(k);
start1.remove(k);
}
if(start1.isEmpty()&&start2.isEmpty()){
return true;
}
}
}
return false;
} |
a1e17d53-fe86-44fa-b279-46043fc292c7 | public String toString(){
StringBuilder sb = new StringBuilder();
sb.append("north:"+start.toString()+"\n");
sb.append("south:"+goal.toString()+"\n");
sb.append(atStart + "\n");
sb.append("------------------");
return sb.toString();
} |
776bb912-6859-4c39-8fdf-5bd8adb31f61 | public State update(List<Integer> moved){
//System.out.println(moved);
for(Integer i: moved){
//System.out.println("I is : "+i);
if(atStart){
this.start.remove(i);
this.goal.add(i);
}else{
this.goal.remove(i);
this.start.add(i);
}
}
this.atStart = !this.atStart;
return this;
} |
afeba957-6399-455b-b4d9-665794588247 | public boolean getAtStart(){
return this.atStart;
} |
f94ea6df-988e-4f34-9db3-5a39cf9405e5 | public List<Integer> getNorthBank(){
return goal;
} |
ea8ea19f-d0bb-4784-8d7a-442102736b2f | public List<Integer> getSouthBank(){
return start;
} |
a792a54c-18fa-4be8-b05f-9c6593a2773c | static public String search(State start, State goal){
ArrayList<State> solution = null; //will hold the states that lead to the solution later
boolean solutionCTL=true; //used to control a loop that builds the solution list
Comparator<Node> comp = new Node();
PriorityQueue<Node> frontier = new PriorityQueue<Node>(1, comp); // holds the frontier (nodes that have not yet been expanded
Node tree = new Node(0, null, start,null); // the base node of the tree (i.e. the start conditions)
boolean notSolved=true; // a variable that controls the main search loop
frontier.add(tree); // loads the root node into the frontier, this is needed due to the way the no solution case is handled
List<Node> expanded; // this variable with hold the nodes that are expanded from the current node before they are loaded into the frontier
Node Active=null; //this with hold the current node being looked at by the tree. it is loaded from the frontier
int numOfNodesExpanded=1;
int totalCost=0;
while(notSolved){
if(frontier.isEmpty()){
notSolved = false;
}else{
Active = frontier.poll();
numOfNodesExpanded++;
}
if(Active.getState().equals(goal)){
notSolved=true;
break;
}else{
expanded = Active.expand();
for(Node n: expanded){
frontier.add(n);
}
}
}
solution = new ArrayList<State>();
totalCost = Active.getCost();
while(solutionCTL){
solution.add(Active.getState());
if(Active.getParent()==null){
solutionCTL=false;
break;
}else{
Active = Active.getParent();
}
}
StringBuilder sb = new StringBuilder();
sb.append("A* "+totalCost+" "+numOfNodesExpanded+"\n");
for(State s : solution){
sb.append(s.toString()+"\n");
}
return sb.toString();
} |
a4f600d8-557c-4b77-8e66-35b98a5ba087 | static public String search(State start, State goal){
ArrayList<State> solution = null; //will hold the states that lead to the solution later
boolean solutionCTL=true; //used to control a loop that builds the solution list
Stack<Node> frontier = new Stack<Node>(); // holds the frontier (nodes that have not yet been expanded
Node tree = new Node(0, null, start,null); // the base node of the tree (i.e. the start conditions)
boolean notSolved=true; // a variable that controls the main search loop
frontier.push(tree); // loads the root node into the frontier, this is needed due to the way the no solution case is handled
List<Node> expanded; // this variable with hold the nodes that are expanded from the current node before they are loaded into the frontier
Node Active=null; //this with hold the current node being looked at by the tree. it is loaded from the frontier
int numOfNodesExpanded=1;
int totalCost=0;
while(notSolved){
if(frontier.isEmpty()){
notSolved = false;
}else{
Active = frontier.pop();
numOfNodesExpanded++;
}
if(Active.getState().equals(goal)){
notSolved=true;
break;
}else{
expanded = Active.expand();
for(Node n: expanded){
frontier.push(n);
}
}
}
solution = new ArrayList<State>();
totalCost = Active.getCost();
while(solutionCTL){
// System.out.println(Active.getState().toString());
solution.add(Active.getState());
if(Active.getParent()==null){
solutionCTL=false;
break;
}else{
Active = Active.getParent();
}
}
StringBuilder sb = new StringBuilder();
sb.append("DFS "+totalCost+" "+numOfNodesExpanded+"\n");
for(State s : solution){
sb.append(s.toString()+"\n");
}
return sb.toString();
} |
d845c075-0544-4838-90c9-ab9df79fed15 | Node(){
this.state = null;
} |
a0f4f00b-7562-4578-adcc-2f6b4fab02e0 | Node(int cost, Node parent, State state, List<Integer> moved){
this.parent = parent;
this.cost = cost;
this.children = new ArrayList<Node>();
this.state = state;
this.moved = moved;
if(moved!=null){
this.state = this.state.update(moved);
int max = 0;
for(Integer i: moved){
if(i>max){
max = i;
}
}
this.cost = cost + max;
}
int max = 0;
for(int i: this.state.getSouthBank()){
if(i> max){
max=i;
}
}
//A* notes
estimate = max + cost; //max is our h(n) cost is the g(n) and estimate is our f(n)
} |
03f855d4-4c86-4db3-8875-1b5f3c4c27ee | public int getCost(){
return cost;
} |
5ef592d9-0d19-436a-aa2d-451ecffe0db0 | public void addChild(Node child){
children.add(child);
} |
fbbe9263-f3ba-439f-9935-66945200f853 | public List<Node> expand(){
if(state.getAtStart()){
List<List<Integer>> pairs = new ArrayList<List<Integer>>();
List<Integer> copy = new ArrayList<Integer>(state.getSouthBank());
if(state.getSouthBank().size()==1){ //if one person on south side
for(Integer i: state.getSouthBank()){
List<Integer> tuple = new ArrayList<Integer>();
tuple.add(i);
Boolean t = state.getAtStart();
State copyState = new State(new ArrayList<Integer>(state.getSouthBank()),
new ArrayList<Integer>(state.getNorthBank()),
t);
Node child = new Node(this.getCost(), this, copyState, tuple);
children.add(child);
}
}
else{ //if >1 person on south side
for(Integer i: state.getSouthBank()){
copy.remove(i);
for(Integer j: copy){
List<Integer> tuple = new ArrayList<Integer>();
tuple.add(i);
tuple.add(j);
pairs.add(tuple);
}
}
for(List<Integer> p: pairs){
//System.out.println(p.toString());
Boolean t = state.getAtStart();
State copyState = new State(new ArrayList<Integer>(state.getSouthBank()),
new ArrayList<Integer>(state.getNorthBank()),
t);
Node child = new Node(this.getCost(), this, copyState, p);
children.add(child);
}
}
}
else{ //if on north side
ArrayList<Integer> copy = new ArrayList<Integer>(state.getNorthBank());
for(Integer i: copy){
List<Integer> tuple = new ArrayList<Integer>();
tuple.add(i);
Boolean t = state.getAtStart();
State copyState = new State(new ArrayList<Integer>(state.getSouthBank()),
new ArrayList<Integer>(state.getNorthBank()),
t);
Node child = new Node(this.getCost(), this, copyState, tuple);
children.add(child);
}
}
return children;
} |
1c301958-48fb-4dc1-9c46-47c323487140 | public Node getChild(int cost){
Node result=null;
for(Node n: children){
if(n.cost==cost){
result=n;
}
}
return result;
} |
c9a5ee90-838c-4690-9b6e-be08fc5f34a5 | public Node getParent(){
return parent;
} |
209f88c2-8635-4930-b4d1-6b76f9272aa8 | public int hashCode(Node node){
return node.state.hashCode();
} |
844cbbf6-010e-497a-8069-62161257b45e | public State getState(){
return this.state;
} |
086abf2d-bdd5-446a-a6e5-f73909eeeb42 | public List<Integer> getMoved(){
return this.moved;
} |
f7542336-e1af-4860-beaf-378e55b04176 | public String toString(){
return this.state.toString();
} |
17f16ab8-ce6b-49fa-a425-545f50a91d9f | public int getEstimate(){
return this.estimate;
} |
f70991ec-906f-4649-8e0f-e627bbec4884 | @Override
public int compare(Node n1, Node n2) {
int result = 0;
if(n1.getEstimate() <= n2.getEstimate()){
result = -1;
}
else{
result = 1;
}
return result;
} |
91502ce2-030d-4da1-9348-b7ba2c0f0cd7 | BFS(State initialState, State goalState){
this.goalState = goalState;
Node tree = new Node(0, null, initialState, null);
frontier = new LinkedList<Node>();
frontier.add(tree);
boolean notSolved=true;
boolean solutionCTL = true;
StringBuilder sb = new StringBuilder();
int numOfNodesExpanded=1;
int totalCost=0;
while(notSolved){
if(frontier.isEmpty()){
notSolved=false;
}
else{
this.currentNode = frontier.poll();
numOfNodesExpanded++;
// System.out.println(currentNode.getState().toString());
}
if(currentNode.getState().equals(goalState)){
notSolved=true;
break;
}
else{
frontier.addAll(currentNode.expand());
}
}
totalCost = currentNode.getCost();
while(solutionCTL){
sb.append(currentNode.toString()+"\n");
// System.out.println("instance cost:"+currentNode.getCost());
if(currentNode.getParent()==null){
solutionCTL=false;
break;
}
else{
currentNode = currentNode.getParent();
}
}
sb.insert(0, numOfNodesExpanded+" \n");
sb.insert(0, "BFS "+totalCost+" ");
result = sb.toString();
// System.out.println(result);
} |
0718637c-9935-4b7a-a3c1-aba452add156 | public String toString(){
return result;
} |
a373231e-b3f6-4bb1-bc71-b842cd4ab5dc | public static void main(String[] args) {
try {
final MongoClient mongo = new MongoClient("localhost", 27017);
final DB db = mongo.getDB("test");
final DBCollection userCollection = db.getCollection("User");
final int size = userCollection.find().size();
System.out.println("size="+size);
final User bob = new User("BOB", Sex.MALE);
List<DBObject> dbObjects = new ArrayList<DBObject>(10);
System.out.println("Date()=" + new Date());
for (int i = 0; i < 10; i++) {
dbObjects.add(bob.getMongoObject());
}
System.out.println("start inserting ");
System.out.println("Date()=" + new Date());
userCollection.insert(dbObjects);
System.out.println("END Date()=" + new Date());
System.out.println("size="+size);
} catch (Exception e) { //not best practice, but it's Example!
e.printStackTrace();
}
} |
4e954613-71fd-4955-b9b0-f2f2b0d41cba | public static void main(String[] args) {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
final UserDao dao = (UserDao) context.getBean("dao");
final List<User> jim = dao.getOtherUserDao().findByNameLike("JIM");
System.out.println("jim="+jim);
} |
82c58629-4420-440c-a58a-188fa0171bca | public static void main(String[] args) {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
final UserDao dao = (UserDao) context.getBean("dao");
final Collection<User> users = dao.getUsers();
for (User user : users) {
System.out.println("user="+user);
}
} |
9c0efb41-ee35-42dd-a4ea-0aedb0949ef2 | public User(String name, Sex sex) {
this.name = name;
this.sex = sex;
} |
92c21063-4a06-4f42-9564-99f835dafe6f | public BasicDBObject getMongoObject(){
final BasicDBObject basicDBObject = new BasicDBObject();
basicDBObject.append("name", this.name);
basicDBObject.append("sex", this.sex.toString());
return basicDBObject;
} |
61bdeb06-39fe-40aa-95ef-63625cfdaac6 | @Override
public String toString() {
return "User{" +
"name='" + name + '\'' +
", sex=" + sex +
'}';
} |
76d606e2-deb0-45b9-b1d8-37cb0ca9fbc0 | public Collection<User> getUsers(){
return template.findAll(User.class);
} |
5f455af9-6cc1-40a8-b6b0-35d7adac9390 | public IOtherUserDao getOtherUserDao() {
return otherUserDao;
} |
923e8df5-1300-4d4a-a2a7-e2bfd013a01b | public void setOtherUserDao(IOtherUserDao otherUserDao) {
this.otherUserDao = otherUserDao;
} |
b54c54ab-27ac-491d-bce6-6558f545b4a4 | List<User> findByNameLike(String name); |
82f67575-d8f3-4ca2-8fda-0fe0f54b9621 | private FactoryDAO(){} |
70b87c91-1623-4259-bece-5872cd99d79f | public static Dao crear(int tipo){
if(tipo==Dao.PERSONA){
return new PersonaDAO();
}else{
return null;
}
} |
a941bffe-b223-4c51-b46e-0650b33e2de9 | public static void persist(Object entity, EntityManager em){
em.persist(entity);
} |
c6b85bb3-c899-4892-bdf4-1e97a76b2de1 | public static void deleteSigleResult(Object o, EntityManager em){
Object o1 = em.merge(o);
em.remove(o1);
} |
7ac84d01-fe37-48eb-b7b9-ad12809a7c73 | public static void update(Object o, EntityManager em ){
em.merge(o);
} |
c2e94dc5-6cd8-410d-90c3-a5c4683be701 | public Person buscarPorDocumento(int documento,EntityManager em){
try{
Query q = (Query) em.createQuery("select p from Person p where p.cedule = :documento");
q.setParameter("documento", documento);
return (Person) q.getSingleResult();
}catch(NoResultException e){
return null;
}
} |
40df027e-92f8-4ca7-8580-03d33c3a7250 | public Person buscarPorDocumento(int documento, EntityManager em){
PersonaDAO dao = (PersonaDAO) FactoryDAO.crear(Dao.PERSONA);
Person entity = dao.buscarPorDocumento(documento, em);
if (entity == null) {return null;}
return entity;
} |
b249a322-6088-40ec-8eb3-149c56f65330 | public void crearPersona(Person vo, EntityManager em) {
Person persona = vo;
Dao dao = FactoryDAO.crear(Dao.PERSONA);
dao.persist(persona, em);
} |
c629dcdb-441b-4940-94cd-5583442842bb | public long getId() {
return id;
} |
6f1709ea-b68b-4b9f-b542-2dc262ea9fc2 | public void setId(long id) {
this.id = id;
} |
5f6756ce-0de8-43e3-ab72-2780b2ccdbc2 | public Date getPayDate() {
return payDate;
} |
313f11ec-9c21-4e5e-b3af-5a06937342a1 | public void setPayDate(Date payDate) {
this.payDate = payDate;
} |
f4d57aab-51f2-4c78-a633-a078ffab6cd6 | public Double getTotalValue() {
return totalValue;
} |
32f4940b-9740-43d3-a2ca-da997a1b80bb | public void setTotalValue(Double totalValue) {
this.totalValue = totalValue;
} |
de172912-f2d1-4301-bfe4-6dde337332a9 | public Pin getPin() {
return pin;
} |
00b9d90e-0b45-48b6-940c-8235a5922314 | public void setPin(Pin pin) {
this.pin = pin;
} |
217e3227-c3e6-4653-a399-0e88a9ba377b | public long getCedule() {
return cedule;
} |
a10c9cca-3f64-414d-909b-79208422c48d | public void setCedule(long cedule) {
this.cedule = cedule;
} |
734ef946-397e-497a-a792-e7a302063178 | public Collection<Pin> getPinCollection() {
return pinCollection;
} |
1f4579c4-6da2-4943-95f0-f39c16502d6a | public void setPinCollection(Collection<Pin> pinCollection) {
this.pinCollection = pinCollection;
} |
1639b427-9aa1-432d-a096-c5836fa57940 | public Eps getEps() {
return eps;
} |
8cdd6936-2229-4ac6-9ed5-ad013f5a39f4 | public void setEps(Eps eps) {
this.eps = eps;
} |
d99d7147-e68f-43d3-9426-15682dfdc2f4 | public long getId() {
return id;
} |
acf4a76b-0dfa-429b-82e5-5a6dec6a4518 | public void setId(long id) {
this.id = id;
} |
f359558a-de0f-498b-9d87-04b6441003e1 | public String getName() {
return name;
} |
dc28d4f0-bc69-46f1-8d1d-ce3a990ca966 | public void setName(String name) {
this.name = name;
} |
b4c6c2ec-da29-41ca-afbd-b0e507373b35 | public Long getAccountNumber() {
return accountNumber;
} |
5d366c2e-cdc4-49c2-8edc-6ee7e7ae9954 | public void setAccountNumber(Long accountNumber) {
this.accountNumber = accountNumber;
} |
f772f0ca-9942-4844-9b18-457c16ffb6b1 | public long getId() {
return id;
} |
37792c49-0c6c-40aa-bb42-beff36dbeef7 | public void setId(long id) {
this.id = id;
} |
8cb65db9-ec01-403c-968e-98be113c42bf | public String getPinState() {
return pinState;
} |
6af78327-1b4f-49b6-8158-1661e384fab2 | public void setPinState(String pinState) {
this.pinState = pinState;
} |
c294a803-e4b7-4c23-bc4e-f0fec6e402f1 | public Date getCreationDate() {
return creationDate;
} |
a03bd956-497e-4fbd-9fe8-e143b37af2d0 | public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
} |
3bdeaa0b-7c99-4b44-bd60-ff93cb50636b | public Date getLimitDate() {
return limitDate;
} |
32a15230-714c-41b9-80d1-d769f55189dc | public void setLimitDate(Date limitDate) {
this.limitDate = limitDate;
} |
5562eca4-875b-40ff-8ff5-d55a2505d549 | public Payment getPayment() {
return payment;
} |
22ea8c2f-26fb-4c83-8a58-2bf435d4eee5 | public void setPayment(Payment payment) {
this.payment = payment;
} |
8d39368e-3261-4460-9c42-52da5bf33129 | public Person getPerson() {
return person;
} |
12464cbe-018c-464f-97d6-fb4c77f9c0ea | public void setPerson(Person person) {
this.person = person;
} |
9b24ad77-e2b8-4883-b341-66f13e9e1db2 | public void cerrarConexion(){
if (em != null) {
em.clear();
em.close();
}
} |
6bb48f9f-4c00-41ee-94f5-aae178138fd6 | public void hacerRollback(){
if(em != null && et != null){
et.rollback();
}
} |
2317ed6e-95d6-44d4-bb41-0814feb5a346 | public void abrirConexion(){
emf = Persistence.createEntityManagerFactory(PU);
em = emf.createEntityManager();
et = em.getTransaction();
et.begin();
} |
609757ee-96c5-4790-8bfd-cda56f060bdd | public PersonFacade(){
personaServicio = new PersonaServicio();
} |
04680aec-3d94-45a3-a082-1f0606ba9b4c | public String crearPersona(Person vo){
String resultado = "";
try{
abrirConexion();
if(false){//personaServicio.buscarPorDocumento((int) vo.getCedule(), em)!= null){
resultado = "Usuario ya registrado";
}else{
personaServicio.crearPersona(vo, em);
resultado = "Creado";
et.commit();
}
}catch(Exception e){
e.printStackTrace();
hacerRollback();
resultado = "Error";
}finally{
cerrarConexion();
return resultado;
}
} |
b69e4c48-4d9d-4bd4-84a6-7475c0e924f7 | private FactoryFachada(){} |
8f0fc89a-fd7f-4645-ac9f-6775a7839a0c | public static void main(String[] args) {
PersonFacade fachada = new PersonFacade();
Person p = new Person();
p.setCedule(1);
p.setPinCollection(null);
p.setEps(null);
System.out.println(fachada.crearPersona(p));
} |
cd9e2d08-3d03-43da-b26d-52ae93fc2f83 | public File getJavaHome() {
return javaHome;
} |
d7e01974-c8bf-4fc8-a958-34a42d8d215e | public File getApplicationJarLocation() {
return applicationJarLocation;
} |
14abe903-65ff-4989-9a26-3236dd1732c3 | public File getDaemonJarLocation() {
return daemonJarLocation;
} |
1e662680-5264-4bf2-b4af-57088f487301 | public File getInitializationScriptLocation() {
return initializationScriptLocation;
} |
24bc7155-6d90-4f04-ae54-aa04fdf602f9 | public InitializationScriptConfiguration(ApplicationConfiguration applicationConfiguration,
DaemonConfiguration daemonConfiguration,
TargetSystemConfiguration targetSystemConfiguration, String daemonJarName) {
this.applicationConfiguration = applicationConfiguration;
this.daemonConfiguration = daemonConfiguration;
this.targetSystemConfiguration = targetSystemConfiguration;
this.daemonJarName = daemonJarName;
} |
c2bf66b8-dc5f-4c08-b13d-6a846c629583 | public ApplicationConfiguration getApplicationConfiguration() {
return applicationConfiguration;
} |
5abbbcea-9047-47d5-865d-77a22e2bd1ed | public DaemonConfiguration getDaemonConfiguration() {
return daemonConfiguration;
} |
3186bf97-b7aa-40c5-abcf-0587cedf9c8c | public TargetSystemConfiguration getTargetSystemConfiguration() {
return targetSystemConfiguration;
} |
62d7af84-f00c-4905-99de-7a95c8cf45f9 | public String getDaemonJarName() {
return daemonJarName;
} |
391ac84f-3c55-43da-b443-3fd7b89b5304 | @Override
public void execute() throws MojoExecutionException, MojoFailureException {
final Map<String, Artifact> artifactMap = mavenProject.getArtifactMap();
final Artifact artifact = artifactMap.get(COMMONS_DAEMON_GROUP_ID + ":"
+ COMMONS_DAEMON_ARTIFACT_ID);
if (null == artifact)
throw new MojoExecutionException(
"Could not retrieve commons-daemon artifact");
final File file = artifact.getFile();
final String daemonJarFileName = file.getName();
InitializationScriptConfiguration initializationScriptConfiguration = new InitializationScriptConfiguration(
applicationConfiguration, daemonConfiguration,
targetSystemConfiguration, daemonJarFileName);
final StringTemplate stringTemplate = loadInitScriptTemplate();
final InitializationScript initializationScript = InitializationScriptFactory
.createInitializationScript(stringTemplate,
initializationScriptConfiguration);
final InitializationScriptWriter initializationScriptWriter = new InitializationScriptWriter(
initializationScript);
try {
initializationScriptWriter
.writeToExecutableFile(projectBuildDirectory);
} catch (IOException e) {
throw new MojoExecutionException(String.format(
"Could not create [%s] in [%s]",
applicationConfiguration.getScriptName(),
projectBuildDirectory), e);
}
} |
6918a80d-bd8e-408f-bbac-31e895a02390 | private StringTemplate loadInitScriptTemplate() {
String resourceName = "init-script_" + ENVIRONMENT + ".st";
try {
InputStream inputStream = new ClassPathResource(resourceName)
.getInputStream();
return new StringTemplate(IOUtils.toString(inputStream));
} catch (IOException e) {
throw new RuntimeException(e);
}
} |
86d96dc5-0520-4fe1-892f-1f4a86afb9b9 | public String getDaemonUser() {
return daemonUser;
} |
2c8f97c9-f0aa-4927-9fcd-c52779993879 | public long getDelayInMillis() {
return delayInMillis;
} |
f305613b-1d8d-4ee7-b0a6-b5210c5b45fc | public String getApplicationName() {
return name;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.