You have two possibilities to access the path params in angular navigation. The first one, asynchronous, is to subscribe to the Observable<ParamMap> observable, which you can access via paramMap method of the ActivatedRoute. Then use the get method with parameter you want to get as argument, as in the example below in the ngOnInit method:

// other imports ignored for breviyty
import { ActivatedRoute } from '@angular/router';
import { switchMap } from 'rxjs/operators';

@Component({
  selector: 'app-public-snippet-details',
  templateUrl: './public-snippet-details.component.html'
})
export class PublicSnippetDetailsComponent implements OnInit {
  snippetId: string;
  snippet$: Observable<Codelet>;

  constructor(
    private publicSnippetsService: PublicSnippetsService,
    private userInfoStore: UserInfoStore,
    private route: ActivatedRoute) {
  }

  ngOnInit() {
    this.snippet$ = this.route.paramMap.pipe(
      switchMap(params => {
        this.snippetId = params.get('id');
        return this.publicSnippetsService.getPublicSnippetById(this.snippetId);
      })
    );
  }

}

The second one, synchronous, is to the snapshot of this route (ActivatedRoute), and directly access the parameter from the paramMap, const bookmarkId = this.route.snapshot.paramMap.get('id');

export class BookmarkDetailsComponent implements OnInit {
  // constructor and other details ignored for brevity

  ngOnInit() {
    this.popup = this.route.snapshot.queryParamMap.get('popup');
    this.userInfoStore.getUserInfo$().subscribe(userInfo => {
      this.userData$ = this.userDataStore.getUserData$();
      this.bookmark = window.history.state.bookmark;
      if (!window.history.state.bookmark) {
        const bookmarkId = this.route.snapshot.paramMap.get('id');
        this.personalBookmarksService.getPersonalBookmarkById(userInfo.sub, bookmarkId).subscribe((response) => {
          this.bookmark = response;
        });
      }
    });
  }
}

Reference - https://angular.io/guide/router


Shared with from Codever. 👉 Use the Copy to mine functionality to copy this snippet to your own personal collection and easy manage your code snippets.

Codever is open source on Github ⭐🙏

MLOPs intro

Machine Learning is used in practically every industry these days, which is associated with Artificial Intelligence. Machine learning is used in a variety of fields, including medicine, eCommerce, and science. It is not difficult to find the most up-to-date machine learning tools, methodologies, procedures, and systems to construct Machine Learning Models to address a problem. The major challenge is keeping these models up to date on such a large scale. This article will explain the rise of MLOps monitoring in 2022.

The current paradigm in machine learning development depends on the cooperation of 4 main areas of study: Big Data, Data Science, Computer Engineering, and Machine Learning.

Continue Reading ...

The simplest way

git remote -v

#result something similar to the following
origin  git@github.com:CodepediaOrg/codepediaorg.github.io.git (fetch)
origin  git@github.com:CodepediaOrg/codepediaorg.github.io.git (push)

Tip to get only the remote URL:

git config --get remote.origin.url

#result something similar to the following
git@github.com:CodepediaOrg/codepediaorg.github.io.git

In order to get more details about a particular remote, use the git remote show [remote-name] command

git remote show origin # here "origin" is the remote name

#result something similar to the following
* remote origin
  Fetch URL: git@github.com:CodepediaOrg/codepediaorg.github.io.git
  Push  URL: git@github.com:CodepediaOrg/codepediaorg.github.io.git
  HEAD branch: master
  Remote branches:
    _posts/2016-08-26-migrate-rest-api-from-jboss-eap6-to-eap7 tracked
    add_multiple_authors_functionality                         tracked
    dependabot/npm_and_yarn/bl-1.2.3                           tracked
    dependabot/npm_and_yarn/grunt-1.3.0                        tracked
    dependabot/npm_and_yarn/hosted-git-info-2.8.9              tracked
    dependabot/npm_and_yarn/ini-1.3.7                          tracked
    dependabot/npm_and_yarn/is-svg-4.3.1                       tracked
    dependabot/npm_and_yarn/lodash-4.17.21                     tracked
    dependabot/npm_and_yarn/path-parse-1.0.7                   new (next fetch will store in remotes/origin)
    dependabot/npm_and_yarn/websocket-extensions-0.1.4         tracked
    feature/add-copy-button-for-code-snippets                  tracked
    feature/add-scroll-up-for-posts                            tracked
    feature/mongo-commands-via-collections                     tracked
    gh-pages                                                   tracked
    master                                                     tracked
    post/multiple-authors-jekyll                               tracked
    refs/remotes/origin/dependabot/npm_and_yarn/lodash-4.17.19 stale (use 'git remote prune' to remove)
    run-grunt                                                  tracked
  Local branches configured for 'git pull':
    master    merges with remote master
    run-grunt merges with remote run-grunt
  Local refs configured for 'git push':
    master    pushes to master    (up to date)
    run-grunt pushes to run-grunt (up to date)

Shared with from Codever. 👉 Use the Copy to mine functionality to copy this snippet to your own personal collection and easy manage your code snippets.

Codever is open source on Github ⭐🙏

Use the find method of the EntityManager, where the primary key is provided as the second parameter:

@Stateless
public class PartnerRepository {

  @Inject private EntityManager em;

  public Optional<Partner> find(String partnerNumber) {
    return Optional.ofNullable(em.find(Partner.class, partnerNumber));
  }
}

The entity looks something like the following, with partnerNumber as primary key:

@Entity
@Access(AccessType.FIELD)
@Table(name = "T_PARTNER")
public class Partner {

  @Id
  @NotNull
  @Column(name = "PARTNER_NUMBER", nullable = false)
  private Integer partnerNumer;

  //other fields ignored for readability
}

Shared with from Codever. 👉 Use the Copy to mine functionality to copy this snippet to your own personal collection and easy manage your code snippets.

Codever is open source on Github ⭐🙏

The native SQL query we want to map in JPA is similar to the following:

SELECT * FROM PARTNER where PARTNER_NUMBER IN ('id1', 'idn').

With JPA you can use a TypedQuery for example and set the expected list of the IN clause directly as query parameter

@Stateless
public class PartnerDataRepository {

	@Inject private EntityManager em;

	public List<PartnerData> findPartnerDataFromList(
		List<String> partnerNumbers) {
	  TypedQuery<PartnerData> query =
		  em.createNamedQuery(
			  PartnerData.FIND_PARTNER_DATA_IN_LIST, PartnerData.class);
	  query.setParameter(PartnerData.PARTNER_NUMBERS, partnerNumbers);

	  return query.getResultList();
	}
}

In the named query itself you can pass the parameter with : as you would when setting a “normal” parameter:

@Entity
@Access(AccessType.FIELD)
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Table(name = PartnerData.TABLE_NAME)
@NamedQueries({
  @NamedQuery(
      name = PartnerData.FIND_PARTNER_DATA_IN_LIST,
      query = "select m from PartnerData m where partnerNumber in :partnerNumbers")
})
public class PartnerData {
  public static final String TABLE_NAME = "PARTNER";

  public static final String PARTNER_NUMBERS = "partnerNumbers";
  public static final String FIND_PARTNER_DATA_IN_LIST =
      "findPartnerDataWithPartnerNumbers";

  //... rest ignored for brevity
}


Shared with from Codever. 👉 Use the Copy to mine functionality to copy this snippet to your own personal collection and easy manage your code snippets.

Codever is open source on Github ⭐🙏